Nexus/API Reference/Futures

Set or move a futures stop or target

POSThttps://app.skylit.ai/api/nexus/v1/trading/accounts/{account}/protect

Set or move the position's stop ("role": "stopLoss") or target ("role": "takeProfit") to price, the same as dragging them on the Futures Desk. One stop and one target per position: sending a new level moves the one there. A stop must sit below the price on a long and above it on a short, a target the other way, or it answers 422 order_refused and nothing moves.

No clientOrderId: the same level sent twice lands on the same level, so one is refused with 400 bad_request. Only takes risk off, so it isn't held by the main account switch or an agent pause. The same checks as a close: your own named account, no trading on an ended account or a challenge entry, and it counts against your write limit.

curl -s -X POST "https://app.skylit.ai/api/nexus/v1/trading/accounts/agent/protect" \
  -H "Authorization: Bearer $SKYLIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"ticker": "NQ", "role": "stopLoss", "price": 25310}'

Authorization

Authorization: Bearer <your API key>

Required. A missing header returns 401; an invalid, revoked or expired key returns 403.

Path parameters

  • accountstringrequired

    practice, agent (your bot's account), evaluation or funded (when you have exactly one running), or a futures account id from capabilities.

Request body

  • tickerstringrequired

    The position, like NQ or NQZ26.

  • rolestringrequired

    stopLoss sets or moves the stop; takeProfit sets or moves the target.

    stopLosstakeProfit
  • pricenumberrequired

    The level, in index points: 0.01 to 999,999.99. It must sit on the losing side of the price for a stop and the winning side for a target.

Responses

  • 200

    The order the engine placed or moved.

  • 400

    The request was refused and nothing moved. Codes: bad_request (no ticker, a role that isn't stopLoss or takeProfit, or a clientOrderId), bad_contract, invalid_price (missing, or outside 0.01 to 999,999.99).

  • 401

    No key, or a key that isn't valid. Codes: missing_api_key, invalid_api_key.

  • 403

    The key works but the account can't do this. Codes: account_suspended, nexus_access_denied, futures_access_denied.

  • 404

    Not on your account. Codes: trade_not_found, account_not_found, order_not_found.

  • 409

    The order clashes with what you hold or sent before. Codes: duplicate_position (with tradeId: add to it instead), trade_closed, open_position_limit (open positions plus resting opens through the API are at 50), working_order_limit (50 options and stock orders already resting through the API), position_size_limit (an add would take the position past 1,000 contracts or 100,000 shares), client_order_id_used, request_in_progress, account_locked, account_busy, account_ended, order_not_working (it already filled, expired, or was cancelled or rejected), stop_triggered (a stop that's been set off is filling now, so it can't be cancelled or changed).

  • 422

    order_refused: the level is on the wrong side of the price, or there's no position. Also market_closed, account_not_tradable, account_locked.

  • 429

    Over a rate limit. Wait Retry-After seconds, then retry. Codes: rate_limited, and stream_limit_reached (too many live streams open: 3 per key, 6 per account).

  • 500

    Something went wrong on our side. If you sent a clientOrderId, retry with the same one. Code: internal_error.

  • 503

    Try again in a moment (honour Retry-After when it's sent). Codes: stale_quote (the quote, or a stock's last trade, is more than 15 seconds old, so nothing filled), no_live_price, rules_pending, unavailable, auth_unavailable, access_check_unavailable, api_keys_unavailable, trades_api_disabled, stream_unavailable (the live stream isn't on, or the server is restarting: try again shortly, or poll the reads).

Response fields

  • dataobject

    The order the action placed or moved, and the account it is in.

    • accountobject
    • orderobject

      A futures order. It's not a Trade: futures keep their own book. Prices are in index points, money in cents.

  • metaobject

    Extra facts about an order. Each field is there only when it applies.

    • fillobject

      The fill: price, priceSource (market or client), and when you sent a price, the bid and ask it was checked against. On an exit, quantity is how many sold.

    • clientOrderIdstring
    • idempotentReplayboolean

      This answer is a repeat of an earlier order with the same clientOrderId.

    • testboolean

      A test order: nothing was placed.

    • notCheckedstring[]

      Futures test orders: what the preview couldn't check, like account_rules_judgment or bracket_netting.

    • discordRoutingobject

      Where Nexus routed the trade to Discord, when it did.

    • nothingToCloseboolean
    • stillOpenstring[]

      A repeated closeAll: positions still open.

    • tradeIdstringuuid

      A resting exit or an options stop: the trade it closes or protects.

    • triggerOnstring

      An options stop: underlying. A stock stop: lastTrade.

    • underlyingPricenumber

      An options stop: the stock's price right now.

    • marketOpenboolean

      An options stop: whether the market's open for the contract.

    • firesNowboolean

      An options stop: the stock's already through a level, so it fires on the next check. firesOn says which leg.

    • wouldFireNowboolean

      A test options stop: what firesNow would say.

    • wouldFillNowboolean

      A test limit: whether the real one would've filled right away, with fillPrice.

    • wouldTriggerNowboolean

      A test stock stop: the last trade's already through it.

    • wouldRestBecausestring

      A test limit: why the real one would rest.

    • alreadyCancelledboolean

      A repeated cancel: it was already cancelled.

Last updated

Was this page helpful?