UNPKG

@proton/ccxt

Version:

A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges

1,038 lines (1,036 loc) 207 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 Exchange from './abstract/xt.js'; import { Precise } from './base/Precise.js'; import { TICK_SIZE } from './base/functions/number.js'; import { AuthenticationError, BadRequest, BadSymbol, ExchangeError, InsufficientFunds, InvalidOrder, NetworkError, NotSupported, OnMaintenance, PermissionDenied, RateLimitExceeded, RequestTimeout } from './base/errors.js'; import { sha256 } from './static_dependencies/noble-hashes/sha256.js'; // --------------------------------------------------------------------------- export default class xt extends Exchange { describe() { return this.deepExtend(super.describe(), { 'id': 'xt', 'name': 'XT', 'countries': ['SC'], // 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': true, 'pro': false, '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, 'createOrder': true, 'createPostOnlyOrder': false, 'createReduceOnlyOrder': true, 'editOrder': false, 'fetchAccounts': 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, 'fetchDeposits': true, 'fetchDepositWithdrawals': false, 'fetchDepositWithdrawFee': false, 'fetchDepositWithdrawFees': false, 'fetchFundingHistory': true, 'fetchFundingRate': true, 'fetchFundingRateHistory': true, 'fetchFundingRates': 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, '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, 'fetchWithdrawal': false, 'fetchWithdrawals': true, 'fetchWithdrawalWhitelist': false, 'reduceMargin': true, 'repayMargin': false, 'setLeverage': true, 'setMargin': false, 'setMarginMode': false, 'setPositionMode': false, 'signIn': false, 'transfer': true, 'withdraw': true, }, 'precisionMode': TICK_SIZE, 'urls': { 'logo': 'https://user-images.githubusercontent.com/14319357/232636712-466df2fc-560a-4ca4-aab2-b1d954a58e24.jpg', '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': 0.05, 'kline': 0.1, 'symbol': 1, 'ticker': 1, 'ticker/book': 1, 'ticker/price': 1, 'ticker/24h': 1, 'time': 1, 'trade/history': 0.1, 'trade/recent': 0.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': 1, 'balance/transfer': 1, 'balance/account/transfer': 1, }, 'delete': { 'batch-order': 1, 'open-order': 1, '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/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/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, }, }, '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/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/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, }, }, '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': NetworkError, '404': ExchangeError, '429': RateLimitExceeded, '500': ExchangeError, '502': ExchangeError, '503': OnMaintenance, 'AUTH_001': AuthenticationError, 'AUTH_002': AuthenticationError, 'AUTH_003': AuthenticationError, 'AUTH_004': AuthenticationError, 'AUTH_005': AuthenticationError, 'AUTH_006': AuthenticationError, 'AUTH_007': AuthenticationError, 'AUTH_101': AuthenticationError, 'AUTH_102': AuthenticationError, 'AUTH_103': AuthenticationError, 'AUTH_104': AuthenticationError, 'AUTH_105': AuthenticationError, 'AUTH_106': PermissionDenied, 'SYMBOL_001': BadSymbol, 'SYMBOL_002': BadSymbol, 'SYMBOL_003': BadSymbol, 'SYMBOL_004': BadSymbol, 'SYMBOL_005': BadSymbol, 'ORDER_001': InvalidOrder, 'ORDER_002': InsufficientFunds, 'ORDER_003': InvalidOrder, 'ORDER_004': InvalidOrder, 'ORDER_005': InvalidOrder, 'ORDER_006': InvalidOrder, 'ORDER_007': PermissionDenied, 'ORDER_F0101': InvalidOrder, 'ORDER_F0102': InvalidOrder, 'ORDER_F0103': InvalidOrder, 'ORDER_F0201': InvalidOrder, 'ORDER_F0202': InvalidOrder, 'ORDER_F0203': InvalidOrder, 'ORDER_F0301': InvalidOrder, 'ORDER_F0401': InvalidOrder, 'ORDER_F0501': InvalidOrder, 'ORDER_F0502': InvalidOrder, 'ORDER_F0601': InvalidOrder, 'COMMON_001': ExchangeError, 'COMMON_002': ExchangeError, 'COMMON_003': BadRequest, 'CURRENCY_001': BadRequest, 'DEPOSIT_001': BadRequest, 'DEPOSIT_002': PermissionDenied, 'DEPOSIT_003': BadRequest, 'DEPOSIT_004': BadRequest, 'DEPOSIT_005': BadRequest, 'DEPOSIT_006': BadRequest, 'DEPOSIT_007': BadRequest, 'DEPOSIT_008': BadRequest, 'WITHDRAW_001': BadRequest, 'WITHDRAW_002': BadRequest, 'WITHDRAW_003': PermissionDenied, 'WITHDRAW_004': BadRequest, 'WITHDRAW_005': BadRequest, 'WITHDRAW_006': BadRequest, 'WITHDRAW_008': PermissionDenied, 'WITHDRAW_009': PermissionDenied, 'WITHDRAW_010': BadRequest, 'WITHDRAW_011': InsufficientFunds, 'WITHDRAW_012': PermissionDenied, 'WITHDRAW_013': PermissionDenied, 'WITHDRAW_014': BadRequest, 'WITHDRAW_015': BadRequest, 'WITHDRAW_016': BadRequest, 'WITHDRAW_017': BadRequest, 'WITHDRAW_018': BadRequest, 'WITHDRAW_019': BadRequest, 'WITHDRAW_020': PermissionDenied, 'WITHDRAW_021': PermissionDenied, 'WITHDRAW_022': BadRequest, 'WITHDRAW_023': BadRequest, 'WITHDRAW_024': BadRequest, 'WITHDRAW_025': BadRequest, 'FUND_001': BadRequest, 'FUND_002': InsufficientFunds, 'FUND_003': BadRequest, 'FUND_004': ExchangeError, 'FUND_005': PermissionDenied, 'FUND_014': BadRequest, 'FUND_015': BadRequest, 'FUND_016': BadRequest, 'FUND_017': BadRequest, 'FUND_018': BadRequest, 'FUND_019': BadRequest, 'FUND_020': BadRequest, 'FUND_021': BadRequest, 'FUND_022': BadRequest, 'FUND_044': BadRequest, 'TRANSFER_001': BadRequest, 'TRANSFER_002': InsufficientFunds, 'TRANSFER_003': BadRequest, 'TRANSFER_004': PermissionDenied, 'TRANSFER_005': PermissionDenied, 'TRANSFER_006': PermissionDenied, 'TRANSFER_007': RequestTimeout, 'TRANSFER_008': BadRequest, 'TRANSFER_009': BadRequest, 'TRANSFER_010': PermissionDenied, 'TRANSFER_011': PermissionDenied, 'TRANSFER_012': PermissionDenied, 'symbol_not_support_trading_via_api': BadSymbol, 'open_order_min_nominal_value_limit': 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} }, 'broad': { 'The symbol does not support trading via API': BadSymbol, 'Exceeds the minimum notional value of a single order': 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} }, }, 'timeframes': { '1m': '1m', '5m': '5m', '15m': '15m', '30m': '30m', '1h': '1h', '2h': '2h', '4h': '4h', '6h': '6h', '8h': '8h', '1d': '1d', '3d': '3d', '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', 'BEP20': 'BNB Smart Chain', 'BEP2': 'BNB-BEP2', 'ETH': 'Ethereum', 'TRON': 'Tron', 'BNB': 'BNB Smart Chain', '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 }, }); } nonce() { return this.milliseconds() - this.options['timeDifference']; } async fetchTime(params = {}) { /** * @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 xt api endpoint * @returns {int} the current integer timestamp in milliseconds from the xt server */ 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'); } async fetchCurrencies(params = {}) { /** * @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 xt api endpoint * @returns {object} an associative dictionary of currencies */ 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 minPrecision = this.parseNumber(this.parsePrecision(this.safeString(entry, 'maxPrecision'))); const networkEntry = this.safeValue(chainsDataIndexed, currencyId, {}); const rawNetworks = this.safeValue(networkEntry, 'supportChains', []); const networks = {}; let minWithdrawString = undefined; let minWithdrawFeeString = undefined; let active = false; let deposit = false; let withdraw = false; for (let j = 0; j < rawNetworks.length; j++) { const rawNetwork = rawNetworks[j]; const networkId = this.safeString(rawNetwork, 'chain'); const network = this.networkIdToCode(networkId); const depositEnabled = this.safeValue(rawNetwork, 'depositEnabled'); deposit = (depositEnabled) ? depositEnabled : deposit; const withdrawEnabled = this.safeValue(rawNetwork, 'withdrawEnabled'); withdraw = (withdrawEnabled) ? withdrawEnabled : withdraw; const networkActive = depositEnabled && withdrawEnabled; active = (networkActive) ? networkActive : active; const withdrawFeeString = this.safeString(rawNetwork, 'withdrawFeeAmount'); if (withdrawFeeString !== undefined) { minWithdrawFeeString = (minWithdrawFeeString === undefined) ? withdrawFeeString : Precise.stringMin(withdrawFeeString, minWithdrawFeeString); } const minNetworkWithdrawString = this.safeString(rawNetwork, 'withdrawMinAmount'); if (minNetworkWithdrawString !== undefined) { minWithdrawString = (minWithdrawString === undefined) ? minNetworkWithdrawString : Precise.stringMin(minNetworkWithdrawString, minWithdrawString); } networks[network] = { 'info': rawNetwork, 'id': networkId, 'network': network, 'name': undefined, 'active': networkActive, 'fee': this.parseNumber(withdrawFeeString), 'precision': minPrecision, 'deposit': depositEnabled, 'withdraw': withdrawEnabled, 'limits': { 'amount': { 'min': undefined, 'max': undefined, }, 'withdraw': { 'min': this.parseNumber(minNetworkWithdrawString), 'max': undefined, }, 'deposit': { 'min': undefined, 'max': undefined, }, }, }; } result[code] = { 'info': entry, 'id': currencyId, 'code': code, 'name': this.safeString(entry, 'fullName'), 'active': active, 'fee': this.parseNumber(minWithdrawFeeString), 'precision': undefined, 'deposit': deposit, 'withdraw': withdraw, 'networks': networks, 'limits': { 'amount': { 'min': undefined, 'max': undefined, }, 'withdraw': { 'min': this.parseNumber(minWithdrawString), 'max': undefined, }, 'deposit': { 'min': undefined, 'max': undefined, }, }, }; } return result; } async fetchMarkets(params = {}) { /** * @method * @name xt#fetchMarkets * @description retrieves data on all markets for xt * @see https://doc.xt.com/#market2symbol * @see https://doc.xt.com/#futures_quotesgetSymbols * @param {object} params extra parameters specific to the xt api endpoint * @returns {[object]} an array of objects representing market data */ if (this.options['adjustForTimeDifference']) { await this.loadTimeDifference(); } const promisesUnresolved = [ this.fetchSpotMarkets(params), this.fetchSwapAndFutureMarkets(params), ]; const promises = await Promise.all(promisesUnresolved); const spotMarkets = promises[0]; const swapAndFutureMarkets = promises[1]; return this.arrayConcat(spotMarkets, swapAndFutureMarkets); } async fetchSpotMarkets(params = {}) { const response = await this.publicSpotGetSymbol(params); // // { // "rc": 0, // "mc": "SUCCESS", // "ma": [], // "result": { // "time": 1677881368812, // "version": "abb101d1543e54bee40687b135411ba0", // "symbols": [ // { // "id": 640, // "symbol": "xt_usdt", // "state": "ONLINE", // "stateTime": 1554048000000, // "tradingEnabled": true, // "openapiEnabled": true, // "nextStateTime": null, // "nextState": null, // "depthMergePrecision": 5, // "baseCurrency": "xt", // "baseCurrencyPrecision": 8, // "baseCurrencyId": 128, // "quoteCurrency": "usdt", // "quoteCurrencyPrecision": 8, // "quoteCurrencyId": 11, // "pricePrecision": 4, // "quantityPrecision": 2, // "orderTypes": ["LIMIT","MARKET"], // "timeInForces": ["GTC","IOC"], // "displayWeight": 10002, // "displayLevel": "FULL", // "plates": [], // "filters":[ // { // "filter": "QUOTE_QTY", // "min": "1" // }, // { // "filter": "PROTECTION_LIMIT", // "buyMaxDeviation": "0.8", // "sellMaxDeviation": "4" // }, // { // "filter": "PROTECTION_MARKET", // "maxDeviation": "0.02" // } // ] // }, // ] // } // } // const data = this.safeValue(response, 'result', {}); const symbols = this.safeValue(data, 'symbols', []); return this.parseMarkets(symbols); } async fetchSwapAndFutureMarkets(params = {}) { const markets = await Promise.all([this.publicLinearGetFutureMarketV1PublicSymbolList(params), this.publicInverseGetFutureMarketV1PublicSymbolList(params)]); // // { // "returnCode": 0, // "msgInfo": "success", // "error": null, // "result": [ // { // "id": 52, // "symbolGroupId": 71, // "symbol": "xt_usdt", // "pair": "xt_usdt", // "contractType": "PERPETUAL", // "productType": "perpetual", // "predictEventType": null, // "underlyingType": "U_BASED", // "contractSize": "1", // "tradeSwitch": true, // "isDisplay": true, // "isOpenApi": false, // "state": 0, // "initLeverage": 20, // "initPositionType": "CROSSED", // "baseCoin": "xt", // "quoteCoin": "usdt", // "baseCoinPrecision": 8, // "baseCoinDisplayPrecision": 4, // "quoteCoinPrecision": 8, // "quoteCoinDisplayPrecision": 4, // "quantityPrecision": 0, // "pricePrecision": 4, // "supportOrderType": "LIMIT,MARKET", // "supportTimeInForce": "GTC,FOK,IOC,GTX", // "supportEntrustType": "TAKE_PROFIT,STOP,TAKE_PROFIT_MARKET,STOP_MARKET,TRAILING_STOP_MARKET", // "supportPositionType": "CROSSED,ISOLATED", // "minQty": "1", // "minNotional": "5", // "maxNotional": "20000000", // "multiplierDown": "0.1", // "multiplierUp": "0.1", // "maxOpenOrders": 200, // "maxEntrusts": 200, // "makerFee": "0.0004", // "takerFee": "0.0006", // "liquidationFee": "0.01", // "marketTakeBound": "0.1", // "depthPrecisionMerge": 5, // "labels": ["HOT"], // "onboardDate": 1657101601000, // "enName": "XTUSDT ", // "cnName": "XTUSDT", // "minStepPrice": "0.0001", // "minPrice": null, // "maxPrice": null, // "deliveryDate": 1669879634000, // "deliveryPrice": null, // "deliveryCompletion": false, // "cnDesc": null, // "enDesc": null // }, // ] // } // const swapAndFutureMarkets = this.arrayConcat(this.safeValue(markets[0], 'result', []), this.safeValue(markets[1], 'result', [])); return this.parseMarkets(swapAndFutureMarkets); } parseMarkets(markets) { const result = []; for (let i = 0; i < markets.length; i++) { result.push(this.parseMarket(markets[i])); } return result; } parseMarket(market) { // // spot // // { // "id": 640, // "symbol": "xt_usdt", // "state": "ONLINE", // "stateTime": 1554048000000, // "tradingEnabled": true, // "openapiEnabled": true, // "nextStateTime": null, // "nextState": null, // "depthMergePrecision": 5, // "baseCurrency": "xt", // "baseCurrencyPrecision": 8, // "baseCurrencyId": 128, // "quoteCurrency": "usdt", // "quoteCurrencyPrecision": 8, // "quoteCurrencyId": 11, // "pricePrecision": 4, // "quantityPrecision": 2, // "orderTypes": ["LIMIT","MARKET"], // "timeInForces": ["GTC","IOC"], // "displayWeight": 10002, // "displayLevel": "FULL", // "plates": [], // "filters":[ // { // "filter": "QUOTE_QTY", // "min": "1" // }, // { // "filter": "PRICE", // "min": null, //