{"openapi":"3.1.0","info":{"title":"Pipsocket trading API","description":"Hosted MT5 accounts behind an API. Every call is for one account, under `/v1/accounts/{account}`, with your workspace's API key in `Authorization: Bearer <key>`. One trade call is one MT5 trade request, sent once: fields are MT5's `MqlTradeRequest` with readable values.","license":{"name":""},"version":"1"},"servers":[{"url":"https://api.pipsocket.com"}],"paths":{"/v1/accounts/{account}":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Account"],"summary":"Get the account","description":"The account's login, status and connection, and the balance, equity and margin from its terminal's last report (once a second). Read from the engine, not the terminal, so it answers while the terminal is away.","operationId":"account","responses":{"200":{"description":"The account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AccountView"},"examples":{"connected":{"summary":"Connected","value":{"balance":10000,"company":"FBS Markets Inc.","connected":true,"credit":0,"currency":"USD","equity":10012.4,"id":"acc_01m6tx3k9f2qw8r7bznd5yvh4c","kill_switch":{"deviation":null,"engaged":false,"since":null},"leverage":500,"login":5058427372,"margin":21.68,"margin_free":9990.72,"margin_mode":"hedging","server":"FBS-Demo","server_time":1794067825,"status":"connected","trade_allowed":true,"trade_mode":"demo"}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"503":{"description":"- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}}},"/v1/accounts/{account}/orders":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Orders"],"summary":"List pending orders","description":"The account's pending orders, read fresh from its terminal.","operationId":"pending_orders","responses":{"200":{"description":"Every pending order.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PendingOrderView"}},"examples":{"orders":{"summary":"One pending order","value":[{"comment":"","magic":0,"position":0,"price_open":1.075,"sl":0,"symbol":"EURUSD","ticket":881402377,"tp":0,"type":"buy_limit","volume_current":0.1,"volume_initial":0.1}]}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}},"post":{"tags":["Orders"],"summary":"Place an order","description":"Sends one trade request (MT5's `TRADE_ACTION_DEAL` for `buy` and `sell`, `TRADE_ACTION_PENDING` for the rest) to the account's terminal, with the stop loss and take profit in the same request, and waits up to 5 seconds for the trade server's answer. The request goes as you send it: nothing is split, retried, rounded or adjusted.","operationId":"place_order","parameters":[{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlaceOrder"},"example":{"sl":1.079,"symbol":"EURUSD","type":"buy","type_filling":"ioc","volume":0.1}}},"required":true},"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":771203455,"order":881402311,"position":0,"price":1.08412,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0.1},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The stop loss or take profit is invalid for this symbol or too close to the price.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Invalid stops","deal":0,"order":0,"position":0,"price":0,"retcode":10016,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID_STOPS","volume":0},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"pending"}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"423":{"description":"- `kill_switch_engaged`: The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"kill_switch_engaged":{"summary":"The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Nothing was sent.","value":{"error":"kill_switch_engaged","message":"The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Closing positions, cancelling orders and setting stops still work."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"refused"}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}}},"/v1/accounts/{account}/orders/check":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"post":{"tags":["Orders"],"summary":"Check an order","description":"MT5's `OrderCheck`: whether the order would pass, and the margin it would take. Nothing is sent to the trade server. Takes the same body as Place an order.","operationId":"check_order","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlaceOrder"},"example":{"sl":1.079,"symbol":"EURUSD","type":"buy","type_filling":"ioc","volume":0.1}}},"required":true},"responses":{"200":{"description":"MT5's check result.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckView"},"examples":{"passed":{"summary":"Passed","value":{"message":"The request passed the check.","result":{"balance":10000,"comment":"Done","equity":10000,"margin":108.41,"margin_free":9891.59,"margin_level":9224.24,"passed":true,"profit":0,"retcode":0,"retcode_name":"OK"},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1}}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `bad_command`: The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"bad_command":{"summary":"The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.","value":{"error":"bad_command","message":"deviation, expiration, tickets and magic must not be negative"}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/orders/{order}":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"delete":{"tags":["Orders"],"summary":"Cancel a pending order","description":"Deletes a pending order (`TRADE_ACTION_REMOVE`).","operationId":"cancel_order","parameters":[{"name":"order","in":"path","description":"The pending order's ticket.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":881402377},{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":0,"order":881402377,"position":0,"price":0,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0},"sent":{"action":"remove","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"","tp":0,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The request is invalid.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Invalid request","deal":0,"order":0,"position":0,"price":0,"retcode":10013,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID","volume":0},"sent":{"action":"remove","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"","tp":0,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"remove","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"","tp":0,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"pending"}}}}}},"400":{"description":"The ticket in the path is not a whole number. No body."},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"remove","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"","tp":0,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"refused"}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}},"patch":{"tags":["Orders"],"summary":"Modify a pending order","description":"Changes a pending order's price, stops and expiry (`TRADE_ACTION_MODIFY`). Every level is given: MT5 replaces them all.","operationId":"modify_order","parameters":[{"name":"order","in":"path","description":"The pending order's ticket.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":881402377},{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModifyOrder"},"example":{"price":1.074,"sl":1.069,"tp":1.09,"type_time":"gtc"}}},"required":true},"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":0,"order":881402377,"position":0,"price":0,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0},"sent":{"action":"modify","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":1.074,"sl":1.069,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The price is invalid.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Invalid price","deal":0,"order":0,"position":0,"price":0,"retcode":10015,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID_PRICE","volume":0},"sent":{"action":"modify","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":1.074,"sl":1.069,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"modify","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":1.074,"sl":1.069,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"pending"}}}}}},"400":{"description":"The ticket in the path is not a whole number. No body."},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_order`: The account has no pending order with that ticket (read fresh from the terminal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_order":{"summary":"The account has no pending order with that ticket (read fresh from the terminal).","value":{"error":"no_such_order","message":"The account has no pending order with that ticket."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"423":{"description":"- `kill_switch_engaged`: The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"kill_switch_engaged":{"summary":"The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Nothing was sent.","value":{"error":"kill_switch_engaged","message":"The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Closing positions, cancelling orders and setting stops still work."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"modify","comment":"","deviation":0,"expiration":0,"magic":0,"order":881402377,"position":0,"position_by":0,"price":1.074,"sl":1.069,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"refused"}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/positions":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Positions"],"summary":"List open positions","description":"The account's open positions, read fresh from its terminal.","operationId":"positions","responses":{"200":{"description":"Every open position.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/PositionView"}},"examples":{"positions":{"summary":"One position","value":[{"comment":"","identifier":881402311,"magic":0,"price_open":1.08412,"sl":1.079,"symbol":"EURUSD","ticket":881402311,"time_msc":1794067801211,"tp":0,"type":"buy","volume":0.1}]}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/positions/{position}":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"patch":{"tags":["Positions"],"summary":"Set stop loss and take profit","description":"Sets an open position's stop loss and take profit (`TRADE_ACTION_SLTP`). Both are given; 0 removes one.","operationId":"set_position_levels","parameters":[{"name":"position","in":"path","description":"The position's ticket.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":881402311},{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PositionLevels"},"example":{"sl":1.079,"tp":1.09}}},"required":true},"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":0,"order":0,"position":0,"price":0,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0},"sent":{"action":"sltp","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The stop loss or take profit is invalid for this symbol or too close to the price.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Invalid stops","deal":0,"order":0,"position":0,"price":0,"retcode":10016,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID_STOPS","volume":0},"sent":{"action":"sltp","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"sltp","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"pending"}}}}}},"400":{"description":"The ticket in the path is not a whole number. No body."},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_position`: The account has no open position with that ticket (read fresh from the terminal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_position":{"summary":"The account has no open position with that ticket (read fresh from the terminal).","value":{"error":"no_such_position","message":"The account has no open position with that ticket."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"sltp","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":1.09,"type":"buy","type_filling":"fok","type_time":"gtc","volume":0},"state":"refused"}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/positions/{position}/close":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"post":{"tags":["Positions"],"summary":"Close a position","description":"Closes all or part of an open position: a deal the other way for the volume given, naming the position (`TRADE_ACTION_DEAL` with `position`).","operationId":"close_position","parameters":[{"name":"position","in":"path","description":"The position's ticket.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":881402311},{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClosePosition"},"example":{"type_filling":"ioc","volume":0.1}}},"required":true},"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":771203498,"order":881402390,"position":0,"price":1.0841,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0.1},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"sell","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The filling mode is not allowed for this symbol.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Unsupported filling mode","deal":0,"order":0,"position":0,"price":0,"retcode":10030,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID_FILL","volume":0},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"sell","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"sell","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"pending"}}}}}},"400":{"description":"The ticket in the path is not a whole number. No body."},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_position`: The account has no open position with that ticket (read fresh from the terminal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_position":{"summary":"The account has no open position with that ticket (read fresh from the terminal).","value":{"error":"no_such_position","message":"The account has no open position with that ticket."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"sell","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"refused"}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/positions/{position}/close-by":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"post":{"tags":["Positions"],"summary":"Close by an opposite position","description":"Closes a position against an opposite position on the same symbol (`TRADE_ACTION_CLOSE_BY`).","operationId":"close_by","parameters":[{"name":"position","in":"path","description":"The position's ticket.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":881402311},{"name":"Idempotency-Key","in":"header","description":"Your own key for this request, 1 to 128 characters. A request with a key the account has used\nbefore (in the last 7 days) is not sent: the first request's answer comes back instead, as it\nstands now.","required":false,"schema":{"type":"string","maxLength":128,"minLength":1}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CloseBy"},"example":{"position_by":881402350}}},"required":true},"responses":{"200":{"description":"MT5's answer: the request is `done` (filled, placed or rejected, as the retcode says), or `unknown` for a repeated key whose first request never got an answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Done","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":771203499,"order":881402391,"position":0,"price":1.0841,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0.1},"sent":{"action":"close_by","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":881402350,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"close_by","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}},"rejected":{"summary":"Rejected by the trade server","value":{"message":"The request is invalid.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Invalid request","deal":0,"order":0,"position":0,"price":0,"retcode":10013,"retcode_external":0,"retcode_name":"TRADE_RETCODE_INVALID","volume":0},"sent":{"action":"close_by","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":881402350,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"close_by","type_filling":"fok","type_time":"gtc","volume":0},"state":"done"}}}}}},"202":{"description":"No answer from the trade server within 5 seconds: the request is `pending` and is never sent again. Look it up to see how it ended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"No answer within 5 seconds","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"close_by","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":881402350,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"close_by","type_filling":"fok","type_time":"gtc","volume":0},"state":"pending"}}}}}},"400":{"description":"The ticket in the path is not a whole number. No body."},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_position`: The account has no open position with that ticket (read fresh from the terminal).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_position":{"summary":"The account has no open position with that ticket (read fresh from the terminal).","value":{"error":"no_such_position","message":"The account has no open position with that ticket."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bridge_outdated`: The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.\n- `account_restarting`: The account's terminal is being replaced. Nothing was sent; try again in a minute.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- a stored request whose state is `refused`: the terminal did not send it (for example `busy`, with 1,000 trades already waiting for the trade server). `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"account_restarting":{"summary":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","value":{"error":"account_restarting","message":"The account's terminal is being replaced; nothing was sent. Try again in a minute."}},"bridge_outdated":{"summary":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","value":{"error":"bridge_outdated","message":"The account's terminal runs bridge protocol v1; restart the account to update it."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"close_by","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":881402350,"price":0,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"close_by","type_filling":"fok","type_time":"gtc","volume":0},"state":"refused"}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/requests/{request}":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Orders"],"summary":"Look up a request","description":"A trade request as it stands now: the request as recorded for the terminal, its state, and MT5's answer. Requests are kept for 7 days.","operationId":"request","parameters":[{"name":"request","in":"path","description":"The request's id (`req_...`), from the trade call's answer.","required":true,"schema":{"type":"string"},"example":"req_5f0c2a9e41d7b3a8c6e2f190"}],"responses":{"200":{"description":"The request is `done`, or `unknown`: the trade server's answer did not arrive in time.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"done":{"summary":"Filled","value":{"message":"The request was completed.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":771203455,"order":881402311,"position":0,"price":1.08412,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0.1},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}},"unknown":{"summary":"No answer in time","value":{"message":"The trade server's answer has not arrived in time. Check positions and history; if the terminal reports it later, this request shows it.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"unknown"}}}}}},"202":{"description":"The request is still `pending`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestView"},"examples":{"pending":{"summary":"Still waiting","value":{"message":"No answer from the trade server yet. The order may still execute; it is not sent again.","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":null,"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"pending"}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_request`: The account has no request with that id (requests are kept 7 days).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_request":{"summary":"The account has no request with that id (requests are kept 7 days).","value":{"error":"no_such_request","message":"There is no such request for this account."}}}}}},"503":{"description":"- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.\n- the request's state is `refused`: the terminal did not send it. `result` says why.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TradeUnavailable"},"examples":{"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"refused":{"summary":"Refused by the terminal","value":{"message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server","request":"req_5f0c2a9e41d7b3a8c6e2f190","result":{"error":"busy","message":"The account's terminal did not send the request: 1000 trading commands are waiting for the trade server"},"sent":{"action":"deal","comment":"","deviation":0,"expiration":0,"magic":0,"order":0,"position":0,"position_by":0,"price":0,"sl":1.079,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"buy","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"refused"}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}}},"/v1/accounts/{account}/symbols":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Symbols"],"summary":"List symbols","description":"Every symbol the broker offers the account, in Market Watch or not, read from the terminal. Large brokers list thousands; read a symbol for its full specification.","operationId":"symbols","responses":{"200":{"description":"Every symbol.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/SymbolSummaryView"}},"examples":{"symbols":{"summary":"Symbols","value":[{"available":true,"contract_size":100000,"currency_base":"EUR","currency_margin":"EUR","currency_profit":"USD","description":"Euro vs US Dollar","digits":5,"in_market_watch":true,"name":"EURUSD","path":"Forex\\EURUSD","trading":"full","volume_max":500,"volume_min":0.01,"volume_step":0.01}]}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `terminal_error`: The terminal did not give the answer asked for.\n- `symbol_too_large`: One symbol's entry is too large for the terminal to list.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"symbol_too_large":{"summary":"One symbol's entry is too large for the terminal to list.","value":{"error":"symbol_too_large","message":"The account's terminal did not list its symbols."}},"terminal_error":{"summary":"The terminal did not give the answer asked for.","value":{"error":"terminal_error","message":"The account's terminal did not answer about the symbol."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/symbols/{symbol}":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Symbols"],"summary":"Get a symbol","description":"A symbol's specification from the terminal: digits, contract size, volume limits, stops and freeze levels, and the filling modes, execution, order types and expirations it allows.","operationId":"symbol","parameters":[{"name":"symbol","in":"path","description":"The symbol exactly as the broker names it, such as `EURUSD`.","required":true,"schema":{"type":"string"},"example":"EURUSD"}],"responses":{"200":{"description":"The symbol.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SymbolView"},"examples":{"symbol":{"summary":"EURUSD","value":{"available":true,"contract_size":100000,"currency_base":"EUR","currency_margin":"EUR","currency_profit":"USD","description":"Euro vs US Dollar","digits":5,"execution":"market","execution_mode":2,"expiration_mode":15,"expirations":["gtc","day","specified","specified_day"],"filling_mode":2,"filling_modes":["ioc"],"freeze_level":0,"name":"EURUSD","order_mode":127,"order_types":["market","limit","stop","stop_limit","sl","tp","close_by"],"point":0.00001,"stops_level":0,"tick_size":0.00001,"tick_value":1,"trade_mode":4,"trading":"full","volume_max":500,"volume_min":0.01,"volume_step":0.01}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_symbol`: The broker has no symbol by that name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_symbol":{"summary":"The broker has no symbol by that name.","value":{"error":"no_such_symbol","message":"The broker has no symbol called XAUUSD.r."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `terminal_error`: The terminal did not give the answer asked for.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"terminal_error":{"summary":"The terminal did not give the answer asked for.","value":{"error":"terminal_error","message":"The account's terminal did not answer about the symbol."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/symbols/{symbol}/tick":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Symbols"],"summary":"Get a symbol's price","description":"The symbol's latest tick (MT5's `MqlTick`) from the terminal. A symbol the terminal has just added to Market Watch can take up to 2 seconds to have a price.","operationId":"tick","parameters":[{"name":"symbol","in":"path","description":"The symbol exactly as the broker names it, such as `EURUSD`.","required":true,"schema":{"type":"string"},"example":"EURUSD"}],"responses":{"200":{"description":"The latest tick.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TickView"},"examples":{"tick":{"summary":"EURUSD","value":{"ask":1.08412,"bid":1.0841,"flags":6,"last":0,"symbol":"EURUSD","time_msc":1794067825114,"volume":0}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.\n- `no_such_symbol`: The broker has no symbol by that name.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}},"no_such_symbol":{"summary":"The broker has no symbol by that name.","value":{"error":"no_such_symbol","message":"The broker has no symbol called XAUUSD.r."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `terminal_error`: The terminal did not give the answer asked for.\n- `no_price`: The terminal has no price for the symbol yet (it waited 2 seconds).\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"no_price":{"summary":"The terminal has no price for the symbol yet (it waited 2 seconds).","value":{"error":"no_price","message":"The terminal has no price for EURUSD yet."}},"terminal_error":{"summary":"The terminal did not give the answer asked for.","value":{"error":"terminal_error","message":"The account's terminal did not answer about the symbol."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/history/deals":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["History"],"summary":"List deals","description":"The account's deals in a time range (MT5's `HistorySelect`), read fresh from its terminal.","operationId":"history_deals","parameters":[{"name":"from","in":"query","description":"The range's start: broker server time, seconds since 1970, included.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":1794009600},{"name":"to","in":"query","description":"The range's end: broker server time, seconds since 1970, included. Not before `from`.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":1794095999}],"responses":{"200":{"description":"Every deal in the range.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/DealView"}},"examples":{"deals":{"summary":"A buy and its close","value":[{"comment":"","commission":-0.35,"entry":"in","fee":0,"magic":0,"order":881402311,"position":881402311,"price":1.08412,"profit":0,"reason":"expert","swap":0,"symbol":"EURUSD","ticket":771203455,"time_msc":1794067801211,"type":"buy","volume":0.1},{"comment":"[sl 1.07900]","commission":-0.35,"entry":"out","fee":0,"magic":0,"order":881402390,"position":881402311,"price":1.079,"profit":-51.2,"reason":"sl","swap":0,"symbol":"EURUSD","ticket":771203498,"time_msc":1794071102540,"type":"sell","volume":0.1}]}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.\n- `range_too_large`: The history range holds more than one answer can carry: ask for a shorter range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}},"range_too_large":{"summary":"The history range holds more than one answer can carry: ask for a shorter range.","value":{"error":"range_too_large","message":"The range holds more than one answer can carry; ask for a shorter range."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bad_command`: The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.\n- `terminal_error`: The terminal did not give the answer asked for.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"bad_command":{"summary":"The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.","value":{"error":"bad_command","message":"deviation, expiration, tickets and magic must not be negative"}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"terminal_error":{"summary":"The terminal did not give the answer asked for.","value":{"error":"terminal_error","message":"The account's terminal did not answer about the symbol."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/history/orders":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["History"],"summary":"List past orders","description":"The account's orders no longer pending in a time range (MT5's `HistorySelect`), with their final state, read fresh from its terminal.","operationId":"history_orders","parameters":[{"name":"from","in":"query","description":"The range's start: broker server time, seconds since 1970, included.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":1794009600},{"name":"to","in":"query","description":"The range's end: broker server time, seconds since 1970, included. Not before `from`.","required":true,"schema":{"type":"integer","format":"int64","minimum":0},"example":1794095999}],"responses":{"200":{"description":"Every order in the range.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/HistoryOrderView"}},"examples":{"orders":{"summary":"A filled market order","value":[{"comment":"","magic":0,"position":881402311,"price_open":0,"state":"filled","symbol":"EURUSD","ticket":881402311,"time_done_msc":1794067801211,"time_setup_msc":1794067801150,"type":"buy","volume_current":0,"volume_initial":0.1}]}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.\n- `range_too_large`: The history range holds more than one answer can carry: ask for a shorter range.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}},"range_too_large":{"summary":"The history range holds more than one answer can carry: ask for a shorter range.","value":{"error":"range_too_large","message":"The range holds more than one answer can carry; ask for a shorter range."}}}}}},"503":{"description":"- `account_not_connected`: The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.\n- `bad_command`: The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.\n- `terminal_error`: The terminal did not give the answer asked for.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"account_not_connected":{"summary":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","value":{"error":"account_not_connected","message":"The account's terminal is not connected."}},"bad_command":{"summary":"The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.","value":{"error":"bad_command","message":"deviation, expiration, tickets and magic must not be negative"}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}},"terminal_error":{"summary":"The terminal did not give the answer asked for.","value":{"error":"terminal_error","message":"The account's terminal did not answer about the symbol."}}}}}},"504":{"description":"- `terminal_timeout`: The account's terminal did not answer within 5 seconds.\n- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}},"terminal_timeout":{"summary":"The account's terminal did not answer within 5 seconds.","value":{"error":"terminal_timeout","message":"The account's terminal did not answer in time."}}}}}}}}},"/v1/accounts/{account}/kill-switch":{"parameters":[{"name":"account","in":"path","description":"The account's id, `acc_` and 26 characters, as the dashboard shows it.","required":true,"schema":{"type":"string","examples":["acc_01m6tx3k9f2qw8r7bznd5yvh4c"]}}],"get":{"tags":["Kill switch"],"summary":"Get the kill switch","description":"Whether the account's kill switch is engaged.","operationId":"kill_switch","responses":{"200":{"description":"The kill switch.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KillSwitchView"},"examples":{"engaged":{"summary":"Engaged","value":{"deviation":20,"engaged":true,"since":1794064225}},"lifted":{"summary":"Not engaged","value":{"deviation":null,"engaged":false,"since":null}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"503":{"description":"- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}},"post":{"tags":["Kill switch"],"summary":"Engage the kill switch","description":"Blocks new exposure first (new orders and changes to pending orders are refused with 423 until it is lifted; the block survives restarts), then deletes every pending order and closes every position, each as one request sent once. It first waits up to 6 seconds for trades still being sent. Engaging it again retries whatever is left. Closing, close by, cancelling and setting stops still work while it is engaged.","operationId":"engage_kill_switch","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/EngageKillSwitch"},{"type":"null"}]},"example":{"deviation":20}}}},"responses":{"200":{"description":"The switch is engaged; each request it sent, with MT5's answer, and whether the account is now flat.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KillSwitchOutcome"},"examples":{"flat":{"summary":"Flat","value":{"cancelled":[],"closed":[{"position":881402311,"request":{"message":"The request was completed.","request":"req_9b1e4d7c2a5f8e0b3d6a9c12","result":{"ask":1.08412,"bid":1.0841,"comment":"Request executed","deal":771203498,"order":881402390,"position":0,"price":1.0841,"retcode":10009,"retcode_external":0,"retcode_name":"TRADE_RETCODE_DONE","volume":0.1},"sent":{"action":"deal","comment":"kill switch","deviation":20,"expiration":0,"magic":0,"order":0,"position":881402311,"position_by":0,"price":1.0841,"sl":0,"stoplimit":0,"symbol":"EURUSD","tp":0,"type":"sell","type_filling":"ioc","type_time":"gtc","volume":0.1},"state":"done"}}],"flat":true,"kill_switch":{"deviation":20,"engaged":true,"since":1794064225},"message":"The kill switch is engaged and the account has no positions or pending orders.","remaining":{"orders":0,"positions":0},"unanswered":[]}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `account_not_connected`, with `kill_switch`: the switch is engaged (and stays engaged), but the terminal stopped answering: no position was closed, though pending orders may already have been deleted. Engage it again once the terminal is connected; a sweep also runs when it reconnects.\n- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KillSwitchUnavailable"},"examples":{"account_not_connected":{"summary":"the switch is engaged (and stays engaged), but the terminal stopped answering: no position was closed, though pending orders may already have been deleted. Engage it again once the terminal is connected; a sweep also runs when it reconnects.","value":{"error":"account_not_connected","kill_switch":{"deviation":20,"engaged":true,"since":1794064225},"message":"The kill switch is engaged, but the account's terminal did not answer, so nothing was closed. Engage it again once the terminal is connected."}},"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}},"delete":{"tags":["Kill switch"],"summary":"Lift the kill switch","description":"Lifts the account's kill switch: new orders and changes to pending orders are accepted again. Lifting a switch that is not engaged changes nothing.","operationId":"lift_kill_switch","responses":{"200":{"description":"The kill switch, lifted.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KillSwitchView"},"examples":{"lifted":{"summary":"Lifted","value":{"deviation":null,"engaged":false,"since":null}}}}}},"401":{"description":"- `missing_api_key`: No API key: send it as `Authorization: Bearer <key>`.\n- `invalid_api_key`: The key is not a workspace's current key (a rolled key stops working within about a minute).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_api_key":{"summary":"The key is not a workspace's current key (a rolled key stops working within about a minute).","value":{"error":"invalid_api_key","message":"The API key is not valid."}},"missing_api_key":{"summary":"No API key: send it as `Authorization: Bearer <key>`.","value":{"error":"missing_api_key","message":"Send your API key as Authorization: Bearer <key>."}}}}}},"404":{"description":"- `no_such_account`: No such account, or one the key's workspace doesn't have: the two look the same.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"no_such_account":{"summary":"No such account, or one the key's workspace doesn't have: the two look the same.","value":{"error":"no_such_account","message":"There is no such account."}}}}}},"422":{"description":"- `invalid_request`: A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"invalid_request":{"summary":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","value":{"error":"invalid_request","message":"price is required for pending orders"}}}}}},"503":{"description":"- `engine_busy`: The account's engine host has too many calls in flight (256). Nothing was done; try again.\n- `engine_unavailable`: The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_busy":{"summary":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","value":{"error":"engine_busy","message":"The engine has too many calls in flight; try again."}},"engine_unavailable":{"summary":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","value":{"error":"engine_unavailable","message":"The account's engine is not connected."}}}}}},"504":{"description":"- `engine_timeout`: The account's engine did not answer within 30 seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorBody"},"examples":{"engine_timeout":{"summary":"The account's engine did not answer within 30 seconds.","value":{"error":"engine_timeout","message":"The account's engine did not answer in time."}}}}}}}}}},"components":{"schemas":{"AccountView":{"type":"object","description":"The account, from the engine and its terminal's last report. Figures from the terminal are null\nuntil it has reported.","required":["id","login","server","status","connected","kill_switch"],"properties":{"id":{"type":"string","description":"The account's id."},"login":{"type":"integer","format":"int64","description":"The MT5 login.","minimum":0},"server":{"type":"string","description":"The broker's trade server."},"status":{"type":"string","description":"What the engine knows of the account's terminal: `starting`, `connected`, `disconnected`,\n`unreachable` (the broker's server can't be reached; it keeps trying), `stopped`, or a status\nsomeone has to act on: `auth_failed` (the broker refused the login), `server_not_found`,\n`login_unknown` or `refused`."},"connected":{"type":"boolean","description":"Whether the terminal reports a connection to the trade server."},"trade_allowed":{"type":["boolean","null"],"description":"Whether MT5 lets this terminal trade: the terminal, the account and automated trading all allow\nit. False for an investor (read-only) login."},"company":{"type":["string","null"],"description":"The broker."},"currency":{"type":["string","null"],"description":"The account's currency."},"leverage":{"type":["integer","null"],"format":"int64"},"margin_mode":{"type":["string","null"],"description":"`hedging`, `netting` or `exchange`."},"trade_mode":{"type":["string","null"],"description":"`demo`, `contest` or `real`."},"balance":{"type":["number","null"],"format":"double"},"equity":{"type":["number","null"],"format":"double"},"credit":{"type":["number","null"],"format":"double"},"margin":{"type":["number","null"],"format":"double"},"margin_free":{"type":["number","null"],"format":"double"},"server_time":{"type":["integer","null"],"format":"int64","description":"The trade server's time at the last report: broker server time, seconds since 1970."},"kill_switch":{"$ref":"#/components/schemas/KillSwitchView"}}},"Action":{"type":"string","description":"MT5's `ENUM_TRADE_REQUEST_ACTIONS`: `deal` (`TRADE_ACTION_DEAL`, a market order or a close),\n`pending` (`TRADE_ACTION_PENDING`), `sltp` (`TRADE_ACTION_SLTP`, a position's stops), `modify`\n(`TRADE_ACTION_MODIFY`, a pending order's levels), `remove` (`TRADE_ACTION_REMOVE`, cancel a pending\norder) and `close_by` (`TRADE_ACTION_CLOSE_BY`).","enum":["deal","pending","sltp","modify","remove","close_by"]},"CheckResult":{"type":"object","description":"MT5's `MqlTradeCheckResult`.","required":["passed","retcode","retcode_name","comment","balance","equity","profit","margin","margin_free","margin_level"],"properties":{"passed":{"type":"boolean","description":"Whether `OrderCheck` passed the request."},"retcode":{"type":"integer","format":"int64","description":"MT5's return code: 0 when the check passed.","x-mt5":"retcode"},"retcode_name":{"type":"string","description":"The return code's name; `UNKNOWN` for a code MT5 doesn't document.","enum":["OK","TRADE_RETCODE_REQUOTE","TRADE_RETCODE_REJECT","TRADE_RETCODE_CANCEL","TRADE_RETCODE_PLACED","TRADE_RETCODE_DONE","TRADE_RETCODE_DONE_PARTIAL","TRADE_RETCODE_ERROR","TRADE_RETCODE_TIMEOUT","TRADE_RETCODE_INVALID","TRADE_RETCODE_INVALID_VOLUME","TRADE_RETCODE_INVALID_PRICE","TRADE_RETCODE_INVALID_STOPS","TRADE_RETCODE_TRADE_DISABLED","TRADE_RETCODE_MARKET_CLOSED","TRADE_RETCODE_NO_MONEY","TRADE_RETCODE_PRICE_CHANGED","TRADE_RETCODE_PRICE_OFF","TRADE_RETCODE_INVALID_EXPIRATION","TRADE_RETCODE_ORDER_CHANGED","TRADE_RETCODE_TOO_MANY_REQUESTS","TRADE_RETCODE_NO_CHANGES","TRADE_RETCODE_SERVER_DISABLES_AT","TRADE_RETCODE_CLIENT_DISABLES_AT","TRADE_RETCODE_LOCKED","TRADE_RETCODE_FROZEN","TRADE_RETCODE_INVALID_FILL","TRADE_RETCODE_CONNECTION","TRADE_RETCODE_ONLY_REAL","TRADE_RETCODE_LIMIT_ORDERS","TRADE_RETCODE_LIMIT_VOLUME","TRADE_RETCODE_INVALID_ORDER","TRADE_RETCODE_POSITION_CLOSED","TRADE_RETCODE_INVALID_CLOSE_VOLUME","TRADE_RETCODE_CLOSE_ORDER_EXIST","TRADE_RETCODE_LIMIT_POSITIONS","TRADE_RETCODE_REJECT_CANCEL","TRADE_RETCODE_LONG_ONLY","TRADE_RETCODE_SHORT_ONLY","TRADE_RETCODE_CLOSE_ONLY","TRADE_RETCODE_FIFO_CLOSE","TRADE_RETCODE_HEDGE_PROHIBITED","UNKNOWN"]},"comment":{"type":"string","x-mt5":"comment"},"balance":{"type":"number","format":"double","description":"The balance after the trade.","x-mt5":"balance"},"equity":{"type":"number","format":"double","description":"The equity after the trade.","x-mt5":"equity"},"profit":{"type":"number","format":"double","description":"The floating profit after the trade.","x-mt5":"profit"},"margin":{"type":"number","format":"double","description":"The margin the trade takes.","x-mt5":"margin"},"margin_free":{"type":"number","format":"double","description":"The free margin after the trade.","x-mt5":"margin_free"},"margin_level":{"type":"number","format":"double","description":"The margin level after the trade, in percent.","x-mt5":"margin_level"}}},"CheckView":{"type":"object","description":"MT5's dry run (`OrderCheck`) of an order.","required":["sent","result","message"],"properties":{"sent":{"$ref":"#/components/schemas/TradeRequest"},"result":{"$ref":"#/components/schemas/CheckResult"},"message":{"type":"string","description":"The return code's meaning, in a sentence."}}},"CloseBy":{"type":"object","description":"Closing a position against an opposite one on the same symbol.","required":["position_by"],"properties":{"position_by":{"type":"integer","format":"int64","description":"The opposite position's ticket.","minimum":0,"x-mt5":"position_by"}},"additionalProperties":false},"ClosePosition":{"type":"object","description":"Closing all or part of a position: a deal the other way naming the position.","required":["volume","type_filling"],"properties":{"volume":{"type":"number","format":"double","description":"Lots to close: the position's whole volume, or part of it.","x-mt5":"volume"},"type_filling":{"allOf":[{"$ref":"#/components/schemas/Filling"}],"description":"How the closing deal may fill. Required: each symbol allows its own modes (its `filling_modes`).","x-mt5":"type_filling"},"price":{"type":["number","null"],"format":"double","description":"Sent as given (0 if left out): brokers with instant or request execution need it, those with\nmarket or exchange execution ignore it.","x-mt5":"price"},"deviation":{"type":["integer","null"],"format":"int64","description":"The largest difference from `price` MT5 accepts, in points, for instant or request execution.","minimum":0,"x-mt5":"deviation"},"magic":{"type":["integer","null"],"format":"int64","description":"Your own number, kept by MT5 on the closing deal.","minimum":0,"x-mt5":"magic"},"comment":{"type":["string","null"],"description":"Up to 31 characters, kept by MT5 on the closing deal.","maxLength":31,"x-mt5":"comment"}},"additionalProperties":false},"DealView":{"type":"object","description":"A deal (MT5's `DEAL_*` properties).","required":["ticket","order","position","symbol","entry","reason","volume","price","profit","commission","swap","fee","magic","comment","time_msc"],"properties":{"ticket":{"type":"integer","format":"int64","minimum":0,"x-mt5":"DEAL_TICKET"},"order":{"type":"integer","format":"int64","description":"The order that made the deal.","minimum":0,"x-mt5":"DEAL_ORDER"},"position":{"type":"integer","format":"int64","description":"The position's id (`identifier`).","minimum":0,"x-mt5":"DEAL_POSITION_ID"},"symbol":{"type":"string","x-mt5":"DEAL_SYMBOL"},"type":{"type":["string","null"],"description":"MT5's `DEAL_TYPE`: `buy`, `sell`, or a balance operation.","enum":["buy","sell","balance","credit","charge","correction","bonus","commission","commission_daily","commission_monthly","commission_agent_daily","commission_agent_monthly","interest","buy_canceled","sell_canceled","dividend","dividend_franked","tax",null]},"entry":{"type":"string","description":"MT5's `DEAL_ENTRY`: `in` opens or adds, `out` closes, `inout` reverses, `out_by` closes by an opposite position.","enum":["in","out","inout","out_by"]},"reason":{"type":"string","description":"MT5's `DEAL_REASON`: who or what made the deal (`expert` for the API, `sl`, `tp`, `so` for a stop out).","enum":["client","mobile","web","expert","sl","tp","so","other"]},"volume":{"type":"number","format":"double","x-mt5":"DEAL_VOLUME"},"price":{"type":"number","format":"double","x-mt5":"DEAL_PRICE"},"profit":{"type":"number","format":"double","x-mt5":"DEAL_PROFIT"},"commission":{"type":"number","format":"double","x-mt5":"DEAL_COMMISSION"},"swap":{"type":"number","format":"double","x-mt5":"DEAL_SWAP"},"fee":{"type":"number","format":"double","x-mt5":"DEAL_FEE"},"magic":{"type":"integer","format":"int64","x-mt5":"DEAL_MAGIC"},"comment":{"type":"string","x-mt5":"DEAL_COMMENT"},"time_msc":{"type":"integer","format":"int64","description":"Broker server time, milliseconds since 1970.","x-mt5":"DEAL_TIME_MSC"}}},"EngageKillSwitch":{"type":"object","description":"Engaging the kill switch may carry the deviation (in points) for its closing deals, which brokers\nwith instant or request execution need; MT5's empty value, 0, otherwise.","properties":{"deviation":{"type":["integer","null"],"format":"int64","description":"The largest difference from the current price the closing deals accept, in points, for\ninstant or request execution. 0 if left out.","minimum":0,"x-mt5":"deviation"}},"additionalProperties":false},"ErrorBody":{"type":"object","description":"A refusal: a code to act on, and a message for people.","required":["error","message"],"properties":{"error":{"type":"string","description":"What went wrong, as a stable code."},"message":{"type":"string","description":"What went wrong, for people. Its wording may change."}}},"Filling":{"type":"string","description":"MT5's `ENUM_ORDER_TYPE_FILLING`: `fok` (`ORDER_FILLING_FOK`, all or nothing), `ioc`\n(`ORDER_FILLING_IOC`, what is available now, the rest cancelled), `return` (`ORDER_FILLING_RETURN`,\nwhat is available now, the rest left as an order) and `boc` (`ORDER_FILLING_BOC`, book or cancel).\nEach symbol allows its own modes: see `filling_modes` on the symbol.","enum":["fok","ioc","return","boc"]},"HistoryOrderView":{"type":"object","description":"An order no longer pending (MT5's `ORDER_*` history properties).","required":["ticket","symbol","volume_initial","volume_current","price_open","magic","comment","position","time_setup_msc","time_done_msc"],"properties":{"ticket":{"type":"integer","format":"int64","minimum":0,"x-mt5":"ORDER_TICKET"},"symbol":{"type":"string","x-mt5":"ORDER_SYMBOL"},"type":{"oneOf":[{"$ref":"#/components/schemas/OrderType"},{"type":"null"}],"x-mt5":"ORDER_TYPE"},"state":{"type":["string","null"],"description":"MT5's `ORDER_STATE`.","enum":["started","placed","canceled","partial","filled","rejected","expired","request_add","request_modify","request_cancel",null]},"volume_initial":{"type":"number","format":"double","x-mt5":"ORDER_VOLUME_INITIAL"},"volume_current":{"type":"number","format":"double","x-mt5":"ORDER_VOLUME_CURRENT"},"price_open":{"type":"number","format":"double","x-mt5":"ORDER_PRICE_OPEN"},"magic":{"type":"integer","format":"int64","x-mt5":"ORDER_MAGIC"},"comment":{"type":"string","x-mt5":"ORDER_COMMENT"},"position":{"type":"integer","format":"int64","minimum":0,"x-mt5":"ORDER_POSITION_ID"},"time_setup_msc":{"type":"integer","format":"int64","description":"Broker server time, milliseconds since 1970.","x-mt5":"ORDER_TIME_SETUP_MSC"},"time_done_msc":{"type":"integer","format":"int64","description":"Broker server time, milliseconds since 1970.","x-mt5":"ORDER_TIME_DONE_MSC"}}},"KillSwitchNotConnected":{"type":"object","description":"The kill switch engaged, but the terminal did not answer, so nothing was closed.","required":["error","kill_switch","message"],"properties":{"error":{"type":"string","description":"`account_not_connected`."},"kill_switch":{"$ref":"#/components/schemas/KillSwitchView"},"message":{"type":"string"}}},"KillSwitchOutcome":{"type":"object","description":"What engaging the kill switch did.","required":["flat","cancelled","closed","unanswered","kill_switch","message"],"properties":{"flat":{"type":"boolean","description":"No positions or pending orders in a fresh read of the account, and no trade that could add\nexposure without a known outcome (`unknown` included)."},"cancelled":{"type":"array","items":{"$ref":"#/components/schemas/SweptOrder"},"description":"Each pending order and the removal sent for it (or the one already waiting for its answer)."},"closed":{"type":"array","items":{"$ref":"#/components/schemas/SweptPosition"},"description":"Each position and the close sent for it (or the one already waiting for its answer)."},"remaining":{"oneOf":[{"$ref":"#/components/schemas/Remaining","description":"What a fresh read found afterwards; null if the terminal did not answer it."},{"type":"null"}]},"unanswered":{"type":"array","items":{"type":"string"},"description":"Ids of requests sent before the switch engaged that could add exposure and have no known\noutcome. If one fills and the terminal reports it, the switch closes what it opened."},"kill_switch":{"$ref":"#/components/schemas/KillSwitchView"},"message":{"type":"string","description":"What the outcome means, in a sentence."}}},"KillSwitchUnavailable":{"oneOf":[{"$ref":"#/components/schemas/ErrorBody"},{"$ref":"#/components/schemas/KillSwitchNotConnected"}],"description":"Engaging the kill switch answered 503: either a refusal before the engine, or the switch engaged\nwhile the terminal did not answer."},"KillSwitchView":{"type":"object","description":"Whether the account's kill switch is engaged.","required":["engaged"],"properties":{"engaged":{"type":"boolean"},"since":{"type":["integer","null"],"format":"int64","description":"When it was engaged: seconds since 1970 (UTC). Null when it is not engaged."},"deviation":{"type":["integer","null"],"format":"int64","description":"The deviation, in points, its closing deals carry. Null when it is not engaged.","minimum":0}}},"ModifyOrder":{"type":"object","description":"A pending order's new levels. `price`, `sl`, `tp` and `type_time` are all required, as MT5 replaces\nevery level: give the ones you keep as they are.","required":["price","sl","tp","type_time"],"properties":{"price":{"type":"number","format":"double","description":"The price the order waits for.","x-mt5":"price"},"sl":{"type":"number","format":"double","description":"Stop loss price; 0 removes it.","x-mt5":"sl"},"tp":{"type":"number","format":"double","description":"Take profit price; 0 removes it.","x-mt5":"tp"},"type_time":{"allOf":[{"$ref":"#/components/schemas/TypeTime"}],"description":"How long the order lasts.","x-mt5":"type_time"},"stoplimit":{"type":["number","null"],"format":"double","description":"Required when the order is a stop-limit order: the price of the limit order placed once `price`\nis reached.","x-mt5":"stoplimit"},"expiration":{"type":["integer","null"],"format":"int64","description":"When the order expires: broker server time, seconds since 1970. Required for `type_time`\n`specified` and `specified_day`.","x-mt5":"expiration"}},"additionalProperties":false},"OrderType":{"type":"string","description":"MT5's `ENUM_ORDER_TYPE`: `buy` and `sell` are market orders (`ORDER_TYPE_BUY`, `ORDER_TYPE_SELL`);\n`buy_limit`, `sell_limit`, `buy_stop`, `sell_stop`, `buy_stop_limit` and `sell_stop_limit` are\npending orders (`ORDER_TYPE_BUY_LIMIT` and so on); `close_by` is `ORDER_TYPE_CLOSE_BY`.","enum":["buy","sell","buy_limit","sell_limit","buy_stop","sell_stop","buy_stop_limit","sell_stop_limit","close_by"]},"PendingOrderView":{"type":"object","description":"A pending order (MT5's `ORDER_*` properties).","required":["ticket","symbol","volume_initial","volume_current","price_open","sl","tp","magic","comment","position"],"properties":{"ticket":{"type":"integer","format":"int64","minimum":0,"x-mt5":"ORDER_TICKET"},"symbol":{"type":"string","x-mt5":"ORDER_SYMBOL"},"type":{"oneOf":[{"$ref":"#/components/schemas/OrderType"},{"type":"null"}],"x-mt5":"ORDER_TYPE"},"volume_initial":{"type":"number","format":"double","x-mt5":"ORDER_VOLUME_INITIAL"},"volume_current":{"type":"number","format":"double","x-mt5":"ORDER_VOLUME_CURRENT"},"price_open":{"type":"number","format":"double","x-mt5":"ORDER_PRICE_OPEN"},"sl":{"type":"number","format":"double","x-mt5":"ORDER_SL"},"tp":{"type":"number","format":"double","x-mt5":"ORDER_TP"},"magic":{"type":"integer","format":"int64","x-mt5":"ORDER_MAGIC"},"comment":{"type":"string","x-mt5":"ORDER_COMMENT"},"position":{"type":"integer","format":"int64","description":"The position the order belongs to, if any.","minimum":0,"x-mt5":"ORDER_POSITION_ID"}}},"PlaceOrder":{"type":"object","description":"A market or pending order. Fields left out are sent as MT5's empty values (0, \"\", `gtc`); there is\nno other default. Fields not listed here are refused.","required":["symbol","type","volume","type_filling"],"properties":{"symbol":{"type":"string","description":"The symbol exactly as the broker names it, such as `EURUSD`.","x-mt5":"symbol"},"type":{"allOf":[{"$ref":"#/components/schemas/OrderType"}],"description":"What to send. `buy` and `sell` fill now; the others wait at `price`. `close_by` is refused here:\nuse Close by.","x-mt5":"type"},"volume":{"type":"number","format":"double","description":"Lots. MT5 rejects a volume outside the symbol's minimum, maximum and step.","x-mt5":"volume"},"type_filling":{"allOf":[{"$ref":"#/components/schemas/Filling"}],"description":"How the order may fill. Required: each symbol allows its own modes (its `filling_modes`).","x-mt5":"type_filling"},"price":{"type":["number","null"],"format":"double","description":"Required for pending orders: the price the order waits for. For a market order it is sent as\ngiven (0 if left out): brokers with instant or request execution need it, those with market or\nexchange execution ignore it.","x-mt5":"price"},"stoplimit":{"type":["number","null"],"format":"double","description":"Required for `buy_stop_limit` and `sell_stop_limit`: the price of the limit order placed once\n`price` is reached.","x-mt5":"stoplimit"},"sl":{"type":["number","null"],"format":"double","description":"Stop loss price, set in the same request. 0 or left out: none.","x-mt5":"sl"},"tp":{"type":["number","null"],"format":"double","description":"Take profit price, set in the same request. 0 or left out: none.","x-mt5":"tp"},"deviation":{"type":["integer","null"],"format":"int64","description":"The largest difference from `price` MT5 accepts, in points, for instant or request execution.","minimum":0,"x-mt5":"deviation"},"type_time":{"oneOf":[{"$ref":"#/components/schemas/TypeTime"},{"type":"null"}],"description":"How long a pending order lasts. `gtc` if left out.","x-mt5":"type_time"},"expiration":{"type":["integer","null"],"format":"int64","description":"When a pending order expires: broker server time, seconds since 1970. Required for `type_time`\n`specified` and `specified_day`.","x-mt5":"expiration"},"magic":{"type":["integer","null"],"format":"int64","description":"Your own number for the order, kept by MT5 on the order, its deals and its position.","minimum":0,"x-mt5":"magic"},"comment":{"type":["string","null"],"description":"Up to 31 characters, kept by MT5 on the order. Brokers may replace it.","maxLength":31,"x-mt5":"comment"}},"additionalProperties":false},"PositionLevels":{"type":"object","description":"A position's stop loss and take profit. Both are required, as MT5 sets both: give the one you keep\nas it is.","required":["sl","tp"],"properties":{"sl":{"type":"number","format":"double","description":"Stop loss price; 0 removes it.","x-mt5":"sl"},"tp":{"type":"number","format":"double","description":"Take profit price; 0 removes it.","x-mt5":"tp"}},"additionalProperties":false},"PositionView":{"type":"object","description":"An open position (MT5's `POSITION_*` properties).","required":["ticket","identifier","symbol","type","volume","price_open","sl","tp","magic","comment","time_msc"],"properties":{"ticket":{"type":"integer","format":"int64","description":"The position's ticket: use it to close the position or set its stops.","minimum":0,"x-mt5":"POSITION_TICKET"},"identifier":{"type":"integer","format":"int64","description":"The position's id, which stays the same if the broker changes the ticket.","minimum":0,"x-mt5":"POSITION_IDENTIFIER"},"symbol":{"type":"string","x-mt5":"POSITION_SYMBOL"},"type":{"type":"string","description":"`buy` or `sell` (MT5's `POSITION_TYPE`).","enum":["buy","sell"]},"volume":{"type":"number","format":"double","x-mt5":"POSITION_VOLUME"},"price_open":{"type":"number","format":"double","x-mt5":"POSITION_PRICE_OPEN"},"sl":{"type":"number","format":"double","x-mt5":"POSITION_SL"},"tp":{"type":"number","format":"double","x-mt5":"POSITION_TP"},"magic":{"type":"integer","format":"int64","minimum":0,"x-mt5":"POSITION_MAGIC"},"comment":{"type":"string","x-mt5":"POSITION_COMMENT"},"time_msc":{"type":"integer","format":"int64","description":"When it was opened: broker server time, milliseconds since 1970.","x-mt5":"POSITION_TIME_MSC"}}},"Remaining":{"type":"object","required":["positions","orders"],"properties":{"positions":{"type":"integer","format":"int64","minimum":0},"orders":{"type":"integer","format":"int64","minimum":0}}},"RequestResult":{"oneOf":[{"$ref":"#/components/schemas/TradeResult"},{"$ref":"#/components/schemas/ErrorBody"}]},"RequestState":{"type":"string","description":"A trade request's state: `pending` (sent, no answer yet: never sent again), `done` (MT5 answered:\nfilled, placed or rejected, as `result.retcode` says), `unknown` (no answer within 130 seconds; it\nbecomes `done` if the terminal reports the answer later) or `refused` (the terminal did not send it).","enum":["pending","done","unknown","refused"]},"RequestView":{"type":"object","description":"A trade request: the request as recorded for the terminal (`sent`), its state, and MT5's answer.","required":["request","state","sent","message"],"properties":{"request":{"type":"string","description":"The request's id (`req_...`): look it up with `GET /requests/{request}`."},"state":{"$ref":"#/components/schemas/RequestState"},"sent":{"$ref":"#/components/schemas/TradeRequest"},"result":{"oneOf":[{"$ref":"#/components/schemas/RequestResult","description":"MT5's `MqlTradeResult` once `done`; why it was not sent once `refused`; otherwise null."},{"type":"null"}]},"message":{"type":"string","description":"What the answer means, in a sentence."}}},"SweptOrder":{"type":"object","required":["order","request"],"properties":{"order":{"type":"integer","format":"int64","description":"The pending order's ticket.","minimum":0},"request":{"$ref":"#/components/schemas/RequestView"}}},"SweptPosition":{"type":"object","required":["position","request"],"properties":{"position":{"type":"integer","format":"int64","description":"The position's ticket.","minimum":0},"request":{"$ref":"#/components/schemas/RequestView"}}},"SymbolSummaryView":{"type":"object","description":"A symbol in the list (MT5's `SYMBOL_*` properties). Properties are read without adding the symbol to\nMarket Watch, so an unavailable one has empty values.","required":["name","description","path","available","digits","contract_size","currency_base","currency_profit","currency_margin","volume_min","volume_max","volume_step","in_market_watch"],"properties":{"name":{"type":"string","x-mt5":"SYMBOL_NAME"},"description":{"type":"string","x-mt5":"SYMBOL_DESCRIPTION"},"path":{"type":"string","description":"Where it sits in the broker's symbol tree.","x-mt5":"SYMBOL_PATH"},"available":{"type":"boolean","description":"Whether the terminal could read its properties."},"digits":{"type":"integer","format":"int64","x-mt5":"SYMBOL_DIGITS"},"contract_size":{"type":"number","format":"double","x-mt5":"SYMBOL_TRADE_CONTRACT_SIZE"},"currency_base":{"type":"string","x-mt5":"SYMBOL_CURRENCY_BASE"},"currency_profit":{"type":"string","x-mt5":"SYMBOL_CURRENCY_PROFIT"},"currency_margin":{"type":"string","x-mt5":"SYMBOL_CURRENCY_MARGIN"},"trading":{"type":["string","null"],"description":"MT5's `SYMBOL_TRADE_MODE`: whether and which way the symbol can be traded.","enum":["disabled","long_only","short_only","close_only","full",null]},"volume_min":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_MIN"},"volume_max":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_MAX"},"volume_step":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_STEP"},"in_market_watch":{"type":"boolean","description":"Whether it is in the terminal's Market Watch.","x-mt5":"SYMBOL_SELECT"}}},"SymbolView":{"type":"object","description":"A symbol's specification (MT5's `SYMBOL_*` properties), with its mode flags spelled out.","required":["name","available","description","digits","point","tick_size","tick_value","contract_size","volume_min","volume_max","volume_step","stops_level","freeze_level","filling_mode","trade_mode","execution_mode","order_mode","expiration_mode","currency_base","currency_profit","currency_margin","filling_modes","order_types","expirations"],"properties":{"name":{"type":"string","x-mt5":"SYMBOL_NAME"},"available":{"type":"boolean","description":"Whether the terminal could read its properties; when false the rest are empty values."},"description":{"type":"string","x-mt5":"SYMBOL_DESCRIPTION"},"digits":{"type":"integer","format":"int64","x-mt5":"SYMBOL_DIGITS"},"point":{"type":"number","format":"double","x-mt5":"SYMBOL_POINT"},"tick_size":{"type":"number","format":"double","x-mt5":"SYMBOL_TRADE_TICK_SIZE"},"tick_value":{"type":"number","format":"double","x-mt5":"SYMBOL_TRADE_TICK_VALUE"},"contract_size":{"type":"number","format":"double","x-mt5":"SYMBOL_TRADE_CONTRACT_SIZE"},"volume_min":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_MIN"},"volume_max":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_MAX"},"volume_step":{"type":"number","format":"double","x-mt5":"SYMBOL_VOLUME_STEP"},"stops_level":{"type":"integer","format":"int64","description":"The closest stops may be to the price, in points.","x-mt5":"SYMBOL_TRADE_STOPS_LEVEL"},"freeze_level":{"type":"integer","format":"int64","description":"How close to the price an order or stop is frozen, in points.","x-mt5":"SYMBOL_TRADE_FREEZE_LEVEL"},"filling_mode":{"type":"integer","format":"int64","description":"MT5's flags, as `filling_modes` spells them out.","x-mt5":"SYMBOL_FILLING_MODE"},"trade_mode":{"type":"integer","format":"int64","description":"MT5's value, as `trading` spells it out.","x-mt5":"SYMBOL_TRADE_MODE"},"execution_mode":{"type":"integer","format":"int64","description":"MT5's value, as `execution` spells it out.","x-mt5":"SYMBOL_TRADE_EXEMODE"},"order_mode":{"type":"integer","format":"int64","description":"MT5's flags, as `order_types` spells them out.","x-mt5":"SYMBOL_ORDER_MODE"},"expiration_mode":{"type":"integer","format":"int64","description":"MT5's flags, as `expirations` spells them out.","x-mt5":"SYMBOL_EXPIRATION_MODE"},"currency_base":{"type":"string","x-mt5":"SYMBOL_CURRENCY_BASE"},"currency_profit":{"type":"string","x-mt5":"SYMBOL_CURRENCY_PROFIT"},"currency_margin":{"type":"string","x-mt5":"SYMBOL_CURRENCY_MARGIN"},"filling_modes":{"type":"array","items":{"type":"string","description":"A filling mode.","enum":["fok","ioc","boc"]},"description":"The `type_filling` modes MT5's `SYMBOL_FILLING_MODE` flags allow. `return` has no flag: whether it is accepted depends on the symbol's execution and the broker."},"execution":{"type":["string","null"],"description":"MT5's `SYMBOL_TRADE_EXEMODE`. Instant and request execution need `price` (and use `deviation`).","enum":["request","instant","market","exchange",null]},"order_types":{"type":"array","items":{"type":"string","description":"An order type.","enum":["market","limit","stop","stop_limit","sl","tp","close_by"]},"description":"The orders the symbol allows (MT5's `SYMBOL_ORDER_MODE`)."},"expirations":{"type":"array","items":{"type":"string","description":"A `type_time`.","enum":["gtc","day","specified","specified_day"]},"description":"The `type_time` values the symbol allows (MT5's `SYMBOL_EXPIRATION_MODE`)."},"trading":{"type":["string","null"],"description":"MT5's `SYMBOL_TRADE_MODE`: whether and which way the symbol can be traded.","enum":["disabled","long_only","short_only","close_only","full",null]}}},"TickView":{"type":"object","description":"A symbol's latest tick (MT5's `MqlTick`). `time_msc`, `last`, `volume` and `flags` are null from\nterminals on bridges older than 2.02.","required":["symbol","bid","ask"],"properties":{"symbol":{"type":"string"},"bid":{"type":"number","format":"double","x-mt5":"bid"},"ask":{"type":"number","format":"double","x-mt5":"ask"},"time_msc":{"type":["integer","null"],"format":"int64","description":"Broker server time, milliseconds since 1970.","x-mt5":"time_msc"},"last":{"type":["number","null"],"format":"double","x-mt5":"last"},"volume":{"type":["number","null"],"format":"double","x-mt5":"volume_real"},"flags":{"type":["integer","null"],"format":"int64","description":"MT5's `TICK_FLAG_*` bits: what changed.","x-mt5":"flags"}}},"TradeRequest":{"type":"object","description":"MT5's `MqlTradeRequest`, field for field, exactly as recorded to send to the terminal: the\nrequest's `state` and `result` say whether it reached MT5. Fields the call does not use carry MT5's\nempty values (0, \"\", `fok`, `gtc`).","required":["action","symbol","type","volume","price","stoplimit","sl","tp","deviation","type_filling","type_time","expiration","order","position","position_by","magic","comment"],"properties":{"action":{"allOf":[{"$ref":"#/components/schemas/Action"}],"description":"What the request does.","x-mt5":"action"},"symbol":{"type":"string","description":"The symbol, exactly as the broker names it.","x-mt5":"symbol"},"type":{"allOf":[{"$ref":"#/components/schemas/OrderType"}],"description":"The order type.","x-mt5":"type"},"volume":{"type":"number","format":"double","description":"Lots.","x-mt5":"volume"},"price":{"type":"number","format":"double","description":"The price: a pending order's, or the one instant and request execution trade at.","x-mt5":"price"},"stoplimit":{"type":"number","format":"double","description":"A stop-limit order's limit price, placed once `price` is reached.","x-mt5":"stoplimit"},"sl":{"type":"number","format":"double","description":"Stop loss price; 0 for none.","x-mt5":"sl"},"tp":{"type":"number","format":"double","description":"Take profit price; 0 for none.","x-mt5":"tp"},"deviation":{"type":"integer","format":"int64","description":"The largest difference from `price` MT5 accepts, in points.","minimum":0,"x-mt5":"deviation"},"type_filling":{"allOf":[{"$ref":"#/components/schemas/Filling"}],"description":"How the order may fill.","x-mt5":"type_filling"},"type_time":{"allOf":[{"$ref":"#/components/schemas/TypeTime"}],"description":"How long a pending order lasts.","x-mt5":"type_time"},"expiration":{"type":"integer","format":"int64","description":"Broker server time, seconds since 1970, as MT5 takes it.","x-mt5":"expiration"},"order":{"type":"integer","format":"int64","description":"The pending order the request is about (modify, remove).","minimum":0,"x-mt5":"order"},"position":{"type":"integer","format":"int64","description":"The position the request is about (close, stops, close by).","minimum":0,"x-mt5":"position"},"position_by":{"type":"integer","format":"int64","description":"The opposite position, for close by.","minimum":0,"x-mt5":"position_by"},"magic":{"type":"integer","format":"int64","description":"Your own number, kept by MT5 on the order, its deals and its position.","minimum":0,"x-mt5":"magic"},"comment":{"type":"string","description":"Up to 31 characters, kept by MT5 on the order.","x-mt5":"comment"}}},"TradeResult":{"type":"object","description":"MT5's `MqlTradeResult`, as the trade server (or the terminal, refusing to send) answered.","required":["retcode","retcode_name","comment","order","deal","position","volume","price","bid","ask","retcode_external"],"properties":{"retcode":{"type":"integer","format":"int64","description":"MT5's return code: see Errors and retcodes.","x-mt5":"retcode"},"retcode_name":{"type":"string","description":"The return code's name; `UNKNOWN` for a code MT5 doesn't document.","enum":["OK","TRADE_RETCODE_REQUOTE","TRADE_RETCODE_REJECT","TRADE_RETCODE_CANCEL","TRADE_RETCODE_PLACED","TRADE_RETCODE_DONE","TRADE_RETCODE_DONE_PARTIAL","TRADE_RETCODE_ERROR","TRADE_RETCODE_TIMEOUT","TRADE_RETCODE_INVALID","TRADE_RETCODE_INVALID_VOLUME","TRADE_RETCODE_INVALID_PRICE","TRADE_RETCODE_INVALID_STOPS","TRADE_RETCODE_TRADE_DISABLED","TRADE_RETCODE_MARKET_CLOSED","TRADE_RETCODE_NO_MONEY","TRADE_RETCODE_PRICE_CHANGED","TRADE_RETCODE_PRICE_OFF","TRADE_RETCODE_INVALID_EXPIRATION","TRADE_RETCODE_ORDER_CHANGED","TRADE_RETCODE_TOO_MANY_REQUESTS","TRADE_RETCODE_NO_CHANGES","TRADE_RETCODE_SERVER_DISABLES_AT","TRADE_RETCODE_CLIENT_DISABLES_AT","TRADE_RETCODE_LOCKED","TRADE_RETCODE_FROZEN","TRADE_RETCODE_INVALID_FILL","TRADE_RETCODE_CONNECTION","TRADE_RETCODE_ONLY_REAL","TRADE_RETCODE_LIMIT_ORDERS","TRADE_RETCODE_LIMIT_VOLUME","TRADE_RETCODE_INVALID_ORDER","TRADE_RETCODE_POSITION_CLOSED","TRADE_RETCODE_INVALID_CLOSE_VOLUME","TRADE_RETCODE_CLOSE_ORDER_EXIST","TRADE_RETCODE_LIMIT_POSITIONS","TRADE_RETCODE_REJECT_CANCEL","TRADE_RETCODE_LONG_ONLY","TRADE_RETCODE_SHORT_ONLY","TRADE_RETCODE_CLOSE_ONLY","TRADE_RETCODE_FIFO_CLOSE","TRADE_RETCODE_HEDGE_PROHIBITED","UNKNOWN"]},"comment":{"type":"string","description":"The broker's comment on the answer.","x-mt5":"comment"},"order":{"type":"integer","format":"int64","description":"The order's ticket, if one was placed.","minimum":0,"x-mt5":"order"},"deal":{"type":"integer","format":"int64","description":"The deal's ticket, if one was made.","minimum":0,"x-mt5":"deal"},"position":{"type":"integer","format":"int64","description":"The position's ticket, where the trade server gives it.","minimum":0},"volume":{"type":"number","format":"double","description":"The volume dealt.","x-mt5":"volume"},"price":{"type":"number","format":"double","description":"The price dealt.","x-mt5":"price"},"bid":{"type":"number","format":"double","description":"The bid when the request was handled (requotes).","x-mt5":"bid"},"ask":{"type":"number","format":"double","description":"The ask when the request was handled (requotes).","x-mt5":"ask"},"retcode_external":{"type":"integer","format":"int64","description":"The external trading system's code, if the broker routes to one.","x-mt5":"retcode_external"}}},"TradeUnavailable":{"oneOf":[{"$ref":"#/components/schemas/ErrorBody"},{"$ref":"#/components/schemas/RequestView"}],"description":"A trade call answered 503: either a refusal (the request was not recorded), or a stored request the\nterminal refused to send (`state: refused`)."},"TypeTime":{"type":"string","description":"MT5's `ENUM_ORDER_TYPE_TIME`: `gtc` (`ORDER_TIME_GTC`, until cancelled), `day` (`ORDER_TIME_DAY`,\nthe trading day), `specified` (`ORDER_TIME_SPECIFIED`, until `expiration`) and `specified_day`\n(`ORDER_TIME_SPECIFIED_DAY`, until the end of `expiration`'s day).","enum":["gtc","day","specified","specified_day"]}},"securitySchemes":{"api_key":{"type":"http","scheme":"bearer","description":"Your workspace's API key (`psk_...`), from the dashboard's API key page."}}},"security":[{"api_key":[]}],"tags":[{"name":"Orders","description":"Market and pending orders, a dry run, and looking up a request."},{"name":"Positions","description":"Open positions: stops, closing, and closing by an opposite position."},{"name":"Account","description":"The account's login, connection, balance and margin."},{"name":"Symbols","description":"The symbols the broker offers, their specifications and prices."},{"name":"History","description":"Deals and past orders in a time range."},{"name":"Kill switch","description":"Block new exposure and flatten the account."}],"x-pipsocket":{"errors":[{"code":"missing_api_key","from":"worker","meaning":"No API key: send it as `Authorization: Bearer <key>`.","status":401},{"code":"invalid_api_key","from":"worker","meaning":"The key is not a workspace's current key (a rolled key stops working within about a minute).","status":401},{"code":"no_such_account","from":"engine","meaning":"No such account, or one the key's workspace doesn't have: the two look the same.","status":404},{"code":"no_such_order","from":"engine","meaning":"The account has no pending order with that ticket (read fresh from the terminal).","status":404},{"code":"no_such_position","from":"engine","meaning":"The account has no open position with that ticket (read fresh from the terminal).","status":404},{"code":"no_such_request","from":"engine","meaning":"The account has no request with that id (requests are kept 7 days).","status":404},{"code":"no_such_symbol","from":"engine","meaning":"The broker has no symbol by that name.","status":404},{"code":"invalid_request","from":"engine","meaning":"A field, query parameter or header is missing, malformed or not allowed, or the body is not JSON. Nothing was sent.","status":422},{"code":"range_too_large","from":"engine","meaning":"The history range holds more than one answer can carry: ask for a shorter range.","status":422},{"code":"kill_switch_engaged","from":"engine","meaning":"The account's kill switch is engaged: new orders and changes to pending orders are refused until it is lifted. Nothing was sent.","status":423},{"code":"account_not_connected","from":"engine","meaning":"The account's terminal is not connected to the engine (stopped, starting, or restarting). Nothing was sent, except by the kill switch: engaging it still engages it, and may already have deleted pending orders.","status":503},{"code":"bridge_outdated","from":"engine","meaning":"The account's terminal runs an older bridge that can't trade: restart the account to update it. Nothing was sent.","status":503},{"code":"account_restarting","from":"engine","meaning":"The account's terminal is being replaced. Nothing was sent; try again in a minute.","status":503},{"code":"bad_command","from":"engine","meaning":"The terminal refused the command, for example a negative `expiration`, or a history range MT5 can't select.","status":503},{"code":"terminal_error","from":"engine","meaning":"The terminal did not give the answer asked for.","status":503},{"code":"symbol_too_large","from":"engine","meaning":"One symbol's entry is too large for the terminal to list.","status":503},{"code":"no_price","from":"engine","meaning":"The terminal has no price for the symbol yet (it waited 2 seconds).","status":503},{"code":"engine_busy","from":"engine","meaning":"The account's engine host has too many calls in flight (256). Nothing was done; try again.","status":503},{"code":"engine_unavailable","from":"worker","meaning":"The account's engine host is not connected to Pipsocket, or disconnected while the call waited. A trade it already had is still settled: look it up.","status":503},{"code":"terminal_timeout","from":"engine","meaning":"The account's terminal did not answer within 5 seconds.","status":504},{"code":"engine_timeout","from":"worker","meaning":"The account's engine did not answer within 30 seconds.","status":504}],"retcodes":[{"code":0,"message":"The request passed the check.","name":"OK"},{"code":10004,"message":"The broker requoted the price.","name":"TRADE_RETCODE_REQUOTE"},{"code":10006,"message":"The trade server rejected the request.","name":"TRADE_RETCODE_REJECT"},{"code":10007,"message":"The request was cancelled by the trader.","name":"TRADE_RETCODE_CANCEL"},{"code":10008,"message":"The order was placed; execution is not confirmed yet.","name":"TRADE_RETCODE_PLACED"},{"code":10009,"message":"The request was completed.","name":"TRADE_RETCODE_DONE"},{"code":10010,"message":"Only part of the request was completed.","name":"TRADE_RETCODE_DONE_PARTIAL"},{"code":10011,"message":"The trade server could not process the request.","name":"TRADE_RETCODE_ERROR"},{"code":10012,"message":"The request was cancelled by a timeout.","name":"TRADE_RETCODE_TIMEOUT"},{"code":10013,"message":"The request is invalid.","name":"TRADE_RETCODE_INVALID"},{"code":10014,"message":"The volume is invalid for this symbol.","name":"TRADE_RETCODE_INVALID_VOLUME"},{"code":10015,"message":"The price is invalid.","name":"TRADE_RETCODE_INVALID_PRICE"},{"code":10016,"message":"The stop loss or take profit is invalid for this symbol or too close to the price.","name":"TRADE_RETCODE_INVALID_STOPS"},{"code":10017,"message":"Trading is disabled.","name":"TRADE_RETCODE_TRADE_DISABLED"},{"code":10018,"message":"The market is closed.","name":"TRADE_RETCODE_MARKET_CLOSED"},{"code":10019,"message":"There is not enough money for the request.","name":"TRADE_RETCODE_NO_MONEY"},{"code":10020,"message":"The price changed.","name":"TRADE_RETCODE_PRICE_CHANGED"},{"code":10021,"message":"There are no quotes to process the request.","name":"TRADE_RETCODE_PRICE_OFF"},{"code":10022,"message":"The order expiration is invalid.","name":"TRADE_RETCODE_INVALID_EXPIRATION"},{"code":10023,"message":"The order changed state.","name":"TRADE_RETCODE_ORDER_CHANGED"},{"code":10024,"message":"Too many requests in a short time.","name":"TRADE_RETCODE_TOO_MANY_REQUESTS"},{"code":10025,"message":"The request changes nothing.","name":"TRADE_RETCODE_NO_CHANGES"},{"code":10026,"message":"Automated trading is disabled by the server.","name":"TRADE_RETCODE_SERVER_DISABLES_AT"},{"code":10027,"message":"Automated trading is disabled in the terminal.","name":"TRADE_RETCODE_CLIENT_DISABLES_AT"},{"code":10028,"message":"The request is locked for processing.","name":"TRADE_RETCODE_LOCKED"},{"code":10029,"message":"The order or position is frozen.","name":"TRADE_RETCODE_FROZEN"},{"code":10030,"message":"The filling mode is not allowed for this symbol.","name":"TRADE_RETCODE_INVALID_FILL"},{"code":10031,"message":"There is no connection to the trade server.","name":"TRADE_RETCODE_CONNECTION"},{"code":10032,"message":"This is only allowed for live accounts.","name":"TRADE_RETCODE_ONLY_REAL"},{"code":10033,"message":"The account has reached its limit of pending orders.","name":"TRADE_RETCODE_LIMIT_ORDERS"},{"code":10034,"message":"The symbol has reached its volume limit for orders and positions.","name":"TRADE_RETCODE_LIMIT_VOLUME"},{"code":10035,"message":"The order type is incorrect or not allowed.","name":"TRADE_RETCODE_INVALID_ORDER"},{"code":10036,"message":"The position is already closed.","name":"TRADE_RETCODE_POSITION_CLOSED"},{"code":10038,"message":"The close volume is more than the position's volume.","name":"TRADE_RETCODE_INVALID_CLOSE_VOLUME"},{"code":10039,"message":"A close order already exists for the position.","name":"TRADE_RETCODE_CLOSE_ORDER_EXIST"},{"code":10040,"message":"The account has reached its limit of open positions.","name":"TRADE_RETCODE_LIMIT_POSITIONS"},{"code":10041,"message":"The pending order's activation was rejected and the order cancelled.","name":"TRADE_RETCODE_REJECT_CANCEL"},{"code":10042,"message":"Only long positions are allowed for this symbol.","name":"TRADE_RETCODE_LONG_ONLY"},{"code":10043,"message":"Only short positions are allowed for this symbol.","name":"TRADE_RETCODE_SHORT_ONLY"},{"code":10044,"message":"Only closing positions is allowed for this symbol.","name":"TRADE_RETCODE_CLOSE_ONLY"},{"code":10045,"message":"Positions may only be closed first in, first out.","name":"TRADE_RETCODE_FIFO_CLOSE"},{"code":10046,"message":"Opposite positions on one symbol are not allowed.","name":"TRADE_RETCODE_HEDGE_PROHIBITED"}]}}