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/wazirx.js
ADDED
@@ -0,0 +1,732 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const Exchange = require ('./base/Exchange');
|
4
|
+
const { ExchangeError, BadRequest, RateLimitExceeded, BadSymbol, ArgumentsRequired, PermissionDenied, InsufficientFunds, InvalidOrder } = require ('./base/errors');
|
5
|
+
const Precise = require ('./base/Precise');
|
6
|
+
|
7
|
+
module.exports = class wazirx extends Exchange {
|
8
|
+
describe () {
|
9
|
+
return this.deepExtend (super.describe (), {
|
10
|
+
'id': 'wazirx',
|
11
|
+
'name': 'WazirX',
|
12
|
+
'countries': [ 'IN' ],
|
13
|
+
'version': 'v2',
|
14
|
+
'rateLimit': 100,
|
15
|
+
'has': {
|
16
|
+
'CORS': false,
|
17
|
+
'spot': true,
|
18
|
+
'margin': undefined, // has but unimplemented
|
19
|
+
'swap': false,
|
20
|
+
'future': false,
|
21
|
+
'option': false,
|
22
|
+
'cancelAllOrders': true,
|
23
|
+
'cancelOrder': true,
|
24
|
+
'createOrder': true,
|
25
|
+
'createStopLimitOrder': true,
|
26
|
+
'createStopMarketOrder': true,
|
27
|
+
'createStopOrder': true,
|
28
|
+
'fetchBalance': true,
|
29
|
+
'fetchBidsAsks': false,
|
30
|
+
'fetchClosedOrders': false,
|
31
|
+
'fetchCurrencies': false,
|
32
|
+
'fetchDepositAddress': false,
|
33
|
+
'fetchDepositAddressesByNetwork': false,
|
34
|
+
'fetchDeposits': true,
|
35
|
+
'fetchFundingFees': false,
|
36
|
+
'fetchFundingHistory': false,
|
37
|
+
'fetchFundingRate': false,
|
38
|
+
'fetchFundingRateHistory': false,
|
39
|
+
'fetchFundingRates': false,
|
40
|
+
'fetchIndexOHLCV': false,
|
41
|
+
'fetchMarkets': true,
|
42
|
+
'fetchMarkOHLCV': false,
|
43
|
+
'fetchMyTrades': false,
|
44
|
+
'fetchOHLCV': false,
|
45
|
+
'fetchOpenOrders': true,
|
46
|
+
'fetchOrder': true,
|
47
|
+
'fetchOrderBook': true,
|
48
|
+
'fetchOrders': true,
|
49
|
+
'fetchPremiumIndexOHLCV': false,
|
50
|
+
'fetchStatus': true,
|
51
|
+
'fetchTicker': true,
|
52
|
+
'fetchTickers': true,
|
53
|
+
'fetchTime': true,
|
54
|
+
'fetchTrades': true,
|
55
|
+
'fetchTradingFee': false,
|
56
|
+
'fetchTradingFees': false,
|
57
|
+
'fetchTransactions': false,
|
58
|
+
'fetchTransfers': false,
|
59
|
+
'fetchWithdrawals': false,
|
60
|
+
'transfer': false,
|
61
|
+
'withdraw': false,
|
62
|
+
},
|
63
|
+
'urls': {
|
64
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/148647666-c109c20b-f8ac-472f-91c3-5f658cb90f49.jpeg',
|
65
|
+
'api': 'https://api.wazirx.com/sapi/v1',
|
66
|
+
'www': 'https://wazirx.com',
|
67
|
+
'doc': 'https://docs.wazirx.com/#public-rest-api-for-wazirx',
|
68
|
+
'fees': 'https://wazirx.com/fees',
|
69
|
+
'referral': 'https://wazirx.com/invite/k7rrnks5',
|
70
|
+
},
|
71
|
+
'api': {
|
72
|
+
'public': {
|
73
|
+
'get': {
|
74
|
+
'exchangeInfo': 1,
|
75
|
+
'depth': 1,
|
76
|
+
'ping': 1,
|
77
|
+
'systemStatus': 1,
|
78
|
+
'tickers/24hr': 1,
|
79
|
+
'ticker/24hr': 1,
|
80
|
+
'time': 1,
|
81
|
+
'trades': 1,
|
82
|
+
},
|
83
|
+
},
|
84
|
+
'private': {
|
85
|
+
'get': {
|
86
|
+
'account': 1,
|
87
|
+
'allOrders': 1,
|
88
|
+
'funds': 1,
|
89
|
+
'historicalTrades': 1,
|
90
|
+
'openOrders': 1,
|
91
|
+
'order': 1,
|
92
|
+
'myTrades': 1,
|
93
|
+
},
|
94
|
+
'post': {
|
95
|
+
'order': 1,
|
96
|
+
'order/test': 1,
|
97
|
+
},
|
98
|
+
'delete': {
|
99
|
+
'order': 1,
|
100
|
+
'openOrders': 1,
|
101
|
+
},
|
102
|
+
},
|
103
|
+
},
|
104
|
+
'fees': {
|
105
|
+
'WRX': { 'maker': this.parseNumber ('0.0'), 'taker': this.parseNumber ('0.0') },
|
106
|
+
},
|
107
|
+
'exceptions': {
|
108
|
+
'exact': {
|
109
|
+
'-1121': BadSymbol, // { "code": -1121, "message": "Invalid symbol." }
|
110
|
+
'1999': BadRequest, // {"code":1999,"message":"symbol is missing, symbol does not have a valid value"} message varies depending on the error
|
111
|
+
'2002': InsufficientFunds, // {"code":2002,"message":"Not enough USDT balance to execute this order"}
|
112
|
+
'2005': BadRequest, // {"code":2005,"message":"Signature is incorrect."}
|
113
|
+
'2078': PermissionDenied, // {"code":2078,"message":"Permission denied."}
|
114
|
+
'2098': BadRequest, // {"code":2098,"message":"Request out of receiving window."}
|
115
|
+
'2031': InvalidOrder, // {"code":2031,"message":"Minimum buy amount must be worth 2.0 USDT"}
|
116
|
+
'2113': BadRequest, // {"code":2113,"message":"RecvWindow must be in range 1..60000"}
|
117
|
+
'2115': BadRequest, // {"code":2115,"message":"Signature not found."}
|
118
|
+
'2136': RateLimitExceeded, // {"code":2136,"message":"Too many api request"}
|
119
|
+
'94001': InvalidOrder, // {"code":94001,"message":"Stop price not found."}
|
120
|
+
},
|
121
|
+
},
|
122
|
+
'options': {
|
123
|
+
// 'fetchTradesMethod': 'privateGetHistoricalTrades',
|
124
|
+
'recvWindow': 10000,
|
125
|
+
},
|
126
|
+
});
|
127
|
+
}
|
128
|
+
|
129
|
+
async fetchMarkets (params = {}) {
|
130
|
+
const response = await this.publicGetExchangeInfo (params);
|
131
|
+
//
|
132
|
+
// {
|
133
|
+
// "timezone":"UTC",
|
134
|
+
// "serverTime":1641336850932,
|
135
|
+
// "symbols":[
|
136
|
+
// {
|
137
|
+
// "symbol":"btcinr",
|
138
|
+
// "status":"trading",
|
139
|
+
// "baseAsset":"btc",
|
140
|
+
// "quoteAsset":"inr",
|
141
|
+
// "baseAssetPrecision":5,
|
142
|
+
// "quoteAssetPrecision":0,
|
143
|
+
// "orderTypes":[
|
144
|
+
// "limit",
|
145
|
+
// "stop_limit"
|
146
|
+
// ],
|
147
|
+
// "isSpotTradingAllowed":true,
|
148
|
+
// "filters":[
|
149
|
+
// {
|
150
|
+
// "filterType":"PRICE_FILTER",
|
151
|
+
// "minPrice":"1",
|
152
|
+
// "tickSize":"1"
|
153
|
+
// }
|
154
|
+
// ]
|
155
|
+
// },
|
156
|
+
//
|
157
|
+
const markets = this.safeValue (response, 'symbols', []);
|
158
|
+
const result = [];
|
159
|
+
for (let i = 0; i < markets.length; i++) {
|
160
|
+
const entry = markets[i];
|
161
|
+
const id = this.safeString (entry, 'symbol');
|
162
|
+
const baseId = this.safeString (entry, 'baseAsset');
|
163
|
+
const quoteId = this.safeString (entry, 'quoteAsset');
|
164
|
+
const base = this.safeCurrencyCode (baseId);
|
165
|
+
const quote = this.safeCurrencyCode (quoteId);
|
166
|
+
const isSpot = this.safeValue (entry, 'isSpotTradingAllowed');
|
167
|
+
const filters = this.safeValue (entry, 'filters');
|
168
|
+
let minPrice = undefined;
|
169
|
+
for (let j = 0; j < filters.length; j++) {
|
170
|
+
const filter = filters[j];
|
171
|
+
const filterType = this.safeString (filter, 'filterType');
|
172
|
+
if (filterType === 'PRICE_FILTER') {
|
173
|
+
minPrice = this.safeNumber (filter, 'minPrice');
|
174
|
+
}
|
175
|
+
}
|
176
|
+
const fee = this.safeValue (this.fees, quote, {});
|
177
|
+
let takerString = this.safeString (fee, 'taker', '0.2');
|
178
|
+
takerString = Precise.stringDiv (takerString, '100');
|
179
|
+
let makerString = this.safeString (fee, 'maker', '0.2');
|
180
|
+
makerString = Precise.stringDiv (makerString, '100');
|
181
|
+
const status = this.safeString (entry, 'status');
|
182
|
+
result.push ({
|
183
|
+
'id': id,
|
184
|
+
'symbol': base + '/' + quote,
|
185
|
+
'base': base,
|
186
|
+
'quote': quote,
|
187
|
+
'settle': undefined,
|
188
|
+
'baseId': baseId,
|
189
|
+
'quoteId': quoteId,
|
190
|
+
'settleId': undefined,
|
191
|
+
'type': 'spot',
|
192
|
+
'spot': isSpot,
|
193
|
+
'margin': false,
|
194
|
+
'swap': false,
|
195
|
+
'future': false,
|
196
|
+
'option': false,
|
197
|
+
'active': (status === 'trading'),
|
198
|
+
'contract': false,
|
199
|
+
'linear': undefined,
|
200
|
+
'inverse': undefined,
|
201
|
+
'taker': this.parseNumber (takerString),
|
202
|
+
'maker': this.parseNumber (makerString),
|
203
|
+
'contractSize': undefined,
|
204
|
+
'expiry': undefined,
|
205
|
+
'expiryDatetime': undefined,
|
206
|
+
'strike': undefined,
|
207
|
+
'optionType': undefined,
|
208
|
+
'precision': {
|
209
|
+
'amount': this.safeInteger (entry, 'baseAssetPrecision'),
|
210
|
+
'price': this.safeInteger (entry, 'quoteAssetPrecision'),
|
211
|
+
},
|
212
|
+
'limits': {
|
213
|
+
'leverage': {
|
214
|
+
'min': undefined,
|
215
|
+
'max': undefined,
|
216
|
+
},
|
217
|
+
'price': {
|
218
|
+
'min': minPrice,
|
219
|
+
'max': undefined,
|
220
|
+
},
|
221
|
+
'amount': {
|
222
|
+
'min': undefined,
|
223
|
+
'max': undefined,
|
224
|
+
},
|
225
|
+
'cost': {
|
226
|
+
'min': undefined,
|
227
|
+
'max': undefined,
|
228
|
+
},
|
229
|
+
},
|
230
|
+
'info': entry,
|
231
|
+
});
|
232
|
+
}
|
233
|
+
return result;
|
234
|
+
}
|
235
|
+
|
236
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
237
|
+
await this.loadMarkets ();
|
238
|
+
const market = this.market (symbol);
|
239
|
+
const request = {
|
240
|
+
'symbol': market['id'],
|
241
|
+
};
|
242
|
+
if (limit !== undefined) {
|
243
|
+
request['limit'] = limit; // [1, 5, 10, 20, 50, 100, 500, 1000]
|
244
|
+
}
|
245
|
+
const response = await this.publicGetDepth (this.extend (request, params));
|
246
|
+
//
|
247
|
+
// {
|
248
|
+
// "timestamp":1559561187,
|
249
|
+
// "asks":[
|
250
|
+
// ["8540.0","1.5"],
|
251
|
+
// ["8541.0","0.0042"]
|
252
|
+
// ],
|
253
|
+
// "bids":[
|
254
|
+
// ["8530.0","0.8814"],
|
255
|
+
// ["8524.0","1.4"]
|
256
|
+
// ]
|
257
|
+
// }
|
258
|
+
//
|
259
|
+
const timestamp = this.safeInteger (response, 'timestamp');
|
260
|
+
return this.parseOrderBook (response, symbol, timestamp);
|
261
|
+
}
|
262
|
+
|
263
|
+
async fetchTicker (symbol, params = {}) {
|
264
|
+
await this.loadMarkets ();
|
265
|
+
const market = this.market (symbol);
|
266
|
+
const request = {
|
267
|
+
'symbol': market['id'],
|
268
|
+
};
|
269
|
+
const ticker = await this.publicGetTicker24hr (this.extend (request, params));
|
270
|
+
//
|
271
|
+
// {
|
272
|
+
// "symbol":"wrxinr",
|
273
|
+
// "baseAsset":"wrx",
|
274
|
+
// "quoteAsset":"inr",
|
275
|
+
// "openPrice":"94.77",
|
276
|
+
// "lowPrice":"92.7",
|
277
|
+
// "highPrice":"95.17",
|
278
|
+
// "lastPrice":"94.03",
|
279
|
+
// "volume":"1118700.0",
|
280
|
+
// "bidPrice":"94.02",
|
281
|
+
// "askPrice":"94.03",
|
282
|
+
// "at":1641382455000
|
283
|
+
// }
|
284
|
+
//
|
285
|
+
return this.parseTicker (ticker, market);
|
286
|
+
}
|
287
|
+
|
288
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
289
|
+
await this.loadMarkets ();
|
290
|
+
const tickers = await this.publicGetTickers24hr ();
|
291
|
+
//
|
292
|
+
// [
|
293
|
+
// {
|
294
|
+
// "symbol":"btcinr",
|
295
|
+
// "baseAsset":"btc",
|
296
|
+
// "quoteAsset":"inr",
|
297
|
+
// "openPrice":"3698486",
|
298
|
+
// "lowPrice":"3641155.0",
|
299
|
+
// "highPrice":"3767999.0",
|
300
|
+
// "lastPrice":"3713212.0",
|
301
|
+
// "volume":"254.11582",
|
302
|
+
// "bidPrice":"3715021.0",
|
303
|
+
// "askPrice":"3715022.0",
|
304
|
+
// }
|
305
|
+
// ...
|
306
|
+
// ]
|
307
|
+
//
|
308
|
+
const result = {};
|
309
|
+
for (let i = 0; i < tickers.length; i++) {
|
310
|
+
const ticker = tickers[i];
|
311
|
+
const parsedTicker = this.parseTicker (ticker);
|
312
|
+
const symbol = parsedTicker['symbol'];
|
313
|
+
result[symbol] = parsedTicker;
|
314
|
+
}
|
315
|
+
return result;
|
316
|
+
}
|
317
|
+
|
318
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
319
|
+
await this.loadMarkets ();
|
320
|
+
const market = this.market (symbol);
|
321
|
+
const request = {
|
322
|
+
'symbol': market['id'],
|
323
|
+
};
|
324
|
+
if (limit !== undefined) {
|
325
|
+
request['limit'] = limit; // Default 500; max 1000.
|
326
|
+
}
|
327
|
+
const method = this.safeString (this.options, 'fetchTradesMethod', 'publicGetTrades');
|
328
|
+
const response = await this[method] (this.extend (request, params));
|
329
|
+
// [
|
330
|
+
// {
|
331
|
+
// "id":322307791,
|
332
|
+
// "price":"93.7",
|
333
|
+
// "qty":"0.7",
|
334
|
+
// "quoteQty":"65.59",
|
335
|
+
// "time":1641386701000,
|
336
|
+
// "isBuyerMaker":false
|
337
|
+
// },
|
338
|
+
// ]
|
339
|
+
return this.parseTrades (response, market, since, limit);
|
340
|
+
}
|
341
|
+
|
342
|
+
parseTrade (trade, market = undefined) {
|
343
|
+
//
|
344
|
+
// {
|
345
|
+
// "id":322307791,
|
346
|
+
// "price":"93.7",
|
347
|
+
// "qty":"0.7",
|
348
|
+
// "quoteQty":"65.59",
|
349
|
+
// "time":1641386701000,
|
350
|
+
// "isBuyerMaker":false
|
351
|
+
// }
|
352
|
+
//
|
353
|
+
const id = this.safeString (trade, 'id');
|
354
|
+
const timestamp = this.safeInteger (trade, 'time');
|
355
|
+
const datetime = this.iso8601 (timestamp);
|
356
|
+
market = this.safeMarket (undefined, market);
|
357
|
+
const isBuyerMaker = this.safeValue (trade, 'isBuyerMaker');
|
358
|
+
const side = isBuyerMaker ? 'sell' : 'buy';
|
359
|
+
const price = this.safeNumber (trade, 'price');
|
360
|
+
const amount = this.safeNumber (trade, 'qty');
|
361
|
+
const cost = this.safeNumber (trade, 'quoteQty');
|
362
|
+
return this.safeTrade ({
|
363
|
+
'info': trade,
|
364
|
+
'id': id,
|
365
|
+
'timestamp': timestamp,
|
366
|
+
'datetime': datetime,
|
367
|
+
'symbol': market['symbol'],
|
368
|
+
'order': id,
|
369
|
+
'type': undefined,
|
370
|
+
'side': side,
|
371
|
+
'takerOrMaker': undefined,
|
372
|
+
'price': price,
|
373
|
+
'amount': amount,
|
374
|
+
'cost': cost,
|
375
|
+
'fee': undefined,
|
376
|
+
}, market);
|
377
|
+
}
|
378
|
+
|
379
|
+
async fetchStatus (params = {}) {
|
380
|
+
const response = await this.publicGetSystemStatus (params);
|
381
|
+
//
|
382
|
+
// {
|
383
|
+
// "status":"normal", // normal, system maintenance
|
384
|
+
// "message":"System is running normally."
|
385
|
+
// }
|
386
|
+
//
|
387
|
+
const status = this.safeString (response, 'status');
|
388
|
+
return {
|
389
|
+
'status': (status === 'normal') ? 'ok' : 'maintenance',
|
390
|
+
'updated': this.milliseconds (),
|
391
|
+
'eta': undefined,
|
392
|
+
'url': undefined,
|
393
|
+
'info': response,
|
394
|
+
};
|
395
|
+
}
|
396
|
+
|
397
|
+
async fetchTime (params = {}) {
|
398
|
+
const response = await this.publicGetTime (params);
|
399
|
+
//
|
400
|
+
// {
|
401
|
+
// "serverTime":1635467280514
|
402
|
+
// }
|
403
|
+
//
|
404
|
+
return this.safeInteger (response, 'serverTime');
|
405
|
+
}
|
406
|
+
|
407
|
+
parseTicker (ticker, market = undefined) {
|
408
|
+
//
|
409
|
+
// {
|
410
|
+
// "symbol":"btcinr",
|
411
|
+
// "baseAsset":"btc",
|
412
|
+
// "quoteAsset":"inr",
|
413
|
+
// "openPrice":"3698486",
|
414
|
+
// "lowPrice":"3641155.0",
|
415
|
+
// "highPrice":"3767999.0",
|
416
|
+
// "lastPrice":"3713212.0",
|
417
|
+
// "volume":"254.11582", // base volume
|
418
|
+
// "bidPrice":"3715021.0",
|
419
|
+
// "askPrice":"3715022.0",
|
420
|
+
// "at":1641382455000 // only on fetchTicker
|
421
|
+
// }
|
422
|
+
//
|
423
|
+
const marketId = this.safeString (ticker, 'symbol');
|
424
|
+
market = this.safeMarket (marketId, market);
|
425
|
+
const symbol = market['symbol'];
|
426
|
+
const last = this.safeString (ticker, 'lastPrice');
|
427
|
+
const open = this.safeString (ticker, 'openPrice');
|
428
|
+
const high = this.safeString (ticker, 'highPrice');
|
429
|
+
const low = this.safeString (ticker, 'lowPrice');
|
430
|
+
const baseVolume = this.safeString (ticker, 'volume');
|
431
|
+
const bid = this.safeString (ticker, 'bidPrice');
|
432
|
+
const ask = this.safeString (ticker, 'askPrice');
|
433
|
+
const timestamp = this.safeString (ticker, 'at');
|
434
|
+
return this.safeTicker ({
|
435
|
+
'symbol': symbol,
|
436
|
+
'timestamp': timestamp,
|
437
|
+
'datetime': this.iso8601 (timestamp),
|
438
|
+
'high': high,
|
439
|
+
'low': low,
|
440
|
+
'bid': bid,
|
441
|
+
'bidVolume': undefined,
|
442
|
+
'ask': ask,
|
443
|
+
'askVolume': undefined,
|
444
|
+
'vwap': undefined,
|
445
|
+
'open': open,
|
446
|
+
'close': last,
|
447
|
+
'last': last,
|
448
|
+
'previousClose': undefined,
|
449
|
+
'change': undefined,
|
450
|
+
'percentage': undefined,
|
451
|
+
'average': undefined,
|
452
|
+
'baseVolume': baseVolume,
|
453
|
+
'quoteVolume': undefined,
|
454
|
+
'info': ticker,
|
455
|
+
}, market, false);
|
456
|
+
}
|
457
|
+
|
458
|
+
parseBalance (response) {
|
459
|
+
const result = { };
|
460
|
+
for (let i = 0; i < response.length; i++) {
|
461
|
+
const balance = response[i];
|
462
|
+
const id = this.safeString (balance, 'asset');
|
463
|
+
const code = this.safeCurrencyCode (id);
|
464
|
+
const account = this.account ();
|
465
|
+
account['free'] = this.safeString (balance, 'free');
|
466
|
+
account['used'] = this.safeString (balance, 'locked');
|
467
|
+
result[code] = account;
|
468
|
+
}
|
469
|
+
return this.safeBalance (result);
|
470
|
+
}
|
471
|
+
|
472
|
+
async fetchBalance (params = {}) {
|
473
|
+
await this.loadMarkets ();
|
474
|
+
const response = await this.privateGetFunds (params);
|
475
|
+
//
|
476
|
+
// [
|
477
|
+
// {
|
478
|
+
// "asset":"inr",
|
479
|
+
// "free":"0.0",
|
480
|
+
// "locked":"0.0"
|
481
|
+
// },
|
482
|
+
// ]
|
483
|
+
//
|
484
|
+
return this.parseBalance (response);
|
485
|
+
}
|
486
|
+
|
487
|
+
async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
488
|
+
if (symbol === undefined) {
|
489
|
+
throw new ArgumentsRequired (this.id + ' fetchOrders() requires a `symbol` argument');
|
490
|
+
}
|
491
|
+
await this.loadMarkets ();
|
492
|
+
const market = this.market (symbol);
|
493
|
+
const request = {
|
494
|
+
'symbol': market['id'],
|
495
|
+
};
|
496
|
+
if (since !== undefined) {
|
497
|
+
request['startTime'] = since;
|
498
|
+
}
|
499
|
+
if (limit !== undefined) {
|
500
|
+
request['limit'] = limit;
|
501
|
+
}
|
502
|
+
const response = await this.privateGetAllOrders (this.extend (request, params));
|
503
|
+
// [
|
504
|
+
// {
|
505
|
+
// "id": 28,
|
506
|
+
// "symbol": "wrxinr",
|
507
|
+
// "price": "9293.0",
|
508
|
+
// "origQty": "10.0",
|
509
|
+
// "executedQty": "8.2",
|
510
|
+
// "status": "cancel",
|
511
|
+
// "type": "limit",
|
512
|
+
// "side": "sell",
|
513
|
+
// "createdTime": 1499827319559,
|
514
|
+
// "updatedTime": 1499827319559
|
515
|
+
// },
|
516
|
+
// {
|
517
|
+
// "id": 30,
|
518
|
+
// "symbol": "wrxinr",
|
519
|
+
// "price": "9293.0",
|
520
|
+
// "stopPrice": "9200.0",
|
521
|
+
// "origQty": "10.0",
|
522
|
+
// "executedQty": "0.0",
|
523
|
+
// "status": "cancel",
|
524
|
+
// "type": "stop_limit",
|
525
|
+
// "side": "sell",
|
526
|
+
// "createdTime": 1499827319559,
|
527
|
+
// "updatedTime": 1507725176595
|
528
|
+
// }
|
529
|
+
// ]
|
530
|
+
let orders = this.parseOrders (response, market, since, limit);
|
531
|
+
orders = this.filterBy (orders, 'symbol', symbol);
|
532
|
+
return orders;
|
533
|
+
}
|
534
|
+
|
535
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
536
|
+
await this.loadMarkets ();
|
537
|
+
const request = {};
|
538
|
+
let market = undefined;
|
539
|
+
if (symbol !== undefined) {
|
540
|
+
market = this.market (symbol);
|
541
|
+
request['symbol'] = market['id'];
|
542
|
+
}
|
543
|
+
const response = await this.privateGetOpenOrders (this.extend (request, params));
|
544
|
+
// [
|
545
|
+
// {
|
546
|
+
// "id": 28,
|
547
|
+
// "symbol": "wrxinr",
|
548
|
+
// "price": "9293.0",
|
549
|
+
// "origQty": "10.0",
|
550
|
+
// "executedQty": "8.2",
|
551
|
+
// "status": "cancel",
|
552
|
+
// "type": "limit",
|
553
|
+
// "side": "sell",
|
554
|
+
// "createdTime": 1499827319559,
|
555
|
+
// "updatedTime": 1499827319559
|
556
|
+
// },
|
557
|
+
// {
|
558
|
+
// "id": 30,
|
559
|
+
// "symbol": "wrxinr",
|
560
|
+
// "price": "9293.0",
|
561
|
+
// "stopPrice": "9200.0",
|
562
|
+
// "origQty": "10.0",
|
563
|
+
// "executedQty": "0.0",
|
564
|
+
// "status": "cancel",
|
565
|
+
// "type": "stop_limit",
|
566
|
+
// "side": "sell",
|
567
|
+
// "createdTime": 1499827319559,
|
568
|
+
// "updatedTime": 1507725176595
|
569
|
+
// }
|
570
|
+
// ]
|
571
|
+
const orders = this.parseOrders (response, market, since, limit);
|
572
|
+
return orders;
|
573
|
+
}
|
574
|
+
|
575
|
+
async cancelAllOrders (symbol = undefined, params = {}) {
|
576
|
+
if (symbol === undefined) {
|
577
|
+
throw new ArgumentsRequired (this.id + ' cancelAllOrders() requires a `symbol` argument');
|
578
|
+
}
|
579
|
+
await this.loadMarkets ();
|
580
|
+
const market = this.market (symbol);
|
581
|
+
const request = {
|
582
|
+
'symbol': market['id'],
|
583
|
+
};
|
584
|
+
return await this.privateDeleteOpenOrders (this.extend (request, params));
|
585
|
+
}
|
586
|
+
|
587
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
588
|
+
if (symbol === undefined) {
|
589
|
+
throw new ArgumentsRequired (this.id + ' cancelOrder() requires a `symbol` argument');
|
590
|
+
}
|
591
|
+
await this.loadMarkets ();
|
592
|
+
const market = this.market (symbol);
|
593
|
+
const request = {
|
594
|
+
'symbol': market['id'],
|
595
|
+
'orderId': id,
|
596
|
+
};
|
597
|
+
const response = await this.privateDeleteOrder (this.extend (request, params));
|
598
|
+
return this.parseOrder (response);
|
599
|
+
}
|
600
|
+
|
601
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
602
|
+
type = type.toLowerCase ();
|
603
|
+
if ((type !== 'limit') && (type !== 'stop_limit')) {
|
604
|
+
throw new ExchangeError (this.id + ' createOrder() supports limit and stop_limit orders only');
|
605
|
+
}
|
606
|
+
if (price === undefined) {
|
607
|
+
throw new ExchangeError (this.id + ' createOrder() requires a price argument');
|
608
|
+
}
|
609
|
+
await this.loadMarkets ();
|
610
|
+
const market = this.market (symbol);
|
611
|
+
const request = {
|
612
|
+
'symbol': market['id'],
|
613
|
+
'side': side,
|
614
|
+
'quantity': amount,
|
615
|
+
'type': 'limit',
|
616
|
+
};
|
617
|
+
request['price'] = this.priceToPrecision (symbol, price);
|
618
|
+
const stopPrice = this.safeString (params, 'stopPrice');
|
619
|
+
if (stopPrice !== undefined) {
|
620
|
+
request['type'] = 'stop_limit';
|
621
|
+
}
|
622
|
+
const response = await this.privatePostOrder (this.extend (request, params));
|
623
|
+
// {
|
624
|
+
// "id": 28,
|
625
|
+
// "symbol": "wrxinr",
|
626
|
+
// "price": "9293.0",
|
627
|
+
// "origQty": "10.0",
|
628
|
+
// "executedQty": "8.2",
|
629
|
+
// "status": "wait",
|
630
|
+
// "type": "limit",
|
631
|
+
// "side": "sell",
|
632
|
+
// "createdTime": 1499827319559,
|
633
|
+
// "updatedTime": 1499827319559
|
634
|
+
// }
|
635
|
+
return this.parseOrder (response, market);
|
636
|
+
}
|
637
|
+
|
638
|
+
parseOrder (order, market = undefined) {
|
639
|
+
// {
|
640
|
+
// "id":1949417813,
|
641
|
+
// "symbol":"ltcusdt",
|
642
|
+
// "type":"limit",
|
643
|
+
// "side":"sell",
|
644
|
+
// "status":"done",
|
645
|
+
// "price":"146.2",
|
646
|
+
// "origQty":"0.05",
|
647
|
+
// "executedQty":"0.05",
|
648
|
+
// "createdTime":1641252564000,
|
649
|
+
// "updatedTime":1641252564000
|
650
|
+
// },
|
651
|
+
const created = this.safeInteger (order, 'createdTime');
|
652
|
+
const updated = this.safeInteger (order, 'updatedTime');
|
653
|
+
const marketId = this.safeString (order, 'symbol');
|
654
|
+
const symbol = this.safeSymbol (marketId, market);
|
655
|
+
const amount = this.safeString (order, 'quantity');
|
656
|
+
const filled = this.safeString (order, 'executedQty');
|
657
|
+
const status = this.parseOrderStatus (this.safeString (order, 'status'));
|
658
|
+
const id = this.safeString (order, 'id');
|
659
|
+
const price = this.safeString (order, 'price');
|
660
|
+
const type = this.safeStringLower (order, 'type');
|
661
|
+
const side = this.safeStringLower (order, 'side');
|
662
|
+
return this.safeOrder ({
|
663
|
+
'info': order,
|
664
|
+
'id': id,
|
665
|
+
'clientOrderId': undefined,
|
666
|
+
'timestamp': created,
|
667
|
+
'datetime': this.iso8601 (created),
|
668
|
+
'lastTradeTimestamp': updated,
|
669
|
+
'status': status,
|
670
|
+
'symbol': symbol,
|
671
|
+
'type': type,
|
672
|
+
'timeInForce': undefined,
|
673
|
+
'postOnly': undefined,
|
674
|
+
'side': side,
|
675
|
+
'price': price,
|
676
|
+
'amount': amount,
|
677
|
+
'filled': filled,
|
678
|
+
'remaining': undefined,
|
679
|
+
'cost': undefined,
|
680
|
+
'fee': undefined,
|
681
|
+
'average': undefined,
|
682
|
+
'trades': [],
|
683
|
+
}, market);
|
684
|
+
}
|
685
|
+
|
686
|
+
parseOrderStatus (status) {
|
687
|
+
const statuses = {
|
688
|
+
'wait': 'open',
|
689
|
+
'done': 'closed',
|
690
|
+
'cancel': 'canceled',
|
691
|
+
};
|
692
|
+
return this.safeString (statuses, status, status);
|
693
|
+
}
|
694
|
+
|
695
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
696
|
+
let url = this.urls['api'] + '/' + path;
|
697
|
+
if (api === 'public') {
|
698
|
+
if (Object.keys (params).length) {
|
699
|
+
url += '?' + this.urlencode (params);
|
700
|
+
}
|
701
|
+
}
|
702
|
+
if (api === 'private') {
|
703
|
+
this.checkRequiredCredentials ();
|
704
|
+
const timestamp = this.milliseconds ();
|
705
|
+
let data = this.extend ({ 'recvWindow': this.options['recvWindow'], 'timestamp': timestamp }, params);
|
706
|
+
data = this.keysort (data);
|
707
|
+
const signature = this.hmac (this.encode (this.urlencode (data)), this.encode (this.secret), 'sha256');
|
708
|
+
url += '?' + this.urlencode (data);
|
709
|
+
url += '&signature=' + signature;
|
710
|
+
headers = {
|
711
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
712
|
+
'X-Api-Key': this.apiKey,
|
713
|
+
};
|
714
|
+
}
|
715
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
716
|
+
}
|
717
|
+
|
718
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
719
|
+
//
|
720
|
+
// {"code":2098,"message":"Request out of receiving window."}
|
721
|
+
//
|
722
|
+
if (response === undefined) {
|
723
|
+
return;
|
724
|
+
}
|
725
|
+
const errorCode = this.safeString (response, 'code');
|
726
|
+
if (errorCode !== undefined) {
|
727
|
+
const feedback = this.id + ' ' + body;
|
728
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback);
|
729
|
+
throw new ExchangeError (feedback);
|
730
|
+
}
|
731
|
+
}
|
732
|
+
};
|