Nexus/API Reference/Options and stocks

Trim or close an options or stock trade

POSThttps://app.skylit.ai/api/nexus/v1/trades/{id}/exits

Sell part of a trade with quantity, or all of what's left with "closeAll": true. Not both. Fills at market (the live bid for options), or at your own price inside the window, as on an open.

On a test order's id this is a test exit, whatever the body says. Futures have no exits: close a futures position with the account close route.

Authorization

Authorization: Bearer <your API key>

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

Path parameters

  • idstringuuidrequired

    The trade's id, from the open or the list.

Headers

  • Idempotency-Keystring

    Your clientOrderId, as a header instead of a body field. If you send both they must match.

Request body

  • quantityinteger

    How many to sell, 1 or more.

  • closeAllboolean

    true sells everything that's left.

  • pricenumber

    Your own fill price, inside the window.

  • ifOutsidestring

    What happens when price is outside the window.

    rejectmarket
  • orderTypestring

    Exits are market orders.

    market
  • clientOrderIdstring

    Your own id for safe retries.

  • testboolean

    Optional. The trade decides: a test order's exit is always a test.

Responses

  • 200

    The trade with its new exit. meta.fill.quantity is how many this exit sold.

  • 400

    The request was refused before anything was traded. Codes: bad_request, bad_contract, invalid_quantity, invalid_price, unsupported_asset_class, unsupported_order_type, only_market_orders, test_orders_unavailable, test_modify_unavailable.

  • 401

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

  • 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), trade_closed, open_position_limit, client_order_id_used, request_in_progress, account_locked, account_busy, account_ended, order_not_working.

  • 422

    Read fine, but the market or the account says no. Codes: market_closed, contract_expired, contract_not_offered, price_outside_market, insufficient_buying_power, account_not_tradable, account_ambiguous, reduce_only_would_open, order_refused.

  • 429

    Over a rate limit. Wait Retry-After seconds, then retry. Code: rate_limited.

  • 503

    Try again in a moment (honour Retry-After when it's sent). Codes: stale_quote, no_live_price, rules_pending, unavailable, auth_unavailable, access_check_unavailable, api_keys_unavailable, trades_api_disabled.

Response fields

  • dataobject

    An options or stock trade, as Nexus shows it. Stocks use direction call for long and put for short, strike 0 and today's date. Nexus may add other fields it shows on a trade (Greeks, P/L, reactions).

    • idstringuuid
    • userIdstringuuid
    • tickerstring
    • strikenumber
    • expirationstringdate
    • directionstring
      callput
    • assetClassstring
      optionsstocks
    • averageEntryPricenumber
    • currentPricenumber

      The latest mark.

    • totalQuantityinteger
    • remainingQuantityinteger
    • statusstring
      activeclosed
    • entryDatestringdate-time
    • exitDatestringdate-time
    • exitsobject[]
    • sourcestring

      api on a trade a key opened.

    • testboolean

      true on a test order.

  • 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.

Last updated

Was this page helpful?