ccxt-look 1.81.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/eslintcache +1 -0
- package/.dockerignore +6 -0
- package/.eslintignore +1 -0
- package/.gitattributes +5 -0
- package/.readthedocs.yaml +16 -0
- package/CONTRIBUTING.md +1049 -0
- package/LICENSE.txt +21 -0
- package/README.md +537 -0
- package/SECURITY.md +5 -0
- package/build/cleanup-old-tags.js +94 -0
- package/build/countries.js +256 -0
- package/build/export-exchanges.js +520 -0
- package/build/fs.js +51 -0
- package/build/transpile.js +1772 -0
- package/build/vss.js +78 -0
- package/ccxt.browser.js +7 -0
- package/ccxt.d.ts +692 -0
- package/ccxt.js +171 -0
- package/cleanup.sh +2 -0
- package/composer-install.sh +20 -0
- package/dist/ccxt.browser.js +208383 -0
- package/gource.sh +3 -0
- package/index.html +7 -0
- package/js/.eslintrc +87 -0
- package/js/aax.js +2686 -0
- package/js/ascendex.js +2584 -0
- package/js/base/.eslintrc.js +43 -0
- package/js/base/Exchange.js +2371 -0
- package/js/base/Precise.js +283 -0
- package/js/base/errorHierarchy.js +47 -0
- package/js/base/errors.js +55 -0
- package/js/base/functions/crypto.js +158 -0
- package/js/base/functions/encode.js +118 -0
- package/js/base/functions/generic.js +270 -0
- package/js/base/functions/misc.js +138 -0
- package/js/base/functions/number.js +329 -0
- package/js/base/functions/platform.js +38 -0
- package/js/base/functions/string.js +21 -0
- package/js/base/functions/throttle.js +79 -0
- package/js/base/functions/time.js +210 -0
- package/js/base/functions/type.js +66 -0
- package/js/base/functions.js +28 -0
- package/js/bequant.js +32 -0
- package/js/bibox.js +1407 -0
- package/js/bigone.js +1366 -0
- package/js/binance.js +5652 -0
- package/js/binancecoinm.js +46 -0
- package/js/binanceus.js +46 -0
- package/js/binanceusdm.js +49 -0
- package/js/bit2c.js +535 -0
- package/js/bitbank.js +842 -0
- package/js/bitbay.js +16 -0
- package/js/bitbns.js +1073 -0
- package/js/bitcoincom.js +15 -0
- package/js/bitfinex.js +1433 -0
- package/js/bitfinex2.js +2025 -0
- package/js/bitflyer.js +840 -0
- package/js/bitforex.js +614 -0
- package/js/bitget.js +2397 -0
- package/js/bithumb.js +980 -0
- package/js/bitmart.js +2516 -0
- package/js/bitmex.js +1809 -0
- package/js/bitopro.js +1443 -0
- package/js/bitpanda.js +1782 -0
- package/js/bitrue.js +1747 -0
- package/js/bitso.js +1062 -0
- package/js/bitstamp.js +1757 -0
- package/js/bitstamp1.js +343 -0
- package/js/bittrex.js +1876 -0
- package/js/bitvavo.js +1579 -0
- package/js/bkex.js +1233 -0
- package/js/bl3p.js +346 -0
- package/js/blockchaincom.js +969 -0
- package/js/btcalpha.js +680 -0
- package/js/btcbox.js +477 -0
- package/js/btcmarkets.js +1022 -0
- package/js/btctradeua.js +466 -0
- package/js/btcturk.js +734 -0
- package/js/buda.js +946 -0
- package/js/bw.js +1265 -0
- package/js/bybit.js +3372 -0
- package/js/bytetrade.js +1336 -0
- package/js/cdax.js +1646 -0
- package/js/cex.js +1410 -0
- package/js/coinbase.js +1342 -0
- package/js/coinbaseprime.js +31 -0
- package/js/coinbasepro.js +1466 -0
- package/js/coincheck.js +755 -0
- package/js/coinex.js +3400 -0
- package/js/coinfalcon.js +880 -0
- package/js/coinmate.js +794 -0
- package/js/coinone.js +816 -0
- package/js/coinspot.js +345 -0
- package/js/crex24.js +1636 -0
- package/js/cryptocom.js +1832 -0
- package/js/currencycom.js +1748 -0
- package/js/delta.js +1547 -0
- package/js/deribit.js +2148 -0
- package/js/digifinex.js +1585 -0
- package/js/eqonex.js +1660 -0
- package/js/exmo.js +1670 -0
- package/js/fairdesk.js +1231 -0
- package/js/flowbtc.js +35 -0
- package/js/fmfwio.js +34 -0
- package/js/ftx.js +2751 -0
- package/js/ftxus.js +38 -0
- package/js/gateio.js +4174 -0
- package/js/gemini.js +1397 -0
- package/js/hitbtc.js +1343 -0
- package/js/hitbtc3.js +2329 -0
- package/js/hollaex.js +1486 -0
- package/js/huobi.js +5706 -0
- package/js/huobijp.js +1710 -0
- package/js/huobipro.js +18 -0
- package/js/idex.js +1439 -0
- package/js/independentreserve.js +649 -0
- package/js/indodax.js +742 -0
- package/js/itbit.js +722 -0
- package/js/kraken.js +2179 -0
- package/js/kucoin.js +2571 -0
- package/js/kucoinfutures.js +1771 -0
- package/js/kuna.js +809 -0
- package/js/latoken.js +1445 -0
- package/js/lbank.js +760 -0
- package/js/liquid.js +1432 -0
- package/js/luno.js +873 -0
- package/js/lykke.js +1147 -0
- package/js/mercado.js +771 -0
- package/js/mexc.js +3151 -0
- package/js/ndax.js +2233 -0
- package/js/novadax.js +1318 -0
- package/js/oceanex.js +816 -0
- package/js/okcoin.js +3841 -0
- package/js/okex.js +16 -0
- package/js/okex5.js +16 -0
- package/js/okx.js +4795 -0
- package/js/paymium.js +498 -0
- package/js/phemex.js +2957 -0
- package/js/poloniex.js +1674 -0
- package/js/probit.js +1346 -0
- package/js/qtrade.js +1588 -0
- package/js/ripio.js +1061 -0
- package/js/static_dependencies/BN/bn.js +3526 -0
- package/js/static_dependencies/README.md +1 -0
- package/js/static_dependencies/crypto-js/crypto-js.js +5988 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/base.js +375 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/edwards.js +433 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/index.js +8 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/mont.js +180 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curve/short.js +938 -0
- package/js/static_dependencies/elliptic/lib/elliptic/curves.js +204 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/index.js +240 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/key.js +119 -0
- package/js/static_dependencies/elliptic/lib/elliptic/ec/signature.js +24 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/index.js +145 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/key.js +100 -0
- package/js/static_dependencies/elliptic/lib/elliptic/eddsa/signature.js +65 -0
- package/js/static_dependencies/elliptic/lib/elliptic/precomputed/secp256k1.js +780 -0
- package/js/static_dependencies/elliptic/lib/elliptic/utils.js +214 -0
- package/js/static_dependencies/elliptic/lib/elliptic.js +22 -0
- package/js/static_dependencies/elliptic/lib/hmac-drbg/hmac-drbg.js +114 -0
- package/js/static_dependencies/fetch-ponyfill/fetch-node.js +39 -0
- package/js/static_dependencies/node-fetch/index.js +1564 -0
- package/js/static_dependencies/node-rsa/NodeRSA.js +223 -0
- package/js/static_dependencies/node-rsa/asn1/ber/errors.js +13 -0
- package/js/static_dependencies/node-rsa/asn1/ber/index.js +21 -0
- package/js/static_dependencies/node-rsa/asn1/ber/reader.js +262 -0
- package/js/static_dependencies/node-rsa/asn1/ber/types.js +36 -0
- package/js/static_dependencies/node-rsa/asn1/index.js +17 -0
- package/js/static_dependencies/node-rsa/encryptEngines/js.js +34 -0
- package/js/static_dependencies/node-rsa/formats/components.js +71 -0
- package/js/static_dependencies/node-rsa/formats/formats.js +31 -0
- package/js/static_dependencies/node-rsa/formats/pkcs1.js +148 -0
- package/js/static_dependencies/node-rsa/formats/pkcs8.js +187 -0
- package/js/static_dependencies/node-rsa/libs/jsbn.js +1252 -0
- package/js/static_dependencies/node-rsa/libs/rsa.js +147 -0
- package/js/static_dependencies/node-rsa/schemes/pkcs1.js +176 -0
- package/js/static_dependencies/node-rsa/schemes/schemes.js +21 -0
- package/js/static_dependencies/node-rsa/utils.js +98 -0
- package/js/static_dependencies/qs/formats.js +18 -0
- package/js/static_dependencies/qs/index.js +11 -0
- package/js/static_dependencies/qs/parse.js +242 -0
- package/js/static_dependencies/qs/stringify.js +269 -0
- package/js/static_dependencies/qs/utils.js +230 -0
- package/js/stex.js +1925 -0
- package/js/test/.eslintrc.js +42 -0
- package/js/test/Exchange/test.balance.js +61 -0
- package/js/test/Exchange/test.borrowRate.js +32 -0
- package/js/test/Exchange/test.currency.js +52 -0
- package/js/test/Exchange/test.fetchBalance.js +23 -0
- package/js/test/Exchange/test.fetchBorrowInterest.js +59 -0
- package/js/test/Exchange/test.fetchBorrowRate.js +32 -0
- package/js/test/Exchange/test.fetchBorrowRates.js +28 -0
- package/js/test/Exchange/test.fetchClosedOrders.js +32 -0
- package/js/test/Exchange/test.fetchCurrencies.js +35 -0
- package/js/test/Exchange/test.fetchDeposits.js +31 -0
- package/js/test/Exchange/test.fetchFundingFees.js +19 -0
- package/js/test/Exchange/test.fetchFundingRateHistory.js +40 -0
- package/js/test/Exchange/test.fetchL2OrderBook.js +23 -0
- package/js/test/Exchange/test.fetchLedger.js +42 -0
- package/js/test/Exchange/test.fetchLeverageTiers.js +33 -0
- package/js/test/Exchange/test.fetchMarketLeverageTiers.js +22 -0
- package/js/test/Exchange/test.fetchMarkets.js +33 -0
- package/js/test/Exchange/test.fetchMyTrades.js +42 -0
- package/js/test/Exchange/test.fetchOHLCV.js +46 -0
- package/js/test/Exchange/test.fetchOpenOrders.js +36 -0
- package/js/test/Exchange/test.fetchOrderBook.js +25 -0
- package/js/test/Exchange/test.fetchOrderBooks.js +35 -0
- package/js/test/Exchange/test.fetchOrders.js +41 -0
- package/js/test/Exchange/test.fetchPositions.js +47 -0
- package/js/test/Exchange/test.fetchStatus.js +35 -0
- package/js/test/Exchange/test.fetchTicker.js +38 -0
- package/js/test/Exchange/test.fetchTickers.js +49 -0
- package/js/test/Exchange/test.fetchTrades.js +39 -0
- package/js/test/Exchange/test.fetchTradingFee.js +18 -0
- package/js/test/Exchange/test.fetchTradingFees.js +22 -0
- package/js/test/Exchange/test.fetchTransactions.js +31 -0
- package/js/test/Exchange/test.fetchWithdrawals.js +31 -0
- package/js/test/Exchange/test.ledgerItem.js +46 -0
- package/js/test/Exchange/test.leverageTier.js +33 -0
- package/js/test/Exchange/test.loadMarkets.js +35 -0
- package/js/test/Exchange/test.market.js +129 -0
- package/js/test/Exchange/test.ohlcv.js +33 -0
- package/js/test/Exchange/test.order.js +62 -0
- package/js/test/Exchange/test.orderbook.js +61 -0
- package/js/test/Exchange/test.position.js +21 -0
- package/js/test/Exchange/test.throttle.js +94 -0
- package/js/test/Exchange/test.ticker.js +95 -0
- package/js/test/Exchange/test.trade.js +68 -0
- package/js/test/Exchange/test.tradingFee.js +34 -0
- package/js/test/Exchange/test.transaction.js +35 -0
- package/js/test/base/.eslintrc +38 -0
- package/js/test/base/functions/test.crypto.js +110 -0
- package/js/test/base/functions/test.datetime.js +62 -0
- package/js/test/base/functions/test.generic.js +152 -0
- package/js/test/base/functions/test.number.js +362 -0
- package/js/test/base/functions/test.time.js +56 -0
- package/js/test/base/functions/test.type.js +53 -0
- package/js/test/base/test.base.js +193 -0
- package/js/test/errors/test.InsufficientFunds.js +86 -0
- package/js/test/errors/test.InvalidNonce.js +64 -0
- package/js/test/errors/test.InvalidOrder.js +35 -0
- package/js/test/errors/test.OrderNotFound.js +39 -0
- package/js/test/test.js +426 -0
- package/js/test/test.timeout_hang.js +12 -0
- package/js/therock.js +1431 -0
- package/js/tidebit.js +632 -0
- package/js/tidex.js +939 -0
- package/js/timex.js +1283 -0
- package/js/upbit.js +1622 -0
- package/js/vcc.js +1353 -0
- package/js/wavesexchange.js +2185 -0
- package/js/wazirx.js +732 -0
- package/js/whitebit.js +1352 -0
- package/js/woo.js +1577 -0
- package/js/xena.js +1948 -0
- package/js/yobit.js +1129 -0
- package/js/zaif.js +647 -0
- package/js/zb.js +4088 -0
- package/js/zipmex.js +40 -0
- package/js/zonda.js +1497 -0
- package/multilang.sh +159 -0
- package/package.json +591 -0
- package/postinstall.js +103 -0
package/js/bitbns.js
ADDED
@@ -0,0 +1,1073 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ArgumentsRequired, InsufficientFunds, OrderNotFound, BadRequest, BadSymbol } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class bitbns extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'bitbns',
|
15
|
+
'name': 'Bitbns',
|
16
|
+
'countries': [ 'IN' ], // India
|
17
|
+
'rateLimit': 1000,
|
18
|
+
'certified': false,
|
19
|
+
'pro': false,
|
20
|
+
'version': 'v2',
|
21
|
+
// new metainfo interface
|
22
|
+
'has': {
|
23
|
+
'CORS': undefined,
|
24
|
+
'spot': true,
|
25
|
+
'margin': undefined, // has but unimplemented
|
26
|
+
'swap': false,
|
27
|
+
'future': false,
|
28
|
+
'option': undefined, // coming soon
|
29
|
+
'cancelOrder': true,
|
30
|
+
'createOrder': true,
|
31
|
+
'fetchBalance': true,
|
32
|
+
'fetchDepositAddress': true,
|
33
|
+
'fetchDeposits': true,
|
34
|
+
'fetchFundingHistory': false,
|
35
|
+
'fetchFundingRate': false,
|
36
|
+
'fetchFundingRateHistory': false,
|
37
|
+
'fetchFundingRates': false,
|
38
|
+
'fetchIndexOHLCV': false,
|
39
|
+
'fetchMarkets': true,
|
40
|
+
'fetchMarkOHLCV': false,
|
41
|
+
'fetchMyTrades': true,
|
42
|
+
'fetchOHLCV': undefined,
|
43
|
+
'fetchOpenOrders': true,
|
44
|
+
'fetchOrder': true,
|
45
|
+
'fetchOrderBook': true,
|
46
|
+
'fetchPremiumIndexOHLCV': false,
|
47
|
+
'fetchStatus': true,
|
48
|
+
'fetchTicker': 'emulated',
|
49
|
+
'fetchTickers': true,
|
50
|
+
'fetchTrades': true,
|
51
|
+
'fetchTradingFee': false,
|
52
|
+
'fetchTradingFees': false,
|
53
|
+
'fetchTransfer': false,
|
54
|
+
'fetchTransfers': false,
|
55
|
+
'fetchWithdrawal': false,
|
56
|
+
'fetchWithdrawals': true,
|
57
|
+
'transfer': false,
|
58
|
+
'withdraw': false,
|
59
|
+
},
|
60
|
+
'timeframes': {
|
61
|
+
},
|
62
|
+
'urls': {
|
63
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/117201933-e7a6e780-adf5-11eb-9d80-98fc2a21c3d6.jpg',
|
64
|
+
'api': {
|
65
|
+
'www': 'https://bitbns.com',
|
66
|
+
'v1': 'https://api.bitbns.com/api/trade/v1',
|
67
|
+
'v2': 'https://api.bitbns.com/api/trade/v2',
|
68
|
+
},
|
69
|
+
'www': 'https://bitbns.com',
|
70
|
+
'referral': 'https://ref.bitbns.com/1090961',
|
71
|
+
'doc': [
|
72
|
+
'https://bitbns.com/trade/#/api-trading/',
|
73
|
+
],
|
74
|
+
'fees': 'https://bitbns.com/fees',
|
75
|
+
},
|
76
|
+
'api': {
|
77
|
+
'www': {
|
78
|
+
'get': [
|
79
|
+
'order/fetchMarkets',
|
80
|
+
'order/fetchTickers',
|
81
|
+
'order/fetchOrderbook',
|
82
|
+
'order/getTickerWithVolume',
|
83
|
+
'exchangeData/ohlc', // ?coin=${coin_name}&page=${page}
|
84
|
+
'exchangeData/orderBook',
|
85
|
+
'exchangeData/tradedetails',
|
86
|
+
],
|
87
|
+
},
|
88
|
+
'v1': {
|
89
|
+
'get': [
|
90
|
+
'platform/status',
|
91
|
+
'tickers',
|
92
|
+
'orderbook/sell/{symbol}',
|
93
|
+
'orderbook/buy/{symbol}',
|
94
|
+
],
|
95
|
+
'post': [
|
96
|
+
'currentCoinBalance/EVERYTHING',
|
97
|
+
'getApiUsageStatus/USAGE',
|
98
|
+
'getOrderSocketToken/USAGE',
|
99
|
+
'currentCoinBalance/{symbol}',
|
100
|
+
'orderStatus/{symbol}',
|
101
|
+
'depositHistory/{symbol}',
|
102
|
+
'withdrawHistory/{symbol}',
|
103
|
+
'withdrawHistoryAll/{symbol}',
|
104
|
+
'depositHistoryAll/{symbol}',
|
105
|
+
'listOpenOrders/{symbol}',
|
106
|
+
'listOpenStopOrders/{symbol}',
|
107
|
+
'getCoinAddress/{symbol}',
|
108
|
+
'placeSellOrder/{symbol}',
|
109
|
+
'placeBuyOrder/{symbol}',
|
110
|
+
'buyStopLoss/{symbol}',
|
111
|
+
'sellStopLoss/{symbol}',
|
112
|
+
'placeSellOrder/{symbol}',
|
113
|
+
'cancelOrder/{symbol}',
|
114
|
+
'cancelStopLossOrder/{symbol}',
|
115
|
+
'listExecutedOrders/{symbol}',
|
116
|
+
'placeMarketOrder/{symbol}',
|
117
|
+
'placeMarketOrderQnty/{symbol}',
|
118
|
+
],
|
119
|
+
},
|
120
|
+
'v2': {
|
121
|
+
'post': [
|
122
|
+
'orders',
|
123
|
+
'cancel',
|
124
|
+
'getordersnew',
|
125
|
+
'marginOrders',
|
126
|
+
],
|
127
|
+
},
|
128
|
+
},
|
129
|
+
'fees': {
|
130
|
+
'trading': {
|
131
|
+
'feeSide': 'quote',
|
132
|
+
'tierBased': false,
|
133
|
+
'percentage': true,
|
134
|
+
'taker': this.parseNumber ('0.0025'),
|
135
|
+
'maker': this.parseNumber ('0.0025'),
|
136
|
+
},
|
137
|
+
},
|
138
|
+
'exceptions': {
|
139
|
+
'exact': {
|
140
|
+
'400': BadRequest, // {"msg":"Invalid Request","status":-1,"code":400}
|
141
|
+
'409': BadSymbol, // {"data":"","status":0,"error":"coin name not supplied or not yet supported","code":409}
|
142
|
+
'416': InsufficientFunds, // {"data":"Oops ! Not sufficient currency to sell","status":0,"error":null,"code":416}
|
143
|
+
'417': OrderNotFound, // {"data":[],"status":0,"error":"Nothing to show","code":417}
|
144
|
+
},
|
145
|
+
'broad': {},
|
146
|
+
},
|
147
|
+
});
|
148
|
+
}
|
149
|
+
|
150
|
+
async fetchStatus (params = {}) {
|
151
|
+
const response = await this.v1GetPlatformStatus (params);
|
152
|
+
//
|
153
|
+
// {
|
154
|
+
// "data":{
|
155
|
+
// "BTC":{"status":1},
|
156
|
+
// "ETH":{"status":1},
|
157
|
+
// "XRP":{"status":1},
|
158
|
+
// },
|
159
|
+
// "status":1,
|
160
|
+
// "error":null,
|
161
|
+
// "code":200
|
162
|
+
// }
|
163
|
+
//
|
164
|
+
const statusRaw = this.safeString (response, 'status');
|
165
|
+
return {
|
166
|
+
'status': this.safeString ({ '1': 'ok' }, statusRaw, statusRaw),
|
167
|
+
'updated': this.milliseconds (),
|
168
|
+
'eta': undefined,
|
169
|
+
'url': undefined,
|
170
|
+
'info': response,
|
171
|
+
};
|
172
|
+
}
|
173
|
+
|
174
|
+
async fetchMarkets (params = {}) {
|
175
|
+
const response = await this.wwwGetOrderFetchMarkets (params);
|
176
|
+
//
|
177
|
+
// [
|
178
|
+
// {
|
179
|
+
// "id":"BTC",
|
180
|
+
// "symbol":"BTC/INR",
|
181
|
+
// "base":"BTC",
|
182
|
+
// "quote":"INR",
|
183
|
+
// "baseId":"BTC",
|
184
|
+
// "quoteId":"",
|
185
|
+
// "active":true,
|
186
|
+
// "limits":{
|
187
|
+
// "amount":{"min":"0.00017376","max":20},
|
188
|
+
// "price":{"min":2762353.2359999996,"max":6445490.883999999},
|
189
|
+
// "cost":{"min":800,"max":128909817.67999998}
|
190
|
+
// },
|
191
|
+
// "precision":{
|
192
|
+
// "amount":8,
|
193
|
+
// "price":2
|
194
|
+
// },
|
195
|
+
// "info":{}
|
196
|
+
// },
|
197
|
+
// ]
|
198
|
+
//
|
199
|
+
const result = [];
|
200
|
+
for (let i = 0; i < response.length; i++) {
|
201
|
+
const market = response[i];
|
202
|
+
const id = this.safeString (market, 'id');
|
203
|
+
const baseId = this.safeString (market, 'base');
|
204
|
+
const quoteId = this.safeString (market, 'quote');
|
205
|
+
const base = this.safeCurrencyCode (baseId);
|
206
|
+
const quote = this.safeCurrencyCode (quoteId);
|
207
|
+
const marketPrecision = this.safeValue (market, 'precision', {});
|
208
|
+
const marketLimits = this.safeValue (market, 'limits', {});
|
209
|
+
const amountLimits = this.safeValue (marketLimits, 'amount', {});
|
210
|
+
const priceLimits = this.safeValue (marketLimits, 'price', {});
|
211
|
+
const costLimits = this.safeValue (marketLimits, 'cost', {});
|
212
|
+
const usdt = (quoteId === 'USDT');
|
213
|
+
// INR markets don't need a _INR prefix
|
214
|
+
const uppercaseId = usdt ? (baseId + '_' + quoteId) : baseId;
|
215
|
+
result.push ({
|
216
|
+
'id': id,
|
217
|
+
'uppercaseId': uppercaseId,
|
218
|
+
'symbol': base + '/' + quote,
|
219
|
+
'base': base,
|
220
|
+
'quote': quote,
|
221
|
+
'settle': undefined,
|
222
|
+
'baseId': baseId,
|
223
|
+
'quoteId': quoteId,
|
224
|
+
'settleId': undefined,
|
225
|
+
'type': 'spot',
|
226
|
+
'spot': true,
|
227
|
+
'margin': false,
|
228
|
+
'swap': false,
|
229
|
+
'future': false,
|
230
|
+
'option': false,
|
231
|
+
'active': undefined,
|
232
|
+
'contract': false,
|
233
|
+
'linear': undefined,
|
234
|
+
'inverse': undefined,
|
235
|
+
'contractSize': undefined,
|
236
|
+
'expiry': undefined,
|
237
|
+
'expiryDatetime': undefined,
|
238
|
+
'strike': undefined,
|
239
|
+
'optionType': undefined,
|
240
|
+
'precision': {
|
241
|
+
'amount': this.safeInteger (marketPrecision, 'amount'),
|
242
|
+
'price': this.safeInteger (marketPrecision, 'price'),
|
243
|
+
},
|
244
|
+
'limits': {
|
245
|
+
'leverage': {
|
246
|
+
'min': undefined,
|
247
|
+
'max': undefined,
|
248
|
+
},
|
249
|
+
'amount': {
|
250
|
+
'min': this.safeNumber (amountLimits, 'min'),
|
251
|
+
'max': this.safeNumber (amountLimits, 'max'),
|
252
|
+
},
|
253
|
+
'price': {
|
254
|
+
'min': this.safeNumber (priceLimits, 'min'),
|
255
|
+
'max': this.safeNumber (priceLimits, 'max'),
|
256
|
+
},
|
257
|
+
'cost': {
|
258
|
+
'min': this.safeNumber (costLimits, 'min'),
|
259
|
+
'max': this.safeNumber (costLimits, 'max'),
|
260
|
+
},
|
261
|
+
},
|
262
|
+
'info': market,
|
263
|
+
});
|
264
|
+
}
|
265
|
+
return result;
|
266
|
+
}
|
267
|
+
|
268
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
269
|
+
await this.loadMarkets ();
|
270
|
+
const market = this.market (symbol);
|
271
|
+
const request = {
|
272
|
+
'symbol': market['id'],
|
273
|
+
};
|
274
|
+
if (limit !== undefined) {
|
275
|
+
request['limit'] = limit; // default 100, max 5000, see https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#order-book
|
276
|
+
}
|
277
|
+
const response = await this.wwwGetOrderFetchOrderbook (this.extend (request, params));
|
278
|
+
//
|
279
|
+
// {
|
280
|
+
// "bids":[
|
281
|
+
// [49352.04,0.843948],
|
282
|
+
// [49352.03,0.742048],
|
283
|
+
// [49349.78,0.686239],
|
284
|
+
// ],
|
285
|
+
// "asks":[
|
286
|
+
// [49443.59,0.065137],
|
287
|
+
// [49444.63,0.098211],
|
288
|
+
// [49449.01,0.066309],
|
289
|
+
// ],
|
290
|
+
// "timestamp":1619172786577,
|
291
|
+
// "datetime":"2021-04-23T10:13:06.577Z",
|
292
|
+
// "nonce":""
|
293
|
+
// }
|
294
|
+
//
|
295
|
+
const timestamp = this.safeInteger (response, 'timestamp');
|
296
|
+
return this.parseOrderBook (response, symbol, timestamp);
|
297
|
+
}
|
298
|
+
|
299
|
+
parseTicker (ticker, market = undefined) {
|
300
|
+
//
|
301
|
+
// {
|
302
|
+
// "symbol":"BTC/INR",
|
303
|
+
// "info":{
|
304
|
+
// "highest_buy_bid":4368494.31,
|
305
|
+
// "lowest_sell_bid":4374835.09,
|
306
|
+
// "last_traded_price":4374835.09,
|
307
|
+
// "yes_price":4531016.27,
|
308
|
+
// "volume":{"max":"4569119.23","min":"4254552.13","volume":62.17722344}
|
309
|
+
// },
|
310
|
+
// "timestamp":1619100020845,
|
311
|
+
// "datetime":1619100020845,
|
312
|
+
// "high":"4569119.23",
|
313
|
+
// "low":"4254552.13",
|
314
|
+
// "bid":4368494.31,
|
315
|
+
// "bidVolume":"",
|
316
|
+
// "ask":4374835.09,
|
317
|
+
// "askVolume":"",
|
318
|
+
// "vwap":"",
|
319
|
+
// "open":4531016.27,
|
320
|
+
// "close":4374835.09,
|
321
|
+
// "last":4374835.09,
|
322
|
+
// "baseVolume":62.17722344,
|
323
|
+
// "quoteVolume":"",
|
324
|
+
// "previousClose":"",
|
325
|
+
// "change":-156181.1799999997,
|
326
|
+
// "percentage":-3.446934874943623,
|
327
|
+
// "average":4452925.68
|
328
|
+
// }
|
329
|
+
//
|
330
|
+
const timestamp = this.safeInteger (ticker, 'timestamp');
|
331
|
+
const marketId = this.safeString (ticker, 'symbol');
|
332
|
+
const symbol = this.safeSymbol (marketId, market);
|
333
|
+
const last = this.safeString (ticker, 'last');
|
334
|
+
return this.safeTicker ({
|
335
|
+
'symbol': symbol,
|
336
|
+
'timestamp': timestamp,
|
337
|
+
'datetime': this.iso8601 (timestamp),
|
338
|
+
'high': this.safeString (ticker, 'high'),
|
339
|
+
'low': this.safeString (ticker, 'low'),
|
340
|
+
'bid': this.safeString (ticker, 'bid'),
|
341
|
+
'bidVolume': this.safeString (ticker, 'bidVolume'),
|
342
|
+
'ask': this.safeString (ticker, 'ask'),
|
343
|
+
'askVolume': this.safeString (ticker, 'askVolume'),
|
344
|
+
'vwap': this.safeString (ticker, 'vwap'),
|
345
|
+
'open': this.safeString (ticker, 'open'),
|
346
|
+
'close': last,
|
347
|
+
'last': last,
|
348
|
+
'previousClose': this.safeString (ticker, 'previousClose'), // previous day close
|
349
|
+
'change': this.safeString (ticker, 'change'),
|
350
|
+
'percentage': this.safeString (ticker, 'percentage'),
|
351
|
+
'average': this.safeString (ticker, 'average'),
|
352
|
+
'baseVolume': this.safeString (ticker, 'baseVolume'),
|
353
|
+
'quoteVolume': this.safeString (ticker, 'quoteVolume'),
|
354
|
+
'info': ticker,
|
355
|
+
}, market, false);
|
356
|
+
}
|
357
|
+
|
358
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
359
|
+
await this.loadMarkets ();
|
360
|
+
const response = await this.wwwGetOrderFetchTickers (params);
|
361
|
+
//
|
362
|
+
// {
|
363
|
+
// "BTC/INR":{
|
364
|
+
// "symbol":"BTC/INR",
|
365
|
+
// "info":{
|
366
|
+
// "highest_buy_bid":4368494.31,
|
367
|
+
// "lowest_sell_bid":4374835.09,
|
368
|
+
// "last_traded_price":4374835.09,
|
369
|
+
// "yes_price":4531016.27,
|
370
|
+
// "volume":{"max":"4569119.23","min":"4254552.13","volume":62.17722344}
|
371
|
+
// },
|
372
|
+
// "timestamp":1619100020845,
|
373
|
+
// "datetime":1619100020845,
|
374
|
+
// "high":"4569119.23",
|
375
|
+
// "low":"4254552.13",
|
376
|
+
// "bid":4368494.31,
|
377
|
+
// "bidVolume":"",
|
378
|
+
// "ask":4374835.09,
|
379
|
+
// "askVolume":"",
|
380
|
+
// "vwap":"",
|
381
|
+
// "open":4531016.27,
|
382
|
+
// "close":4374835.09,
|
383
|
+
// "last":4374835.09,
|
384
|
+
// "baseVolume":62.17722344,
|
385
|
+
// "quoteVolume":"",
|
386
|
+
// "previousClose":"",
|
387
|
+
// "change":-156181.1799999997,
|
388
|
+
// "percentage":-3.446934874943623,
|
389
|
+
// "average":4452925.68
|
390
|
+
// }
|
391
|
+
// }
|
392
|
+
//
|
393
|
+
return this.parseTickers (response, symbols);
|
394
|
+
}
|
395
|
+
|
396
|
+
parseBalance (response) {
|
397
|
+
const timestamp = undefined;
|
398
|
+
const result = {
|
399
|
+
'info': response,
|
400
|
+
'timestamp': timestamp,
|
401
|
+
'datetime': this.iso8601 (timestamp),
|
402
|
+
};
|
403
|
+
const data = this.safeValue (response, 'data', {});
|
404
|
+
const keys = Object.keys (data);
|
405
|
+
for (let i = 0; i < keys.length; i++) {
|
406
|
+
const key = keys[i];
|
407
|
+
const parts = key.split ('availableorder');
|
408
|
+
const numParts = parts.length;
|
409
|
+
if (numParts > 1) {
|
410
|
+
const currencyId = this.safeString (parts, 1);
|
411
|
+
if (currencyId !== 'Money') {
|
412
|
+
const code = this.safeCurrencyCode (currencyId);
|
413
|
+
const account = this.account ();
|
414
|
+
account['free'] = this.safeString (data, key);
|
415
|
+
account['used'] = this.safeString (data, 'inorder' + currencyId);
|
416
|
+
result[code] = account;
|
417
|
+
}
|
418
|
+
}
|
419
|
+
}
|
420
|
+
return this.safeBalance (result);
|
421
|
+
}
|
422
|
+
|
423
|
+
async fetchBalance (params = {}) {
|
424
|
+
await this.loadMarkets ();
|
425
|
+
const response = await this.v1PostCurrentCoinBalanceEVERYTHING (params);
|
426
|
+
//
|
427
|
+
// {
|
428
|
+
// "data":{
|
429
|
+
// "availableorderMoney":0,
|
430
|
+
// "availableorderBTC":0,
|
431
|
+
// "availableorderXRP":0,
|
432
|
+
// "inorderMoney":0,
|
433
|
+
// "inorderBTC":0,
|
434
|
+
// "inorderXRP":0,
|
435
|
+
// "inorderNEO":0,
|
436
|
+
// },
|
437
|
+
// "status":1,
|
438
|
+
// "error":null,
|
439
|
+
// "code":200
|
440
|
+
// }
|
441
|
+
//
|
442
|
+
return this.parseBalance (response);
|
443
|
+
}
|
444
|
+
|
445
|
+
parseOrderStatus (status) {
|
446
|
+
const statuses = {
|
447
|
+
'0': 'open',
|
448
|
+
// 'PARTIALLY_FILLED': 'open',
|
449
|
+
// 'FILLED': 'closed',
|
450
|
+
// 'CANCELED': 'canceled',
|
451
|
+
// 'PENDING_CANCEL': 'canceling', // currently unused
|
452
|
+
// 'REJECTED': 'rejected',
|
453
|
+
// 'EXPIRED': 'expired',
|
454
|
+
};
|
455
|
+
return this.safeString (statuses, status, status);
|
456
|
+
}
|
457
|
+
|
458
|
+
parseOrder (order, market = undefined) {
|
459
|
+
//
|
460
|
+
// createOrder
|
461
|
+
//
|
462
|
+
// {
|
463
|
+
// "data":"Successfully placed bid to purchase currency",
|
464
|
+
// "status":1,
|
465
|
+
// "error":null,
|
466
|
+
// "id":5424475,
|
467
|
+
// "code":200
|
468
|
+
// }
|
469
|
+
//
|
470
|
+
// fetchOrder
|
471
|
+
//
|
472
|
+
// {
|
473
|
+
// "entry_id":5424475,
|
474
|
+
// "btc":0.01,
|
475
|
+
// "rate":2000,
|
476
|
+
// "time":"2021-04-25T17:05:42.000Z",
|
477
|
+
// "type":0,
|
478
|
+
// "status":0,
|
479
|
+
// "total":0.01,
|
480
|
+
// "avg_cost":null,
|
481
|
+
// "side":"BUY",
|
482
|
+
// "amount":0.01,
|
483
|
+
// "remaining":0.01,
|
484
|
+
// "filled":0,
|
485
|
+
// "cost":null,
|
486
|
+
// "fee":0.05
|
487
|
+
// }
|
488
|
+
//
|
489
|
+
// fetchOpenOrders
|
490
|
+
//
|
491
|
+
// {
|
492
|
+
// "entry_id":5424475,
|
493
|
+
// "btc":0.01,
|
494
|
+
// "rate":2000,
|
495
|
+
// "time":"2021-04-25T17:05:42.000Z",
|
496
|
+
// "type":0,
|
497
|
+
// "status":0
|
498
|
+
// }
|
499
|
+
//
|
500
|
+
const id = this.safeString2 (order, 'id', 'entry_id');
|
501
|
+
const marketId = this.safeString (order, 'symbol');
|
502
|
+
const symbol = this.safeSymbol (marketId, market);
|
503
|
+
const timestamp = this.parse8601 (this.safeString (order, 'time'));
|
504
|
+
const price = this.safeString (order, 'rate');
|
505
|
+
const amount = this.safeString2 (order, 'amount', 'btc');
|
506
|
+
const filled = this.safeString (order, 'filled');
|
507
|
+
const remaining = this.safeString (order, 'remaining');
|
508
|
+
const average = this.safeString (order, 'avg_cost');
|
509
|
+
const cost = this.safeString (order, 'cost');
|
510
|
+
let type = this.safeStringLower (order, 'type');
|
511
|
+
if (type === '0') {
|
512
|
+
type = 'limit';
|
513
|
+
}
|
514
|
+
const status = this.parseOrderStatus (this.safeString (order, 'status'));
|
515
|
+
const side = this.safeStringLower (order, 'side');
|
516
|
+
const feeCost = this.safeNumber (order, 'fee');
|
517
|
+
let fee = undefined;
|
518
|
+
if (feeCost !== undefined) {
|
519
|
+
const feeCurrencyCode = undefined;
|
520
|
+
fee = {
|
521
|
+
'cost': feeCost,
|
522
|
+
'currency': feeCurrencyCode,
|
523
|
+
};
|
524
|
+
}
|
525
|
+
return this.safeOrder ({
|
526
|
+
'info': order,
|
527
|
+
'id': id,
|
528
|
+
'clientOrderId': undefined,
|
529
|
+
'timestamp': timestamp,
|
530
|
+
'datetime': this.iso8601 (timestamp),
|
531
|
+
'lastTradeTimestamp': undefined,
|
532
|
+
'symbol': symbol,
|
533
|
+
'type': type,
|
534
|
+
'timeInForce': undefined,
|
535
|
+
'postOnly': undefined,
|
536
|
+
'side': side,
|
537
|
+
'price': price,
|
538
|
+
'stopPrice': undefined,
|
539
|
+
'amount': amount,
|
540
|
+
'cost': cost,
|
541
|
+
'average': average,
|
542
|
+
'filled': filled,
|
543
|
+
'remaining': remaining,
|
544
|
+
'status': status,
|
545
|
+
'fee': fee,
|
546
|
+
'trades': undefined,
|
547
|
+
}, market);
|
548
|
+
}
|
549
|
+
|
550
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
551
|
+
if (type !== 'limit' && type !== 'market') {
|
552
|
+
throw new ExchangeError (this.id + ' allows limit and market orders only');
|
553
|
+
}
|
554
|
+
await this.loadMarkets ();
|
555
|
+
const market = this.market (symbol);
|
556
|
+
const request = {
|
557
|
+
'side': side.toUpperCase (),
|
558
|
+
'symbol': market['uppercaseId'],
|
559
|
+
'quantity': this.amountToPrecision (symbol, amount),
|
560
|
+
// 'target_rate': this.priceToPrecision (symbol, targetRate),
|
561
|
+
// 't_rate': this.priceToPrecision (symbol, stopPrice),
|
562
|
+
// 'trail_rate': this.priceToPrecision (symbol, trailRate),
|
563
|
+
// To Place Simple Buy or Sell Order use rate
|
564
|
+
// To Place Stoploss Buy or Sell Order use rate & t_rate
|
565
|
+
// To Place Bracket Buy or Sell Order use rate , t_rate, target_rate & trail_rate
|
566
|
+
};
|
567
|
+
let method = 'v2PostOrders';
|
568
|
+
if (type === 'limit') {
|
569
|
+
request['rate'] = this.priceToPrecision (symbol, price);
|
570
|
+
} else if (type === 'market') {
|
571
|
+
method = 'v1PostPlaceMarketOrderQntySymbol';
|
572
|
+
request['market'] = market['quoteId'];
|
573
|
+
} else {
|
574
|
+
throw new ExchangeError (this.id + ' allows limit and market orders only');
|
575
|
+
}
|
576
|
+
const response = await this[method] (this.extend (request, params));
|
577
|
+
//
|
578
|
+
// {
|
579
|
+
// "data":"Successfully placed bid to purchase currency",
|
580
|
+
// "status":1,
|
581
|
+
// "error":null,
|
582
|
+
// "id":5424475,
|
583
|
+
// "code":200
|
584
|
+
// }
|
585
|
+
//
|
586
|
+
return this.parseOrder (response, market);
|
587
|
+
}
|
588
|
+
|
589
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
590
|
+
if (symbol === undefined) {
|
591
|
+
throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument');
|
592
|
+
}
|
593
|
+
await this.loadMarkets ();
|
594
|
+
const market = this.market (symbol);
|
595
|
+
const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtcancelOrder' : 'cancelOrder';
|
596
|
+
const request = {
|
597
|
+
'entry_id': id,
|
598
|
+
'symbol': market['uppercaseId'],
|
599
|
+
'side': quoteSide,
|
600
|
+
};
|
601
|
+
const response = await this.v2PostCancel (this.extend (request, params));
|
602
|
+
return this.parseOrder (response, market);
|
603
|
+
}
|
604
|
+
|
605
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
606
|
+
if (symbol === undefined) {
|
607
|
+
throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument');
|
608
|
+
}
|
609
|
+
await this.loadMarkets ();
|
610
|
+
const market = this.market (symbol);
|
611
|
+
const request = {
|
612
|
+
'symbol': market['id'],
|
613
|
+
'entry_id': id,
|
614
|
+
};
|
615
|
+
const response = await this.v1PostOrderStatusSymbol (this.extend (request, params));
|
616
|
+
//
|
617
|
+
// {
|
618
|
+
// "data":[
|
619
|
+
// {
|
620
|
+
// "entry_id":5424475,
|
621
|
+
// "btc":0.01,
|
622
|
+
// "rate":2000,
|
623
|
+
// "time":"2021-04-25T17:05:42.000Z",
|
624
|
+
// "type":0,
|
625
|
+
// "status":0,
|
626
|
+
// "total":0.01,
|
627
|
+
// "avg_cost":null,
|
628
|
+
// "side":"BUY",
|
629
|
+
// "amount":0.01,
|
630
|
+
// "remaining":0.01,
|
631
|
+
// "filled":0,
|
632
|
+
// "cost":null,
|
633
|
+
// "fee":0.05
|
634
|
+
// }
|
635
|
+
// ],
|
636
|
+
// "status":1,
|
637
|
+
// "error":null,
|
638
|
+
// "code":200
|
639
|
+
// }
|
640
|
+
//
|
641
|
+
const data = this.safeValue (response, 'data', []);
|
642
|
+
const first = this.safeValue (data, 0);
|
643
|
+
return this.parseOrder (first, market);
|
644
|
+
}
|
645
|
+
|
646
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
647
|
+
if (symbol === undefined) {
|
648
|
+
throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument');
|
649
|
+
}
|
650
|
+
await this.loadMarkets ();
|
651
|
+
const market = this.market (symbol);
|
652
|
+
const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtListOpenOrders' : 'listOpenOrders';
|
653
|
+
const request = {
|
654
|
+
'symbol': market['uppercaseId'],
|
655
|
+
'side': quoteSide,
|
656
|
+
'page': 0,
|
657
|
+
};
|
658
|
+
const response = await this.v2PostGetordersnew (this.extend (request, params));
|
659
|
+
//
|
660
|
+
// {
|
661
|
+
// "data":[
|
662
|
+
// {
|
663
|
+
// "entry_id":5424475,
|
664
|
+
// "btc":0.01,
|
665
|
+
// "rate":2000,
|
666
|
+
// "time":"2021-04-25T17:05:42.000Z",
|
667
|
+
// "type":0,
|
668
|
+
// "status":0
|
669
|
+
// }
|
670
|
+
// ],
|
671
|
+
// "status":1,
|
672
|
+
// "error":null,
|
673
|
+
// "code":200
|
674
|
+
// }
|
675
|
+
//
|
676
|
+
const data = this.safeValue (response, 'data', []);
|
677
|
+
return this.parseOrders (data, market, since, limit);
|
678
|
+
}
|
679
|
+
|
680
|
+
parseTrade (trade, market = undefined) {
|
681
|
+
//
|
682
|
+
// fetchMyTrades
|
683
|
+
//
|
684
|
+
// {
|
685
|
+
// "type": "BTC Sell order executed",
|
686
|
+
// "typeI": 6,
|
687
|
+
// "crypto": 5000,
|
688
|
+
// "amount": 35.4,
|
689
|
+
// "rate": 709800,
|
690
|
+
// "date": "2020-05-22T15:05:34.000Z",
|
691
|
+
// "unit": "INR",
|
692
|
+
// "factor": 100000000,
|
693
|
+
// "fee": 0.09,
|
694
|
+
// "delh_btc": -5000,
|
695
|
+
// "delh_inr": 0,
|
696
|
+
// "del_btc": 0,
|
697
|
+
// "del_inr": 35.4,
|
698
|
+
// "id": "2938823"
|
699
|
+
// }
|
700
|
+
//
|
701
|
+
// fetchTrades
|
702
|
+
//
|
703
|
+
// {
|
704
|
+
// "tradeId":"1909151",
|
705
|
+
// "price":"61904.6300",
|
706
|
+
// "quote_volume":1618.05,
|
707
|
+
// "base_volume":0.02607254,
|
708
|
+
// "timestamp":1634548602000,
|
709
|
+
// "type":"buy"
|
710
|
+
// }
|
711
|
+
//
|
712
|
+
market = this.safeMarket (undefined, market);
|
713
|
+
const orderId = this.safeString2 (trade, 'id', 'tradeId');
|
714
|
+
let timestamp = this.parse8601 (this.safeString (trade, 'date'));
|
715
|
+
timestamp = this.safeInteger (trade, 'timestamp', timestamp);
|
716
|
+
const priceString = this.safeString2 (trade, 'rate', 'price');
|
717
|
+
let amountString = this.safeString (trade, 'amount');
|
718
|
+
let side = this.safeStringLower (trade, 'type');
|
719
|
+
if (side !== undefined) {
|
720
|
+
if (side.indexOf ('buy') >= 0) {
|
721
|
+
side = 'buy';
|
722
|
+
} else if (side.indexOf ('sell') >= 0) {
|
723
|
+
side = 'sell';
|
724
|
+
}
|
725
|
+
}
|
726
|
+
const factor = this.safeString (trade, 'factor');
|
727
|
+
let costString = undefined;
|
728
|
+
if (factor !== undefined) {
|
729
|
+
amountString = Precise.stringDiv (amountString, factor);
|
730
|
+
} else {
|
731
|
+
amountString = this.safeString (trade, 'base_volume');
|
732
|
+
costString = this.safeString (trade, 'quote_volume');
|
733
|
+
}
|
734
|
+
const symbol = market['symbol'];
|
735
|
+
let fee = undefined;
|
736
|
+
const feeCostString = this.safeString (trade, 'fee');
|
737
|
+
if (feeCostString !== undefined) {
|
738
|
+
const feeCurrencyCode = market['quote'];
|
739
|
+
fee = {
|
740
|
+
'cost': feeCostString,
|
741
|
+
'currency': feeCurrencyCode,
|
742
|
+
};
|
743
|
+
}
|
744
|
+
return this.safeTrade ({
|
745
|
+
'info': trade,
|
746
|
+
'timestamp': timestamp,
|
747
|
+
'datetime': this.iso8601 (timestamp),
|
748
|
+
'symbol': symbol,
|
749
|
+
'id': orderId,
|
750
|
+
'order': orderId,
|
751
|
+
'type': undefined,
|
752
|
+
'side': side,
|
753
|
+
'takerOrMaker': undefined,
|
754
|
+
'price': priceString,
|
755
|
+
'amount': amountString,
|
756
|
+
'cost': costString,
|
757
|
+
'fee': fee,
|
758
|
+
}, market);
|
759
|
+
}
|
760
|
+
|
761
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
762
|
+
if (symbol === undefined) {
|
763
|
+
throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument');
|
764
|
+
}
|
765
|
+
await this.loadMarkets ();
|
766
|
+
const market = this.market (symbol);
|
767
|
+
const request = {
|
768
|
+
'symbol': market['id'],
|
769
|
+
'page': 0,
|
770
|
+
};
|
771
|
+
if (since !== undefined) {
|
772
|
+
request['since'] = this.iso8601 (since);
|
773
|
+
}
|
774
|
+
const response = await this.v1PostListExecutedOrdersSymbol (this.extend (request, params));
|
775
|
+
//
|
776
|
+
// {
|
777
|
+
// "data": [
|
778
|
+
// {
|
779
|
+
// "type": "BTC Sell order executed",
|
780
|
+
// "typeI": 6,
|
781
|
+
// "crypto": 5000,
|
782
|
+
// "amount": 35.4,
|
783
|
+
// "rate": 709800,
|
784
|
+
// "date": "2020-05-22T15:05:34.000Z",
|
785
|
+
// "unit": "INR",
|
786
|
+
// "factor": 100000000,
|
787
|
+
// "fee": 0.09,
|
788
|
+
// "delh_btc": -5000,
|
789
|
+
// "delh_inr": 0,
|
790
|
+
// "del_btc": 0,
|
791
|
+
// "del_inr": 35.4,
|
792
|
+
// "id": "2938823"
|
793
|
+
// },
|
794
|
+
// {
|
795
|
+
// "type": "BTC Sell order executed",
|
796
|
+
// "typeI": 6,
|
797
|
+
// "crypto": 195000,
|
798
|
+
// "amount": 1380.58,
|
799
|
+
// "rate": 709765.5,
|
800
|
+
// "date": "2020-05-22T15:05:34.000Z",
|
801
|
+
// "unit": "INR",
|
802
|
+
// "factor": 100000000,
|
803
|
+
// "fee": 3.47,
|
804
|
+
// "delh_btc": -195000,
|
805
|
+
// "delh_inr": 0,
|
806
|
+
// "del_btc": 0,
|
807
|
+
// "del_inr": 1380.58,
|
808
|
+
// "id": "2938823"
|
809
|
+
// }
|
810
|
+
// ],
|
811
|
+
// "status": 1,
|
812
|
+
// "error": null,
|
813
|
+
// "code": 200
|
814
|
+
// }
|
815
|
+
//
|
816
|
+
const data = this.safeValue (response, 'data', []);
|
817
|
+
return this.parseTrades (data, market, since, limit);
|
818
|
+
}
|
819
|
+
|
820
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
821
|
+
if (symbol === undefined) {
|
822
|
+
throw new ArgumentsRequired (this.id + ' fetchTrades() requires a symbol argument');
|
823
|
+
}
|
824
|
+
await this.loadMarkets ();
|
825
|
+
const market = this.market (symbol);
|
826
|
+
const request = {
|
827
|
+
'coin': market['baseId'],
|
828
|
+
'market': market['quoteId'],
|
829
|
+
};
|
830
|
+
const response = await this.wwwGetExchangeDataTradedetails (this.extend (request, params));
|
831
|
+
//
|
832
|
+
// [
|
833
|
+
// {"tradeId":"1909151","price":"61904.6300","quote_volume":1618.05,"base_volume":0.02607254,"timestamp":1634548602000,"type":"buy"},
|
834
|
+
// {"tradeId":"1909153","price":"61893.9000","quote_volume":16384.42,"base_volume":0.26405767,"timestamp":1634548999000,"type":"sell"},
|
835
|
+
// {"tradeId":"1909155","price":"61853.1100","quote_volume":2304.37,"base_volume":0.03716263,"timestamp":1634549670000,"type":"sell"}
|
836
|
+
// }
|
837
|
+
//
|
838
|
+
return this.parseTrades (response, market, since, limit);
|
839
|
+
}
|
840
|
+
|
841
|
+
async fetchDeposits (code = undefined, since = undefined, limit = undefined, params = {}) {
|
842
|
+
if (code === undefined) {
|
843
|
+
throw new ArgumentsRequired (this.id + ' fetchDeposits() requires a currency code argument');
|
844
|
+
}
|
845
|
+
await this.loadMarkets ();
|
846
|
+
const currency = this.currency (code);
|
847
|
+
const request = {
|
848
|
+
'symbol': currency['id'],
|
849
|
+
'page': 0,
|
850
|
+
};
|
851
|
+
const response = await this.v1PostDepositHistorySymbol (this.extend (request, params));
|
852
|
+
//
|
853
|
+
// {
|
854
|
+
// "data":[
|
855
|
+
// {
|
856
|
+
// "type":"USDT deposited",
|
857
|
+
// "typeI":1,
|
858
|
+
// "amount":100,
|
859
|
+
// "date":"2021-04-24T14:56:04.000Z",
|
860
|
+
// "unit":"USDT",
|
861
|
+
// "factor":100,
|
862
|
+
// "fee":0,
|
863
|
+
// "delh_btc":0,
|
864
|
+
// "delh_inr":0,
|
865
|
+
// "rate":0,
|
866
|
+
// "del_btc":10000,
|
867
|
+
// "del_inr":0
|
868
|
+
// }
|
869
|
+
// ],
|
870
|
+
// "status":1,
|
871
|
+
// "error":null,
|
872
|
+
// "code":200
|
873
|
+
// }
|
874
|
+
//
|
875
|
+
const data = this.safeValue (response, 'data', []);
|
876
|
+
return this.parseTransactions (data, currency, since, limit);
|
877
|
+
}
|
878
|
+
|
879
|
+
async fetchWithdrawals (code = undefined, since = undefined, limit = undefined, params = {}) {
|
880
|
+
if (code === undefined) {
|
881
|
+
throw new ArgumentsRequired (this.id + ' fetchWithdrawals() requires a currency code argument');
|
882
|
+
}
|
883
|
+
await this.loadMarkets ();
|
884
|
+
const currency = this.currency (code);
|
885
|
+
const request = {
|
886
|
+
'symbol': currency['id'],
|
887
|
+
'page': 0,
|
888
|
+
};
|
889
|
+
const response = await this.v1PostWithdrawHistorySymbol (this.extend (request, params));
|
890
|
+
//
|
891
|
+
// ...
|
892
|
+
//
|
893
|
+
const data = this.safeValue (response, 'data', []);
|
894
|
+
return this.parseTransactions (data, currency, since, limit);
|
895
|
+
}
|
896
|
+
|
897
|
+
parseTransactionStatusByType (status, type = undefined) {
|
898
|
+
const statusesByType = {
|
899
|
+
'deposit': {
|
900
|
+
'0': 'pending',
|
901
|
+
'1': 'ok',
|
902
|
+
},
|
903
|
+
'withdrawal': {
|
904
|
+
'0': 'pending', // Email Sent
|
905
|
+
'1': 'canceled', // Cancelled (different from 1 = ok in deposits)
|
906
|
+
'2': 'pending', // Awaiting Approval
|
907
|
+
'3': 'failed', // Rejected
|
908
|
+
'4': 'pending', // Processing
|
909
|
+
'5': 'failed', // Failure
|
910
|
+
'6': 'ok', // Completed
|
911
|
+
},
|
912
|
+
};
|
913
|
+
const statuses = this.safeValue (statusesByType, type, {});
|
914
|
+
return this.safeString (statuses, status, status);
|
915
|
+
}
|
916
|
+
|
917
|
+
parseTransaction (transaction, currency = undefined) {
|
918
|
+
//
|
919
|
+
// fetchDeposits
|
920
|
+
//
|
921
|
+
// {
|
922
|
+
// "type":"USDT deposited",
|
923
|
+
// "typeI":1,
|
924
|
+
// "amount":100,
|
925
|
+
// "date":"2021-04-24T14:56:04.000Z",
|
926
|
+
// "unit":"USDT",
|
927
|
+
// "factor":100,
|
928
|
+
// "fee":0,
|
929
|
+
// "delh_btc":0,
|
930
|
+
// "delh_inr":0,
|
931
|
+
// "rate":0,
|
932
|
+
// "del_btc":10000,
|
933
|
+
// "del_inr":0
|
934
|
+
// }
|
935
|
+
//
|
936
|
+
// fetchWithdrawals
|
937
|
+
//
|
938
|
+
// ...
|
939
|
+
//
|
940
|
+
const currencyId = this.safeString (transaction, 'unit');
|
941
|
+
const code = this.safeCurrencyCode (currencyId, currency);
|
942
|
+
const timestamp = this.parse8601 (this.safeString (transaction, 'date'));
|
943
|
+
let type = this.safeString (transaction, 'type');
|
944
|
+
let status = undefined;
|
945
|
+
if (type !== undefined) {
|
946
|
+
if (type.indexOf ('deposit') >= 0) {
|
947
|
+
type = 'deposit';
|
948
|
+
status = 'ok';
|
949
|
+
} else if (type.indexOf ('withdraw') >= 0) {
|
950
|
+
type = 'withdrawal';
|
951
|
+
}
|
952
|
+
}
|
953
|
+
// const status = this.parseTransactionStatusByType (this.safeString (transaction, 'status'), type);
|
954
|
+
const amount = this.safeNumber (transaction, 'amount');
|
955
|
+
const feeCost = this.safeNumber (transaction, 'fee');
|
956
|
+
let fee = undefined;
|
957
|
+
if (feeCost !== undefined) {
|
958
|
+
fee = { 'currency': code, 'cost': feeCost };
|
959
|
+
}
|
960
|
+
return {
|
961
|
+
'info': transaction,
|
962
|
+
'id': undefined,
|
963
|
+
'txid': undefined,
|
964
|
+
'timestamp': timestamp,
|
965
|
+
'datetime': this.iso8601 (timestamp),
|
966
|
+
'network': undefined,
|
967
|
+
'address': undefined,
|
968
|
+
'addressTo': undefined,
|
969
|
+
'addressFrom': undefined,
|
970
|
+
'tag': undefined,
|
971
|
+
'tagTo': undefined,
|
972
|
+
'tagFrom': undefined,
|
973
|
+
'type': type,
|
974
|
+
'amount': amount,
|
975
|
+
'currency': code,
|
976
|
+
'status': status,
|
977
|
+
'updated': undefined,
|
978
|
+
'internal': undefined,
|
979
|
+
'fee': fee,
|
980
|
+
};
|
981
|
+
}
|
982
|
+
|
983
|
+
async fetchDepositAddress (code, params = {}) {
|
984
|
+
await this.loadMarkets ();
|
985
|
+
const currency = this.currency (code);
|
986
|
+
const request = {
|
987
|
+
'symbol': currency['id'],
|
988
|
+
};
|
989
|
+
const response = await this.v1PostGetCoinAddressSymbol (this.extend (request, params));
|
990
|
+
//
|
991
|
+
// {
|
992
|
+
// "data":{
|
993
|
+
// "token":"0x680dee9edfff0c397736e10b017cf6a0aee4ba31",
|
994
|
+
// "expiry":"2022-04-24 22:30:11"
|
995
|
+
// },
|
996
|
+
// "status":1,
|
997
|
+
// "error":null
|
998
|
+
// }
|
999
|
+
//
|
1000
|
+
const data = this.safeValue (response, 'data', {});
|
1001
|
+
const address = this.safeString (data, 'token');
|
1002
|
+
const tag = this.safeString (data, 'tag');
|
1003
|
+
this.checkAddress (address);
|
1004
|
+
return {
|
1005
|
+
'currency': code,
|
1006
|
+
'address': address,
|
1007
|
+
'tag': tag,
|
1008
|
+
'network': undefined,
|
1009
|
+
'info': response,
|
1010
|
+
};
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
nonce () {
|
1014
|
+
return this.milliseconds ();
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
sign (path, api = 'www', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
1018
|
+
if (!(api in this.urls['api'])) {
|
1019
|
+
throw new ExchangeError (this.id + ' does not have a testnet/sandbox URL for ' + api + ' endpoints');
|
1020
|
+
}
|
1021
|
+
if (api !== 'www') {
|
1022
|
+
this.checkRequiredCredentials ();
|
1023
|
+
headers = {
|
1024
|
+
'X-BITBNS-APIKEY': this.apiKey,
|
1025
|
+
};
|
1026
|
+
}
|
1027
|
+
const baseUrl = this.implodeHostname (this.urls['api'][api]);
|
1028
|
+
let url = baseUrl + '/' + this.implodeParams (path, params);
|
1029
|
+
const query = this.omit (params, this.extractParams (path));
|
1030
|
+
const nonce = this.nonce ().toString ();
|
1031
|
+
if (method === 'GET') {
|
1032
|
+
if (Object.keys (query).length) {
|
1033
|
+
url += '?' + this.urlencode (query);
|
1034
|
+
}
|
1035
|
+
} else if (method === 'POST') {
|
1036
|
+
if (Object.keys (query).length) {
|
1037
|
+
body = this.json (query);
|
1038
|
+
} else {
|
1039
|
+
body = '{}';
|
1040
|
+
}
|
1041
|
+
const auth = {
|
1042
|
+
'timeStamp_nonce': nonce,
|
1043
|
+
'body': body,
|
1044
|
+
};
|
1045
|
+
const payload = this.stringToBase64 (this.json (auth));
|
1046
|
+
const signature = this.hmac (payload, this.encode (this.secret), 'sha512');
|
1047
|
+
headers['X-BITBNS-PAYLOAD'] = this.decode (payload);
|
1048
|
+
headers['X-BITBNS-SIGNATURE'] = signature;
|
1049
|
+
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
1050
|
+
}
|
1051
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
1055
|
+
if (response === undefined) {
|
1056
|
+
return; // fallback to default error handler
|
1057
|
+
}
|
1058
|
+
//
|
1059
|
+
// {"msg":"Invalid Request","status":-1,"code":400}
|
1060
|
+
// {"data":[],"status":0,"error":"Nothing to show","code":417}
|
1061
|
+
//
|
1062
|
+
const code = this.safeString (response, 'code');
|
1063
|
+
const message = this.safeString (response, 'msg');
|
1064
|
+
const error = (code !== undefined) && (code !== '200');
|
1065
|
+
if (error || (message !== undefined)) {
|
1066
|
+
const feedback = this.id + ' ' + body;
|
1067
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], code, feedback);
|
1068
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], message, feedback);
|
1069
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback);
|
1070
|
+
throw new ExchangeError (feedback); // unknown message
|
1071
|
+
}
|
1072
|
+
}
|
1073
|
+
};
|