UNPKG

ccxt

Version:

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

957 lines (955 loc) • 150 kB
// ---------------------------------------------------------------------------- // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN: // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code // EDIT THE CORRESPONDENT .ts FILE INSTEAD // --------------------------------------------------------------------------- import { sha256 } from '@noble/hashes/sha2.js'; import Exchange from './abstract/toobit.js'; import { OperationFailed, ArgumentsRequired, ExchangeError, BadRequest, OrderNotFound, BadSymbol, NotSupported, PermissionDenied, RateLimitExceeded, OperationRejected, InvalidOrder, InsufficientFunds } from './base/errors.js'; import { Precise } from './base/Precise.js'; import { TICK_SIZE } from './base/functions/number.js'; // --------------------------------------------------------------------------- /** * @class toobit * @augments Exchange */ export default class toobit extends Exchange { describe() { return this.deepExtend(super.describe(), { 'id': 'toobit', 'name': 'Toobit', 'countries': ['KY'], // Cayman Islands 'version': 'v1', 'rateLimit': 20, // 50 requests per second 'certified': false, 'pro': true, 'has': { 'CORS': undefined, 'spot': true, 'margin': false, 'swap': true, 'future': false, 'option': false, 'borrowCrossMargin': false, 'borrowIsolatedMargin': false, 'borrowMargin': false, 'cancelAllOrders': true, 'cancelOrder': true, 'cancelOrders': true, 'createOrder': true, 'fetchAllGreeks': false, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchBorrowInterest': false, 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, 'fetchBorrowRates': false, 'fetchBorrowRatesPerSymbol': false, 'fetchClosedOrders': true, 'fetchCrossBorrowRate': false, 'fetchCrossBorrowRates': false, 'fetchCurrencies': true, 'fetchDepositAddress': true, 'fetchDeposits': true, 'fetchFundingRateHistory': true, 'fetchFundingRates': true, 'fetchGreeks': false, 'fetchIndexOHLCV': true, 'fetchIsolatedBorrowRate': false, 'fetchIsolatedBorrowRates': false, 'fetchLastPrices': true, 'fetchLedger': true, 'fetchLeverage': true, 'fetchMarkets': true, 'fetchMarkOHLCV': true, 'fetchMyTrades': true, 'fetchOHLCV': true, 'fetchOpenOrders': true, 'fetchOption': false, 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrders': true, 'fetchPositions': true, 'fetchStatus': true, 'fetchTickers': true, 'fetchTime': true, 'fetchTrades': true, 'fetchTradingFees': true, 'fetchVolatilityHistory': false, 'fetchWithdrawals': true, 'repayCrossMargin': false, 'repayIsolatedMargin': false, 'setLeverage': true, 'setMarginMode': true, 'transfer': true, 'withdraw': true, }, 'urls': { 'logo': 'https://github.com/user-attachments/assets/58e1b718-c6fd-49e2-8a49-797da6b9c008', 'api': { 'common': 'https://api.toobit.com', 'private': 'https://api.toobit.com', }, 'www': 'https://www.toobit.com/', 'doc': [ 'https://api-docs.toobit.com/', ], 'referral': { 'url': 'https://www.toobit.com/en-US/r?i=IFFPy0', 'discount': 0.1, }, 'fees': 'https://www.toobit.com/fee', }, 'api': { 'common': { 'get': { 'api/v1/time': 1, 'api/v1/ping': 1, 'api/v1/exchangeInfo': 1, 'quote/v1/depth': 1, // todo: by limit 1-10 'quote/v1/depth/merged': 1, 'quote/v1/trades': 1, 'quote/v1/klines': 1, 'quote/v1/index/klines': 1, 'quote/v1/indexPriceComponents': 1, 'quote/v1/markPrice/klines': 1, 'quote/v1/markPrice': 10, // 5 requests per second 'quote/v1/index': 1, 'quote/v1/ticker/24hr': 40, // todo: 1-40 depending noSymbol 'quote/v1/contract/ticker/24hr': 40, // todo: 1-40 depending noSymbol 'quote/v1/ticker/price': 1, 'quote/v1/contract/ticker/price': 1, 'quote/v1/ticker/bookTicker': 1, 'quote/v1/contract/ticker/bookTicker': 1, 'api/v1/futures/fundingRate': 1, 'api/v1/futures/historyFundingRate': 1, 'api/v1/futures/riskLimits': 1, }, }, 'private': { 'get': { 'api/v1/account': 5, 'api/v1/account/checkApiKey': 1, 'api/v1/spot/order': 1 * 1.67, 'api/v1/spot/openOrders': 1 * 1.67, 'api/v1/futures/openOrders': 1 * 1.67, 'api/v1/spot/tradeOrders': 5 * 1.67, 'api/v1/futures/historyOrders': 5 * 1.67, 'api/v1/account/trades': 5 * 1.67, 'api/v1/account/balanceFlow': 5, 'api/v1/account/depositOrders': 5, 'api/v1/account/withdrawOrders': 5, 'api/v1/account/deposit/address': 1, // contracts 'api/v1/subAccount': 5, 'api/v1/account/subAccount': 5, 'api/v1/subAccount/list': 5, 'api/v1/futures/accountLeverage': 1, 'api/v1/futures/order': 1 * 1.67, 'api/v1/futures/positions': 5 * 1.67, 'api/v1/futures/historyPositions': 5, 'api/v1/futures/balance': 5, 'api/v1/futures/userTrades': 5 * 1.67, 'api/v1/futures/balanceFlow': 5, 'api/v1/futures/commissionRate': 5, 'api/v1/futures/todayPnl': 5, 'api/v1/account/download/detail': 10, 'api/v1/agent/inviteUserList': 1, 'api/v1/agent/commissionDataList': 1, 'api/v1/agent/commissionDataInfo': 1, 'api/v1/agent/inviteRelationCheck': 1, 'api/v1/agent/depositDetailList': 1, 'api/v1/agent/querySubAgentData': 1, 'api/v1/agent/spotOrdersList': 1, 'api/v1/agent/futuresOrdersList': 1, 'api/v1/agent/futuresPositionsList': 1, 'api/v1/agent/invite-commission-detail': 1, 'api/v1/agent/user/export': 1, 'api/v1/agent/export-list': 1, 'api/v1/agent/export-url': 1, }, 'post': { 'api/v1/spot/orderTest': 1 * 1.67, 'api/v1/spot/order': 1 * 1.67, 'api/v1/futures/order': 1 * 1.67, 'api/v1/spot/batchOrders': 2 * 1.67, 'api/v1/subAccount/transfer': 1, 'api/v1/account/withdraw': 1, // contracts 'api/v1/futures/marginType': 1, 'api/v1/futures/leverage': 1, 'api/v1/futures/batchOrders': 2 * 1.67, 'api/v1/futures/position/trading-stop': 3 * 1.67, 'api/v1/futures/positionMargin': 1, 'api/v1/futures/order/update': 2 * 1.67, 'api/v1/futures/autoAddMargin': 1, 'api/v1/futures/flashClose': 1, 'api/v1/futures/reversePosition': 5, 'api/v1/account/download/apply': 1000, 'api/v1/userDataStream': 1, 'api/v1/listenKey': 1, }, 'delete': { 'api/v1/spot/order': 1 * 1.67, 'api/v1/futures/order': 1 * 1.67, 'api/v1/spot/openOrders': 5 * 1.67, 'api/v1/futures/batchOrders': 3 * 1.67, 'api/v1/spot/cancelOrderByIds': 5 * 1.67, 'api/v1/futures/cancelOrderByIds': 3 * 1.67, 'api/v1/userDataStream': 1, 'api/v1/listenKey': 1, }, 'put': { 'api/v1/userDataStream': 1, 'api/v1/listenKey': 1, }, }, }, 'timeframes': { '1m': '1m', '3m': '3m', '5m': '5m', '15m': '15m', '30m': '30m', '1h': '1h', '2h': '2h', '4h': '4h', '6h': '6h', '8h': '8h', '12h': '12h', '1d': '1d', '1w': '1w', '1M': '1M', }, 'precisionMode': TICK_SIZE, 'exceptions': { 'exact': { '-1000': OperationFailed, // An unknown error occurred while processing the request. '-1001': OperationFailed, // Internal error; unable to process your request. Please try again. '-1002': PermissionDenied, // You are not authorized to execute this request. '-1003': RateLimitExceeded, // Too many requests queued. '-1004': BadRequest, // {"code":-1004,"msg":"Missing required parameter \u0027xyz\u0027"} | {"code":-1004,"msg":"Bad request"} '-1005': PermissionDenied, // No Permission '-1006': OperationFailed, // An unexpected response was received from the message bus. Execution status unknown. '-1007': OperationFailed, // Timeout waiting for response from backend server. Send status unknown; execution status unknown. '-1014': OperationFailed, // Unsupported order combination. '-1015': RateLimitExceeded, // Reach the rate limit .Please slow down your request speed. '-1016': OperationRejected, // This service is no longer available. '-1020': OperationRejected, // This operation is not supported. '-1021': OperationRejected, // Timestamp for this request is outside of the recvWindow. '-1022': OperationRejected, // Signature for this request is not valid. '-1023': PermissionDenied, // Please set IP whitelist before using API '-1031': OperationRejected, // The feature has been suspended '-1100': BadRequest, // Illegal characters found in a parameter. '-1101': BadRequest, // Too many parameters sent for this endpoint. '-1102': BadRequest, // A mandatory parameter was not sent, was empty/null, or malformed. '-1103': BadRequest, // An unknown parameter was sent. '-1104': BadRequest, // Not all sent parameters were read. '-1105': BadRequest, // A parameter was empty. '-1106': BadRequest, // A parameter was sent when not required. '-1107': PermissionDenied, // The accessKey is missing from the request header or parameters, or the accessKey is not in the correct format. '-1111': BadRequest, // Precision is over the maximum defined for this asset. '-1112': OperationRejected, // No orders on book for symbol. '-1114': BadRequest, // TimeInForce parameter sent when not required. '-1115': BadRequest, // Invalid timeInForce. '-1116': BadRequest, // Invalid orderType. '-1117': BadRequest, // Invalid side. '-1118': InvalidOrder, // New client order ID was empty. '-1119': InvalidOrder, // Original client order ID was empty. '-1120': BadRequest, // Invalid interval. '-1121': BadSymbol, // Invalid symbol. '-1125': OperationRejected, // This listenKey does not exist. '-1127': OperationRejected, // Lookup interval is too big. '-1128': BadRequest, // Combination of optional parameters invalid. '-1129': BadRequest, // The time range cannot exceed one year. '-1130': BadRequest, // Invalid data sent for a parameter. '-1131': InsufficientFunds, // Balance insufficient '-1132': OperationRejected, // Order price too high. '-1133': OperationRejected, // Order price lower than the minimum,please check general broker info. '-1134': OperationRejected, // Order price decimal too long,please check general broker info. '-1135': OperationRejected, // Order quantity too large. '-1136': OperationRejected, // Order quantity lower than the minimum. '-1137': OperationRejected, // Order quantity decimal too long. '-1138': OperationRejected, // Order price exceeds permissible range. '-1139': OperationRejected, // Order has been filled. '-1140': OperationRejected, // Transaction amount lower than the minimum. '-1141': InvalidOrder, // Duplicate clientOrderId '-1142': InvalidOrder, // Order has been canceled '-1143': OrderNotFound, // Cannot be found on order book '-1144': OperationRejected, // Order has been locked '-1145': OperationRejected, // This order type does not support cancellation '-1146': OperationFailed, // Order creation timeout '-1147': OperationFailed, // Order cancellation timeout '-1148': InvalidOrder, // Market order amount decimal too long '-1149': OperationFailed, // Create order failed '-1150': OperationFailed, // Cancel order failed '-1151': OperationRejected, // The trading pair is not open yet '-1153': PermissionDenied, // User not exist '-1156': InvalidOrder, // Order quantity invalid '-1157': OperationRejected, // The trading pair is not available for api trading '-1158': InvalidOrder, // create limit maker order failed '-1161': OperationRejected, // Reduce margin forbidden '-1164': OperationRejected, // Auto add margin error '-1165': BadRequest, // Invalid stopType. '-1166': BadRequest, // Invalid callbackType. '-1170': OperationRejected, // finance account exist. '-1171': ExchangeError, // account not exist. '-1172': OperationFailed, // Balance transfer failed. '-1181': PermissionDenied, // Currently not allowed to withdraw. '-1182': PermissionDenied, // Currently not allowed to deposit. '-1193': OperationRejected, // Create order count limit '-1194': OperationRejected, // Create market order forbidden '-1195': OperationRejected, // Create limit order price too small '-1196': OperationRejected, // Create limit order price too big '-1197': OperationRejected, // Create limit order buy price too big '-1198': OperationRejected, // Create limit order sell price too small '-1199': OperationRejected, // Create order buy quantity too small '-1200': OperationRejected, // Create order buy quantity too big '-1201': OperationRejected, // Create limit order sell price too big '-1202': OperationRejected, // Create order sell quantity too small '-1203': OperationRejected, // Create order sell quantity too big '-1204': PermissionDenied, // account not authorized '-1205': BadRequest, // same account not transfer '-1206': OperationRejected, // Orders over the maximum transaction amount '-1207': InvalidOrder, // planOrder count limit. '-1208': InvalidOrder, // stopProfitLoss order count limit. '-1209': InvalidOrder, // stopProfitLoss order position limit. '-1210': InvalidOrder, // dynamic stop profit long fallQuantity high. '-1211': InvalidOrder, // dynamic stop profit activePrice low. '-1212': InvalidOrder, // dynamic stop profit activePrice high. '-1213': BadSymbol, // Account symbol does not match '-1214': PermissionDenied, // No opening trades '-1215': PermissionDenied, // No closing trades '-1216': OperationRejected, // Trigger transfer limit failed '-1217': InvalidOrder, // Create stop order buy price too big '-1300': BadRequest, // Duplicate transferId '-1400': BadRequest, // API voucher type is not allowed. '-1401': PermissionDenied, // You are not eligible to use API trial voucher. '-1402': OperationFailed, // API voucher query failed. '-1403': OperationFailed, // API voucher receive failed. '-1404': ExchangeError, // API voucher agent config failed. '-1405': ExchangeError, // API voucher not found. '-1406': OperationRejected, // API voucher is already in use. '-1407': OperationRejected, // API voucher threshold is not met. '-1408': InsufficientFunds, // Contract asset is less than zero. '-1409': OperationRejected, // API voucher status is invalid. '-1410': InsufficientFunds, // API voucher system account balance is insufficient. '-1411': OperationRejected, // API voucher transfer is processing. '-1412': OperationRejected, // API voucher can not be merged. '-1413': BadRequest, // API voucher trade rate does not match. '-1414': BadRequest, // API voucher fee rule does not match. '-1415': BadRequest, // API voucher token does not match. '-1416': InsufficientFunds, // Some API vouchers can not be received due to insufficient system balance. '-1417': OperationRejected, // Some API vouchers do not meet the receiving threshold. '-2010': OperationFailed, // NEW_ORDER_REJECTED '-2011': OperationFailed, // CANCEL_REJECTED '-2013': OrderNotFound, // Order does not exist. '-2014': PermissionDenied, // API-key format invalid. '-2015': PermissionDenied, // Invalid API-key, IP, or permissions for action. '-2016': BadRequest, // No trading window could be found for the symbol. Try ticker/24hrs instead. '-2017': PermissionDenied, // The API key has expired. Please update your API key immediately. '-2018': PermissionDenied, // API triggered risk control restrictions have been suspended, if you have any questions, please contact support@toobit.com . // errors above 3xxx are from swap API '-3000': BadRequest, // Option not exist. '-3001': OperationRejected, // The option has expired. '-3002': InvalidOrder, // Order failed: position exceeded limit '-3050': ExchangeError, // The ApiKey corresponding to the account already exists '-3051': OperationRejected, // The sub-user has assets are not allowed to be deleted '-3052': BadRequest, // sub-user id error '-3101': OperationRejected, // Open margin account error '-3102': OperationRejected, // Get margin safety error '-3103': BadRequest, // Risk config is not exit '-3105': OperationRejected, // Token can not borrow '-3107': OperationRejected, // Token can not withdraw '-3108': OperationRejected, // Get token avail withdraw error '-3109': OperationRejected, // Margin withdraw failed '-3110': InsufficientFunds, // Margin avail withdraw not enough failed '-3116': OperationRejected, // Repay fail '-3117': OperationRejected, // Get margin all position fail '-3120': OperationRejected, // Get repay order fail '-3124': OperationRejected, // Position and order data error '-3125': OperationRejected, // Position size cannot meet target leverage '-3126': OperationRejected, // Adjust leverage fail '-3127': OperationFailed, // Adjust leverage timeout '-3128': OperationRejected, // The margin mode cannot be changed while you have an open order/position '-3129': BadRequest, // Cone futures change position type error '-3130': OperationRejected, // Order margin insufficient '-3131': NotSupported, // Leverage reduction is not supported in Isolated Margin Mode with open positions. '-3132': InvalidOrder, // Maximum allowed leverage reached, please lower your leverage. '-3133': InvalidOrder, // The number of open orders exceeds the limit. '-3136': OperationRejected, // Quick symbol activity only limit/buy/ioc order is supported '-3137': OperationRejected, // Open countdown is not over '-3138': OperationRejected, // Open activity pre_hold is handling '-3139': OperationRejected, // Open activity max amount limit '-3140': OperationRejected, // Open activity min amount limit '-3141': InvalidOrder, // Invalid long stop profit price. '-3142': InvalidOrder, // Invalid long stop loss price. '-3143': InvalidOrder, // Invalid short stop profit price. '-3144': InvalidOrder, // Invalid short stop loss price. '-3145': InvalidOrder, // No position, Please confirm your position direction. '-3147': OperationRejected, // previous transfer is being processed. please try again later. '-3148': InvalidOrder, // create order exceeds max futures risk limit. '-3149': InvalidOrder, // The reduction in margin is unlawful. '-3150': NotSupported, // cross position margin adjustments are not supported. '-3151': NotSupported, // Separate position mode is not supported. '-3152': BadRequest, // Separate-position mismatch: position mode must be SEPARATE. '-3153': BadRequest, // Whole-position mismatch: position mode must be WHOLE. '-32045': ExchangeError, // Copy trading follower not found. '-32090': OperationRejected, // Trading pair change is not allowed. '-32093': OperationRejected, // Copy trading position type cannot be changed. '-120041': PermissionDenied, // Copy trading leader is not available. '-120047': ExchangeError, // Leader does not exist. '-120055': OperationRejected, // The follower currently has copy position, cannot be removed. '-120067': ExchangeError, // Copy trading level config not found. '-120072': BadRequest, // Copy trading leader config is invalid. '-120073': OperationRejected, // Unable to switch invite setting. '-120078': BadRequest, // unLeadStartTime or unLeadEndTime is invalid. '-120510': BadRequest, // Invite code already exists. '-120511': BadRequest, // Invite code contains sensitive content. '-120512': BadRequest, // Invite code is invalid. }, 'broad': { 'Unknown order sent': OrderNotFound, 'Duplicate order sent': InvalidOrder, 'Market is closed': OperationRejected, 'Account has insufficient balance for requested action': InsufficientFunds, 'Market orders are not supported for this symbol': OperationRejected, 'Iceberg orders are not supported for this symbol': OperationRejected, 'Stop loss orders are not supported for this symbol': OperationRejected, 'Stop loss limit orders are not supported for this symbol': OperationRejected, 'Take profit orders are not supported for this symbol': OperationRejected, 'Take profit limit orders are not supported for this symbol': OperationRejected, 'QTY is zero or less': BadRequest, 'IcebergQty exceeds QTY': OperationRejected, 'This action disabled is on this account': PermissionDenied, 'Unsupported order combination': BadRequest, 'Order would trigger immediately': OperationRejected, 'Cancel order is invalid. Check origClOrdId and orderId': OperationRejected, 'Order would immediately match and take': OperationRejected, }, }, 'commonCurrencies': {}, 'options': { 'defaultType': 'spot', 'accountsByType': { 'spot': 'MAIN', 'swap': 'FUTURES', }, 'networks': { 'BTC': 'BTC', 'ERC20': 'ETH', 'ETH': 'ETH', 'BEP20': 'BSC', 'TRC20': 'TRX', 'SOL': 'SOL', 'MATIC': 'MATIC', 'ARBONE': 'ARBITRUM', 'BASE': 'BASE', 'TON': 'TON', 'AVAXC': 'AVAXC', 'DOGE': 'DOGE', 'XRP': 'XRP', 'DOT': 'DOT', 'ADA': 'ADA', 'LTC': 'LTC', 'APT': 'APT', 'ATOM': 'ATOM', 'ALGO': 'ALGO', 'NEAR': 'NEAR', 'XLM': 'XLM', 'SUI': 'SUI', 'ETC': 'ETC', 'EOS': 'EOS', 'WAVES': 'WAVES', 'ICP': 'ICP', 'ONE': 'ONE', // 'CHZ2': 'CHZ2', }, 'networksById': { 'ETH': 'ERC20', 'ERC20': 'ERC20', }, }, 'features': { 'spot': { 'sandbox': false, 'createOrder': { 'marginMode': false, 'triggerPrice': true, 'triggerPriceType': undefined, 'triggerDirection': false, 'stopLossPrice': false, 'takeProfitPrice': false, 'attachedStopLossTakeProfit': undefined, 'timeInForce': { 'IOC': true, 'FOK': true, 'PO': true, 'GTD': false, }, 'hedged': false, 'trailing': false, 'leverage': false, 'marketBuyRequiresPrice': false, 'marketBuyByCost': false, 'selfTradePrevention': false, 'iceberg': false, }, 'createOrders': undefined, 'fetchOHLCV': { 'limit': 1000, }, 'fetchMyTrades': { 'marginMode': false, 'limit': 1000, 'daysBack': 100000, 'untilDays': 100000, 'symbolRequired': true, }, 'fetchOrder': { 'marginMode': false, 'trigger': false, 'trailing': false, 'symbolRequired': false, }, 'fetchOpenOrders': { 'marginMode': false, 'limit': 1000, 'trigger': false, 'trailing': false, 'symbolRequired': false, }, 'fetchOrders': { 'marginMode': false, 'limit': 500, 'daysBack': 100000, 'untilDays': 100000, 'trigger': false, 'trailing': false, 'symbolRequired': false, }, 'fetchClosedOrders': undefined, }, 'forDerivatives': { 'createOrders': undefined, }, 'swap': { 'linear': undefined, 'inverse': undefined, }, 'future': { 'linear': undefined, 'inverse': undefined, }, }, }); } /** * @method * @name toobit#fetchStatus * @description the latest known information on the availability of the exchange API * @see https://toobit-docs.github.io/apidocs/spot/v1/en/#test-connectivity * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure} */ async fetchStatus(params = {}) { const response = await this.commonGetApiV1Ping(params); return { 'status': 'ok', 'updated': undefined, 'eta': undefined, 'url': undefined, 'info': response, }; } /** * @method * @name toobit#fetchTime * @description fetches the current integer timestamp in milliseconds from the exchange server * @see https://api-docs.toobit.com/api/spot-market-data.html#check-server-time * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the exchange server */ async fetchTime(params = {}) { const response = await this.commonGetApiV1Time(params); // // { // "serverTime": 1699827319559 // } // return this.safeInteger(response, 'serverTime'); } /** * @method * @name toobit#fetchCurrencies * @description fetches all available currencies on an exchange * @see https://api-docs.toobit.com/api/spot-market-data.html#exchange-information * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object} an associative dictionary of currencies */ async fetchCurrencies(params = {}) { const response = await this.commonGetApiV1ExchangeInfo(params); this.options['exchangeInfo'] = response; // we store it in options for later use in fetchMarkets // // { // "timezone": "UTC", // "serverTime": "1755583099926", // "brokerFilters": [], // "symbols": [ // { // "filters": [ // { // "minPrice": "0.01", // "maxPrice": "10000000.00000000", // "tickSize": "0.01", // "filterType": "PRICE_FILTER" // }, // { // "minQty": "0.0001", // "maxQty": "4000", // "stepSize": "0.0001", // "filterType": "LOT_SIZE" // }, // { // "minNotional": "5", // "filterType": "MIN_NOTIONAL" // }, // { // "minAmount": "5", // "maxAmount": "6600000", // "minBuyPrice": "0.01", // "filterType": "TRADE_AMOUNT" // }, // { // "maxSellPrice": "99999999", // "buyPriceUpRate": "0.1", // "sellPriceDownRate": "0.1", // "filterType": "LIMIT_TRADING" // }, // { // "buyPriceUpRate": "0.1", // "sellPriceDownRate": "0.1", // "filterType": "MARKET_TRADING" // }, // { // "noAllowMarketStartTime": "0", // "noAllowMarketEndTime": "0", // "limitOrderStartTime": "0", // "limitOrderEndTime": "0", // "limitMinPrice": "0", // "limitMaxPrice": "0", // "filterType": "OPEN_QUOTE" // } // ], // "exchangeId": "301", // "symbol": "ETHUSDT", // "symbolName": "ETHUSDT", // "status": "TRADING", // "baseAsset": "ETH", // "baseAssetName": "ETH", // "baseAssetPrecision": "0.0001", // "quoteAsset": "USDT", // "quoteAssetName": "USDT", // "quotePrecision": "0.01", // "icebergAllowed": false, // "isAggregate": false, // "allowMargin": true, // } // ], // "options": [], // "contracts": [ // { // "filters": [ ... ], // "exchangeId": "301", // "symbol": "BTC-SWAP-USDT", // "symbolName": "BTC-SWAP-USDTUSDT", // "status": "TRADING", // "baseAsset": "BTC-SWAP-USDT", // "baseAssetPrecision": "0.001", // "quoteAsset": "USDT", // "quoteAssetPrecision": "0.1", // "icebergAllowed": false, // "inverse": false, // "index": "BTC", // "indexToken": "BTCUSDT", // "marginToken": "USDT", // "marginPrecision": "0.0001", // "contractMultiplier": "0.001", // "underlying": "BTC", // "riskLimits": [ // { // "riskLimitId": "200020911", // "quantity": "42000.0", // "initialMargin": "0.02", // "maintMargin": "0.01", // "isWhite": false // }, // { // "riskLimitId": "200020912", // "quantity": "84000.0", // "initialMargin": "0.04", // "maintMargin": "0.02", // "isWhite": false // }, // ... // ] // }, // ], // "coins": [ // { // "orgId": "9001", // "coinId": "TCOM", // "coinName": "TCOM", // "coinFullName": "TCOM", // "allowWithdraw": true, // "allowDeposit": true, // "chainTypes": [ // { // "chainType": "BSC", // "withdrawFee": "49.55478", // "minWithdrawQuantity": "77", // "maxWithdrawQuantity": "0", // "minDepositQuantity": "48", // "allowDeposit": true, // "allowWithdraw": false // } // ], // "isVirtual": false // }, // ... // const coins = this.safeList(response, 'coins', []); const result = {}; for (let i = 0; i < coins.length; i++) { const coin = coins[i]; const parsed = this.parseCurrency(coin); if (parsed !== undefined) { const code = parsed['code']; result[code] = parsed; } } return result; } parseCurrency(rawCurrency) { const id = this.safeString(rawCurrency, 'coinId'); const code = this.safeCurrencyCode(id); const networks = {}; const rawNetworks = this.safeList(rawCurrency, 'chainTypes', []); for (let j = 0; j < rawNetworks.length; j++) { const rawNetwork = rawNetworks[j]; const networkId = this.safeString(rawNetwork, 'chainType'); const networkCode = this.networkIdToCode(networkId, code); if (networkCode !== undefined) { networks[networkCode] = { 'id': networkId, 'network': networkCode, 'margin': undefined, 'deposit': this.safeBool(rawNetwork, 'allowDeposit'), 'withdraw': this.safeBool(rawNetwork, 'allowWithdraw'), 'active': undefined, 'fee': this.safeNumber(rawNetwork, 'withdrawFee'), 'precision': undefined, 'limits': { 'deposit': { 'min': this.safeNumber(rawNetwork, 'minDepositQuantity'), 'max': undefined, }, 'withdraw': { 'min': this.safeNumber(rawNetwork, 'minWithdrawQuantity'), 'max': this.safeNumber(rawNetwork, 'maxWithdrawQuantity'), }, }, 'info': rawNetwork, }; } } return this.safeCurrencyStructure({ 'id': id, 'code': code, 'name': this.safeString(rawCurrency, 'coinFullName'), 'type': undefined, 'active': undefined, 'deposit': this.safeBool(rawCurrency, 'allowDeposit'), 'withdraw': this.safeBool(rawCurrency, 'allowWithdraw'), 'fee': undefined, 'precision': undefined, 'limits': { 'amount': { 'min': undefined, 'max': undefined, }, 'withdraw': { 'min': undefined, 'max': undefined, }, }, 'networks': networks, 'info': rawCurrency, }); } /** * @method * @name toobit#fetchMarkets * @description retrieves data on all markets for toobit * @see https://api-docs.toobit.com/api/spot-market-data.html#exchange-information * @see https://api-docs.toobit.com/api/usdt-m-market-data.html#exchange-information * @param {object} [params] extra parameters specific to the exchange API endpoint * @returns {object[]} an array of objects representing market data */ async fetchMarkets(params = {}) { let response = this.safeDict(this.options, 'exchangeInfo'); if (response !== undefined) { this.options['exchangeInfo'] = undefined; // reset it to avoid using old cached data } else { response = await this.commonGetApiV1ExchangeInfo(params); } // // { // "timezone": "UTC", // "serverTime": "1755583099926", // "brokerFilters": [], // "symbols": [ // { // "filters": [ // { // "minPrice": "0.01", // "maxPrice": "10000000.00000000", // "tickSize": "0.01", // "filterType": "PRICE_FILTER" // }, // { // "minQty": "0.0001", // "maxQty": "4000", // "stepSize": "0.0001", // "filterType": "LOT_SIZE" // }, // { // "minNotional": "5", // "filterType": "MIN_NOTIONAL" // }, // { // "minAmount": "5", // "maxAmount": "6600000", // "minBuyPrice": "0.01", // "filterType": "TRADE_AMOUNT" // }, // { // "maxSellPrice": "99999999", // "buyPriceUpRate": "0.1", // "sellPriceDownRate": "0.1", // "filterType": "LIMIT_TRADING" // }, // { // "buyPriceUpRate": "0.1", // "sellPriceDownRate": "0.1", // "filterType": "MARKET_TRADING" // }, // { // "noAllowMarketStartTime": "0", // "noAllowMarketEndTime": "0", // "limitOrderStartTime": "0", // "limitOrderEndTime": "0", // "limitMinPrice": "0", // "limitMaxPrice": "0", // "filterType": "OPEN_QUOTE" // } // ], // "exchangeId": "301", // "symbol": "ETHUSDT", // "symbolName": "ETHUSDT", // "status": "TRADING", // "baseAsset": "ETH", // "baseAssetName": "ETH", // "baseAssetPrecision": "0.0001", // "quoteAsset": "USDT", // "quoteAssetName": "USDT", // "quotePrecision": "0.01", // "icebergAllowed": false, // "isAggregate": false, // "allowMargin": true, // } // ], // "options": [], // "contracts": [ // { // "filters": [ ... ], // "exchangeId": "301", // "symbol": "BTC-SWAP-USDT", // "symbolName": "BTC-SWAP-USDTUSDT", // "status": "TRADING", // "baseAsset": "BTC-SWAP-USDT", // "baseAssetPrecision": "0.001", // "quoteAsset": "USDT", // "quoteAssetPrecision": "0.1", // "icebergAllowed": false, // "inverse": false, // "index": "BTC", // "indexToken": "BTCUSDT", // "marginToken": "USDT", // "marginPrecision": "0.0001", // "contractMultiplier": "0.001", // "underlying": "BTC", // "riskLimits": [ // { // "riskLimitId": "200020911", // "quantity": "42000.0", // "initialMargin": "0.02", // "maintMargin": "0.01", // "isWhite": false // }, // { // "riskLimitId": "200020912", // "quantity": "84000.0", // "initialMargin": "0.04", // "maintMargin": "0.02", // "isWhite": false // }, // ... // ] // }, // ], // "coins": [ // { // "orgId": "9001", // "coinId": "TCOM", // "coinName": "TCOM", // "coinFullName": "TCOM", // "allowWithdraw": true, // "allowDeposit": true, // "chainTypes": [ // { // "chainType": "BSC", // "withdrawFee": "49.55478", // "minWithdrawQuantity": "77", // "maxWithdrawQuantity": "0", // "minDepositQuantity": "48", // "allowDeposit": true, // "allowWithdraw": false // } // ], // "isVirtual": false // }, // ... // const symbols = this.safeList(response, 'symbols', []); const contracts = this.safeList(response, 'contracts', []); const all = this.arrayConcat(symbols, contracts); const result = []; for (let i = 0; i < all.length; i++) { const market = all[i]; const parsed = this.parseMarket(market); if (parsed !== undefined) { result.push(parsed); } } return result; } parseMarket(market) { const id = this.safeString(market, 'symbol'); const baseId = this.safeString(market, 'baseAsset', ''); const quoteId = this.safeString(market, 'quoteAsset'); const baseParts = baseId.split('-'); const baseIdClean = basePar