Type/to search
Built-in Functions
Structures
Built-in Variables and Constants
Conventions
Exchanges
Capability Matrix
Centralized Exchanges
AscendEx
Backpack
BigONE
Binance
Bitfinex
bitFlyer
Bitget
Bithumb
Bitstamp
Bybit
Coincheck
Coinone
CoinW
Crypto.com
DeepCoin
Deribit
DigiFinex
Gate
Gemini
HashKey
HitBTC
HTX
Korbit
Kraken
KuCoin
LBank
MEXC
OKX
Poloniex
Upbit
WEEX
WOO X
Zaif
Decentralized Exchanges (DEX)
Prediction Markets
Securities and Futures
On-chain & Custom

Backpack (Spot): Spot trading on Backpack Exchange (mainly USDC-quoted), including the tokenized stocks listed on the exchange; the account reads the spot balances. Access uses an API key created on Backpack (an ED25519 key pair). Perpetual contracts are served by the Futures_Backpack exchange object.

Futures_Backpack (Futures): Backpack Exchange USDC perpetual contracts, including perpetuals on tokenized stocks. The account is a unified collateral account with cross margin and one-way positions only. Access uses an API key created on Backpack (an ED25519 key pair). Spot is served by the Backpack exchange object.

Names and Configuration
exchange.GetName()TypeAliases
BackpackSpotBackpack Exchange
Futures_BackpackFutures—
FieldRequiredDescription
---
Access KeyYesThe public key of the Backpack API key (base64).
Secret KeyYesThe ED25519 private key matching the public key (32-byte seed, base64 or hex).

Trading Pairs and Contract Codes
Backpack (Spot)

Pair examples: SOL_USDC, BTC_USDC, SPCX-US_USDC

Trading pairs are written as SOL_USDC. Tokenized stocks whose exchange name contains . (such as SPCX.US) are written with - in pairs and asset names: SPCX-US_USDC.

Futures_Backpack (Futures)

Pair examples: BTC_USDC, ETH_USDC

Backpack perpetuals are quoted in USDC; trading pairs are written as ETH_USDC (USDC is assumed when the quote currency is omitted). Tokenized stocks whose exchange name contains . (such as MU.US) are written with - in pairs and asset names: MU-US_USDC.

Contract codeDescription
swapPerpetual contract (exchange code ETH_USDC_PERP); the full symbol looks like ETH_USDC.swap.

Backpack lists perpetual contracts only; any other contract code is rejected.

Exchange-specific IO Commands
CommandArgumentsDescriptionReturns
selfTradePreventionModestringSelf-trade prevention for subsequent orders and conditional orders; one of Allow, RejectTaker, RejectMaker, RejectBoth (case-sensitive).The value set on success; an error for any other value.
apimethod, path[, params[, raw]]Call a Backpack endpoint directly; requests are signed by default. (more below the table)The raw exchange response; an error is raised when the response carries a message or error error message.

The rest of the longer descriptions in the table:

  • api: Private endpoints need the exchange's instruction name instruction (such as balanceQuery or orderQueryAll) in params (or in the raw object); it is used for signing only and is not sent with the request. A non-empty raw replaces params entirely: for GET it may be a JSON object or a=1&b=2, for other methods it must be a JSON object. path may also be a full URL. With false as the 4th argument the request is not signed, which only works for public GET endpoints.

For the common commands base and currency see exchange.IO.

Common Usage
Call private endpoints (signing needs instruction) and public endpoints
javascript
function main() { // Private endpoint: instruction is the exchange-defined instruction name; it is only // signed, not sent with the request var balances = exchange.IO("api", "GET", "/api/v1/capital", {instruction: "balanceQuery"}) Log(balances) // {"USDC": {"available": "...", "locked": "...", "staked": "..."}, ...} var orders = exchange.IO("api", "GET", "/api/v1/orders", {instruction: "orderQueryAll"}) Log(orders) // array of open orders // Public endpoint: false as the last argument skips signing (GET only) var t = exchange.IO("api", "GET", "/api/v1/ticker", "symbol=SOL_USDC", false) Log(t.lastPrice) }
Set self-trade prevention (values are case-sensitive)
javascript
function main() { // Later orders and conditional orders carry it; an unknown value fails and returns null Log(exchange.IO("selfTradePreventionMode", "RejectTaker")) // RejectTaker }

Function Support

Not supported (the call fails with an error and returns null): exchange.ModifyOrder, exchange.ModifyConditionOrder.

Served through a fallback:

  • exchange.GetRecords: Native periods are 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M; other periods are synthesized by the docker.

Margin, Account and Simulation
Futures_Backpack (Futures)

Margin mode: Backpack uses a unified collateral account with cross margin only and no cross/isolated switch. exchange.SetMarginLevel() changes the account-level leverage limit (leverageLimit), which applies to all contracts; the call also turns on the account's auto-borrow settings (autoBorrowSettlements, autoLend, autoRepayBorrows).

Position mode: One-way (net) positions only, no hedge mode. Closing orders (closebuy, closesell) are placed as reduce-only (reduceOnly). MarginLevel in exchange.GetPositions() is the reciprocal of the initial margin fraction.

Account: exchange.GetAccount() reads the collateral account: Balance is the available net equity, FrozenBalance the locked net equity and Equity the net equity; each collateral currency is listed in exchange.GetAssets().

Notes
All exchange objects
  • The client order ID clientId must be an integer from 0 to 4294967295; any other value fails and the order is not sent.
  • The batch data of exchange.GetTickers() has no order book, so Buy and Sell are the last trade price; use exchange.GetTicker() for the real best bid and ask.
  • Conditional orders support take-profit and stop-loss only, not OCO. Backpack trigger orders do not distinguish take-profit from stop-loss, so the type is inferred on query from the trigger price relative to the current last price. With an order price of 0 the order executes at market once triggered. Modifying a conditional order is not supported; cancel and recreate it instead.
  • exchange.GetHistoryOrders() and exchange.GetHistoryConditionOrders() query one symbol at a time and do not support since (the exchange's order history endpoint has no time range); a since greater than 0 or an empty symbol is rejected.
Backpack (Spot)
  • The amount of a market buy order is the quote currency to spend (placed with Backpack's quoteQuantity); a market sell order uses the base currency amount. Such market buy orders have no order price in queries, so Price is 0, and Amount is the filled base currency amount.
  • exchange.GetOrders() and exchange.GetHistoryOrders() return regular orders only, without conditional orders; querying a conditional order ID with exchange.GetOrder() fails, so use exchange.GetConditionOrder() for conditional orders, and exchange.GetConditionOrders() / exchange.GetHistoryConditionOrders() for open and historical conditional orders.
  • exchange.GetAccount() and exchange.GetAssets() count available and frozen amounts only, not staked amounts.
Futures_Backpack (Futures)
  • The amount of a market order is the contract quantity (in the base currency) for both buys and sells.
  • exchange.GetOrders() and exchange.GetHistoryOrders() return regular orders only, without conditional orders; querying a conditional order ID with exchange.GetOrder() fails, so use exchange.GetConditionOrder() for conditional orders.
  • Funding intervals differ between contracts; exchange.GetFundings() reports each one from the exchange's contract information.