UNPKG

ccxt

Version:

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

923 lines (919 loc) • 239 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var sha2_js = require('@noble/hashes/sha2.js'); var xt$1 = require('./abstract/xt.js'); var Precise = require('./base/Precise.js'); var number = require('./base/functions/number.js'); var errors = require('./base/errors.js'); // ---------------------------------------------------------------------------- // --------------------------------------------------------------------------- /** * @class xt * @augments Exchange */ class xt extends xt$1["default"] { describe() { return this.deepExtend(super.describe(), { 'id': 'xt', 'name': 'XT', 'countries': ['SC'], // Seychelles // spot api ratelimits are undefined, 10/s/ip, 50/s/ip, 100/s/ip or 200/s/ip // futures 3 requests per second => 1000ms / (100 * 3.33) = 3.003 (get assets -> fetchMarkets & fetchCurrencies) // futures 10 requests per second => 1000ms / (100 * 1) = 10 (all other) // futures 1000 times per minute for each single IP -> Otherwise account locked for 10min 'rateLimit': 100, 'version': 'v4', 'certified': false, 'pro': true, 'has': { 'CORS': false, 'spot': true, 'margin': true, 'swap': true, 'future': true, 'option': false, 'addMargin': true, 'borrowMargin': false, 'cancelAllOrders': true, 'cancelOrder': true, 'cancelOrders': true, 'createDepositAddress': false, 'createMarketBuyOrderWithCost': true, 'createMarketSellOrderWithCost': false, 'createOrder': true, 'createPostOnlyOrder': false, 'createReduceOnlyOrder': true, 'editOrder': true, 'fetchAccounts': false, 'fetchAllGreeks': false, 'fetchBalance': true, 'fetchBidsAsks': true, 'fetchBorrowInterest': false, 'fetchBorrowRate': false, 'fetchBorrowRateHistories': false, 'fetchBorrowRateHistory': false, 'fetchBorrowRatesPerSymbol': false, 'fetchCanceledOrders': true, 'fetchClosedOrders': true, 'fetchCurrencies': true, 'fetchDeposit': false, 'fetchDepositAddress': true, 'fetchDepositAddresses': false, 'fetchDepositAddressesByNetwork': false, 'fetchDeposits': true, 'fetchDepositWithdrawals': false, 'fetchDepositWithdrawFee': false, 'fetchDepositWithdrawFees': false, 'fetchFundingHistory': true, 'fetchFundingInterval': true, 'fetchFundingIntervals': false, 'fetchFundingRate': true, 'fetchFundingRateHistory': true, 'fetchFundingRates': false, 'fetchGreeks': false, 'fetchIndexOHLCV': false, 'fetchL3OrderBook': false, 'fetchLedger': true, 'fetchLedgerEntry': false, 'fetchLeverage': false, 'fetchLeverageTiers': true, 'fetchMarketLeverageTiers': true, 'fetchMarkets': true, 'fetchMarkOHLCV': false, 'fetchMyTrades': true, 'fetchOHLCV': true, 'fetchOpenInterest': false, 'fetchOpenInterestHistory': false, 'fetchOpenOrders': true, 'fetchOption': false, 'fetchOptionChain': false, 'fetchOrder': true, 'fetchOrderBook': true, 'fetchOrderBooks': false, 'fetchOrders': true, 'fetchOrdersByStatus': true, 'fetchOrderTrades': false, 'fetchPosition': true, 'fetchPositions': true, 'fetchPremiumIndexOHLCV': false, 'fetchSettlementHistory': false, 'fetchStatus': false, 'fetchTicker': true, 'fetchTickers': true, 'fetchTime': true, 'fetchTrades': true, 'fetchTradingFee': false, 'fetchTradingFees': false, 'fetchTradingLimits': false, 'fetchTransactionFee': false, 'fetchTransactionFees': false, 'fetchTransactions': false, 'fetchTransfer': false, 'fetchTransfers': false, 'fetchVolatilityHistory': false, 'fetchWithdrawal': false, 'fetchWithdrawals': true, 'fetchWithdrawalWhitelist': false, 'reduceMargin': true, 'repayMargin': false, 'setLeverage': true, 'setMargin': false, 'setMarginMode': true, 'setPositionMode': false, 'signIn': false, 'transfer': true, 'withdraw': true, }, 'precisionMode': number.TICK_SIZE, 'urls': { 'logo': 'https://github.com/user-attachments/assets/1f916564-6507-4549-af96-22837bb0a0c7', 'api': { 'spot': 'https://sapi.xt.com', 'linear': 'https://fapi.xt.com', 'inverse': 'https://dapi.xt.com', 'user': 'https://api.xt.com', }, 'www': 'https://xt.com', 'referral': 'https://www.xt.com/en/accounts/register?ref=9PTM9VW', 'doc': [ 'https://doc.xt.com/', 'https://github.com/xtpub/api-doc', ], 'fees': 'https://www.xt.com/en/rate', }, 'api': { 'public': { 'spot': { 'get': { 'currencies': 1, 'depth': 10, 'kline': 1, 'symbol': 1, // 1 for a single symbol 'ticker': 1, // 1 for a single symbol 'ticker/book': 1, // 1 for a single symbol 'ticker/price': 1, // 1 for a single symbol 'ticker/24h': 1, // 1 for a single symbol 'time': 1, 'trade/history': 1, 'trade/recent': 1, 'wallet/support/currency': 1, }, }, 'linear': { 'get': { 'future/market/v1/public/contract/risk-balance': 1, 'future/market/v1/public/contract/open-interest': 1, 'future/market/v1/public/leverage/bracket/detail': 1, 'future/market/v1/public/leverage/bracket/list': 1, 'future/market/v1/public/q/agg-ticker': 1, 'future/market/v1/public/q/agg-tickers': 1, 'future/market/v1/public/q/deal': 1, 'future/market/v1/public/q/depth': 1, 'future/market/v1/public/q/funding-rate': 1, 'future/market/v1/public/q/funding-rate-record': 1, 'future/market/v1/public/q/index-price': 1, 'future/market/v1/public/q/kline': 1, 'future/market/v1/public/q/mark-price': 1, 'future/market/v1/public/q/symbol-index-price': 1, 'future/market/v1/public/q/symbol-mark-price': 1, 'future/market/v1/public/q/ticker': 1, 'future/market/v1/public/q/tickers': 1, 'future/market/v1/public/symbol/coins': 3.33, 'future/market/v1/public/symbol/detail': 3.33, 'future/market/v1/public/symbol/list': 1, }, }, 'inverse': { 'get': { 'future/market/v1/public/contract/risk-balance': 1, 'future/market/v1/public/contract/open-interest': 1, 'future/market/v1/public/leverage/bracket/detail': 1, 'future/market/v1/public/leverage/bracket/list': 1, 'future/market/v1/public/q/agg-ticker': 1, 'future/market/v1/public/q/agg-tickers': 1, 'future/market/v1/public/q/deal': 1, 'future/market/v1/public/q/depth': 1, 'future/market/v1/public/q/funding-rate': 1, 'future/market/v1/public/q/funding-rate-record': 1, 'future/market/v1/public/q/index-price': 1, 'future/market/v1/public/q/kline': 1, 'future/market/v1/public/q/mark-price': 1, 'future/market/v1/public/q/symbol-index-price': 1, 'future/market/v1/public/q/symbol-mark-price': 1, 'future/market/v1/public/q/ticker': 1, 'future/market/v1/public/q/tickers': 1, 'future/market/v1/public/symbol/coins': 3.33, 'future/market/v1/public/symbol/detail': 3.33, 'future/market/v1/public/symbol/list': 1, }, }, }, 'private': { 'spot': { 'get': { 'balance': 1, 'balances': 1, 'batch-order': 1, 'deposit/address': 1, 'deposit/history': 1, 'history-order': 1, 'open-order': 1, 'order': 1, 'order/{orderId}': 1, 'trade': 1, 'withdraw/history': 1, }, 'post': { 'order': 0.2, 'withdraw': 10, 'balance/transfer': 1, 'balance/account/transfer': 1, 'ws-token': 1, }, 'delete': { 'batch-order': 1, 'open-order': 1, 'order/{orderId}': 1, }, 'put': { 'order/{orderId}': 1, }, }, 'linear': { 'get': { 'future/trade/v1/entrust/plan-detail': 1, 'future/trade/v1/entrust/plan-list': 1, 'future/trade/v1/entrust/plan-list-history': 1, 'future/trade/v1/entrust/profit-detail': 1, 'future/trade/v1/entrust/profit-list': 1, 'future/trade/v1/order/detail': 1, 'future/trade/v1/order/list': 1, 'future/trade/v1/order/list-history': 1, 'future/trade/v1/order/trade-list': 1, 'future/user/v1/account/info': 1, 'future/user/v1/balance/bills': 1, 'future/user/v1/balance/detail': 1, 'future/user/v1/balance/funding-rate-list': 1, 'future/user/v1/balance/list': 1, 'future/user/v1/position/adl': 1, 'future/user/v1/position/break-list': 1, 'future/user/v1/position/list': 1, 'future/user/v1/user/collection/list': 1, 'future/user/v1/user/listen-key': 1, }, 'post': { 'future/trade/v1/entrust/cancel-all-plan': 1, 'future/trade/v1/entrust/cancel-all-profit-stop': 1, 'future/trade/v1/entrust/cancel-plan': 1, 'future/trade/v1/entrust/cancel-profit-stop': 1, 'future/trade/v1/entrust/create-plan': 1, 'future/trade/v1/entrust/create-profit': 1, 'future/trade/v1/entrust/update-profit-stop': 1, 'future/trade/v1/order/cancel': 1, 'future/trade/v1/order/cancel-all': 1, 'future/trade/v1/order/create': 1, 'future/trade/v1/order/create-batch': 1, 'future/trade/v1/order/update': 1, 'future/user/v1/account/open': 1, 'future/user/v1/position/adjust-leverage': 1, 'future/user/v1/position/auto-margin': 1, 'future/user/v1/position/close-all': 1, 'future/user/v1/position/margin': 1, 'future/user/v1/user/collection/add': 1, 'future/user/v1/user/collection/cancel': 1, 'future/user/v1/position/change-type': 1, }, }, 'inverse': { 'get': { 'future/trade/v1/entrust/plan-detail': 1, 'future/trade/v1/entrust/plan-list': 1, 'future/trade/v1/entrust/plan-list-history': 1, 'future/trade/v1/entrust/profit-detail': 1, 'future/trade/v1/entrust/profit-list': 1, 'future/trade/v1/order/detail': 1, 'future/trade/v1/order/list': 1, 'future/trade/v1/order/list-history': 1, 'future/trade/v1/order/trade-list': 1, 'future/user/v1/account/info': 1, 'future/user/v1/balance/bills': 1, 'future/user/v1/balance/detail': 1, 'future/user/v1/balance/funding-rate-list': 1, 'future/user/v1/balance/list': 1, 'future/user/v1/position/adl': 1, 'future/user/v1/position/break-list': 1, 'future/user/v1/position/list': 1, 'future/user/v1/user/collection/list': 1, 'future/user/v1/user/listen-key': 1, }, 'post': { 'future/trade/v1/entrust/cancel-all-plan': 1, 'future/trade/v1/entrust/cancel-all-profit-stop': 1, 'future/trade/v1/entrust/cancel-plan': 1, 'future/trade/v1/entrust/cancel-profit-stop': 1, 'future/trade/v1/entrust/create-plan': 1, 'future/trade/v1/entrust/create-profit': 1, 'future/trade/v1/entrust/update-profit-stop': 1, 'future/trade/v1/order/cancel': 1, 'future/trade/v1/order/cancel-all': 1, 'future/trade/v1/order/create': 1, 'future/trade/v1/order/create-batch': 1, 'future/trade/v1/order/update': 1, 'future/user/v1/account/open': 1, 'future/user/v1/position/adjust-leverage': 1, 'future/user/v1/position/auto-margin': 1, 'future/user/v1/position/close-all': 1, 'future/user/v1/position/margin': 1, 'future/user/v1/user/collection/add': 1, 'future/user/v1/user/collection/cancel': 1, 'future/user/v1/position/change-type': 1, }, }, 'user': { 'get': { 'user/account': 1, 'user/account/api-key': 1, }, 'post': { 'user/account': 1, 'user/account/api-key': 1, }, 'put': { 'user/account/api-key': 1, }, 'delete': { 'user/account/{apiKeyId}': 1, }, }, }, }, 'fees': { 'spot': { 'tierBased': true, 'percentage': true, 'maker': this.parseNumber('0.002'), 'taker': this.parseNumber('0.002'), 'tiers': { 'maker': [ [this.parseNumber('0'), this.parseNumber('0.002')], [this.parseNumber('5000'), this.parseNumber('0.0018')], [this.parseNumber('10000'), this.parseNumber('0.0016')], [this.parseNumber('20000'), this.parseNumber('0.0014')], [this.parseNumber('50000'), this.parseNumber('0.0012')], [this.parseNumber('150000'), this.parseNumber('0.0010')], [this.parseNumber('300000'), this.parseNumber('0.0008')], [this.parseNumber('600000'), this.parseNumber('0.0007')], [this.parseNumber('1200000'), this.parseNumber('0.0006')], [this.parseNumber('2500000'), this.parseNumber('0.0005')], [this.parseNumber('6000000'), this.parseNumber('0.0004')], [this.parseNumber('15000000'), this.parseNumber('0.0003')], [this.parseNumber('30000000'), this.parseNumber('0.0002')], ], 'taker': [ [this.parseNumber('0'), this.parseNumber('0.002')], [this.parseNumber('5000'), this.parseNumber('0.0018')], [this.parseNumber('10000'), this.parseNumber('0.0016')], [this.parseNumber('20000'), this.parseNumber('0.0014')], [this.parseNumber('50000'), this.parseNumber('0.0012')], [this.parseNumber('150000'), this.parseNumber('0.0010')], [this.parseNumber('300000'), this.parseNumber('0.0008')], [this.parseNumber('600000'), this.parseNumber('0.0007')], [this.parseNumber('1200000'), this.parseNumber('0.0006')], [this.parseNumber('2500000'), this.parseNumber('0.0005')], [this.parseNumber('6000000'), this.parseNumber('0.0004')], [this.parseNumber('15000000'), this.parseNumber('0.0003')], [this.parseNumber('30000000'), this.parseNumber('0.0002')], ], }, }, 'contract': { 'tierBased': true, 'percentage': true, 'maker': this.parseNumber('0.0004'), 'taker': this.parseNumber('0.0006'), 'tiers': { 'maker': [ [this.parseNumber('0'), this.parseNumber('0.0004')], [this.parseNumber('200000'), this.parseNumber('0.00038')], [this.parseNumber('1000000'), this.parseNumber('0.00036')], [this.parseNumber('5000000'), this.parseNumber('0.00034')], [this.parseNumber('10000000'), this.parseNumber('0.00032')], [this.parseNumber('15000000'), this.parseNumber('0.00028')], [this.parseNumber('30000000'), this.parseNumber('0.00024')], [this.parseNumber('50000000'), this.parseNumber('0.0002')], [this.parseNumber('100000000'), this.parseNumber('0.00016')], [this.parseNumber('300000000'), this.parseNumber('0.00012')], [this.parseNumber('500000000'), this.parseNumber('0.00008')], ], 'taker': [ [this.parseNumber('0'), this.parseNumber('0.0006')], [this.parseNumber('200000'), this.parseNumber('0.000588')], [this.parseNumber('1000000'), this.parseNumber('0.00057')], [this.parseNumber('5000000'), this.parseNumber('0.00054')], [this.parseNumber('10000000'), this.parseNumber('0.00051')], [this.parseNumber('15000000'), this.parseNumber('0.00048')], [this.parseNumber('30000000'), this.parseNumber('0.00045')], [this.parseNumber('50000000'), this.parseNumber('0.00045')], [this.parseNumber('100000000'), this.parseNumber('0.00036')], [this.parseNumber('300000000'), this.parseNumber('0.00033')], [this.parseNumber('500000000'), this.parseNumber('0.0003')], ], }, }, }, 'exceptions': { 'exact': { '400': errors.NetworkError, // {"returnCode":1,"msgInfo":"failure","error":{"code":"400","msg":"Connection refused: /10.0.26.71:8080"},"result":null} '404': errors.ExchangeError, // interface does not exist '429': errors.RateLimitExceeded, // The request is too frequent, please control the request rate according to the speed limit requirement '500': errors.ExchangeError, // Service exception '502': errors.ExchangeError, // Gateway exception '503': errors.OnMaintenance, // Service unavailable, please try again later 'AUTH_001': errors.AuthenticationError, // missing request header xt-validate-appkey 'AUTH_002': errors.AuthenticationError, // missing request header xt-validate-timestamp 'AUTH_003': errors.AuthenticationError, // missing request header xt-validate-recvwindow 'AUTH_004': errors.AuthenticationError, // bad request header xt-validate-recvwindow 'AUTH_005': errors.AuthenticationError, // missing request header xt-validate-algorithms 'AUTH_006': errors.AuthenticationError, // bad request header xt-validate-algorithms 'AUTH_007': errors.AuthenticationError, // missing request header xt-validate-signature 'AUTH_101': errors.AuthenticationError, // ApiKey does not exist 'AUTH_102': errors.AuthenticationError, // ApiKey is not activated 'AUTH_103': errors.AuthenticationError, // Signature error, {"rc":1,"mc":"AUTH_103","ma":[],"result":null} 'AUTH_104': errors.AuthenticationError, // Unbound IP request 'AUTH_105': errors.AuthenticationError, // outdated message 'AUTH_106': errors.PermissionDenied, // Exceeded apikey permission 'SYMBOL_001': errors.BadSymbol, // Symbol not exist 'SYMBOL_002': errors.BadSymbol, // Symbol offline 'SYMBOL_003': errors.BadSymbol, // Symbol suspend trading 'SYMBOL_004': errors.BadSymbol, // Symbol country disallow trading 'SYMBOL_005': errors.BadSymbol, // The symbol does not support trading via API 'ORDER_001': errors.InvalidOrder, // Platform rejection 'ORDER_002': errors.InsufficientFunds, // insufficient funds 'ORDER_003': errors.InvalidOrder, // Trading Pair Suspended 'ORDER_004': errors.InvalidOrder, // no transaction 'ORDER_005': errors.InvalidOrder, // Order not exist 'ORDER_006': errors.InvalidOrder, // Too many open orders 'ORDER_007': errors.PermissionDenied, // The sub-account has no transaction authority 'ORDER_F0101': errors.InvalidOrder, // Trigger Price Filter - Min 'ORDER_F0102': errors.InvalidOrder, // Trigger Price Filter - Max 'ORDER_F0103': errors.InvalidOrder, // Trigger Price Filter - Step Value 'ORDER_F0201': errors.InvalidOrder, // Trigger Quantity Filter - Min 'ORDER_F0202': errors.InvalidOrder, // Trigger Quantity Filter - Max 'ORDER_F0203': errors.InvalidOrder, // Trigger Quantity Filter - Step Value 'ORDER_F0301': errors.InvalidOrder, // Trigger QUOTE_QTY Filter - Min Value 'ORDER_F0401': errors.InvalidOrder, // Trigger PROTECTION_ONLINE Filter 'ORDER_F0501': errors.InvalidOrder, // Trigger PROTECTION_LIMIT Filter - Buy Max Deviation 'ORDER_F0502': errors.InvalidOrder, // Trigger PROTECTION_LIMIT Filter - Sell Max Deviation 'ORDER_F0601': errors.InvalidOrder, // Trigger PROTECTION_MARKET Filter 'COMMON_001': errors.ExchangeError, // The user does not exist 'COMMON_002': errors.ExchangeError, // System busy, please try it later 'COMMON_003': errors.BadRequest, // Operation failed, please try it later 'CURRENCY_001': errors.BadRequest, // Information of currency is abnormal 'DEPOSIT_001': errors.BadRequest, // Deposit is not open 'DEPOSIT_002': errors.PermissionDenied, // The current account security level is low, please bind any two security verifications in mobile phone/email/Google Authenticator before deposit 'DEPOSIT_003': errors.BadRequest, // The format of address is incorrect, please enter again 'DEPOSIT_004': errors.BadRequest, // The address is already exists, please enter again 'DEPOSIT_005': errors.BadRequest, // Can not find the address of offline wallet 'DEPOSIT_006': errors.BadRequest, // No deposit address, please try it later 'DEPOSIT_007': errors.BadRequest, // Address is being generated, please try it later 'DEPOSIT_008': errors.BadRequest, // Deposit is not available 'WITHDRAW_001': errors.BadRequest, // Withdraw is not open 'WITHDRAW_002': errors.BadRequest, // The withdrawal address is invalid 'WITHDRAW_003': errors.PermissionDenied, // The current account security level is low, please bind any two security verifications in mobile phone/email/Google Authenticator before withdraw 'WITHDRAW_004': errors.BadRequest, // The withdrawal address is not added 'WITHDRAW_005': errors.BadRequest, // The withdrawal address cannot be empty 'WITHDRAW_006': errors.BadRequest, // Memo cannot be empty 'WITHDRAW_008': errors.PermissionDenied, // Risk control is triggered, withdraw of this currency is not currently supported 'WITHDRAW_009': errors.PermissionDenied, // Withdraw failed, some assets in this withdraw are restricted by T+1 withdraw 'WITHDRAW_010': errors.BadRequest, // The precision of withdrawal is invalid 'WITHDRAW_011': errors.InsufficientFunds, // free balance is not enough 'WITHDRAW_012': errors.PermissionDenied, // Withdraw failed, your remaining withdrawal limit today is not enough 'WITHDRAW_013': errors.PermissionDenied, // Withdraw failed, your remaining withdrawal limit today is not enough, the withdrawal amount can be increased by completing a higher level of real-name authentication 'WITHDRAW_014': errors.BadRequest, // This withdrawal address cannot be used in the internal transfer function, please cancel the internal transfer function before submitting 'WITHDRAW_015': errors.BadRequest, // The withdrawal amount is not enough to deduct the handling fee 'WITHDRAW_016': errors.BadRequest, // This withdrawal address is already exists 'WITHDRAW_017': errors.BadRequest, // This withdrawal has been processed and cannot be canceled 'WITHDRAW_018': errors.BadRequest, // Memo must be a number 'WITHDRAW_019': errors.BadRequest, // Memo is incorrect, please enter again 'WITHDRAW_020': errors.PermissionDenied, // Your withdrawal amount has reached the upper limit for today, please try it tomorrow 'WITHDRAW_021': errors.PermissionDenied, // Your withdrawal amount has reached the upper limit for today, you can only withdraw up to {0} this time 'WITHDRAW_022': errors.BadRequest, // Withdrawal amount must be greater than {0} 'WITHDRAW_023': errors.BadRequest, // Withdrawal amount must be less than {0} 'WITHDRAW_024': errors.BadRequest, // Withdraw is not supported 'WITHDRAW_025': errors.BadRequest, // Please create a FIO address in the deposit page 'FUND_001': errors.BadRequest, // Duplicate request (a bizId can only be requested once) 'FUND_002': errors.InsufficientFunds, // Insufficient account balance 'FUND_003': errors.BadRequest, // Transfer operations are not supported (for example, sub-accounts do not support financial transfers) 'FUND_004': errors.ExchangeError, // Unfreeze failed 'FUND_005': errors.PermissionDenied, // Transfer prohibited 'FUND_014': errors.BadRequest, // The transfer-in account id and transfer-out account ID cannot be the same 'FUND_015': errors.BadRequest, // From and to business types cannot be the same 'FUND_016': errors.BadRequest, // Leverage transfer, symbol cannot be empty 'FUND_017': errors.BadRequest, // Parameter error 'FUND_018': errors.BadRequest, // Invalid freeze record 'FUND_019': errors.BadRequest, // Freeze users not equal 'FUND_020': errors.BadRequest, // Freeze currency are not equal 'FUND_021': errors.BadRequest, // Operation not supported 'FUND_022': errors.BadRequest, // Freeze record does not exist 'FUND_044': errors.BadRequest, // The maximum length of the amount is 113 and cannot exceed the limit 'TRANSFER_001': errors.BadRequest, // Duplicate request (a bizId can only be requested once) 'TRANSFER_002': errors.InsufficientFunds, // Insufficient account balance 'TRANSFER_003': errors.BadRequest, // User not registered 'TRANSFER_004': errors.PermissionDenied, // The currency is not allowed to be transferred 'TRANSFER_005': errors.PermissionDenied, // The user’s currency is not allowed to be transferred 'TRANSFER_006': errors.PermissionDenied, // Transfer prohibited 'TRANSFER_007': errors.RequestTimeout, // Request timed out 'TRANSFER_008': errors.BadRequest, // Transferring to a leveraged account is abnormal 'TRANSFER_009': errors.BadRequest, // Departing from a leveraged account is abnormal 'TRANSFER_010': errors.PermissionDenied, // Leverage cleared, transfer prohibited 'TRANSFER_011': errors.PermissionDenied, // Leverage with borrowing, transfer prohibited 'TRANSFER_012': errors.PermissionDenied, // Currency transfer prohibited 'symbol_not_support_trading_via_api': errors.BadSymbol, // {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null} 'open_order_min_nominal_value_limit': errors.InvalidOrder, // {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null} 'insufficient_balance': errors.InsufficientFunds, }, 'broad': { 'The symbol does not support trading via API': errors.BadSymbol, // {"returnCode":1,"msgInfo":"failure","error":{"code":"symbol_not_support_trading_via_api","msg":"The symbol does not support trading via API"},"result":null} 'Exceeds the minimum notional value of a single order': errors.InvalidOrder, // {"returnCode":1,"msgInfo":"failure","error":{"code":"open_order_min_nominal_value_limit","msg":"Exceeds the minimum notional value of a single order"},"result":null} 'insufficient balance': errors.InsufficientFunds, }, }, 'timeframes': { '1m': '1m', '5m': '5m', '15m': '15m', '30m': '30m', '1h': '1h', // spot only '2h': '2h', // spot only '4h': '4h', '6h': '6h', // spot only '8h': '8h', // spot only '1d': '1d', '3d': '3d', // spot only '1w': '1w', '1M': '1M', // spot only }, 'commonCurrencies': {}, 'options': { 'adjustForTimeDifference': false, 'timeDifference': 0, 'accountsById': { 'spot': 'SPOT', 'leverage': 'LEVER', 'finance': 'FINANCE', 'swap': 'FUTURES_U', 'future': 'FUTURES_U', 'linear': 'FUTURES_U', 'inverse': 'FUTURES_C', }, 'networks': { 'ERC20': 'Ethereum', 'TRC20': 'Tron', 'TRX': 'Tron', 'BEP20': 'BNB Smart Chain', 'BEP2': 'BNB-BEP2', 'ETH': 'Ethereum', 'AVAX': 'AVAX C-Chain', 'GAL': 'GAL(FT)', 'ALEO': 'ALEO(IOU)', 'BTC': 'Bitcoin', 'XT': 'XT Smart Chain', 'ETC': 'Ethereum Classic', 'MATIC': 'Polygon', 'LTC': 'Litecoin', 'BTS': 'BitShares', 'XRP': 'Ripple', 'XLM': 'Stellar Network', 'ADA': 'Cardano', 'XWC': 'XWC-XWC', 'DOGE': 'dogecoin', 'DCR': 'Decred', 'SC': 'Siacoin', 'XTZ': 'Tezos', 'ZEC': 'Zcash', 'XMR': 'Monero', 'LSK': 'Lisk', 'ATOM': 'Cosmos', 'ONT': 'Ontology', 'ALGO': 'Algorand', 'SOL': 'SOL-SOL', 'DOT': 'Polkadot', 'ZEN': 'Horizen', 'FIL': 'Filecoin', 'CHZ': 'chz', 'ICP': 'Internet Computer', 'KSM': 'Kusama', 'LUNA': 'Terra', 'THETA': 'Theta Token', 'FTM': 'Fantom', 'VET': 'VeChain', 'NEAR': 'NEAR Protocol', 'ONE': 'Harmony', 'KLAY': 'Klaytn', 'AR': 'Arweave', 'CELT': 'OKT', 'EGLD': 'Elrond eGold', 'CRO': 'CRO-CRONOS', 'BCH': 'Bitcoin Cash', 'GLMR': 'Moonbeam', 'LOOP': 'LOOP-LRC', 'REI': 'REI Network', 'ASTR': 'Astar Network', 'OP': 'OPT', 'MMT': 'MMT-MMT', 'TBC': 'TBC-TBC', 'OMAX': 'OMAX-OMAX CHAIN', 'GMMT': 'GMMT chain', 'ZIL': 'Zilliqa', }, 'networksById': { 'Ethereum': 'ERC20', 'Tron': 'TRC20', 'BNB Smart Chain': 'BEP20', 'BNB-BEP2': 'BEP2', 'Bitcoin': 'BTC', 'XT Smart Chain': 'XT', 'Ethereum Classic': 'ETC', 'Polygon': 'MATIC', 'Litecoin': 'LTC', 'BitShares': 'BTS', 'Ripple': 'XRP', 'Stellar Network': 'XLM', 'Cardano': 'ADA', 'XWC-XWC': 'XWC', 'dogecoin': 'DOGE', 'Decred': 'DCR', 'Siacoin': 'SC', 'Tezos': 'XTZ', 'Zcash': 'ZEC', 'Monero': 'XMR', 'Lisk': 'LSK', 'Cosmos': 'ATOM', 'Ontology': 'ONT', 'Algorand': 'ALGO', 'SOL-SOL': 'SOL', 'Polkadot': 'DOT', 'Horizen': 'ZEN', 'Filecoin': 'FIL', 'chz': 'CHZ', 'Internet Computer': 'ICP', 'Kusama': 'KSM', 'Terra': 'LUNA', 'Theta Token': 'THETA', 'Fantom': 'FTM', 'VeChain': 'VET', 'AVAX C-Chain': 'AVAX', 'NEAR Protocol': 'NEAR', 'Harmony': 'ONE', 'Klaytn': 'KLAY', 'Arweave': 'AR', 'OKT': 'CELT', 'Elrond eGold': 'EGLD', 'CRO-CRONOS': 'CRO', 'Bitcoin Cash': 'BCH', 'Moonbeam': 'GLMR', 'LOOP-LRC': 'LOOP', 'REI Network': 'REI', 'Astar Network': 'ASTR', 'GAL(FT)': 'GAL', 'ALEO(IOU)': 'ALEO', 'OPT': 'OP', 'MMT-MMT': 'MMT', 'TBC-TBC': 'TBC', 'OMAX-OMAX CHAIN': 'OMAX', 'GMMT chain': 'GMMT', 'Zilliqa': 'ZIL', }, 'createMarketBuyOrderRequiresPrice': true, 'recvWindow': '5000', // in milliseconds, spot only }, 'features': { 'default': { 'sandbox': false, 'createOrder': { 'marginMode': true, 'triggerPrice': false, 'triggerDirection': false, 'triggerPriceType': undefined, 'stopLossPrice': false, 'takeProfitPrice': false, 'attachedStopLossTakeProfit': undefined, 'timeInForce': { 'IOC': true, 'FOK': true, 'PO': true, 'GTD': false, }, 'hedged': false, 'trailing': false, 'leverage': false, 'marketBuyByCost': true, 'marketBuyRequiresPrice': false, 'selfTradePrevention': false, 'iceberg': false, }, 'createOrders': undefined, 'fetchMyTrades': { 'marginMode': true, 'limit': 100, 'daysBack': 100000, // todo 'untilDays': 100000, // todo 'marketType': true, 'subType': true, 'symbolRequired': false, }, 'fetchOrder': { 'marginMode': false, 'trigger': true, // todo TPSL kind 'trailing': false, 'marketType': true, 'subType': true, 'symbolRequired': false, }, 'fetchOpenOrders': { 'marginMode': true, 'limit': 100, 'trigger': true, // todo TPSL 'trailing': false, 'marketType': true, 'subType': true, 'symbolRequired': false, }, 'fetchOrders': { 'marginMode': true, 'limit': 100, 'daysBack': 100000, // todo 'untilDays': 100000, // todo 'trigger': true, // todo TPSL 'trailing': false, 'marketType': true, 'subType': true, 'symbolRequired': false, }, 'fetchClosedOrders': { 'marginMode': true, 'limit': 100, 'daysBack': 100000, // todo 'daysBackCanceled': 1, // todo 'untilDays': 100000, // todo 'trigger': true, // todo TPSL 'trailing': false, 'marketType': true, 'subType': true, 'symbolRequired': false, }, 'fetchOHLCV': { 'limit': 1000, // todo for derivatives }, }, 'spot': { 'extends': 'default', }, 'forDerivatives': { 'extends': 'default', 'createOrder': { 'marginMode': false, 'triggerPrice': true, // todo 'triggerPriceType': { 'last': true, 'mark': true, 'index': true, }, 'stopLossPrice': true, 'takeProfitPrice': true, }, 'fetchMyTrades': { 'daysBack': undefined, 'untilDays': undefined, }, }, 'swap': { 'linear': { 'extends': 'forDerivatives', }, 'inverse': { 'extends': 'forDerivatives', }, }, 'future': { 'linear': { 'extends': 'forDerivatives', }, 'inverse': { 'extends': 'forDerivatives', }, }, }, }); } nonce() { return this.milliseconds() - this.options['timeDifference']; } /** * @method * @name xt#fetchTime * @description fetches the current integer timestamp in milliseconds from the xt server * @see https://doc.xt.com/#market1serverInfo * @param {object} params extra parameters specific to the exchange API endpoint * @returns {int} the current integer timestamp in milliseconds from the xt server */ async fetchTime(params = {}) { const response = await this.publicSpotGetTime(params); // // { // "rc": 0, // "mc": "SUCCESS", // "ma": [], // "result": { // "serverTime": 1677823301643 // } // } // const data = this.safeValue(response, 'result'); return this.safeInteger(data, 'serverTime'); } /** * @method * @name xt#fetchCurrencies * @description fetches all available currencies on an exchange * @see https://doc.xt.com/#deposit_withdrawalsupportedCurrenciesGet * @param {object} params extra parameters specific to the exchange API endpoint * @returns {object} an associative dictionary of currencies */ async fetchCurrencies(params = {}) { const promisesRaw = [this.publicSpotGetWalletSupportCurrency(params), this.publicSpotGetCurrencies(params)]; const [chainsResponse, currenciesResponse] = await Promise.all(promisesRaw); // // currencies // // { // "time": "1686626116145", // "version": "5dbbb2f2527c22b2b2e3b47187ef13d1", // "currencies": [ // { // "id": "2", // "currency": "btc", // "fullName": "Bitcoin", // "logo": "https://a.static-global.com/1/currency/btc.png", // "cmcLink": "https://coinmarketcap.com/currencies/bitcoin/", // "weight": "99999", // "maxPrecision": "10", // "depositStatus": "1", // "withdrawStatus": "1", // "convertEnabled": "1", // "transferEnabled": "1", // "isChainExist": "1", // "plates": [152] // }, // ], // } // // // chains // // { // "rc": 0, // "mc": "SUCCESS", // "ma": [], // "result": [ // { // "currency": "btc", // "supportChains": [ // { // "chain": "Bitcoin", // "depositEnabled": true, // "withdrawEnabled": true, // "withdrawFeeAmount": 0.0009, // "withdrawMinAmount": 0.0005, // "depositFeeRate": 0 // }, // ] // }, // ] // } // // note: individual network's full data is available on per-currency endpoint: https://www.xt.com/sapi/v4/balance/public/currency/11 // const chainsData = this.safeValue(chainsResponse, 'result', []); const currenciesResult = this.safeValue(currenciesResponse, 'result', []); const currenciesData = this.safeValue(currenciesResult, 'currencies', []); const chainsDataIndexed = this.indexBy(chainsData, 'currency'); const result = {}; for (let i = 0; i < currenciesData.length; i++) { const entry = currenciesData[i]; const currencyId = this.safeString(entry, 'currency'); const code = this.safeCurrencyCode(currencyId); const networkEntry = this.safeValue(chainsDataIndexed, currencyId, {}); const rawNetworks = this.safeValue(networkEntry, 'supportChains', []); const networks = {}; for (let j = 0; j < rawNetworks.length; j++) { const rawNetwork = rawNetworks[j]; const networkId = this.safeString(rawNetwork, 'chain'); const networkCode = this.networkIdToCode(networkId, code); if (networkCode !== undefined) { networks[networkCode] = { 'info': rawNetwork, 'id': networkId, 'network': networkCode, 'name': undefined,