exchange.IO
exchange.IO() function is used to call other interfaces related to the exchange object.
exchange.IO(k, ...args)Examples
-
Use the
"api"mode to call the OKX futures batch order placement interface, and pass the JSON-formatted order data via therawparameter:javascriptfunction main() { var arrOrders = [ {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"1","posSide":"long"}, {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"2","posSide":"long"} ] // Call exchange.IO to directly access the exchange's batch order placement interface var ret = exchange.IO("api", "POST", "/api/v5/trade/batch-orders", "", JSON.stringify(arrOrders)) Log(ret) }pythonimport json def main(): arrOrders = [ {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"1","posSide":"long"}, {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"2","posSide":"long"} ] ret = exchange.IO("api", "POST", "/api/v5/trade/batch-orders", "", json.dumps(arrOrders)) Log(ret)rustfn main() { // Rust has no JSON serialization; construct the order array directly using a raw string let arrOrders = r#"[ {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"1","posSide":"long"}, {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"2","posSide":"long"} ]"#; // Call exchange.IO to directly access the exchange's batch order placement interface; multiple parameters are passed in as a tuple let ret = exchange.IO(("api", "POST", "/api/v5/trade/batch-orders", "", arrOrders)); Log!(ret); }c++void main() { json arrOrders = R"([ {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"1","posSide":"long"}, {"instId":"BTC-USDT-SWAP","tdMode":"cross","side":"buy","ordType":"limit","px":"16000","sz":"2","posSide":"long"} ])"_json; auto ret = exchange.IO("api", "POST", "/api/v5/trade/batch-orders", "", arrOrders.dump()); Log(ret); } -
When the value of a key in the
paramsparameter is of string type, you need to wrap the parameter value with single quotes:javascriptvar amount = 1 var price = 10 var basecurrency = "ltc" function main () { // Note that there is a ' character on both the left and right sides of amount.toString() and price.toString() var message = "symbol=" + basecurrency + "&amount='" + amount.toString() + "'&price='" + price.toString() + "'&side=buy" + "&type=limit" var id = exchange.IO("api", "POST", "/v1/order/new", message) }pythonamount = 1 price = 10 basecurrency = "ltc" def main(): message = "symbol=" + basecurrency + "&amount='" + str(amount) + "'&price='" + str(price) + "'&side=buy" + "&type=limit" id = exchange.IO("api", "POST", "/v1/order/new", message)rustfn main() { let amount = 1; let price = 10; let basecurrency = "ltc"; // Note that there is a ' character on both the left and right sides of the amount and price parameter values let message = format!("symbol={}&amount='{}'&price='{}'&side=buy&type=limit", basecurrency, amount, price); let id = exchange.IO(("api", "POST", "/v1/order/new", message)); }c++void main() { auto amount = 1.0; auto price = 10.0; auto basecurrency = "ltc"; string message = str_format("symbol=%s&amount=\"%.1f\"&price=\"%.1f\"&side=buy&type=limit", basecurrency, amount, price); auto id = exchange.IO("api", "POST", "/v1/order/new", message); } -
The
resourceparameter supports passing in a complete URL:javascriptfunction main() { var ret = exchange.IO("api", "GET", "https://www.okx.com/api/v5/account/max-withdrawal", "ccy=BTC") Log(ret) }pythondef main(): ret = exchange.IO("api", "GET", "https://www.okx.com/api/v5/account/max-withdrawal", "ccy=BTC") Log(ret)rustfn main() { let ret = exchange.IO(("api", "GET", "https://www.okx.com/api/v5/account/max-withdrawal", "ccy=BTC")); Log!(ret); }c++void main() { auto ret = exchange.IO("api", "GET", "https://www.okx.com/api/v5/account/max-withdrawal", "ccy=BTC"); Log(ret); } -
A GET request that does not use the
rawparameter:javascriptfunction main(){ var ret = exchange.IO("api", "GET", "/api/v5/trade/orders-pending", "instType=SPOT") Log(ret) }pythondef main(): ret = exchange.IO("api", "GET", "/api/v5/trade/orders-pending", "instType=SPOT") Log(ret)rustfn main() { let ret = exchange.IO(("api", "GET", "/api/v5/trade/orders-pending", "instType=SPOT")); Log!(ret); }c++void main() { auto ret = exchange.IO("api", "GET", "/api/v5/trade/orders-pending", "instType=SPOT"); Log(ret); } -
Switch trading pair at runtime:
javascriptfunction main() { // For example, when the live bot starts, the exchange object's current trading pair is BTC_USDT; print the ticker of the current trading pair Log(exchange.GetTicker()) // Switch the trading pair to LTC_BTC exchange.IO("currency", "LTC_BTC") Log(exchange.GetTicker()) }pythondef main(): Log(exchange.GetTicker()) exchange.IO("currency", "LTC_BTC") Log(exchange.GetTicker())rustfn main() { // For example, when the live bot starts, the exchange object's current trading pair is BTC_USDT; print the ticker of the current trading pair Log!(exchange.GetTicker(None)); // Switch the trading pair to LTC_BTC let _ = exchange.IO(("currency", "LTC_BTC")); Log!(exchange.GetTicker(None)); }c++void main() { Log(exchange.GetTicker()); exchange.IO("currency", "LTC_BTC"); Log(exchange.GetTicker()); } -
Switch the exchange API base address:
javascriptfunction main () { // exchanges[0] is the first exchange object added when the live bot was created exchanges[0].IO("base", "https://api.huobi.pro") }pythondef main(): exchanges[0].IO("base", "https://api.huobi.pro")rustfn main() { // exchanges[0] is the first exchange object added when the live bot was created let _ = exchanges[0].IO(("base", "https://api.huobi.pro")); }c++void main() { exchanges[0].IO("base", "https://api.huobi.pro"); } -
Switch the market data API base address via
"mbase"(using Bitfinex as an example):javascriptfunction main() { exchange.SetBase("https://api.bitfinex.com") exchange.IO("mbase", "https://api-pub.bitfinex.com") }pythondef main(): exchange.SetBase("https://api.bitfinex.com") exchange.IO("mbase", "https://api-pub.bitfinex.com")rustfn main() { exchange.SetBase("https://api.bitfinex.com"); let _ = exchange.IO(("mbase", "https://api-pub.bitfinex.com")); }c++void main() { exchange.SetBase("https://api.bitfinex.com"); exchange.IO("mbase", "https://api-pub.bitfinex.com"); } -
Switch between the demo/live trading environment (using OKX Futures as an example):
javascriptfunction main() { exchange.IO("simulate", true) // Switch to demo trading environment // ... trading logic ... exchange.IO("simulate", false) // Switch back to live trading environment }pythondef main(): exchange.IO("simulate", True) # ... trading logic ... exchange.IO("simulate", False)rustfn main() { let _ = exchange.IO(("simulate", true)); // Switch to demo trading environment // ... trading logic ... let _ = exchange.IO(("simulate", false)); // Switch back to live trading environment }c++void main() { exchange.IO("simulate", true); // ... trading logic ... exchange.IO("simulate", false); } -
Switch contract margin mode and position mode (using Binance Futures as an example):
javascriptfunction main() { exchange.IO("dual", true) // Switch to hedge mode (dual position) exchange.IO("dual", false) // Switch to one-way mode exchange.SetContractType("swap") exchange.IO("cross", true) // Switch to cross margin exchange.IO("cross", false) // Switch to isolated margin }pythondef main(): exchange.IO("dual", True) exchange.IO("dual", False) exchange.SetContractType("swap") exchange.IO("cross", True) exchange.IO("cross", False)rustfn main() { let _ = exchange.IO(("dual", true)); // Switch to hedge mode (dual position) let _ = exchange.IO(("dual", false)); // Switch to one-way mode let _ = exchange.SetContractType("swap"); let _ = exchange.IO(("cross", true)); // Switch to cross margin let _ = exchange.IO(("cross", false)); // Switch to isolated margin }c++void main() { exchange.IO("dual", true); exchange.IO("dual", false); exchange.SetContractType("swap"); exchange.IO("cross", true); exchange.IO("cross", false); } -
Switch to unified account mode (using Binance Futures as an example):
javascriptfunction main() { exchange.IO("unified", true) // Switch to unified account mode exchange.IO("unified", false) // Switch to normal mode }pythondef main(): exchange.IO("unified", True) exchange.IO("unified", False)rustfn main() { let _ = exchange.IO(("unified", true)); // Switch to unified account mode let _ = exchange.IO(("unified", false)); // Switch to normal mode }c++void main() { exchange.IO("unified", true); exchange.IO("unified", false); } -
Set self-trade prevention mode (using Binance as an example):
javascriptfunction main() { // "NONE" means disable STP mode, other parameters: "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH" exchange.IO("selfTradePreventionMode", "NONE") }pythondef main(): exchange.IO("selfTradePreventionMode", "NONE")rustfn main() { // "NONE" means disable STP mode, other parameters: "EXPIRE_TAKER", "EXPIRE_MAKER", "EXPIRE_BOTH" let _ = exchange.IO(("selfTradePreventionMode", "NONE")); }c++void main() { exchange.IO("selfTradePreventionMode", "NONE"); } -
Futures_edgeX calculates the order Hash and signs it:
javascriptfunction main() { var strJson = `{ "assetIdSynthetic": "0x4554482d3900000000000000000000", "assetIdCollateral": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "assetIdFee": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "isBuyingSynthetic": true, "amountSynthetic": 10000000, "amountCollateral": 13020000, "amountFee": 6250, "nonce": 676432751, "accountID": 601416704693633632, "expirationTimestamp": 484831 }` var signature = exchange.IO("calcOrderHashAndSign", strJson) Log(signature) }pythonimport json def main(): params = { "assetIdSynthetic": "0x4554482d3900000000000000000000", "assetIdCollateral": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "assetIdFee": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "isBuyingSynthetic": True, "amountSynthetic": 10000000, "amountCollateral": 13020000, "amountFee": 6250, "nonce": 676432751, "accountID": 601416704693633632, "expirationTimestamp": 484831 } signature = exchange.IO("calcOrderHashAndSign", json.dumps(params)) Log(signature)rustfn main() { let strJson = r#"{ "assetIdSynthetic": "0x4554482d3900000000000000000000", "assetIdCollateral": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "assetIdFee": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "isBuyingSynthetic": true, "amountSynthetic": 10000000, "amountCollateral": 13020000, "amountFee": 6250, "nonce": 676432751, "accountID": 601416704693633632, "expirationTimestamp": 484831 }"#; let signature = exchange.IO(("calcOrderHashAndSign", strJson)); Log!(signature); }c++void main() { json params = R"({ "assetIdSynthetic": "0x4554482d3900000000000000000000", "assetIdCollateral": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "assetIdFee": "0x2ce625e94458d39dd0bf3b45a843544dd4a14b8169045a3a3d15aa564b936c5", "isBuyingSynthetic": true, "amountSynthetic": 10000000, "amountCollateral": 13020000, "amountFee": 6250, "nonce": 676432751, "accountID": 601416704693633632, "expirationTimestamp": 484831 })"_json; auto signature = exchange.IO("calcOrderHashAndSign", params.dump()); Log(signature); } -
rate mode rate limiting - Limit GetTicker to a maximum of 10 calls per second; returns null when the limit is exceeded:
javascriptfunction main() { exchange.IO("rate", "GetTicker", 10, "1s") for (var i = 0; i < 20; i++) { var ticker = exchange.GetTicker("BTC_USDT") if (ticker) { Log("Ticker:", ticker.Last) } else { Log("Rate limit exceeded") } } }pythondef main(): exchange.IO("rate", "GetTicker", 10, "1s") for i in range(20): ticker = exchange.GetTicker("BTC_USDT") if ticker: Log("Ticker:", ticker["Last"]) else: Log("Rate limit exceeded")rustfn main() { let _ = exchange.IO(("rate", "GetTicker", 10, "1s")); for _i in 0..20 { // GetTicker returns Err when the limit is exceeded match exchange.GetTicker("BTC_USDT") { Ok(ticker) => Log!("Ticker:", ticker.Last), Err(_) => Log!("Rate limit exceeded"), } } }c++// C++ is not supported yet -
rate mode rate limiting - Use the
"delay"parameter to automatically wait instead of returning null when the limit is exceeded:javascriptfunction main() { exchange.IO("rate", "GetTicker", 10, "1s", "delay") for (var i = 0; i < 20; i++) { var ticker = exchange.GetTicker("BTC_USDT") Log("Call", i+1, "Ticker:", ticker.Last) } }pythondef main(): exchange.IO("rate", "GetTicker", 10, "1s", "delay") for i in range(20): ticker = exchange.GetTicker("BTC_USDT") Log("Call", i+1, "Ticker:", ticker["Last"])rustfn main() { let _ = exchange.IO(("rate", "GetTicker", 10, "1s", "delay")); for i in 0..20 { let ticker = exchange.GetTicker("BTC_USDT").unwrap(); Log!("Call", i + 1, "Ticker:", ticker.Last); } }c++// C++ is not supported yet -
Multiple functions sharing a rate limit quota:
javascriptfunction main() { // GetTicker and GetDepth share the rate limit quota, with a combined maximum of 10 calls per second exchange.IO("rate", "GetTicker,GetDepth", 10, "1s") for (var i = 0; i < 20; i++) { if (i % 2 == 0) { Log("Ticker:", exchange.GetTicker("BTC_USDT")) } else { Log("Depth:", exchange.GetDepth("BTC_USDT")) } } }pythondef main(): exchange.IO("rate", "GetTicker,GetDepth", 10, "1s") for i in range(20): if i % 2 == 0: Log("Ticker:", exchange.GetTicker("BTC_USDT")) else: Log("Depth:", exchange.GetDepth("BTC_USDT"))rustfn main() { // GetTicker and GetDepth share the rate limit quota, with a combined maximum of 10 calls per second let _ = exchange.IO(("rate", "GetTicker,GetDepth", 10, "1s")); for i in 0..20 { if i % 2 == 0 { Log!("Ticker:", exchange.GetTicker("BTC_USDT")); } else { Log!("Depth:", exchange.GetDepth("BTC_USDT")); } } }c++// C++ is not supported yet -
Use a wildcard to uniformly limit the call frequency of all APIs:
javascriptfunction main() { exchange.IO("rate", "*", 100, "1m") for (var i = 0; i < 10; i++) { exchange.GetTicker("BTC_USDT") exchange.GetDepth("BTC_USDT") exchange.GetAccount() Log("Round", i+1, "completed") Sleep(1000) } }pythondef main(): exchange.IO("rate", "*", 100, "1m") for i in range(10): exchange.GetTicker("BTC_USDT") exchange.GetDepth("BTC_USDT") exchange.GetAccount() Log("Round", i+1, "completed") Sleep(1000)rustfn main() { let _ = exchange.IO(("rate", "*", 100, "1m")); for i in 0..10 { let _ = exchange.GetTicker("BTC_USDT"); let _ = exchange.GetDepth("BTC_USDT"); let _ = exchange.GetAccount(); Log!("Round", i + 1, "completed"); Sleep(1000); } }c++// C++ is not supported yet -
quota mode - strict rate limiting aligned to time windows:
javascriptfunction main() { exchange.IO("quota", "GetTicker", 3, "1s") for (var i = 0; i < 10; i++) { var ticker = exchange.GetTicker("BTC_USDT") if (ticker) { Log(_D(), "Ticker:", ticker.Last) } else { Log(_D(), "Quota exceeded, waiting for next window") } Sleep(100) } }pythondef main(): exchange.IO("quota", "GetTicker", 3, "1s") for i in range(10): ticker = exchange.GetTicker("BTC_USDT") if ticker: Log(_D(), "Ticker:", ticker["Last"]) else: Log(_D(), "Quota exceeded, waiting for next window") Sleep(100)rustfn main() { let _ = exchange.IO(("quota", "GetTicker", 3, "1s")); for _i in 0..10 { match exchange.GetTicker("BTC_USDT") { Ok(ticker) => Log!(_D(None), "Ticker:", ticker.Last), Err(_) => Log!(_D(None), "Quota exceeded, waiting for next window"), } Sleep(100); } }c++// C++ not supported yet -
quota mode - intraday quota, resets daily at the specified time:
javascriptfunction main() { exchange.IO("quota", "GetTicker", 1000, "@0815") var count = 0 while (true) { var ticker = exchange.GetTicker("BTC_USDT") if (ticker) { count++ Log("Call count:", count, "Ticker:", ticker.Last) } else { Log("Daily quota exceeded, waiting for reset at 08:15") Sleep(60000) // Wait 1 minute } Sleep(1000) } }pythondef main(): exchange.IO("quota", "GetTicker", 1000, "@0815") count = 0 while True: ticker = exchange.GetTicker("BTC_USDT") if ticker: count += 1 Log("Call count:", count, "Ticker:", ticker["Last"]) else: Log("Daily quota exceeded, waiting for reset at 08:15") Sleep(60000) # Wait 1 minute Sleep(1000)rustfn main() { let _ = exchange.IO(("quota", "GetTicker", 1000, "@0815")); let mut count = 0; loop { match exchange.GetTicker("BTC_USDT") { Ok(ticker) => { count += 1; Log!("Call count:", count, "Ticker:", ticker.Last); } Err(_) => { Log!("Daily quota exceeded, waiting for reset at 08:15"); Sleep(60000); // Wait 1 minute } } Sleep(1000); } }c++// C++ not supported yet -
Combining multiple rate-limiting rules:
javascriptfunction main() { exchange.IO("rate", "GetTicker", 10, "1s") // GetTicker 10 times per second exchange.IO("rate", "GetDepth", 5, "1s") // GetDepth 5 times per second exchange.IO("rate", "CreateOrder", 2, "1s") // CreateOrder 2 times per second exchange.IO("quota", "*", 1000, "@0000") // All APIs reset daily at 00:00, cap of 1000 calls Log("Rate limits configured successfully") for (var i = 0; i < 5; i++) { exchange.GetTicker("BTC_USDT") exchange.GetDepth("BTC_USDT") Sleep(200) } }pythondef main(): exchange.IO("rate", "GetTicker", 10, "1s") # GetTicker 10 times per second exchange.IO("rate", "GetDepth", 5, "1s") # GetDepth 5 times per second exchange.IO("rate", "CreateOrder", 2, "1s") # CreateOrder 2 times per second exchange.IO("quota", "*", 1000, "@0000") # All APIs reset daily at 00:00, cap of 1000 calls Log("Rate limits configured successfully") for i in range(5): exchange.GetTicker("BTC_USDT") exchange.GetDepth("BTC_USDT") Sleep(200)rustfn main() { let _ = exchange.IO(("rate", "GetTicker", 10, "1s")); // GetTicker 10 times per second let _ = exchange.IO(("rate", "GetDepth", 5, "1s")); // GetDepth 5 times per second let _ = exchange.IO(("rate", "CreateOrder", 2, "1s")); // CreateOrder 2 times per second let _ = exchange.IO(("quota", "*", 1000, "@0000")); // All APIs reset daily at 00:00, cap of 1000 calls Log!("Rate limits configured successfully"); for _i in 0..5 { let _ = exchange.GetTicker("BTC_USDT"); let _ = exchange.GetDepth("BTC_USDT"); Sleep(200); } }c++// C++ is not supported yet
Returns
| Type | Description |
string / number / bool / object / array / any | The |
Arguments
| Name | Type | Required | Description |
k | string | Yes | Call type identifier. Different values correspond to different functions; please refer to the descriptions in each section below for details. |
arg | string / number / bool / object / array / any | Yes | Extended parameters. Different parameters need to be passed in according to the different |
See Also
Remarks
I. Directly Calling Exchange APIs ("api" mode)
javascript
exchange.IO("api", httpMethod, resource, params, raw)
Used to call the exchange's native API endpoints that are not wrapped by FMZ. FMZ automatically handles signature verification; you only need to fill in the request parameters.
| Parameter | Type | Required | Description |
|---|---|---|---|
| httpMethod | string | Yes | GET, POST, etc. |
| resource | string | Yes | Request path or full URL |
| params | string | No | Request parameters in URL-encoded format |
| raw | string | No | Raw request body (JSON, etc.) |
Returns a null value on failure, and this mode is only supported in live trading.
II. Switching Trading Pairs at Runtime ("currency" mode)
javascript
exchange.IO("currency", "ETH_USDT")
Used to dynamically switch trading pairs at runtime. The trading pair format is uppercase letters separated by an underscore. This instruction is equivalent to exchange.SetCurrency.
In backtesting mode, only spot is supported, and you can only switch to a trading pair with the same quote currency. After switching trading pairs for futures, you need to call
exchange.SetContractType()again.
III. Switching the Base Address ("base" / "mbase" mode)
-
"base": Switches the base address of the trading interface, equivalent toexchange.SetBase(). -
"mbase": Switches the base address of the market data interface, suitable for exchanges that use different domain names for market data and trading.
IV. Common Trading Mode Instructions
The following instructions are common across multiple exchanges. For the specific support of each exchange, please refer to the description in Section V.
| Instruction | Parameter | Function |
|---|---|---|
simulate | bool | Simulated trading (true) / Live trading (false) |
cross | bool | Cross margin (true) / Isolated margin (false) |
dual | bool | Hedge mode (true) / One-way mode (false) |
unified | bool | Unified account (true) / Standard account (false) |
trade_margin | none | Switch to isolated margin mode |
trade_super_margin | none | Switch to cross margin mode |
trade_normal | none | Switch back to normal spot mode |
selfTradePreventionMode | string | Self-Trade Prevention (STP) mode |
V. Exchange-Specific IO Commands
All exchanges support the "api" and "currency" commands; only the exchange-specific commands are listed below.
Spot Exchanges
Binance
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to isolated margin mode |
trade_super_margin | None | Switch to cross margin mode |
trade_normal | None | Switch back to normal spot mode |
unified | bool | Unified account mode |
selfTradePreventionMode | string | Self-trade prevention; options: EXPIRE_TAKER/EXPIRE_MAKER/EXPIRE_BOTH/NONE |
OKX
| Command | Parameter | Description |
|---|---|---|
simulate | bool | Switch between demo and live trading |
trade_margin | None | Isolated margin (tdMode=isolated) |
trade_super_margin | None | Cross margin (tdMode=cross) |
trade_normal | None | Switch back to normal spot mode |
tdMode | string | Directly set the trading mode; cross must be used in portfolio margin mode |
Huobi
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to isolated margin mode |
trade_super_margin | None | Switch to cross margin mode |
trade_normal | None | Switch back to normal spot mode |
Bybit
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to margin mode |
trade_normal | None | Switch back to normal spot mode |
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to isolated margin mode |
trade_super_margin | None | Switch to cross margin mode |
trade_normal | None | Switch back to normal spot mode |
unified | bool | Unified account mode |
Bitget
| Command | Parameter | Description |
|---|---|---|
simulate | bool | Switch between demo and live trading |
CoinEx
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to margin mode |
trade_normal | None | Switch back to normal mode |
WOO
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to margin mode |
trade_normal | None | Switch back to normal mode |
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to margin mode |
trade_normal | None | Switch back to normal mode |
AscendEx
| Command | Parameter | Description |
|---|---|---|
trade_margin | None | Switch to margin mode |
trade_normal | None | Switch back to normal mode |
Gemini
| Command | Parameter | Description |
|---|---|---|
subAccount | string | Set the sub-account name |
Poloniex
| Command | Parameter | Description |
|---|---|---|
accountId | string | Set the account ID |
Bitfinex
| Command | Parameter | Description |
|---|---|---|
version | None | Get the current API version number |
Backpack
| Command | Parameter | Description |
|---|---|---|
selfTradePreventionMode | string | Self-trade prevention; options: Allow/RejectTaker/RejectMaker/RejectBoth/Ban |
Hyperliquid (Spot)
| Command | Parameter | Description |
|---|---|---|
source | "a"/"b" | Switch the API data source |
vaultAddress | string | Set the vault address; pass an empty string to disable |
walletAddress | string | Set the wallet address |
expiresAfter | number | Order expiration time (milliseconds); set to 0 to disable |
Futures Exchanges
Futures_Binance (Binance Futures)
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
unified | bool | Unified account (uses papi.binance.com after switching) |
selfTradePreventionMode | string | Self-trade prevention; options: EXPIRE_TAKER/EXPIRE_MAKER/EXPIRE_BOTH/NONE |
extend_key | string | Set extended fields in the API response (comma-separated) |
Futures_OKX (OKX Futures)
| Command | Parameter | Description |
|---|---|---|
simulate | bool | Switch between demo and live trading |
cross | bool | Cross/isolated margin; defaults to cross |
dual | bool | Hedge (long_short_mode)/one-way (net_mode) position mode |
Futures_HuobiDM (Huobi Futures)
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin; defaults to isolated. Only supported for XXX_USDT perpetual swaps (swap) |
dual | bool | Hedge (dual_side)/one-way (single_side) position mode |
unified | bool | Unified account mode |
signHost | string | Set the API signature Host address; pass an empty string to disable |
Futures_Bybit
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
Futures_KuCoin
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_GateIO
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
unified | bool | Unified account mode |
Futures_Bitget
| Command | Parameter | Description |
|---|---|---|
simulate | bool | Switch between demo and live trading |
cross | bool | Cross (crossed)/isolated (isolated) margin |
dual | bool | Hedge (hedge_mode)/one-way (one_way_mode) position mode |
Futures_MEXC
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_BitMEX
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_CoinEx
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_WOO
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
Futures_Kraken
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin (only supported for multi-collateral accounts) |
Futures_Aevo
| Command | Parameter | Description |
|---|---|---|
signingKey | string | Set the signing key and return the public key. Must be obtained from the exchange's API Key page; note that it is time-sensitive |
Futures_Hyperliquid
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
source | "a"/"b" | Switch the API data source |
vaultAddress | string | Set the vault address; pass an empty string to disable |
walletAddress | string | Set the wallet address |
expiresAfter | number | Order expiration time (milliseconds); set to 0 to disable |
Futures_Deepcoin
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
merge | bool | Merge positions (true)/split positions (false) |
Futures_DigiFinex
| Command | Parameter | Description |
|---|---|---|
simulate | bool | Switch between demo and live trading |
cross | bool | Cross/isolated margin |
Futures_ApolloX
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_Aster
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
Futures_CoinW
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_BitMart
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
Futures_Backpack
| Command | Parameter | Description |
|---|---|---|
selfTradePreventionMode | string | Self-trade prevention; options: Allow/RejectTaker/RejectMaker/RejectBoth/Ban |
Futures_Lighter
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
expiry | number | Order expiration timestamp (milliseconds); defaults to 29 days, minimum 4 minutes |
Futures_Crypto.com
| Command | Parameter | Description |
|---|---|---|
accountId | string | Set the trading account ID |
Futures_Bitfinex
| Command | Parameter | Description |
|---|---|---|
mbase | string | Set the market data API base address |
Futures_edgeX
| Command | Parameter | Description |
|---|---|---|
calcOrderHashAndSign | string(JSON) | Compute the order hash and sign it; returns the signature string |
Futures_Bibox
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin; defaults to cross |
Futures_Pionex
| Command | Parameter | Description |
|---|---|---|
cross | bool | Cross/isolated margin |
dual | bool | Hedge/one-way position mode |
Futures_Phemex
| Command | Parameter | Description |
|---|---|---|
dual | bool | Hedge/one-way position mode. Cross/isolated margin must be set on the exchange's web interface |
Futures_WooFi
Only the generic commands
"api"and"currency"are supported; no exchange-specific commands.
VI. Special Platform IO Commands
Polymarket (Prediction Market)
| Command | Parameters | Description |
|---|---|---|
nonce | [number] | Gets or sets the order's nonce value. Returns the current nonce when no parameter is passed; sets a new nonce when a value is passed |
proxyWalletAddress | None | Gets the proxy wallet address |
redeem | symbol, [wait] | Redeems settled positions (gas-free via Relayer). wait defaults to true, waiting for transaction confirmation; when wait is false, returns {"transactionID": "..."} immediately |
merge | symbol, [amount], [wait] | Merges and redeems YES+NO tokens into USDC (gas-free via Relayer). When amount is 0 or not passed, automatically takes the smaller position size of the two outcomes. wait defaults to true, waiting for transaction confirmation |
l2_credentials | None | Gets L2 authentication information, returns {"apiKey":"","secret":"","passphrase":""}, used for scenarios such as WebSocket connections |
batchOrders | array | Batch order placement; the parameter is an array of order objects, each object containing symbol, side, price, amount fields, as well as an optional option field |
Web3 (Blockchain)
| Command | Parameters | Description |
|---|---|---|
abi | contract address, ABI string | Registers a contract ABI |
address | [private key] | Gets the wallet address |
encode / pack | type, data... | ABI-encodes data |
encodePacked | type, data... | ABI tightly-packed encodes data |
hash | param 1-4 | Computes the hash value |
decode / unpack | type, data... | ABI-decodes data |
key | string | Switches the private key used for operations |
IB (Interactive Brokers)
| Command | Parameters | Description |
|---|---|---|
status | None | Gets the connection status |
time | None | Gets the IB server time |
reqId | None | Forces retrieval of a new request ID |
orderId | None | Gets the next available order ID |
ignore | string (array) | Ignores the specified error codes |
scan | string (JSON) | Executes the market scanner |
wait | [number] | Waits for a market data event, with an optional timeout in seconds |
debug | bool | Debug mode |
marketDataType | number | Market data type (1 real-time / 2 frozen / 3 delayed / 4 delayed frozen) |
Futu (Futu Securities)
| Command | Parameters | Description |
|---|---|---|
refresh | bool | Cache refresh; when caching is disabled, the rate limit is a maximum of 10 times per 30 seconds |
accounts | None | Gets the list of all accounts |
status | None | Gets the connection status |
lock | None | Locks trading |
unlock | None | Unlocks trading |
wait | None | Waits for a market data event |
VII. API Rate Limiting Control ("rate" / "quota" modes)
javascript
exchange.IO("rate", functionNames, maxCalls, period, [behavior])
exchange.IO("quota", functionNames, maxCalls, period, [behavior])
- rate: Smooth rate limiting, not strictly aligned to time windows.
- quota: Quota-based rate limiting, strictly aligned to time windows.
| Parameter | Type | Description |
|---|---|---|
| functionNames | string | Function names, separated by commas for multiple; * means all |
| maxCalls | number | Maximum number of calls within a single time period |
| period | string | Time period ("1s"/"1m"/"1h") or reset time point ("@0815") |
| behavior | string | Optional; "delay" means wait when the limit is exceeded, defaults to returning null |
The rate limiting of
Buy/Sellfollows the settings ofCreateOrder;Gofollows the settings of the actual concurrent function;IO/apionly takes effect forexchange.IO("api", ...).