Close a position
Build your request
Change the values and the command follows. The token is never typed here: the command reads it from the SPECTRE_LOCAL_API_TOKEN environment variable. Run it in your own terminal.
curl -X POST 'http://127.0.0.1:48180/v1/positions/close' \
-H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"connection_id": 12,
"instrument": "binance:futures:BTCUSDT"
}'Closes the position of the instrument the way the window does. On futures it sends a market order for the size of the position. On spot it cancels all orders and closes the position in one command.
bearerToken trading:writeAuthorizationBearer <token>The Local API token: spt_ and 64 hex characters. Copy it from Settings App → General → Local API. It is accepted only in the Authorization header. The names listed with an operation are the scopes it requires. The token of the terminal carries all of them.
Scope: trading:write
application/json- body
connection_id*integerint64instrument*stringInstrument address, exchange:market:symbol.
The terminal accepted the command.
application/json- response
The answer of every trading, trigger and leverage command.
accepted*booleanAccepted by the terminal, not by the exchange.
operation_id*stringThe id of the operation in the trading operations log of the terminal. The key of a placed order is t- and this id.
key*|The key of the placed order, t-…, or of the placed trigger: sl_…, tp_… or stop_…. null for cancels, amendments and leverage.
connection_id*integerint64instrument*stringcurl -X POST 'http://127.0.0.1:48180/v1/positions/close' \ -H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "connection_id": 12, "instrument": "binance:futures:BTCUSDT"}'{ "accepted": true, "operation_id": "173029440000000004", "key": "t-173029440000000004", "connection_id": 12, "instrument": "binance:futures:BTCUSDT"}Cancel an order DELETE
Sends the cancel to the exchange. The confirmation arrives in the stream.
Place a trigger order POST
`stop_loss` and `take_profit` are placed on the open position and take only `trigger_price`. `stop` needs its own `side` and `notional`. Without `rule` a buy stop triggers above the market and a sell stop below.