Set the leverage
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/account/leverage' \
-H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \
-H 'Content-Type: application/json' \
-d '{
"connection_id": 12,
"instrument": "binance:futures:BTCUSDT",
"leverage": 20
}'Sets a fixed leverage or a leverage mode. Pass exactly one of leverage and mode. The applied value shows in GET after the exchange answers.
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.
leverage?integerA fixed leverage. Exactly one of leverage and mode.
1 <= valuemode?stringA leverage mode of the terminal. Exactly one of leverage and mode.
"max""smart"The terminal accepted the command. key is null.
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/account/leverage' \ -H "Authorization: Bearer $SPECTRE_LOCAL_API_TOKEN" \ -H 'Content-Type: application/json' \ -d '{ "connection_id": 12, "instrument": "binance:futures:BTCUSDT", "leverage": 20}'{ "accepted": true, "operation_id": "173029440000000009", "key": null, "connection_id": 12, "instrument": "binance:futures:BTCUSDT"}Leverage and margin mode GET
The leverage the terminal has loaded for the instrument. It is loaded when the instrument is chosen in the window or when the leverage is set with `POST`. Before that the answer is `409 not_active`.
Set the margin mode POST
The exchange rejects a change while a position is open. The `accepted` answer does not show that.