Nexus/API Reference/Spreads

Set a held spread's stop and target

PUThttps://app.skylit.ai/api/nexus/v1/spreads/{spreadId}/exit

Sets the underlying prices that close a spread you hold: a stop, a target or both, each with when (AT_OR_BELOW or AT_OR_ABOVE). It replaces both levels: a level you leave out is taken off. When the underlying reaches one, the spread closes at the market. Once one is reached the exit can't change (409 exit_triggered). Not allowed while Simulated is paused for members; taking an exit off always is. Your agent's main account setting never applies.

The answer is the spread, as GET /api/nexus/v1/spreads lists it.

curl -s -X PUT "https://app.skylit.ai/api/nexus/v1/spreads/5dd923e8-8cbe-4198-bad2-9f51ac222a61/exit" \
  -H "Authorization: Bearer $SKYLIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"stop":{"price":600,"when":"AT_OR_BELOW"},"target":{"price":700,"when":"AT_OR_ABOVE"}}'

Authorization

Authorization: Bearer <your API key>

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

Path parameters

  • spreadIdstringuuidrequired

    The held spread's spreadId, from GET /api/nexus/v1/spreads.

Request body

  • accountstring

    main or left out. Any other account answers 422 port_unsupported.

    main
  • portstring

    Leave it out. Spreads trade on your main account only, so any port answers 422 port_unsupported.

  • stopobject
    • pricenumber | null

      The underlying's price.

    • whenstring
      AT_OR_BELOWAT_OR_ABOVE
  • targetobject
    • pricenumber | null

      The underlying's price.

    • whenstring
      AT_OR_BELOWAT_OR_ABOVE

Responses

  • 200

    The spread, with its exit.

  • 400

    Refused before anything was sent. Codes: bad_request (an unknown field, a leg that isn't options or stocks, legs that don't form the strategy, a missing limitPrice on a limit, a market order with one, a quantity over 100, a modify with neither quantity nor limitPrice, a date that isn't YYYY-MM-DD), expiry_day_cutoff (on a leg's expiration day, new spread opens stop at 3:00 PM ET; closes are never refused).

  • 401

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

  • 403

    The key works but this can't happen right now. Codes: feature_disabled (spreads aren't open to you, opening spreads is switched off while you can still close and cancel, or a broken wing butterfly), main_not_enabled (an open while "Let my agent trade my main account" is off; closes, cancels and exits never need it), paper_desk_paused (Simulated is paused for members: you can still preview and place a close, cancel, and take an exit off), read_only, plus the shared account_suspended and nexus_access_denied.

  • 404

    Not on your account. Codes: order_not_found (no spread order of yours with that id), spread_not_found (no open spread of yours with that id).

  • 409

    It clashes with what you hold or sent before. Codes: preview_mismatch (the ticket isn't what the preview priced: preview again), spread_conflict (closing a spread you don't hold, closing more than you hold or than your resting closes leave, or opening one you hold the other way round: close it instead), working_order_limit (your resting API orders, stops included, and every working spread order count together toward 50, spread orders placed on the Spreads ticket in Nexus included), client_order_id_used, order_not_working (it already filled, expired, or was cancelled or rejected), exit_triggered (the stop or target was reached and the spread is closing, so its exit can't change).

  • 422

    Read fine, but the account says no. Codes: port_unsupported (any account but main, or any port), insufficient_buying_power (with orderId when the order was recorded as rejected), order_rejected (recorded as rejected as it was placed; orderId points to it), contract_expired.

  • 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. Codes: no_live_quote (a leg, or the underlying, has no live quote; quotes older than 15 s never fill), unavailable (spreads aren't on this server, or a check couldn't be read).

Response fields

  • dataobjectrequired
    • spreadIdstringuuid
    • accountstring
      main
    • strategystring

      VERTICAL, IRON_CONDOR, BUTTERFLY, CALENDAR, DIAGONAL, COVERED_STOCK and the others the desk opens.

    • underlyingstring
    • netEffectstring

      How it opened.

      DEBITCREDIT
    • quantityinteger
    • openPricenumber | null

      Per spread, a size (netEffect says which way).

    • markPricenumber | null

      Per spread at the legs' marks; null until every leg has one.

    • unrealizedPnlnumber | null

      Dollars the held quantity makes at the marks; null with markPrice.

    • realizedPnlnumber | null

      Dollars partial closes already made.

    • collateralnumber | null

      Dollars set aside while it is held.

    • exitobject
    • legsobject[]
  • metaobjectrequired
    • accountstring
      main

Last updated

Was this page helpful?