Crypto.com
Crypto (Spot): Crypto.com Exchange spot trading (Exchange v1 API https://api.crypto.com/exchange/v1), accessed with an API Key and Secret Key, including spot margin orders (exchange.IO("trade_margin")). Balances come from the Crypto.com unified account; Crypto.com derivatives are a separate exchange object, Futures_Crypto.
Futures_Crypto (Futures): Crypto.com Exchange derivatives: perpetual and delivery contracts (Exchange v1 API https://api.crypto.com/exchange/v1), accessed with an API Key and Secret Key. Tokens in the account can be converted into a USD-denominated amount used as futures margin; position queries and the leverage setting apply to the master account, and exchange.IO("accountId", ...) selects another account. Crypto.com spot is a separate exchange object, Crypto.
Names and Configuration
exchange.GetName() | Type | Aliases |
|---|---|---|
Crypto | Spot | — |
Futures_Crypto | Futures | Crypto.com Futures |
| Field | Required | |
| - | - | |
| Access Key | Yes | |
| Secret Key | Yes |
Trading Pairs and Contract Codes
Crypto (Spot)
Pair examples: BTC_USDT, CRO_USD
Trading pairs are written BASE_QUOTE, the same as Crypto.com's instrument names.
Futures_Crypto (Futures)
Pair examples: BTC_USD, ETH_USD
Trading pairs look like BTC_USD, matching Crypto.com's BTCUSD-PERP (perpetual) and BTCUSD-YYMMDD (delivery).
| Contract code | Description |
|---|---|
swap | Perpetual contract. |
January | The delivery contract expiring in January. |
February | The delivery contract expiring in February. |
March | The delivery contract expiring in March. |
April | The delivery contract expiring in April. |
May | The delivery contract expiring in May. |
June | The delivery contract expiring in June. |
July | The delivery contract expiring in July. |
August | The delivery contract expiring in August. |
September | The delivery contract expiring in September. |
October | The delivery contract expiring in October. |
November | The delivery contract expiring in November. |
December | The delivery contract expiring in December. |
this_week | The nearest-expiring delivery contract. |
next_week | The second-nearest-expiring delivery contract. |
quarter | The nearest delivery contract expiring in March, June, September or December. |
next_quarter | The second-nearest delivery contract expiring in March, June, September or December. |
Delivery contracts use the English name of the expiry month as the contract code, for example trading pair BTC_USD with contract code October, meaning the latest-expiring delivery contract (the monthly contract) in the nearest such month. Other delivery contracts in the same month (weekly contracts, for example) use the native contract code as the contract code, such as BTC_USD.BTCUSD-261009. Delivery contracts in exchange.GetMarkets follow the same naming and each contract appears once.
Native contract code examples: BTCUSD-261030
Crypto.com delivery contract codes in the form BTCUSD-YYMMDD can also be used directly.
Exchange-specific IO Commands
Crypto (Spot)
| Command | Arguments | Description | Returns |
|---|---|---|---|
api | httpMethod, method[, params[, raw]] | Call a Crypto.com endpoint directly; the resource is the RPC method name, such as private/user-balance or public/get-tickers (a path starting with /exchange/v1/ or a full URL also works). (more below the table) | The complete exchange response (code is 0); null on a business error. |
trade_margin | — | Switch to spot margin; subsequent regular orders are placed with spot_margin=MARGIN, and conditional orders with MARGIN_ORDER in exec_inst. Affects order placement only; no request is sent to the exchange. | The command name itself. |
trade_normal | — | Switch back to regular spot orders (the default). | The command name itself. |
The rest of the longer descriptions in the table:
api: Requests are signed by default and sent as a JSON-RPC body, with theparamsobject keeping its JSON types (nested objects and arrays are sent as they are); arawJSON object string replacesparamsentirely. With the sign argument set tofalsethe request is unsigned, andGETparameters go into the query string.
For the common commands base and currency see exchange.IO.
Futures_Crypto (Futures)
| Command | Arguments | Description | Returns |
|---|---|---|---|
api | httpMethod, method[, params[, raw]] | Call a Crypto.com endpoint directly; the resource is the RPC method name, such as private/get-positions or public/get-tickers (a path starting with /exchange/v1/ or a full URL also works). (more below the table) | The complete exchange response (code is 0); null on a business error. |
accountId | string | Set the trading account ID (account uuid) used for querying positions and setting leverage; the master account is used when not set. | An object such as {"accountId": "..."}. |
The rest of the longer descriptions in the table:
api: Requests are signed by default and sent as a JSON-RPC body, with theparamsobject keeping its JSON types (nested objects and arrays are sent as they are); arawJSON object string replacesparamsentirely. With the sign argument set tofalsethe request is unsigned, andGETparameters go into the query string.
For the common commands base and currency see exchange.IO.
Common Usage
Call the API by JSON-RPC method name
javascript
function main() {
// Private method: signed by default, sent as a JSON-RPC request body;
// the whole reply (code 0) is returned
var r = exchange.IO("api", "POST", "private/user-balance")
Log(r.result.data[0].position_balances)
// Public method: false as the last argument skips signing; GET params go in the query
var t = exchange.IO("api", "GET", "public/get-tickers", "instrument_name=BTC_USDT", false)
Log(t.result.data[0]) // {"i": "BTC_USDT", "a": "...", "b": "...", "k": "...", ...}
}
Look up the account uuids and choose the account for positions and leverage (Futures_Crypto only)
javascript
function main() {
var r = exchange.IO("api", "POST", "private/get-accounts")
var uuid = r.result.master_account.uuid
Log("Master account:", uuid, "Sub-accounts:", r.result.sub_account_list)
// Positions and leverage now use this account (the master account when not set)
Log(exchange.IO("accountId", uuid)) // {"accountId": "..."}
Log(exchange.GetPositions())
}
Function Support
No unsupported standard functions.
Served through a fallback:
exchange.GetRecords: Native periods are 1m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 12h, 1d, 1w, 14d, 1M; other periods are synthesized by the docker.
Margin, Account and Simulation
Futures_Crypto (Futures)
Margin mode: Cross margin on the unified account with no isolated mode; the margin mode in exchange.GetPositions() is always cross; exchange.IO("cross", ...) fails.
Position mode: One-way positions: each contract has a single net position, with Crypto.com expressing long and short by the sign of the quantity; exchange.IO("dual", ...) fails.
Account: exchange.SetMarginLevel() sets the leverage of the whole trading account (Crypto.com's account-level leverage); it must be an integer from 1 to 100.
Notes
Crypto (Spot)
- The amount of a market buy order is in the base currency (Crypto.com's
quantity), not a quote-currency amount; a conditional buy order that becomes a market order when triggered is also placed in the base currency. - Conditional orders support take-profit and stop-loss only, not OCO; they trigger on the last traded price. Conditional orders are placed, modified, canceled and queried through Crypto.com's Advanced Order Management API.
- Limit orders support
tifIOC, FOK and maker-only (postOnly); maker-only cannot be combined with IOC or FOK, and passingtiforpostOnlyon a market order reports an error. Conditional orders with an order price (a limit order once triggered) supporttifandpostOnlytoo; conditional orders that execute at market once triggered report an error when given them. exchange.ModifyOrder()andexchange.ModifyConditionOrder()are supported (Crypto.com amends the order in place, keeping its order ID); conditional orders can change the trigger price, order price and amount, and an order price of -1 turns a conditional limit order into one that executes at market when triggered (a positive price does the reverse).tifandpostOnlycannot be changed (passing them reports an error).exchange.GetOrders()andexchange.GetConditionOrders()without arguments return the open orders of all trading pairs.exchange.GetHistoryOrders()andexchange.GetHistoryConditionOrders()return the latest 100 records whenlimitis not given, and page automatically to fill a largerlimit. Withoutsince, Crypto.com returns only the last day of conditional order history; passsinceto query earlier records.- The frozen amount in
exchange.GetAssets()is Crypto.com'sreserved_qty(open orders plus margin in use), and the available amount is the holding minus it.
Futures_Crypto (Futures)
exchange.GetFundingscannot query in batch: without arguments or with a range (such asUSD.swap) it reports an error and returns a null value; pass a specific perpetual symbol such asBTC_USD.swap.- Funding settles every hour; the rate is Crypto.com's
funding_ratevaluation. - The order amount is sent as Crypto.com's
quantitydirectly; seeCtValinexchange.GetMarketsfor the contract size (CtValCcy, the size currency, is the underlying coin). - Conditional orders support take-profit and stop-loss only, not OCO; they trigger on the mark price.
- Limit orders support
tifIOC, FOK and maker-only (postOnly); maker-only cannot be combined with IOC or FOK, and passingtiforpostOnlyon a market order reports an error. Conditional orders with an order price (a limit order once triggered) supporttifandpostOnlytoo; conditional orders that execute at market once triggered report an error when given them. Both regular and conditional orders support reduce-only (reduceOnly). exchange.ModifyOrder()andexchange.ModifyConditionOrder()are supported (Crypto.com amends the order in place); conditional orders can change the trigger price, order price and amount, and an order price of -1 turns a conditional limit order into one that executes at market when triggered (a positive price does the reverse).tifandpostOnlycannot be changed (passing them reports an error).- Without
since,exchange.GetHistoryConditionOrders()returns only the last day of conditional order history from Crypto.com; passsinceto query earlier records.