sfccxt
Version:
A JavaScript / Python / PHP cryptocurrency trading library with support for 130+ exchanges
950 lines (945 loc) • 341 kB
JavaScript
'use strict';
// ---------------------------------------------------------------------------
const Exchange = require ('./base/Exchange');
const { ExchangeError, ArgumentsRequired, ExchangeNotAvailable, InsufficientFunds, OrderNotFound, InvalidOrder, DDoSProtection, InvalidNonce, AuthenticationError, RateLimitExceeded, PermissionDenied, NotSupported, BadRequest, BadSymbol, AccountSuspended, OrderImmediatelyFillable, OnMaintenance, BadResponse, RequestTimeout, OrderNotFillable, MarginModeAlreadySet } = require ('./base/errors');
const { TRUNCATE, DECIMAL_PLACES } = require ('./base/functions/number');
const Precise = require ('./base/Precise');
// ---------------------------------------------------------------------------
module.exports = class binance extends Exchange {
describe () {
return this.deepExtend (super.describe (), {
'id': 'binance',
'name': 'Binance',
'countries': [ 'JP', 'MT' ], // Japan, Malta
'rateLimit': 50,
'certified': true,
'pro': true,
// new metainfo interface
'has': {
'CORS': undefined,
'spot': true,
'margin': true,
'swap': true,
'future': true,
'option': undefined,
'addMargin': true,
'borrowMargin': true,
'cancelAllOrders': true,
'cancelOrder': true,
'cancelOrders': undefined,
'createDepositAddress': false,
'createOrder': true,
'createReduceOnlyOrder': true,
'createStopLimitOrder': true,
'createStopMarketOrder': false,
'createStopOrder': true,
'editOrder': true,
'fetchAccounts': undefined,
'fetchBalance': true,
'fetchBidsAsks': true,
'fetchBorrowInterest': true,
'fetchBorrowRate': true,
'fetchBorrowRateHistories': false,
'fetchBorrowRateHistory': true,
'fetchBorrowRates': false,
'fetchBorrowRatesPerSymbol': false,
'fetchCanceledOrders': false,
'fetchClosedOrder': false,
'fetchClosedOrders': 'emulated',
'fetchCurrencies': true,
'fetchDeposit': false,
'fetchDepositAddress': true,
'fetchDepositAddresses': false,
'fetchDepositAddressesByNetwork': false,
'fetchDeposits': true,
'fetchDepositWithdrawFee': 'emulated',
'fetchDepositWithdrawFees': true,
'fetchFundingHistory': true,
'fetchFundingRate': true,
'fetchFundingRateHistory': true,
'fetchFundingRates': true,
'fetchIndexOHLCV': true,
'fetchL3OrderBook': false,
'fetchLedger': undefined,
'fetchLeverage': false,
'fetchLeverageTiers': true,
'fetchMarketLeverageTiers': 'emulated',
'fetchMarkets': true,
'fetchMarkOHLCV': true,
'fetchMyTrades': true,
'fetchOHLCV': true,
'fetchOpenInterestHistory': true,
'fetchOpenOrder': false,
'fetchOpenOrders': true,
'fetchOrder': true,
'fetchOrderBook': true,
'fetchOrderBooks': false,
'fetchOrders': true,
'fetchOrderTrades': true,
'fetchPosition': undefined,
'fetchPositions': true,
'fetchPositionsRisk': true,
'fetchPremiumIndexOHLCV': false,
'fetchStatus': true,
'fetchTicker': true,
'fetchTickers': true,
'fetchTime': true,
'fetchTrades': true,
'fetchTradingFee': true,
'fetchTradingFees': true,
'fetchTradingLimits': undefined,
'fetchTransactionFee': undefined,
'fetchTransactionFees': true,
'fetchTransactions': false,
'fetchTransfers': true,
'fetchWithdrawal': false,
'fetchWithdrawals': true,
'fetchWithdrawalWhitelist': false,
'reduceMargin': true,
'repayMargin': true,
'setLeverage': true,
'setMargin': false,
'setMarginMode': true,
'setPositionMode': true,
'signIn': false,
'transfer': true,
'withdraw': true,
},
'timeframes': {
'1s': '1s', // spot only for now
'1m': '1m',
'3m': '3m',
'5m': '5m',
'15m': '15m',
'30m': '30m',
'1h': '1h',
'2h': '2h',
'4h': '4h',
'6h': '6h',
'8h': '8h',
'12h': '12h',
'1d': '1d',
'3d': '3d',
'1w': '1w',
'1M': '1M',
},
'urls': {
'logo': 'https://user-images.githubusercontent.com/1294454/29604020-d5483cdc-87ee-11e7-94c7-d1a8d9169293.jpg',
'test': {
'dapiPublic': 'https://testnet.binancefuture.com/dapi/v1',
'dapiPrivate': 'https://testnet.binancefuture.com/dapi/v1',
'eapiPublic': 'https://testnet.binanceops.com/eapi/v1',
'eapiPrivate': 'https://testnet.binanceops.com/eapi/v1',
'fapiPublic': 'https://testnet.binancefuture.com/fapi/v1',
'fapiPrivate': 'https://testnet.binancefuture.com/fapi/v1',
'fapiPrivateV2': 'https://testnet.binancefuture.com/fapi/v2',
'public': 'https://testnet.binance.vision/api/v3',
'private': 'https://testnet.binance.vision/api/v3',
'v1': 'https://testnet.binance.vision/api/v1',
},
'api': {
'wapi': 'https://api.binance.com/wapi/v3',
'sapi': 'https://api.binance.com/sapi/v1',
'sapiV2': 'https://api.binance.com/sapi/v2',
'sapiV3': 'https://api.binance.com/sapi/v3',
'dapiPublic': 'https://dapi.binance.com/dapi/v1',
'dapiPrivate': 'https://dapi.binance.com/dapi/v1',
'eapiPublic': 'https://eapi.binance.com/eapi/v1',
'eapiPrivate': 'https://eapi.binance.com/eapi/v1',
'dapiPrivateV2': 'https://dapi.binance.com/dapi/v2',
'dapiData': 'https://dapi.binance.com/futures/data',
'fapiPublic': 'https://fapi.binance.com/fapi/v1',
'fapiPrivate': 'https://fapi.binance.com/fapi/v1',
'fapiData': 'https://fapi.binance.com/futures/data',
'fapiPrivateV2': 'https://fapi.binance.com/fapi/v2',
'public': 'https://api.binance.com/api/v3',
'private': 'https://api.binance.com/api/v3',
'v1': 'https://api.binance.com/api/v1',
},
'www': 'https://www.binance.com',
'referral': {
'url': 'https://accounts.binance.com/en/register?ref=D7YA7CLY',
'discount': 0.1,
},
'doc': [
'https://binance-docs.github.io/apidocs/spot/en',
],
'api_management': 'https://www.binance.com/en/usercenter/settings/api-management',
'fees': 'https://www.binance.com/en/fee/schedule',
},
'depth': 1,
'api': {
// the API structure below will need 3-layer apidefs
'sapi': {
// IP (api) = 1200 per minute => (rateLimit = 50)
// IP (sapi) request rate limit of 12 000 per minute
// 1 IP (sapi) => cost = 0.1
// 10 IP (sapi) => cost = 1
// UID (sapi) request rate limit of 180 000 per minute
// 1 UID (sapi) => cost = 1200 / 180 000 = 0.006667
'get': {
'system/status': 0.1,
// these endpoints require this.apiKey
'accountSnapshot': 240, // Weight(IP): 2400 => cost = 0.1 * 2400 = 240
'margin/asset': 1, // Weight(IP): 10 => cost = 0.1 * 10 = 1
'margin/pair': 1,
'margin/allAssets': 0.1,
'margin/allPairs': 0.1,
'margin/priceIndex': 1,
// these endpoints require this.apiKey + this.secret
'asset/assetDividend': 1,
'asset/dribblet': 0.1,
'asset/transfer': 0.1,
'asset/assetDetail': 0.1,
'asset/tradeFee': 0.1,
'asset/ledger-transfer/cloud-mining/queryByPage': 4,
'margin/loan': 1,
'margin/repay': 1,
'margin/account': 1,
'margin/transfer': 0.1,
'margin/interestHistory': 0.1,
'margin/forceLiquidationRec': 0.1,
'margin/order': 1,
'margin/openOrders': 1,
'margin/allOrders': 20, // Weight(IP): 200 => cost = 0.1 * 200 = 20
'margin/myTrades': 1,
'margin/maxBorrowable': 5, // Weight(IP): 50 => cost = 0.1 * 50 = 5
'margin/maxTransferable': 5,
'margin/tradeCoeff': 1,
'margin/isolated/transfer': 0.1,
'margin/isolated/account': 1,
'margin/isolated/pair': 1,
'margin/isolated/allPairs': 1,
'margin/isolated/accountLimit': 0.1,
'margin/interestRateHistory': 0.1,
'margin/orderList': 1,
'margin/allOrderList': 20, // Weight(IP): 200 => cost = 0.1 * 200 = 20
'margin/openOrderList': 1,
'margin/crossMarginData': { 'cost': 0.1, 'noCoin': 0.5 },
'margin/isolatedMarginData': { 'cost': 0.1, 'noCoin': 1 },
'margin/isolatedMarginTier': 0.1,
'margin/rateLimit/order': 2,
'margin/dribblet': 0.1,
'loan/income': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'loan/ongoing/orders': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/ltv/adjustment/history': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/borrow/history': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/repay/history': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/loanable/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/collateral/data': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/repay/collateral/rate': 600, // Weight(IP): 6000 => cost = 0.1 * 6000 = 600
'loan/vip/ongoing/orders': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/vip/repay/history': 40, // Weight(IP): 400 => cost = 0.1 * 400 = 40
'loan/vip/collateral/account': 600, // Weight(IP): 6000 => cost = 0.1 * 6000 = 600
'fiat/orders': 600.03, // Weight(UID): 90000 => cost = 0.006667 * 90000 = 600.03
'fiat/payments': 0.1,
'futures/transfer': 1,
'futures/loan/borrow/history': 1,
'futures/loan/repay/history': 1,
'futures/loan/wallet': 1,
'futures/loan/adjustCollateral/history': 1,
'futures/loan/liquidationHistory': 1,
'rebate/taxQuery': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
// https://binance-docs.github.io/apidocs/spot/en/#withdraw-sapi
'capital/config/getall': 1, // get networks for withdrawing USDT ERC20 vs USDT Omni
'capital/deposit/address': 1,
'capital/deposit/hisrec': 0.1,
'capital/deposit/subAddress': 0.1,
'capital/deposit/subHisrec': 0.1,
'capital/withdraw/history': 0.1,
'convert/tradeFlow': 0.6667, // Weight(UID): 100 => cost = 0.006667 * 100 = 0.6667
'convert/exchangeInfo': 50,
'convert/assetInfo': 10,
'convert/orderStatus': 0.6667,
'account/status': 0.1,
'account/apiTradingStatus': 0.1,
'account/apiRestrictions/ipRestriction': 0.1,
'bnbBurn': 0.1,
// 'sub-account/assets': 1, (v3 endpoint)
'sub-account/futures/account': 1,
'sub-account/futures/accountSummary': 0.1,
'sub-account/futures/positionRisk': 1,
'sub-account/futures/internalTransfer': 0.1,
'sub-account/list': 0.1,
'sub-account/margin/account': 1,
'sub-account/margin/accountSummary': 1,
'sub-account/spotSummary': 0.1,
'sub-account/status': 1,
'sub-account/sub/transfer/history': 0.1,
'sub-account/transfer/subUserHistory': 0.1,
'sub-account/universalTransfer': 0.1,
'sub-account/apiRestrictions/ipRestriction/thirdPartyList': 1,
'managed-subaccount/asset': 0.1,
'managed-subaccount/accountSnapshot': 240,
// lending endpoints
'lending/daily/product/list': 0.1,
'lending/daily/userLeftQuota': 0.1,
'lending/daily/userRedemptionQuota': 0.1,
'lending/daily/token/position': 0.1,
'lending/union/account': 0.1,
'lending/union/purchaseRecord': 0.1,
'lending/union/redemptionRecord': 0.1,
'lending/union/interestHistory': 0.1,
'lending/project/list': 0.1,
'lending/project/position/list': 0.1,
// mining endpoints
'mining/pub/algoList': 0.1,
'mining/pub/coinList': 0.1,
'mining/worker/detail': 0.5, // Weight(IP): 5 => cost = 0.1 * 5 = 0.5
'mining/worker/list': 0.5,
'mining/payment/list': 0.5,
'mining/statistics/user/status': 0.5,
'mining/statistics/user/list': 0.5,
'mining/payment/uid': 0.5,
// liquid swap endpoints
'bswap/pools': 0.1,
'bswap/liquidity': { 'cost': 0.1, 'noPoolId': 1 },
'bswap/liquidityOps': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
'bswap/quote': 1.00005, // Weight(UID): 150 => cost = 0.006667 * 150 = 1.00005
'bswap/swap': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
'bswap/poolConfigure': 1.00005, // Weight(UID): 150 => cost = 0.006667 * 150 = 1.00005
'bswap/addLiquidityPreview': 1.00005, // Weight(UID): 150 => cost = 0.006667 * 150 = 1.00005
'bswap/removeLiquidityPreview': 1.00005, // Weight(UID): 150 => cost = 0.006667 * 150 = 1.00005
'bswap/unclaimedRewards': 6.667, // Weight(UID): 1000 => cost = 0.006667 * 1000 = 6.667
'bswap/claimedHistory': 6.667, // Weight(UID): 1000 => cost = 0.006667 * 1000 = 6.667
// leveraged token endpoints
'blvt/tokenInfo': 0.1,
'blvt/subscribe/record': 0.1,
'blvt/redeem/record': 0.1,
'blvt/userLimit': 0.1,
// broker api TODO (NOT IN DOCS)
'apiReferral/ifNewUser': 1,
'apiReferral/customization': 1,
'apiReferral/userCustomization': 1,
'apiReferral/rebate/recentRecord': 1,
'apiReferral/rebate/historicalRecord': 1,
'apiReferral/kickback/recentRecord': 1,
'apiReferral/kickback/historicalRecord': 1,
// brokerage API TODO https://binance-docs.github.io/Brokerage-API/General/ does not state ratelimits
'broker/subAccountApi': 1,
'broker/subAccount': 1,
'broker/subAccountApi/commission/futures': 1,
'broker/subAccountApi/commission/coinFutures': 1,
'broker/info': 1,
'broker/transfer': 1,
'broker/transfer/futures': 1,
'broker/rebate/recentRecord': 1,
'broker/rebate/historicalRecord': 1,
'broker/subAccount/bnbBurn/status': 1,
'broker/subAccount/depositHist': 1,
'broker/subAccount/spotSummary': 1,
'broker/subAccount/marginSummary': 1,
'broker/subAccount/futuresSummary': 1,
'broker/rebate/futures/recentRecord': 1,
'broker/subAccountApi/ipRestriction': 1,
'broker/universalTransfer': 1,
// v2 not supported yet
// GET /sapi/v2/broker/subAccount/futuresSummary
'account/apiRestrictions': 0.1,
// c2c / p2p
'c2c/orderMatch/listUserOrderHistory': 0.1,
// nft endpoints
'nft/history/transactions': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
'nft/history/deposit': 20.001,
'nft/history/withdraw': 20.001,
'nft/user/getAsset': 20.001,
'pay/transactions': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
'giftcard/verify': 0.1,
'giftcard/cryptography/rsa-public-key': 0.1,
'giftcard/buyCode/token-limit': 0.1,
'algo/futures/openOrders': 0.1,
'algo/futures/historicalOrders': 0.1,
'algo/futures/subOrders': 0.1,
'portfolio/account': 0.1,
'portfolio/collateralRate': 5,
'portfolio/pmLoan': 3.3335,
// staking
'staking/productList': 0.1,
'staking/position': 0.1,
'staking/stakingRecord': 0.1,
'staking/personalLeftQuota': 0.1,
},
'post': {
'asset/dust': 1,
'asset/dust-btc': 0.1,
'asset/transfer': 0.1,
'asset/get-funding-asset': 0.1,
'asset/convert-transfer': 0.033335,
'asset/convert-transfer/queryByPage': 0.033335,
'account/disableFastWithdrawSwitch': 0.1,
'account/enableFastWithdrawSwitch': 0.1,
// 'account/apiRestrictions/ipRestriction': 1, discontinued
// 'account/apiRestrictions/ipRestriction/ipList': 1, discontinued
'capital/withdraw/apply': 4.0002, // Weight(UID): 600 => cost = 0.006667 * 600 = 4.0002
'margin/transfer': 1, // Weight(IP): 600 => cost = 0.1 * 600 = 60
'margin/loan': 20.001, // Weight(UID): 3000 => cost = 0.006667 * 3000 = 20.001
'margin/repay': 20.001,
'margin/order': 0.040002, // Weight(UID): 6 => cost = 0.006667 * 6 = 0.040002
'margin/order/oco': 0.040002,
// 'margin/isolated/create': 1, discontinued
'margin/isolated/transfer': 4.0002, // Weight(UID): 600 => cost = 0.006667 * 600 = 4.0002
'margin/isolated/account': 2.0001, // Weight(UID): 300 => cost = 0.006667 * 300 = 2.0001
'bnbBurn': 0.1,
'sub-account/virtualSubAccount': 0.1,
'sub-account/margin/transfer': 4.0002, // Weight(UID): 600 => cost = 0.006667 * 600 = 4.0002
'sub-account/margin/enable': 0.1,
'sub-account/futures/enable': 0.1,
'sub-account/futures/transfer': 0.1,
'sub-account/futures/internalTransfer': 0.1,
'sub-account/transfer/subToSub': 0.1,
'sub-account/transfer/subToMaster': 0.1,
'sub-account/universalTransfer': 0.1,
// v2 not supported yet
// 'sub-account/subAccountApi/ipRestriction': 20,
'managed-subaccount/deposit': 0.1,
'managed-subaccount/withdraw': 0.1,
'userDataStream': 0.1,
'userDataStream/isolated': 0.1,
'futures/transfer': 0.1,
// lending
'lending/customizedFixed/purchase': 0.1,
'lending/daily/purchase': 0.1,
'lending/daily/redeem': 0.1,
// liquid swap endpoints
'bswap/liquidityAdd': 60, // Weight(UID): 1000 + (Additional: 1 request every 3 seconds = 0.333 requests per second) => cost = ( 1000 / rateLimit ) / 0.333 = 60.0000006
'bswap/liquidityRemove': 60, // Weight(UID): 1000 + (Additional: 1 request every three seconds)
'bswap/swap': 60, // Weight(UID): 1000 + (Additional: 1 request every three seconds)
'bswap/claimRewards': 6.667, // Weight(UID): 1000 => cost = 0.006667 * 1000 = 6.667
// leveraged token endpoints
'blvt/subscribe': 0.1,
'blvt/redeem': 0.1,
// brokerage API TODO: NO MENTION OF RATELIMITS IN BROKERAGE DOCS
'apiReferral/customization': 1,
'apiReferral/userCustomization': 1,
'apiReferral/rebate/historicalRecord': 1,
'apiReferral/kickback/historicalRecord': 1,
'broker/subAccount': 1,
'broker/subAccount/margin': 1,
'broker/subAccount/futures': 1,
'broker/subAccountApi': 1,
'broker/subAccountApi/permission': 1,
'broker/subAccountApi/commission': 1,
'broker/subAccountApi/commission/futures': 1,
'broker/subAccountApi/commission/coinFutures': 1,
'broker/transfer': 1,
'broker/transfer/futures': 1,
'broker/rebate/historicalRecord': 1,
'broker/subAccount/bnbBurn/spot': 1,
'broker/subAccount/bnbBurn/marginInterest': 1,
'broker/subAccount/blvt': 1,
'broker/subAccountApi/ipRestriction': 1,
'broker/subAccountApi/ipRestriction/ipList': 1,
'broker/universalTransfer': 1,
'broker/subAccountApi/permission/universalTransfer': 1,
'broker/subAccountApi/permission/vanillaOptions': 1,
//
'giftcard/createCode': 0.1,
'giftcard/redeemCode': 0.1,
'giftcard/buyCode': 0.1,
'algo/futures/newOrderVp': 20.001,
'algo/futures/newOrderTwap': 20.001,
// staking
'staking/purchase': 0.1,
'staking/redeem': 0.1,
'staking/setAutoStaking': 0.1,
'portfolio/repay': 20.001,
'loan/borrow': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'loan/repay': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'loan/adjust/ltv': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'loan/customize/margin_call': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'loan/vip/repay': 40, // Weight(UID): 6000 => cost = 0.006667 * 6000 = 40
'convert/getQuote': 20.001,
'convert/acceptQuote': 3.3335,
},
'put': {
'userDataStream': 0.1,
'userDataStream/isolated': 0.1,
},
'delete': {
// 'account/apiRestrictions/ipRestriction/ipList': 1, discontinued
'margin/openOrders': 0.1,
'margin/order': 0.0066667, // Weight(UID): 1 => cost = 0.006667
'margin/orderList': 0.0066667,
'margin/isolated/account': 2.0001, // Weight(UID): 300 => cost = 0.006667 * 300 = 2.0001
'userDataStream': 0.1,
'userDataStream/isolated': 0.1,
// brokerage API TODO NO MENTION OF RATELIMIT IN BROKERAGE DOCS
'broker/subAccountApi': 1,
'broker/subAccountApi/ipRestriction/ipList': 1,
'algo/futures/order': 0.1,
},
},
'sapiV2': {
'get': {
'sub-account/futures/account': 0.1,
'sub-account/futures/positionRisk': 0.1,
},
},
'sapiV3': {
'get': {
'sub-account/assets': 1,
},
'post': {
'asset/getUserAsset': 0.5,
},
},
// deprecated
'wapi': {
'post': {
'withdraw': 1,
'sub-account/transfer': 1,
},
'get': {
'depositHistory': 1,
'withdrawHistory': 1,
'depositAddress': 1,
'accountStatus': 1,
'systemStatus': 1,
'apiTradingStatus': 1,
'userAssetDribbletLog': 1,
'tradeFee': 1,
'assetDetail': 1,
'sub-account/list': 1,
'sub-account/transfer/history': 1,
'sub-account/assets': 1,
},
},
'dapiPublic': {
'get': {
'ping': 1,
'time': 1,
'exchangeInfo': 1,
'depth': { 'cost': 2, 'byLimit': [ [ 50, 2 ], [ 100, 5 ], [ 500, 10 ], [ 1000, 20 ] ] },
'trades': 5,
'historicalTrades': 20,
'aggTrades': 20,
'premiumIndex': 10,
'fundingRate': 1,
'klines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'continuousKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'indexPriceKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'markPriceKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
'ticker/price': { 'cost': 1, 'noSymbol': 2 },
'ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
'openInterest': 1,
'pmExchangeInfo': 1,
},
},
'dapiData': {
'get': {
'openInterestHist': 1,
'topLongShortAccountRatio': 1,
'topLongShortPositionRatio': 1,
'globalLongShortAccountRatio': 1,
'takerBuySellVol': 1,
'basis': 1,
},
},
'dapiPrivate': {
'get': {
'positionSide/dual': 30,
'order': 1,
'openOrder': 1,
'openOrders': { 'cost': 1, 'noSymbol': 5 },
'allOrders': { 'cost': 20, 'noSymbol': 40 },
'balance': 1,
'account': 5,
'positionMargin/history': 1,
'positionRisk': 1,
'userTrades': { 'cost': 20, 'noSymbol': 40 },
'income': 20,
'leverageBracket': 1,
'forceOrders': { 'cost': 20, 'noSymbol': 50 },
'adlQuantile': 5,
'orderAmendment': 1,
'pmAccountInfo': 5,
},
'post': {
'positionSide/dual': 1,
'order': 4,
'batchOrders': 5,
'countdownCancelAll': 10,
'leverage': 1,
'marginType': 1,
'positionMargin': 1,
'listenKey': 1,
},
'put': {
'listenKey': 1,
'order': 1,
'batchOrders': 5,
},
'delete': {
'order': 1,
'allOpenOrders': 1,
'batchOrders': 5,
'listenKey': 1,
},
},
'dapiPrivateV2': {
'get': {
'leverageBracket': 1,
},
},
'fapiPublic': {
'get': {
'ping': 1,
'time': 1,
'exchangeInfo': 1,
'depth': { 'cost': 2, 'byLimit': [ [ 50, 2 ], [ 100, 5 ], [ 500, 10 ], [ 1000, 20 ] ] },
'trades': 5,
'historicalTrades': 20,
'aggTrades': 20,
'klines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'continuousKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'markPriceKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'indexPriceKlines': { 'cost': 1, 'byLimit': [ [ 99, 1 ], [ 499, 2 ], [ 1000, 5 ], [ 10000, 10 ] ] },
'fundingRate': 1,
'premiumIndex': 1,
'ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
'ticker/price': { 'cost': 1, 'noSymbol': 2 },
'ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
'openInterest': 1,
'indexInfo': 1,
'apiTradingStatus': { 'cost': 1, 'noSymbol': 10 },
'lvtKlines': 1,
'pmExchangeInfo': 1,
},
},
'fapiData': {
'get': {
'openInterestHist': 1,
'topLongShortAccountRatio': 1,
'topLongShortPositionRatio': 1,
'globalLongShortAccountRatio': 1,
'takerlongshortRatio': 1,
},
},
'fapiPrivate': {
'get': {
'forceOrders': { 'cost': 20, 'noSymbol': 50 },
'allOrders': 5,
'openOrder': 1,
'openOrders': 1,
'order': 1,
'account': 5,
'balance': 5,
'leverageBracket': 1,
'positionMargin/history': 1,
'positionRisk': 5,
'positionSide/dual': 30,
'userTrades': 5,
'income': 30,
'commissionRate': 20,
'apiTradingStatus': 1,
'multiAssetsMargin': 30,
// broker endpoints
'apiReferral/ifNewUser': 1,
'apiReferral/customization': 1,
'apiReferral/userCustomization': 1,
'apiReferral/traderNum': 1,
'apiReferral/overview': 1,
'apiReferral/tradeVol': 1,
'apiReferral/rebateVol': 1,
'apiReferral/traderSummary': 1,
'adlQuantile': 5,
'pmAccountInfo': 5,
},
'post': {
'batchOrders': 5,
'positionSide/dual': 1,
'positionMargin': 1,
'marginType': 1,
'order': 4,
'leverage': 1,
'listenKey': 1,
'countdownCancelAll': 10,
'multiAssetsMargin': 1,
// broker endpoints
'apiReferral/customization': 1,
'apiReferral/userCustomization': 1,
},
'put': {
'listenKey': 1,
},
'delete': {
'batchOrders': 1,
'order': 1,
'allOpenOrders': 1,
'listenKey': 1,
},
},
'fapiPrivateV2': {
'get': {
'account': 1,
'balance': 1,
'positionRisk': 1,
},
},
'eapiPublic': {
'get': {
'ping': 1,
'time': 1,
'exchangeInfo': 1,
'index': 1,
'ticker': 5,
'mark': 5,
'depth': 1,
'klines': 1,
'trades': 5,
'historicalTrades': 20,
'exerciseHistory': 3,
'openInterest': 3,
},
},
'eapiPrivate': {
'get': {
'account': 3,
'position': 5,
'openOrders': { 'cost': 1, 'noSymbol': 40 },
'historyOrders': 3,
'userTrades': 5,
'exerciseRecord': 5,
'bill': 1,
'marginAccount': 3,
'mmp': 1,
'countdownCancelAll': 1,
},
'post': {
'transfer': 1,
'order': 1,
'batchOrders': 5,
'listenKey': 1,
'mmpSet': 1,
'mmpReset': 1,
'countdownCancelAll': 1,
'countdownCancelAllHeartBeat': 10,
},
'put': {
'listenKey': 1,
},
'delete': {
'order': 1,
'batchOrders': 1,
'allOpenOrders': 1,
'allOpenOrdersByUnderlying': 1,
'listenKey': 1,
},
},
'public': {
'get': {
'ping': 1,
'time': 1,
'depth': { 'cost': 1, 'byLimit': [ [ 100, 1 ], [ 500, 5 ], [ 1000, 10 ], [ 5000, 50 ] ] },
'trades': 1,
'aggTrades': 1,
'historicalTrades': 5,
'klines': 1,
'ticker/24hr': { 'cost': 1, 'noSymbol': 40 },
'ticker/price': { 'cost': 1, 'noSymbol': 2 },
'ticker/bookTicker': { 'cost': 1, 'noSymbol': 2 },
'exchangeInfo': 10,
},
'put': {
'userDataStream': 1,
},
'post': {
'userDataStream': 1,
},
'delete': {
'userDataStream': 1,
},
},
'private': {
'get': {
'allOrderList': 10, // oco
'openOrderList': 3, // oco
'orderList': 2, // oco
'order': 2,
'openOrders': { 'cost': 3, 'noSymbol': 40 },
'allOrders': 10,
'account': 10,
'myTrades': 10,
'rateLimit/order': 20,
},
'post': {
'order/oco': 1,
'order': 1,
'order/cancelReplace': 1,
'order/test': 1,
},
'delete': {
'openOrders': 1, // added on 2020-04-25 for canceling all open orders per symbol
'orderList': 1, // oco
'order': 1,
},
},
},
'fees': {
'trading': {
'feeSide': 'get',
'tierBased': false,
'percentage': true,
'taker': this.parseNumber ('0.001'),
'maker': this.parseNumber ('0.001'),
},
'future': {
'trading': {
'feeSide': 'quote',
'tierBased': true,
'percentage': true,
'taker': this.parseNumber ('0.000400'),
'maker': this.parseNumber ('0.000200'),
'tiers': {
'taker': [
[ this.parseNumber ('0'), this.parseNumber ('0.000400') ],
[ this.parseNumber ('250'), this.parseNumber ('0.000400') ],
[ this.parseNumber ('2500'), this.parseNumber ('0.000350') ],
[ this.parseNumber ('7500'), this.parseNumber ('0.000320') ],
[ this.parseNumber ('22500'), this.parseNumber ('0.000300') ],
[ this.parseNumber ('50000'), this.parseNumber ('0.000270') ],
[ this.parseNumber ('100000'), this.parseNumber ('0.000250') ],
[ this.parseNumber ('200000'), this.parseNumber ('0.000220') ],
[ this.parseNumber ('400000'), this.parseNumber ('0.000200') ],
[ this.parseNumber ('750000'), this.parseNumber ('0.000170') ],
],
'maker': [
[ this.parseNumber ('0'), this.parseNumber ('0.000200') ],
[ this.parseNumber ('250'), this.parseNumber ('0.000160') ],
[ this.parseNumber ('2500'), this.parseNumber ('0.000140') ],
[ this.parseNumber ('7500'), this.parseNumber ('0.000120') ],
[ this.parseNumber ('22500'), this.parseNumber ('0.000100') ],
[ this.parseNumber ('50000'), this.parseNumber ('0.000080') ],
[ this.parseNumber ('100000'), this.parseNumber ('0.000060') ],
[ this.parseNumber ('200000'), this.parseNumber ('0.000040') ],
[ this.parseNumber ('400000'), this.parseNumber ('0.000020') ],
[ this.parseNumber ('750000'), this.parseNumber ('0') ],
],
},
},
},
'delivery': {
'trading': {
'feeSide': 'base',
'tierBased': true,
'percentage': true,
'taker': this.parseNumber ('0.000500'),
'maker': this.parseNumber ('0.000100'),
'tiers': {
'taker': [
[ this.parseNumber ('0'), this.parseNumber ('0.000500') ],
[ this.parseNumber ('250'), this.parseNumber ('0.000450') ],
[ this.parseNumber ('2500'), this.parseNumber ('0.000400') ],
[ this.parseNumber ('7500'), this.parseNumber ('0.000300') ],
[ this.parseNumber ('22500'), this.parseNumber ('0.000250') ],
[ this.parseNumber ('50000'), this.parseNumber ('0.000240') ],
[ this.parseNumber ('100000'), this.parseNumber ('0.000240') ],
[ this.parseNumber ('200000'), this.parseNumber ('0.000240') ],
[ this.parseNumber ('400000'), this.parseNumber ('0.000240') ],
[ this.parseNumber ('750000'), this.parseNumber ('0.000240') ],
],
'maker': [
[ this.parseNumber ('0'), this.parseNumber ('0.000100') ],
[ this.parseNumber ('250'), this.parseNumber ('0.000080') ],
[ this.parseNumber ('2500'), this.parseNumber ('0.000050') ],
[ this.parseNumber ('7500'), this.parseNumber ('0.0000030') ],
[ this.parseNumber ('22500'), this.parseNumber ('0') ],
[ this.parseNumber ('50000'), this.parseNumber ('-0.000050') ],
[ this.parseNumber ('100000'), this.parseNumber ('-0.000060') ],
[ this.parseNumber ('200000'), this.parseNumber ('-0.000070') ],
[ this.parseNumber ('400000'), this.parseNumber ('-0.000080') ],
[ this.parseNumber ('750000'), this.parseNumber ('-0.000090') ],
],
},
},
},
'option': {},
},
'commonCurrencies': {
'BCC': 'BCC', // kept for backward-compatibility https://github.com/ccxt/ccxt/issues/4848
'YOYO': 'YOYOW',
},
'precisionMode': DECIMAL_PLACES,
// exchange-specific options
'options': {
'fetchCurrencies': true, // this is a private call and it requires API keys
// 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades
'defaultTimeInForce': 'GTC', // 'GTC' = Good To Cancel (default), 'IOC' = Immediate Or Cancel
'defaultType': 'spot', // 'spot', 'future', 'margin', 'delivery'
'hasAlreadyAuthenticatedSuccessfully': false,
'warnOnFetchOpenOrdersWithoutSymbol': true,
// not an error
// https://github.com/ccxt/ccxt/issues/11268
// https://github.com/ccxt/ccxt/pull/11624
// POST https://fapi.binance.com/fapi/v1/marginType 400 Bad Request
// binanceusdm
'throwMarginModeAlreadySet': false,
'fetchPositions': 'positionRisk', // or 'account'
'recvWindow': 10 * 1000, // 10 sec
'timeDifference': 0, // the difference between system clock and Binance clock
'adjustForTimeDifference': false, // controls the adjustment logic upon instantiation
'newOrderRespType': {
'market': 'FULL', // 'ACK' for order id, 'RESULT' for full order or 'FULL' for order with fills
'limit': 'FULL', // we change it from 'ACK' by default to 'FULL' (returns immediately if limit is not hit)
},
'quoteOrderQty': true, // whether market orders support amounts in quote currency
'broker': {
'spot': 'x-R4BD3S82',
'margin': 'x-R4BD3S82',
'future': 'x-xcKtGhcu',
'delivery': 'x-xcKtGhcu',
},
'accountsByType': {
'main': 'MAIN',
'spot': 'MAIN',
'funding': 'FUNDING',
'margin': 'MARGIN',
'cross': 'MARGIN',
'future': 'UMFUTURE',
'delivery': 'CMFUTURE',
},
'accountsById': {
'MAIN': 'spot',
'FUNDING': 'funding',
'MARGIN': 'margin',
'UMFUTURE': 'future',
'CMFUTURE': 'delivery',
},
'networks': {
'ERC20': 'ETH',
'TRC20': 'TRX',
'BEP2': 'BNB',
'BEP20': 'BSC',
'OMNI': 'OMNI',
'EOS': 'EOS',
'SPL': 'SOL',
},
// keeping this object for backward-compatibility
'reverseNetworks': {
'tronscan.org': 'TRC20',
'etherscan.io': 'ERC20',
'bscscan.com': 'BSC',
'explorer.binance.org': 'BEP2',
'bithomp.com': 'XRP',
'bloks.io': 'EOS',
'stellar.expert': 'XLM',
'blockchair.com/bitcoin': 'BTC',
'blockchair.com/bitcoin-cash': 'BCH',
'blockchair.com/ecash': 'XEC',
'explorer.litecoin.net': 'LTC',
'explorer.avax.network': 'AVAX',
'solscan.io': 'SOL',
'polkadot.subscan.io': 'DOT',
'dashboard.internetcomputer.org': 'ICP',
'explorer.chiliz.com': 'CHZ',
'cardanoscan.io': 'ADA',
'mainnet.theoan.com': 'AION',
'algoexplorer.io': 'ALGO',
'explorer.ambrosus.com': 'AMB',
'viewblock.io/zilliqa': 'ZIL',
'viewblock.io/arweave': 'AR',
'explorer.ark.io': 'ARK',
'atomscan.com': 'ATOM',
'www.mintscan.io': 'CTK',
'explorer.bitcoindiamond.org': 'BCD',