Skip to content

Close One Leg

Submit a MARKET exit for one filled owner in the current run. All other legs continue running.

Endpoint URL

http
Local Host   :  POST http://127.0.0.1:5000/api/v1/strategy/close_leg
Ngrok Domain :  POST https://<your-ngrok-domain>.ngrok-free.app/api/v1/strategy/close_leg
Custom Domain:  POST https://<your-custom-domain>/api/v1/strategy/close_leg

Sample API Request

json
{
  "apikey": "<your_app_apikey>",
  "strategy_id": 7,
  "leg_id": 2
}

Sample cURL Request

bash
curl -X POST http://127.0.0.1:5000/api/v1/strategy/close_leg \
  -H 'Content-Type: application/json' \
  -d '{
  "apikey": "<your_app_apikey>",
  "strategy_id": 7,
  "leg_id": 2
}'

Sample API Response

json
{
  "status": "success",
  "run_id": 42,
  "leg_id": 2,
  "run_stopped": false,
  "exits": [
    {
      "leg_id": 2,
      "ok": true,
      "position_ref": "80bb5fc9333f4922a582229f06a0fe45",
      "exit_owner": "live",
      "error": null
    }
  ]
}

Request Body

ParameterDescriptionMandatory/OptionalDefault Value
apikeyYour Tradeboard API keyMandatory-
strategy_idPositive Strategy RMS idMandatory-
leg_idPositive configured leg idMandatory-

Response Fields

FieldTypeDescription
statusstringsuccess or error
run_idintegerCurrent run containing the leg
leg_idintegerLeg requested by the caller
run_stoppedbooleanTrue only when this call already proved the last owner flat
exitsarrayExit result for the leg

Notes

  • leg_id is the configuration id in data.legs[].id from Strategy Status, not an order or run id.
  • A normal broker acknowledgement is asynchronous, so run_stopped is usually false even for the last leg. A later fill can finalise the run.
  • A refused exit, an unfilled entry, a non-open leg, or a missing current run returns HTTP 409 and does not open an opposing configured-size position.
  • Manual leg closure does not invoke trail-to-entry for the remaining legs.

Back to: Strategy RMS API