{"asyncapi":"3.0.0","info":{"title":"Phoenix Perpetuals streams","version":"1.0.0","description":"The account stream and market data over WebSocket: JSON text frames, the same keys as the REST API (Authorization: Bearer on the upgrade). Prices and sizes are decimal strings, times Unix milliseconds."},"defaultContentType":"application/json","servers":{"live":{"host":"api.phoenixperpsfunding.com","protocol":"wss","description":"Live: the account stream","security":[{"$ref":"#/components/securitySchemes/bearer"}],"x-pp-environment":"live"},"sandbox":{"host":"sandbox-api.phoenixperpsfunding.com","protocol":"wss","description":"Sandbox: the account stream","security":[{"$ref":"#/components/securitySchemes/bearer"}],"x-pp-environment":"sandbox"},"market":{"host":"stream.phoenixperpsfunding.com","protocol":"wss","description":"Market data, for a key or app token of either environment","security":[{"$ref":"#/components/securitySchemes/bearer"}]}},"channels":{"account":{"address":"/v1/stream","title":"Account stream","description":"Orders, fills, positions, strategies and live risk of your accounts as they change: a snapshot of each account, then every event once, with resume.","servers":[{"$ref":"#/servers/live"},{"$ref":"#/servers/sandbox"}],"messages":{"AccountHello":{"$ref":"#/components/messages/AccountHello"},"AccountSnapshot":{"$ref":"#/components/messages/AccountSnapshot"},"AccountSnapshotEnd":{"$ref":"#/components/messages/AccountSnapshotEnd"},"AccountEvent":{"$ref":"#/components/messages/AccountEvent"},"AccountRisk":{"$ref":"#/components/messages/AccountRisk"},"AccountHeartbeat":{"$ref":"#/components/messages/AccountHeartbeat"},"AccountPong":{"$ref":"#/components/messages/AccountPong"},"AccountUnsubscribed":{"$ref":"#/components/messages/AccountUnsubscribed"},"AccountNotice":{"$ref":"#/components/messages/AccountNotice"},"AccountError":{"$ref":"#/components/messages/AccountError"},"AccountSubscribeRequest":{"$ref":"#/components/messages/AccountSubscribeRequest"},"AccountUnsubscribeRequest":{"$ref":"#/components/messages/AccountUnsubscribeRequest"},"AccountPingRequest":{"$ref":"#/components/messages/AccountPingRequest"}},"bindings":{"ws":{"query":{"type":"object","properties":{"resume":{"type":"string","description":"The id of the last event you have: the events after it come first (within the replay window), then a snapshot.","example":"evt_01JAB7Q8XK4M2N5P7R9S3T5V7W"}},"required":[],"additionalProperties":false},"bindingVersion":"0.1.0"}}},"market":{"address":"/v1/market-data","title":"Market data","description":"The connection for market data: subscribe to channels, list them, ping. Any key or app token of either environment.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketHello":{"$ref":"#/components/messages/MarketHello"},"MarketSubscribed":{"$ref":"#/components/messages/MarketSubscribed"},"MarketSnapshotEnd":{"$ref":"#/components/messages/MarketSnapshotEnd"},"MarketUnsubscribed":{"$ref":"#/components/messages/MarketUnsubscribed"},"MarketList":{"$ref":"#/components/messages/MarketList"},"MarketHeartbeat":{"$ref":"#/components/messages/MarketHeartbeat"},"MarketPong":{"$ref":"#/components/messages/MarketPong"},"MarketError":{"$ref":"#/components/messages/MarketError"},"MarketSubscribeRequest":{"$ref":"#/components/messages/MarketSubscribeRequest"},"MarketUnsubscribeRequest":{"$ref":"#/components/messages/MarketUnsubscribeRequest"},"MarketListRequest":{"$ref":"#/components/messages/MarketListRequest"},"MarketPingRequest":{"$ref":"#/components/messages/MarketPingRequest"}},"x-pp-control":true},"ticker":{"address":"/v1/market-data","title":"Ticker","description":"The latest prices, at most once per interval_ms.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataTicker":{"$ref":"#/components/messages/MarketDataTicker"}},"x-pp-channel":"ticker","x-pp-params":{"interval_ms":{"type":"integer","enum":[100,250,500,1000],"description":"The shortest time between frames (default 250).","example":250}}},"book":{"address":"/v1/market-data","title":"Order book","description":"The top of the book to the depth asked, whole every time (replace what you hold), at most every 250 ms.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataBook":{"$ref":"#/components/messages/MarketDataBook"}},"x-pp-channel":"book","x-pp-params":{"depth":{"type":"integer","enum":[1,5,10,20],"description":"Levels on each side (default 10).","example":10}}},"trades":{"address":"/v1/market-data","title":"Trades","description":"Trades as they print, batched every 100 ms; first the history asked.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataTrades":{"$ref":"#/components/messages/MarketDataTrades"}},"x-pp-channel":"trades","x-pp-params":{"history":{"type":"integer","description":"Recent trades sent first, 0 to 200 (default 20).","example":20}}},"candles":{"address":"/v1/market-data","title":"Candles","description":"Candles: first the history asked, then the forming candle as it changes and each closed one.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataCandles":{"$ref":"#/components/messages/MarketDataCandles"}},"x-pp-channel":"candles","x-pp-params":{"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"The candle interval (required).","example":"1m"},"history":{"type":"integer","description":"Closed candles sent first, 0 to 500 (default 100); the forming one follows in a frame of its own.","example":100}}},"stats":{"address":"/v1/market-data","title":"Stats","description":"24-hour figures and open interest, every 5 seconds (GET /v1/markets/stats answers the same for every market).","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataStats":{"$ref":"#/components/messages/MarketDataStats"}},"x-pp-channel":"stats","x-pp-params":{}},"status":{"address":"/v1/market-data","title":"Market status","description":"The price feed's state, when it changes.","servers":[{"$ref":"#/servers/market"}],"messages":{"MarketDataStatus":{"$ref":"#/components/messages/MarketDataStatus"}},"x-pp-channel":"status","x-pp-params":{}}},"operations":{"receiveAccountStream":{"action":"receive","channel":{"$ref":"#/channels/account"},"summary":"What the account stream sends.","messages":[{"$ref":"#/channels/account/messages/AccountHello"},{"$ref":"#/channels/account/messages/AccountSnapshot"},{"$ref":"#/channels/account/messages/AccountSnapshotEnd"},{"$ref":"#/channels/account/messages/AccountEvent"},{"$ref":"#/channels/account/messages/AccountRisk"},{"$ref":"#/channels/account/messages/AccountHeartbeat"},{"$ref":"#/channels/account/messages/AccountPong"},{"$ref":"#/channels/account/messages/AccountUnsubscribed"},{"$ref":"#/channels/account/messages/AccountNotice"},{"$ref":"#/channels/account/messages/AccountError"}]},"sendAccountStream":{"action":"send","channel":{"$ref":"#/channels/account"},"summary":"What you send on the account stream.","messages":[{"$ref":"#/channels/account/messages/AccountSubscribeRequest"},{"$ref":"#/channels/account/messages/AccountUnsubscribeRequest"},{"$ref":"#/channels/account/messages/AccountPingRequest"}]},"receiveMarketData":{"action":"receive","channel":{"$ref":"#/channels/market"},"summary":"The answers on a market data connection.","messages":[{"$ref":"#/channels/market/messages/MarketHello"},{"$ref":"#/channels/market/messages/MarketSubscribed"},{"$ref":"#/channels/market/messages/MarketSnapshotEnd"},{"$ref":"#/channels/market/messages/MarketUnsubscribed"},{"$ref":"#/channels/market/messages/MarketList"},{"$ref":"#/channels/market/messages/MarketHeartbeat"},{"$ref":"#/channels/market/messages/MarketPong"},{"$ref":"#/channels/market/messages/MarketError"}]},"sendMarketData":{"action":"send","channel":{"$ref":"#/channels/market"},"summary":"What you send on a market data connection.","messages":[{"$ref":"#/channels/market/messages/MarketSubscribeRequest"},{"$ref":"#/channels/market/messages/MarketUnsubscribeRequest"},{"$ref":"#/channels/market/messages/MarketListRequest"},{"$ref":"#/channels/market/messages/MarketPingRequest"}]},"receiveTicker":{"action":"receive","channel":{"$ref":"#/channels/ticker"},"summary":"Ticker frames.","messages":[{"$ref":"#/channels/ticker/messages/MarketDataTicker"}]},"receiveBook":{"action":"receive","channel":{"$ref":"#/channels/book"},"summary":"Order book frames.","messages":[{"$ref":"#/channels/book/messages/MarketDataBook"}]},"receiveTrades":{"action":"receive","channel":{"$ref":"#/channels/trades"},"summary":"Trades frames.","messages":[{"$ref":"#/channels/trades/messages/MarketDataTrades"}]},"receiveCandles":{"action":"receive","channel":{"$ref":"#/channels/candles"},"summary":"Candles frames.","messages":[{"$ref":"#/channels/candles/messages/MarketDataCandles"}]},"receiveStats":{"action":"receive","channel":{"$ref":"#/channels/stats"},"summary":"Stats frames.","messages":[{"$ref":"#/channels/stats/messages/MarketDataStats"}]},"receiveStatus":{"action":"receive","channel":{"$ref":"#/channels/status"},"summary":"Market status frames.","messages":[{"$ref":"#/channels/status/messages/MarketDataStatus"}]}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"An API key or an app's access token, as for the REST API. From a browser, the subprotocols pp.v1 and pp.key.<token> instead."}},"messages":{"AccountHello":{"name":"hello","title":"hello","summary":"First, on every connection: the accounts your key reaches.","payload":{"type":"object","description":"First, on every connection: the accounts your key reaches.","properties":{"type":{"type":"string","enum":["hello"],"description":"The frame.","example":"hello"},"session":{"type":"string","description":"This connection.","example":"ses_5f0c9a7d8e1b4c6a9f3e5d7b"},"environment":{"type":"string","enum":["live","sandbox"],"description":"The environment of the host you called.","example":"sandbox"},"heartbeat_ms":{"type":"integer","description":"How often a heartbeat comes.","example":15000},"accounts":{"type":"array","items":{"type":"string","description":"An account number.","example":"SANDBOX-00042-001"},"description":"Account numbers."}},"required":["type","session","environment","heartbeat_ms","accounts"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"hello","session":"ses_5f0c9a7d8e1b4c6a9f3e5d7b","environment":"sandbox","heartbeat_ms":15000,"accounts":["SANDBOX-00042-001"]}}]},"AccountSnapshot":{"name":"snapshot","title":"snapshot","summary":"An account as it stands, once per account you subscribe to: build your state from it.","payload":{"type":"object","description":"An account as it stands, once per account you subscribe to: build your state from it.","properties":{"type":{"type":"string","enum":["snapshot"],"description":"The frame.","example":"snapshot"},"account_id":{"type":"string","description":"The account number.","example":"SANDBOX-00042-001"},"orders":{"type":"array","items":{"$ref":"#/components/schemas/Order"},"description":"Its working orders."},"positions":{"type":"array","items":{"$ref":"#/components/schemas/Position"},"description":"Its open positions."},"risk":{"$ref":"#/components/schemas/AccountRiskOrNull"},"error":{"type":"string","description":"Why the account could not be read now (orders, positions and risk are then empty): read it again by REST.","example":"state_unavailable"}},"required":["type","account_id","orders","positions","risk"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"snapshot","account_id":"SANDBOX-00042-001","orders":[{"id":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W","client_order_id":null,"account_id":"SANDBOX-00042-001","market":"BTC-USD","side":"sell","type":"stop_market","status":"working","size":"0.5","filled_size":"0","limit_price":null,"stop_price":"61000","average_fill_price":null,"fee":null,"reduce_only":null,"time_in_force":"gtc","expires_at":null,"post_only":null,"source":"platform","strategy_id":null,"exits":null,"cancel_reason":null,"reject":{"code":"insufficient_margin","message":null},"created_at":1791460800000,"filled_at":null,"canceled_at":null,"updated_at":1791460800000}],"positions":[{"id":"pos_01JAB7Q8XK4M2N5P7R9S3T5V7W","market":"BTC-USD","side":"long","size":"0.5","entry_price":"62000","mark_price":"63000","notional":"31500","unrealized_pnl":"500","leverage":10,"margin_mode":"isolated","initial_margin":"3100","added_margin":"0","margin":"3100","liquidation":{"price":"56420.5","distance_pct":"10.44","account_wide":false},"breach_prices":{"daily_loss":"52000.1","max_drawdown":"43000.2"},"exits":{"take_profit":[{"order_id":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W","type":"stop_market","price":"61000","size":"0.5"}],"stop_loss":[{"order_id":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W","type":"stop_market","price":"61000","size":"0.5"}]},"protected":true,"opened_at":1791460800000}],"risk":{"as_of":1791460800000,"stale":false,"balance":"101000","equity":"101500","unrealized_pnl":"500","pnl_today":"650.2","realized_today":"150.2","fees_today":"24.8","trades_today":3,"margin_used":"3100","margin_available":"97900","exposure":{"gross":"31500","long":"31500","short":"0","effective_leverage":"0.3103","markets":[{"market":"BTC-USD","notional":"31500","leverage":"0.3103","cap":"1000000","cap_used_pct":"3.15"}]},"daily_loss":{"limit":"5000","floor":"95000","room":"4200.5","used_pct":"16","resets_at":1791460800000,"on_breach":"fail_account","estimated":false,"mode":"end_of_day","at_least":false,"lifted":false},"max_drawdown":{"limit":"5000","floor":"95000","room":"4200.5","used_pct":"16","resets_at":1791460800000,"on_breach":"fail_account","estimated":false,"mode":"end_of_day","at_least":false,"lifted":false},"profit_target":{"goal_balance":"108000","remaining":"7000","progress_pct":"12.5","requires_flat":false},"trading_days":{"count":2,"required":3},"nearest_liquidation":{"market":"BTC-USD","price":"56420.5","distance_pct":"10.44"},"trading_day_ends_at":1791460800000,"warnings":[{"code":"daily_loss_used","level":"warning","market":"BTC-USD","value":"76.5"}]},"error":"state_unavailable"}}]},"AccountSnapshotEnd":{"name":"snapshot_end","title":"snapshot_end","summary":"Every snapshot of a subscribe was sent.","payload":{"type":"object","description":"Every snapshot of a subscribe was sent.","properties":{"type":{"type":"string","enum":["snapshot_end"],"description":"The frame.","example":"snapshot_end"},"accounts":{"type":"array","items":{"type":"string","description":"An account number.","example":"SANDBOX-00042-001"},"description":"Account numbers."}},"required":["type","accounts"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"snapshot_end","accounts":["SANDBOX-00042-001"]}}]},"AccountEvent":{"name":"event","title":"event","summary":"An event of an account you follow, once: as GET /v1/events answers it.","payload":{"type":"object","description":"An event of an account you follow, once: as GET /v1/events answers it.","properties":{"type":{"type":"string","enum":["event"],"description":"The frame.","example":"event"},"seq":{"type":"integer","description":"Counts this connection's events, without a gap.","example":1},"event":{"$ref":"#/components/schemas/Event"},"replayed":{"type":"boolean","description":"Sent again after a resume.","example":true}},"required":["type","seq","event"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"event","seq":1,"event":{"id":"evt_01JAB7Q8XK4M2N5P7R9S3T5V7W","type":"order.filled","account_id":"SANDBOX-00042-001","time":1791460800000,"source":"api","data":{"order":{"id":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W","status":"filled"}}},"replayed":true}}]},"AccountRisk":{"name":"risk","title":"risk","summary":"An account's risk changed (subscribed with risk).","payload":{"type":"object","description":"An account's risk changed (subscribed with risk).","properties":{"type":{"type":"string","enum":["risk"],"description":"The frame.","example":"risk"},"account_id":{"type":"string","description":"The account number.","example":"SANDBOX-00042-001"},"data":{"$ref":"#/components/schemas/AccountRisk"}},"required":["type","account_id","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"risk","account_id":"SANDBOX-00042-001","data":{"as_of":1791460800000,"stale":false,"balance":"101000","equity":"101500","unrealized_pnl":"500","pnl_today":"650.2","realized_today":"150.2","fees_today":"24.8","trades_today":3,"margin_used":"3100","margin_available":"97900","exposure":{"gross":"31500","long":"31500","short":"0","effective_leverage":"0.3103","markets":[{"market":"BTC-USD","notional":"31500","leverage":"0.3103","cap":"1000000","cap_used_pct":"3.15"}]},"daily_loss":{"limit":"5000","floor":"95000","room":"4200.5","used_pct":"16","resets_at":1791460800000,"on_breach":"fail_account","estimated":false,"mode":"end_of_day","at_least":false,"lifted":false},"max_drawdown":{"limit":"5000","floor":"95000","room":"4200.5","used_pct":"16","resets_at":1791460800000,"on_breach":"fail_account","estimated":false,"mode":"end_of_day","at_least":false,"lifted":false},"profit_target":{"goal_balance":"108000","remaining":"7000","progress_pct":"12.5","requires_flat":false},"trading_days":{"count":2,"required":3},"nearest_liquidation":{"market":"BTC-USD","price":"56420.5","distance_pct":"10.44"},"trading_day_ends_at":1791460800000,"warnings":[{"code":"daily_loss_used","level":"warning","market":"BTC-USD","value":"76.5"}]}}}]},"AccountHeartbeat":{"name":"heartbeat","title":"heartbeat","summary":"The connection is alive. Three missed: reconnect.","payload":{"type":"object","description":"The connection is alive. Three missed: reconnect.","properties":{"type":{"type":"string","enum":["heartbeat"],"description":"The frame.","example":"heartbeat"},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"The time on the server.","example":1791460800000}},"required":["type","time"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"heartbeat","time":1791460800000}}]},"AccountPong":{"name":"pong","title":"pong","summary":"The answer to a ping.","payload":{"type":"object","description":"The answer to a ping.","properties":{"type":{"type":"string","enum":["pong"],"description":"The frame.","example":"pong"},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"The time on the server.","example":1791460800000}},"required":["type","time"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"pong","time":1791460800000}}]},"AccountUnsubscribed":{"name":"unsubscribed","title":"unsubscribed","summary":"Those accounts are no longer followed.","payload":{"type":"object","description":"Those accounts are no longer followed.","properties":{"type":{"type":"string","enum":["unsubscribed"],"description":"The frame.","example":"unsubscribed"},"accounts":{"type":"array","items":{"type":"string","description":"An account number.","example":"SANDBOX-00042-001"},"description":"Account numbers."}},"required":["type","accounts"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"unsubscribed","accounts":["SANDBOX-00042-001"]}}]},"AccountNotice":{"name":"notice","title":"notice","summary":"Something to know about this connection, before the snapshot.","payload":{"type":"object","description":"Something to know about this connection, before the snapshot.","properties":{"type":{"type":"string","enum":["notice"],"description":"The frame.","example":"notice"},"code":{"type":"string","enum":["resume_gap"],"description":"resume_gap: the resume could not be covered (an unknown event, or one older than the replay window): events after it may be missing here.","example":"resume_gap"},"after":{"type":"string","description":"The resume asked: read GET /v1/events?after= it for what was missed.","example":"evt_01JAB7Q8XK4M2N5P7R9S3T5V7W"}},"required":["type","code","after"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"notice","code":"resume_gap","after":"evt_01JAB7Q8XK4M2N5P7R9S3T5V7W"}}]},"AccountError":{"name":"error","title":"error","summary":"A message of yours that could not be done. The connection stays open; the SDKs end the stream on it, since it would follow less than they asked.","payload":{"type":"object","description":"A message of yours that could not be done. The connection stays open; the SDKs end the stream on it, since it would follow less than they asked.","properties":{"type":{"type":"string","enum":["error"],"description":"The frame.","example":"error"},"code":{"type":"string","enum":["invalid_json","too_many_accounts","account_not_found"],"description":"What went wrong.","example":"account_not_found"},"account_id":{"type":"string","description":"The account it is about.","example":"SANDBOX-00042-009"},"details":{"type":"object","description":"More about it.","example":{"max":50}}},"required":["type","code"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"error","code":"account_not_found","account_id":"SANDBOX-00042-009","details":{"max":50}}}]},"AccountSubscribeRequest":{"name":"subscribe","title":"subscribe","summary":"Follow accounts: a snapshot of each, then their events. Without accounts, every account your key reaches, and those opened later (each with its snapshot).","payload":{"type":"object","description":"Follow accounts: a snapshot of each, then their events. Without accounts, every account your key reaches, and those opened later (each with its snapshot).","properties":{"op":{"type":"string","enum":["subscribe"],"description":"What you ask.","example":"subscribe"},"accounts":{"type":"array","items":{"type":"string","description":"An account number.","example":"SANDBOX-00042-001"},"description":"The accounts to follow; without it, every account your key reaches."},"risk":{"type":"boolean","description":"Risk frames too (none by default; the snapshot carries the risk either way).","example":true}},"required":["op"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"subscribe","accounts":["SANDBOX-00042-001"],"risk":true}}]},"AccountUnsubscribeRequest":{"name":"unsubscribe","title":"unsubscribe","summary":"Stop following accounts.","payload":{"type":"object","description":"Stop following accounts.","properties":{"op":{"type":"string","enum":["unsubscribe"],"description":"What you ask.","example":"unsubscribe"},"accounts":{"type":"array","items":{"type":"string","description":"An account number.","example":"SANDBOX-00042-001"},"description":"Account numbers."}},"required":["op","accounts"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"unsubscribe","accounts":["SANDBOX-00042-001"]}}]},"AccountPingRequest":{"name":"ping","title":"ping","summary":"Ask for a pong.","payload":{"type":"object","description":"Ask for a pong.","properties":{"op":{"type":"string","enum":["ping"],"description":"What you ask.","example":"ping"}},"required":["op"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"ping"}}]},"MarketHello":{"name":"hello","title":"hello","summary":"First, on every connection: what it offers, and its limits.","payload":{"type":"object","description":"First, on every connection: what it offers, and its limits.","properties":{"type":{"type":"string","enum":["hello"],"description":"The frame.","example":"hello"},"session":{"type":"string","description":"This connection.","example":"mds_5f0c9a7d8e1b4c6a9f3e5d7b"},"heartbeat_ms":{"type":"integer","description":"How often a heartbeat comes.","example":15000},"channels":{"type":"array","items":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"A channel.","example":"ticker"},"description":"The channels you can subscribe to."},"intervals":{"type":"array","items":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"An interval.","example":"1m"},"description":"The candle intervals."},"limits":{"type":"object","properties":{"subscriptions":{"type":"integer","description":"Subscriptions one connection holds at most (a market on a channel; each candle interval counts).","example":200},"symbols_per_subscribe":{"type":"integer","description":"Markets one subscribe names at most.","example":50},"messages_per_s":{"type":"integer","description":"Messages a second you may send; beyond, the connection closes 4009.","example":20}},"required":["subscriptions","symbols_per_subscribe","messages_per_s"],"additionalProperties":false}},"required":["type","session","heartbeat_ms","channels","intervals","limits"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"hello","session":"mds_5f0c9a7d8e1b4c6a9f3e5d7b","heartbeat_ms":15000,"channels":["ticker"],"intervals":["1m"],"limits":{"subscriptions":200,"symbols_per_subscribe":50,"messages_per_s":20}}}]},"MarketSubscribed":{"name":"subscribed","title":"subscribed","summary":"A subscribe was done: then the channel's current state, then snapshot_end.","payload":{"type":"object","description":"A subscribe was done: then the channel's current state, then snapshot_end.","properties":{"type":{"type":"string","enum":["subscribed"],"description":"The frame.","example":"subscribed"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"},"symbols":{"type":"array","items":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"description":"Market ids."},"rejected":{"type":"array","items":{"type":"object","properties":{"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"code":{"type":"string","enum":["market_not_found","too_many_subscriptions"],"description":"Why.","example":"market_not_found"}},"required":["symbol","code"],"additionalProperties":false},"description":"The markets refused, each with why."},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"The candle interval (candles).","example":"1m"}},"required":["type","channel","symbols","rejected"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"subscribed","id":1,"channel":"ticker","symbols":["BTC-USD"],"rejected":[{"symbol":"BTC-USD","code":"market_not_found"}],"interval":"1m"}}]},"MarketSnapshotEnd":{"name":"snapshot_end","title":"snapshot_end","summary":"The current state of a subscribe was sent: live frames follow.","payload":{"type":"object","description":"The current state of a subscribe was sent: live frames follow.","properties":{"type":{"type":"string","enum":["snapshot_end"],"description":"The frame.","example":"snapshot_end"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"}},"required":["type","channel"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"snapshot_end","id":1,"channel":"ticker"}}]},"MarketUnsubscribed":{"name":"unsubscribed","title":"unsubscribed","summary":"An unsubscribe was done: what it ended, and what it named that was not followed.","payload":{"type":"object","description":"An unsubscribe was done: what it ended, and what it named that was not followed.","properties":{"type":{"type":"string","enum":["unsubscribed"],"description":"The frame.","example":"unsubscribed"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"},"symbols":{"type":"array","items":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"description":"The markets no longer followed."},"rejected":{"type":"array","items":{"type":"object","properties":{"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"code":{"type":"string","enum":["not_subscribed"],"description":"Why.","example":"not_subscribed"}},"required":["symbol","code"],"additionalProperties":false},"description":"The markets named that were not followed."},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"The candle interval named (candles).","example":"1m"}},"required":["type","channel","symbols","rejected"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"unsubscribed","id":1,"channel":"ticker","symbols":["BTC-USD"],"rejected":[{"symbol":"BTC-USD","code":"not_subscribed"}],"interval":"1m"}}]},"MarketList":{"name":"list","title":"list","summary":"The answer to list.","payload":{"type":"object","description":"The answer to list.","properties":{"type":{"type":"string","enum":["list"],"description":"The frame.","example":"list"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"subscriptions":{"type":"array","items":{"type":"object","properties":{"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"},"symbol":{"type":"string","description":"The market id, or * for every market.","example":"BTC-USD"},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"The candle interval.","example":"1m"}},"required":["channel","symbol"],"additionalProperties":false},"description":"Your subscriptions."}},"required":["type","subscriptions"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"list","id":1,"subscriptions":[{"channel":"ticker","symbol":"BTC-USD","interval":"1m"}]}}]},"MarketHeartbeat":{"name":"heartbeat","title":"heartbeat","summary":"The connection is alive.","payload":{"type":"object","description":"The connection is alive.","properties":{"type":{"type":"string","enum":["heartbeat"],"description":"The frame.","example":"heartbeat"},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"The time on the server.","example":1791460800000}},"required":["type","time"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"heartbeat","time":1791460800000}}]},"MarketPong":{"name":"pong","title":"pong","summary":"The answer to a ping.","payload":{"type":"object","description":"The answer to a ping.","properties":{"type":{"type":"string","enum":["pong"],"description":"The frame.","example":"pong"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"The time on the server.","example":1791460800000}},"required":["type","time"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"pong","id":1,"time":1791460800000}}]},"MarketError":{"name":"error","title":"error","summary":"A message of yours that could not be done. The connection stays open.","payload":{"type":"object","description":"A message of yours that could not be done. The connection stays open.","properties":{"type":{"type":"string","enum":["error"],"description":"The frame.","example":"error"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"code":{"type":"string","enum":["invalid_json","invalid_request","invalid_parameter","state_unavailable"],"description":"What went wrong.","example":"invalid_parameter"},"details":{"type":"object","description":"The field at fault, or the market.","example":{"field":"symbols","issue":"1 to 50"}}},"required":["type","code"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"error","id":1,"code":"invalid_parameter","details":{"field":"symbols","issue":"1 to 50"}}}]},"MarketSubscribeRequest":{"name":"subscribe","title":"subscribe","summary":"Follow markets on a channel. An option out of its range, or one the channel does not take, is refused with invalid_parameter.","payload":{"type":"object","description":"Follow markets on a channel. An option out of its range, or one the channel does not take, is refused with invalid_parameter.","properties":{"op":{"type":"string","enum":["subscribe"],"description":"What you ask.","example":"subscribe"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"},"symbols":{"type":"array","items":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"description":"Market ids, 1 to 50 (stats: [\"*\"] for every market; status: none)."},"interval_ms":{"type":"integer","enum":[100,250,500,1000],"description":"ticker: the shortest time between frames (default 250).","example":250},"depth":{"type":"integer","enum":[1,5,10,20],"description":"book: levels on each side (default 10).","example":10},"history":{"type":"integer","description":"trades: recent trades sent first, 0 to 200 (default 20). candles: closed candles sent first, 0 to 500 (default 100), then the forming one.","example":100},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"candles: the interval.","example":"1m"}},"required":["op","channel"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"subscribe","id":1,"channel":"ticker","symbols":["BTC-USD"],"interval_ms":250,"depth":10,"history":100,"interval":"1m"}}]},"MarketUnsubscribeRequest":{"name":"unsubscribe","title":"unsubscribe","summary":"Stop following markets on a channel.","payload":{"type":"object","description":"Stop following markets on a channel.","properties":{"op":{"type":"string","enum":["unsubscribe"],"description":"What you ask.","example":"unsubscribe"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1},"channel":{"type":"string","enum":["ticker","book","trades","candles","stats","status"],"description":"The channel.","example":"ticker"},"symbols":{"type":"array","items":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"description":"The markets to stop following; none, or an empty list, for every one of the channel (status: none)."},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"candles: the interval to stop; none for every interval of those markets.","example":"1m"}},"required":["op","channel"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"unsubscribe","id":1,"channel":"ticker","symbols":["BTC-USD"],"interval":"1m"}}]},"MarketListRequest":{"name":"list","title":"list","summary":"Ask for your subscriptions.","payload":{"type":"object","description":"Ask for your subscriptions.","properties":{"op":{"type":"string","enum":["list"],"description":"What you ask.","example":"list"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1}},"required":["op"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"list","id":1}}]},"MarketPingRequest":{"name":"ping","title":"ping","summary":"Ask for a pong.","payload":{"type":"object","description":"Ask for a pong.","properties":{"op":{"type":"string","enum":["ping"],"description":"What you ask.","example":"ping"},"id":{"type":["integer","string"],"description":"Your id for the request, echoed in its answers.","example":1}},"required":["op"],"additionalProperties":false},"x-pp-direction":"send","examples":[{"payload":{"op":"ping","id":1}}]},"MarketDataTicker":{"name":"ticker","title":"ticker","summary":"The latest prices, at most once per interval_ms.","payload":{"type":"object","description":"The latest prices, at most once per interval_ms.","properties":{"type":{"type":"string","enum":["ticker"],"description":"The frame.","example":"ticker"},"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"data":{"type":"object","properties":{"bid":{"type":["string","null"],"format":"decimal","description":"The best bid.","example":"63012.5"},"ask":{"type":["string","null"],"format":"decimal","description":"The best ask.","example":"63012.5"},"last":{"type":["string","null"],"format":"decimal","description":"The last trade.","example":"63012.5"},"time":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When it was last updated.","example":1791460800000}},"required":["bid","ask","last","time"],"additionalProperties":false}},"required":["type","symbol","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"ticker","symbol":"BTC-USD","data":{"bid":"63012.5","ask":"63012.5","last":"63012.5","time":1791460800000}}}]},"MarketDataBook":{"name":"book","title":"book","summary":"The top of the book to the depth asked, whole every time (replace what you hold), at most every 250 ms.","payload":{"type":"object","description":"The top of the book to the depth asked, whole every time (replace what you hold), at most every 250 ms.","properties":{"type":{"type":"string","enum":["book"],"description":"The frame.","example":"book"},"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"data":{"type":"object","properties":{"bids":{"type":"array","items":{"type":"array","items":{"type":"string","format":"decimal"},"description":"A price and the size at it.","example":["63012.5","1.204"]},"description":"Bids, best first."},"asks":{"type":"array","items":{"type":"array","items":{"type":"string","format":"decimal"},"description":"A price and the size at it.","example":["63012.5","1.204"]},"description":"Asks, best first."},"time":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When the book was read.","example":1791460800000}},"required":["bids","asks","time"],"additionalProperties":false}},"required":["type","symbol","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"book","symbol":"BTC-USD","data":{"bids":[["63012.5","1.204"]],"asks":[["63012.5","1.204"]],"time":1791460800000}}}]},"MarketDataTrades":{"name":"trades","title":"trades","summary":"Trades as they print, batched every 100 ms; first the history asked.","payload":{"type":"object","description":"Trades as they print, batched every 100 ms; first the history asked.","properties":{"type":{"type":"string","enum":["trades"],"description":"The frame.","example":"trades"},"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"The trade.","example":"4f1a2c-118"},"price":{"type":["string","null"],"format":"decimal","description":"Its price.","example":"63012.5"},"size":{"type":["string","null"],"format":"decimal","description":"Its size.","example":"0.25"},"side":{"type":"string","enum":["buy","sell"],"description":"The side that took liquidity.","example":"buy"},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When it traded.","example":1791460800000}},"required":["id","price","size","side","time"],"additionalProperties":false},"description":"Trades, oldest first."}},"required":["type","symbol","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"trades","symbol":"BTC-USD","data":[{"id":"4f1a2c-118","price":"63012.5","size":"0.25","side":"buy","time":1791460800000}]}}]},"MarketDataCandles":{"name":"candles","title":"candles","summary":"Candles: first the history asked, then the forming candle as it changes and each closed one.","payload":{"type":"object","description":"Candles: first the history asked, then the forming candle as it changes and each closed one.","properties":{"type":{"type":"string","enum":["candles"],"description":"The frame.","example":"candles"},"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"interval":{"type":"string","enum":["1m","3m","5m","15m","30m","1h","2h","4h","6h","12h","1d","1w","1M"],"description":"The candle interval.","example":"1m"},"data":{"type":"array","items":{"type":"object","properties":{"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When the candle starts.","example":1791460800000},"open":{"type":["string","null"],"format":"decimal","description":"The first price.","example":"63012.5"},"high":{"type":["string","null"],"format":"decimal","description":"The highest.","example":"63012.5"},"low":{"type":["string","null"],"format":"decimal","description":"The lowest.","example":"63012.5"},"close":{"type":["string","null"],"format":"decimal","description":"The last.","example":"63012.5"},"volume":{"type":["string","null"],"format":"decimal","description":"The size traded.","example":"0.25"},"final":{"type":"boolean","description":"false: still forming, it comes again as it changes.","example":true},"revised":{"type":"boolean","description":"A closed candle sent again with its final figures.","example":true}},"required":["time","open","high","low","close","volume","final"],"additionalProperties":false},"description":"Candles, oldest first."}},"required":["type","symbol","interval","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"candles","symbol":"BTC-USD","interval":"1m","data":[{"time":1791460800000,"open":"63012.5","high":"63012.5","low":"63012.5","close":"63012.5","volume":"0.25","final":true,"revised":true}]}}]},"MarketDataStats":{"name":"stats","title":"stats","summary":"24-hour figures and open interest, every 5 seconds (GET /v1/markets/stats answers the same for every market).","payload":{"type":"object","description":"24-hour figures and open interest, every 5 seconds (GET /v1/markets/stats answers the same for every market).","properties":{"type":{"type":"string","enum":["stats"],"description":"The frame.","example":"stats"},"symbol":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"data":{"type":"object","properties":{"last":{"type":["string","null"],"format":"decimal","description":"The last trade.","example":"63012.5"},"change_24h":{"type":["string","null"],"format":"decimal","description":"The change over 24 hours.","example":"63012.5"},"change_24h_pct":{"type":["string","null"],"format":"decimal","description":"That change in percent.","example":"1.42"},"high_24h":{"type":["string","null"],"format":"decimal","description":"The highest in 24 hours.","example":"63012.5"},"low_24h":{"type":["string","null"],"format":"decimal","description":"The lowest in 24 hours.","example":"63012.5"},"volume_24h":{"type":["string","null"],"format":"decimal","description":"The size traded in 24 hours.","example":"0.25"},"notional_volume_24h":{"type":["string","null"],"format":"decimal","description":"The value traded in 24 hours, in USD.","example":"182340112.50"},"open_interest":{"type":["string","null"],"format":"decimal","description":"The market's open interest: the size held open in positions.","example":"0.25"},"notional_open_interest":{"type":["string","null"],"format":"decimal","description":"That open interest in USD, at the last price.","example":"5910412345.20"}},"required":["last","change_24h","change_24h_pct","high_24h","low_24h","volume_24h","notional_volume_24h","open_interest","notional_open_interest"],"additionalProperties":false}},"required":["type","symbol","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"stats","symbol":"BTC-USD","data":{"last":"63012.5","change_24h":"63012.5","change_24h_pct":"1.42","high_24h":"63012.5","low_24h":"63012.5","volume_24h":"0.25","notional_volume_24h":"182340112.50","open_interest":"0.25","notional_open_interest":"5910412345.20"}}}]},"MarketDataStatus":{"name":"status","title":"status","summary":"The price feed's state, when it changes.","payload":{"type":"object","description":"The price feed's state, when it changes.","properties":{"type":{"type":"string","enum":["status"],"description":"The frame.","example":"status"},"data":{"type":"object","properties":{"feed":{"type":"object","properties":{"state":{"type":"string","enum":["live","degraded","down"],"description":"live: prices are flowing.","example":"live"},"age_ms":{"type":["integer","null"],"description":"Milliseconds since the last price.","example":120}},"required":["state","age_ms"],"additionalProperties":false}},"required":["feed"],"additionalProperties":false}},"required":["type","data"],"additionalProperties":false},"x-pp-direction":"receive","examples":[{"payload":{"type":"status","data":{"feed":{"state":"live","age_ms":120}}}}]}},"schemas":{"Order":{"type":"object","properties":{"id":{"type":"string","description":"The order.","example":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W"},"client_order_id":{"type":["string","null"],"description":"Your own id for it, when it was placed through the API.","example":null},"account_id":{"type":"string","description":"The account number.","example":"SANDBOX-00042-001"},"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"side":{"type":["string","null"],"enum":["buy","sell",null],"description":"The order's side; null for an order placed elsewhere before the API saw it.","example":"sell"},"type":{"type":["string","null"],"enum":["market","limit","stop_market","stop_limit","take_market","take_limit",null],"description":"The order's type.","example":"stop_market"},"status":{"type":"string","enum":["pending","working","filled","canceled","rejected","expired","unconfirmed"],"description":"unconfirmed: the engine has not confirmed its last state yet.","example":"working"},"size":{"type":["string","null"],"format":"decimal","description":"The size, in the base asset.","example":"0.5"},"filled_size":{"type":["string","null"],"format":"decimal","description":"How much filled.","example":"0"},"limit_price":{"type":["string","null"],"format":"decimal","description":"Its limit price.","example":null},"stop_price":{"type":["string","null"],"format":"decimal","description":"Its trigger price.","example":"61000"},"average_fill_price":{"type":["string","null"],"format":"decimal","description":"The average fill price.","example":null},"fee":{"type":["string","null"],"format":"decimal","description":"The fee its fill paid.","example":null},"reduce_only":{"type":["boolean","null"],"description":"It may only reduce a position; null when not known (placed elsewhere).","example":null},"time_in_force":{"type":"string","enum":["gtc","gtd","ioc","fok"],"description":"How long it rests.","example":"gtc"},"expires_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"A gtd order: when it expires (it ends expired then); null otherwise.","example":null},"post_only":{"type":["boolean","null"],"description":"It may only rest, never fill at once; null when not known (placed elsewhere).","example":null},"source":{"type":"string","enum":["api","mcp","platform","strategy","tradingview","system"],"description":"Where it was placed: this API, an AI assistant (the MCP server), a trading platform, a strategy, a TradingView alert, or the system (a liquidation).","example":"platform"},"strategy_id":{"type":["string","null"],"description":"The strategy that placed it (source strategy).","example":null},"exits":{"type":["object","null"],"description":"Exits attached to it (orders placed through the API).","example":null},"cancel_reason":{"type":["string","null"],"enum":["user","cancel_all","flatten","close_all","position_closed","position_reversed","close_assist","oco","replaced","strategy","key_loss_stop","risk_rule","system_restart","external",null],"description":"Why it was canceled.","example":null},"reject":{"type":["object","null"],"properties":{"code":{"type":"string","description":"The error code.","example":"insufficient_margin"},"message":{"type":["string","null"],"description":"What happened.","example":null}},"required":["code","message"],"additionalProperties":false},"created_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When it was placed.","example":1791460800000},"filled_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When it filled.","example":null},"canceled_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When it was canceled.","example":null},"updated_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"Its latest change.","example":1791460800000}},"required":["id","client_order_id","account_id","market","side","type","status","size","filled_size","limit_price","stop_price","average_fill_price","fee","reduce_only","time_in_force","expires_at","post_only","source","strategy_id","exits","cancel_reason","reject","created_at","filled_at","canceled_at"],"additionalProperties":false},"Position":{"type":"object","properties":{"id":{"type":"string","description":"This position, while it stays open on the same side.","example":"pos_01JAB7Q8XK4M2N5P7R9S3T5V7W"},"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"side":{"type":"string","enum":["long","short"],"description":"Long or short.","example":"long"},"size":{"type":"string","format":"decimal","description":"The size, in the base asset.","example":"0.5"},"entry_price":{"type":["string","null"],"format":"decimal","description":"The average entry price.","example":"62000"},"mark_price":{"type":["string","null"],"format":"decimal","description":"The market price it is valued at.","example":"63000"},"notional":{"type":["string","null"],"format":"decimal","description":"Its value at that price.","example":"31500"},"unrealized_pnl":{"type":["string","null"],"format":"decimal","description":"Its open P&L.","example":"500"},"leverage":{"type":"integer","description":"Its leverage.","example":10},"margin_mode":{"type":"string","enum":["isolated","cross"],"description":"Its margin mode.","example":"isolated"},"initial_margin":{"type":["string","null"],"format":"decimal","description":"The margin it took at entry.","example":"3100"},"added_margin":{"type":["string","null"],"format":"decimal","description":"Margin you added to it.","example":"0"},"margin":{"type":["string","null"],"format":"decimal","description":"What it holds of the balance.","example":"3100"},"liquidation":{"type":["object","null"],"properties":{"price":{"type":["string","null"],"format":"decimal","description":"The price at which it is liquidated; null when there is none or it depends on several positions.","example":"56420.5"},"distance_pct":{"type":["string","null"],"format":"decimal","description":"How far the market price is from it, in percent.","example":"10.44"},"account_wide":{"type":"boolean","description":"Cross margin on several markets: no single price, every one of them moves it.","example":false}},"required":["price","distance_pct","account_wide"],"additionalProperties":false},"breach_prices":{"type":"object","properties":{"daily_loss":{"type":["string","null"],"format":"decimal","description":"The price at which this position alone would breach the daily loss limit.","example":"52000.1"},"max_drawdown":{"type":["string","null"],"format":"decimal","description":"The price at which it alone would breach the max drawdown.","example":"43000.2"}},"required":["daily_loss","max_drawdown"],"additionalProperties":false},"exits":{"type":"object","properties":{"take_profit":{"type":"array","items":{"$ref":"#/components/schemas/ExitLeg"},"description":"Limit orders on the closing side."},"stop_loss":{"type":"array","items":{"$ref":"#/components/schemas/ExitLeg"},"description":"Stop orders on the closing side."}},"required":["take_profit","stop_loss"],"additionalProperties":false},"protected":{"type":"boolean","description":"At least one stop loss rests on it.","example":true},"opened_at":{"type":["integer","null"],"format":"int64","x-pp-unit":"ms","description":"When it opened.","example":1791460800000}},"required":["id","market","side","size","entry_price","mark_price","notional","unrealized_pnl","leverage","margin_mode","initial_margin","added_margin","margin","liquidation","breach_prices","exits","protected","opened_at"],"additionalProperties":false},"ExitLeg":{"type":"object","properties":{"order_id":{"type":"string","description":"The working order.","example":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W"},"type":{"type":"string","enum":["market","limit","stop_market","stop_limit","take_market","take_limit"],"description":"The order's type.","example":"stop_market"},"price":{"type":["string","null"],"format":"decimal","description":"Its trigger or limit price.","example":"61000"},"size":{"type":["string","null"],"format":"decimal","description":"Its size.","example":"0.5"}},"required":["order_id","type","price","size"],"additionalProperties":false},"AccountRiskOrNull":{"type":["object","null"],"properties":{"as_of":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When the oldest figure here was read.","example":1791460800000},"stale":{"type":"boolean","description":"Some figures are older than usual (the engine was busy).","example":false},"balance":{"type":"string","format":"decimal","description":"The balance.","example":"101000"},"equity":{"type":"string","format":"decimal","description":"The balance plus the open P&L at the market price.","example":"101500"},"unrealized_pnl":{"type":"string","format":"decimal","description":"The open P&L.","example":"500"},"pnl_today":{"type":"string","format":"decimal","description":"The equity change since midnight New York, open positions included: what the daily loss rule counts.","example":"650.2"},"realized_today":{"type":"string","format":"decimal","description":"The P&L closed today.","example":"150.2"},"fees_today":{"type":"string","format":"decimal","description":"The fees paid today.","example":"24.8"},"trades_today":{"type":"integer","description":"Trades closed today.","example":3},"margin_used":{"type":"string","format":"decimal","description":"The margin your positions hold.","example":"3100"},"margin_available":{"type":["string","null"],"format":"decimal","description":"What is left of the balance for new positions.","example":"97900"},"exposure":{"type":"object","properties":{"gross":{"type":"string","format":"decimal","description":"The value of every open position.","example":"31500"},"long":{"type":"string","format":"decimal","description":"The value of the long ones.","example":"31500"},"short":{"type":"string","format":"decimal","description":"The value of the short ones.","example":"0"},"effective_leverage":{"type":["string","null"],"format":"decimal","description":"Gross exposure over equity.","example":"0.3103"},"markets":{"type":"array","items":{"type":"object","properties":{"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"notional":{"type":"string","format":"decimal","description":"The value held on it.","example":"31500"},"leverage":{"type":["string","null"],"format":"decimal","description":"That value over equity.","example":"0.3103"},"cap":{"type":["string","null"],"format":"decimal","description":"The exposure cap of the market.","example":"1000000"},"cap_used_pct":{"type":["string","null"],"format":"decimal","description":"How much of the cap is used, counting your other accounts on the same rule, in percent.","example":"3.15"}},"required":["market","notional","leverage","cap","cap_used_pct"],"additionalProperties":false},"description":"Per market, largest first."}},"required":["gross","long","short","effective_leverage","markets"],"additionalProperties":false},"daily_loss":{"$ref":"#/components/schemas/Limit"},"max_drawdown":{"$ref":"#/components/schemas/Limit"},"profit_target":{"type":["object","null"],"properties":{"goal_balance":{"type":"string","format":"decimal","description":"The balance that reaches it.","example":"108000"},"remaining":{"type":"string","format":"decimal","description":"Still to make.","example":"7000"},"progress_pct":{"type":["string","null"],"format":"decimal","description":"How far, in percent.","example":"12.5"},"requires_flat":{"type":"boolean","description":"Positions must be closed when it is reached.","example":false}},"required":["goal_balance","remaining","progress_pct","requires_flat"],"additionalProperties":false},"trading_days":{"type":"object","properties":{"count":{"type":["integer","null"],"description":"Days with a trade so far.","example":2},"required":{"type":["integer","null"],"description":"Days the rule needs.","example":3}},"required":["count","required"],"additionalProperties":false},"nearest_liquidation":{"type":["object","null"],"properties":{"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"price":{"type":"string","format":"decimal","description":"Its liquidation price.","example":"56420.5"},"distance_pct":{"type":"string","format":"decimal","description":"How far the price is from it, in percent.","example":"10.44"}},"required":["market","price","distance_pct"],"additionalProperties":false},"trading_day_ends_at":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When the trading day ends (midnight New York).","example":1791460800000},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/Warning"},"description":"What needs your attention, most serious first."}},"required":["as_of","stale","balance","equity","unrealized_pnl","pnl_today","realized_today","fees_today","trades_today","margin_used","margin_available","exposure","daily_loss","max_drawdown","profit_target","trading_days","nearest_liquidation","trading_day_ends_at","warnings"],"additionalProperties":false,"description":"The live risk; null while the account is being opened."},"Limit":{"type":["object","null"],"description":"A loss limit and the room left to it.","properties":{"limit":{"type":"string","format":"decimal","description":"The limit, in USD.","example":"5000"},"floor":{"type":"string","format":"decimal","description":"The equity at which it is breached.","example":"95000"},"room":{"type":"string","format":"decimal","description":"How much more the account may lose before it.","example":"4200.5"},"used_pct":{"type":["string","null"],"format":"decimal","description":"How much of it is used, in percent.","example":"16"},"resets_at":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"Daily loss only: when it resets (midnight New York).","example":1791460800000},"on_breach":{"type":"string","enum":["fail_account","flatten","flatten_and_pause"],"description":"Daily loss only: what happens when it is reached.","example":"fail_account"},"estimated":{"type":"boolean","description":"Daily loss only: the day's start is estimated (the engine does not publish it).","example":false},"mode":{"type":"string","enum":["end_of_day","end_of_trade","static","intraday_equity"],"description":"Max drawdown only: how the reference moves.","example":"end_of_day"},"at_least":{"type":"boolean","description":"Max drawdown only: the engine may hold a higher floor than shown (it follows equity highs).","example":false},"lifted":{"type":"boolean","description":"The rule no longer applies this limit (its cut-off was reached).","example":false}},"required":["lifted"],"additionalProperties":false},"Warning":{"type":"object","properties":{"code":{"type":"string","enum":["daily_loss_used","max_drawdown_used","liquidation_near","no_stop_loss","margin_used","order_without_position"],"description":"What it is about.","example":"daily_loss_used"},"level":{"type":"string","enum":["info","warning","critical"],"description":"How serious.","example":"warning"},"market":{"type":"string","description":"The market it is about.","example":"BTC-USD"},"value":{"type":"string","format":"decimal","description":"The figure behind it, in percent.","example":"76.5"}},"required":["code","level"],"additionalProperties":false},"Event":{"type":"object","properties":{"id":{"type":"string","description":"The event; pass it as after (GET /v1/events) or resume (the stream) to continue from it.","example":"evt_01JAB7Q8XK4M2N5P7R9S3T5V7W"},"type":{"type":"string","enum":["order.created","order.edited","order.filled","order.canceled","order.rejected","order.expired","fill.created","position.opened","position.changed","position.closed","strategy.created","strategy.leg_placed","strategy.leg_modified","strategy.leg_filled","strategy.leg_canceled","strategy.leg_rejected","strategy.orphan_repaired","strategy.slice","strategy.triggered","strategy.ended","tradingview.alert_executed","tradingview.alert_refused","account.updated","account.passed","account.failed","account.payout_eligible","account.disabled","account.removed","key.loss_stop","key.expiring","system.restarted","risk.warning","risk.cleared","alert.triggered"],"description":"What happened (GET /v1/webhook-event-types says what each type means).","example":"order.filled"},"account_id":{"type":"string","description":"The account number.","example":"SANDBOX-00042-001"},"time":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When it happened.","example":1791460800000},"source":{"type":"string","enum":["api","mcp","platform","engine","strategy","tradingview"],"description":"Where it came from: an order placed through this API or by an AI assistant (the MCP server), one placed on a trading platform, the engine itself (positions), a strategy of this API, or a TradingView alert.","example":"api"},"data":{"type":"object","description":"order or fill (the objects REST answers), with changes or close_reason when they apply. A position.* event carries position { market, side, size, average_price } as the engine reported it, and previous_size: read GET .../positions/{market} for its margin, P&L and liquidation.","example":{"order":{"id":"ord_01JAB7Q8XK4M2N5P7R9S3T5V7W","status":"filled"}}}},"required":["id","type","account_id","time","source","data"],"additionalProperties":false},"AccountRisk":{"type":"object","properties":{"as_of":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When the oldest figure here was read.","example":1791460800000},"stale":{"type":"boolean","description":"Some figures are older than usual (the engine was busy).","example":false},"balance":{"type":"string","format":"decimal","description":"The balance.","example":"101000"},"equity":{"type":"string","format":"decimal","description":"The balance plus the open P&L at the market price.","example":"101500"},"unrealized_pnl":{"type":"string","format":"decimal","description":"The open P&L.","example":"500"},"pnl_today":{"type":"string","format":"decimal","description":"The equity change since midnight New York, open positions included: what the daily loss rule counts.","example":"650.2"},"realized_today":{"type":"string","format":"decimal","description":"The P&L closed today.","example":"150.2"},"fees_today":{"type":"string","format":"decimal","description":"The fees paid today.","example":"24.8"},"trades_today":{"type":"integer","description":"Trades closed today.","example":3},"margin_used":{"type":"string","format":"decimal","description":"The margin your positions hold.","example":"3100"},"margin_available":{"type":["string","null"],"format":"decimal","description":"What is left of the balance for new positions.","example":"97900"},"exposure":{"type":"object","properties":{"gross":{"type":"string","format":"decimal","description":"The value of every open position.","example":"31500"},"long":{"type":"string","format":"decimal","description":"The value of the long ones.","example":"31500"},"short":{"type":"string","format":"decimal","description":"The value of the short ones.","example":"0"},"effective_leverage":{"type":["string","null"],"format":"decimal","description":"Gross exposure over equity.","example":"0.3103"},"markets":{"type":"array","items":{"type":"object","properties":{"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"notional":{"type":"string","format":"decimal","description":"The value held on it.","example":"31500"},"leverage":{"type":["string","null"],"format":"decimal","description":"That value over equity.","example":"0.3103"},"cap":{"type":["string","null"],"format":"decimal","description":"The exposure cap of the market.","example":"1000000"},"cap_used_pct":{"type":["string","null"],"format":"decimal","description":"How much of the cap is used, counting your other accounts on the same rule, in percent.","example":"3.15"}},"required":["market","notional","leverage","cap","cap_used_pct"],"additionalProperties":false},"description":"Per market, largest first."}},"required":["gross","long","short","effective_leverage","markets"],"additionalProperties":false},"daily_loss":{"$ref":"#/components/schemas/Limit"},"max_drawdown":{"$ref":"#/components/schemas/Limit"},"profit_target":{"type":["object","null"],"properties":{"goal_balance":{"type":"string","format":"decimal","description":"The balance that reaches it.","example":"108000"},"remaining":{"type":"string","format":"decimal","description":"Still to make.","example":"7000"},"progress_pct":{"type":["string","null"],"format":"decimal","description":"How far, in percent.","example":"12.5"},"requires_flat":{"type":"boolean","description":"Positions must be closed when it is reached.","example":false}},"required":["goal_balance","remaining","progress_pct","requires_flat"],"additionalProperties":false},"trading_days":{"type":"object","properties":{"count":{"type":["integer","null"],"description":"Days with a trade so far.","example":2},"required":{"type":["integer","null"],"description":"Days the rule needs.","example":3}},"required":["count","required"],"additionalProperties":false},"nearest_liquidation":{"type":["object","null"],"properties":{"market":{"type":"string","description":"A market id: the asset and USD; an option adds its venue or hours after a dot.","example":"BTC-USD"},"price":{"type":"string","format":"decimal","description":"Its liquidation price.","example":"56420.5"},"distance_pct":{"type":"string","format":"decimal","description":"How far the price is from it, in percent.","example":"10.44"}},"required":["market","price","distance_pct"],"additionalProperties":false},"trading_day_ends_at":{"type":"integer","format":"int64","x-pp-unit":"ms","description":"When the trading day ends (midnight New York).","example":1791460800000},"warnings":{"type":"array","items":{"$ref":"#/components/schemas/Warning"},"description":"What needs your attention, most serious first."}},"required":["as_of","stale","balance","equity","unrealized_pnl","pnl_today","realized_today","fees_today","trades_today","margin_used","margin_available","exposure","daily_loss","max_drawdown","profit_target","trading_days","nearest_liquidation","trading_day_ends_at","warnings"],"additionalProperties":false}}}}