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/kuna.js
ADDED
@@ -0,0 +1,809 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ArgumentsRequired, InsufficientFunds, OrderNotFound, NotSupported } = require ('./base/errors');
|
7
|
+
|
8
|
+
// ---------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = class kuna extends Exchange {
|
11
|
+
describe () {
|
12
|
+
return this.deepExtend (super.describe (), {
|
13
|
+
'id': 'kuna',
|
14
|
+
'name': 'Kuna',
|
15
|
+
'countries': [ 'UA' ],
|
16
|
+
'rateLimit': 1000,
|
17
|
+
'version': 'v2',
|
18
|
+
'has': {
|
19
|
+
'CORS': undefined,
|
20
|
+
'spot': true,
|
21
|
+
'margin': undefined,
|
22
|
+
'swap': false,
|
23
|
+
'future': false,
|
24
|
+
'option': false,
|
25
|
+
'cancelOrder': true,
|
26
|
+
'createOrder': true,
|
27
|
+
'fetchBalance': true,
|
28
|
+
'fetchFundingHistory': false,
|
29
|
+
'fetchFundingRate': false,
|
30
|
+
'fetchFundingRateHistory': false,
|
31
|
+
'fetchFundingRates': false,
|
32
|
+
'fetchIndexOHLCV': false,
|
33
|
+
'fetchL3OrderBook': true,
|
34
|
+
'fetchLeverage': false,
|
35
|
+
'fetchMarkets': true,
|
36
|
+
'fetchMarkOHLCV': false,
|
37
|
+
'fetchMyTrades': true,
|
38
|
+
'fetchOHLCV': 'emulated',
|
39
|
+
'fetchOpenOrders': true,
|
40
|
+
'fetchOrder': true,
|
41
|
+
'fetchOrderBook': true,
|
42
|
+
'fetchPositions': false,
|
43
|
+
'fetchPositionsRisk': false,
|
44
|
+
'fetchPremiumIndexOHLCV': false,
|
45
|
+
'fetchTicker': true,
|
46
|
+
'fetchTickers': true,
|
47
|
+
'fetchTime': true,
|
48
|
+
'fetchTrades': true,
|
49
|
+
'fetchTradingFee': false,
|
50
|
+
'fetchTradingFees': false,
|
51
|
+
'reduceMargin': false,
|
52
|
+
'setLeverage': false,
|
53
|
+
'setPositionMode': false,
|
54
|
+
'withdraw': undefined,
|
55
|
+
},
|
56
|
+
'timeframes': undefined,
|
57
|
+
'urls': {
|
58
|
+
'extension': '.json',
|
59
|
+
'referral': 'https://kuna.io?r=kunaid-gvfihe8az7o4',
|
60
|
+
'logo': 'https://user-images.githubusercontent.com/51840849/87153927-f0578b80-c2c0-11ea-84b6-74612568e9e1.jpg',
|
61
|
+
'api': {
|
62
|
+
'xreserve': 'https://api.xreserve.fund',
|
63
|
+
'v3': 'https://api.kuna.io',
|
64
|
+
'public': 'https://kuna.io', // v2
|
65
|
+
'private': 'https://kuna.io', // v2
|
66
|
+
},
|
67
|
+
'www': 'https://kuna.io',
|
68
|
+
'doc': 'https://kuna.io/documents/api',
|
69
|
+
'fees': 'https://kuna.io/documents/api',
|
70
|
+
},
|
71
|
+
'api': {
|
72
|
+
'xreserve': {
|
73
|
+
'get': {
|
74
|
+
'nonce': 1,
|
75
|
+
'fee': 1,
|
76
|
+
'delegated-transactions': 1,
|
77
|
+
},
|
78
|
+
'post': {
|
79
|
+
'delegate-transfer': 1,
|
80
|
+
},
|
81
|
+
},
|
82
|
+
'v3': {
|
83
|
+
'public': {
|
84
|
+
'get': {
|
85
|
+
'timestamp': 1,
|
86
|
+
'currencies': 1,
|
87
|
+
'markets': 1,
|
88
|
+
'tickers': 1,
|
89
|
+
'k': 1,
|
90
|
+
'trades_history': 1,
|
91
|
+
'fees': 1,
|
92
|
+
'exchange-rates': 1,
|
93
|
+
'exchange-rates/currency': 1,
|
94
|
+
'book/market': 1,
|
95
|
+
'kuna_codes/code/check': 1,
|
96
|
+
'landing_page_statistic': 1,
|
97
|
+
'translations/locale': 1,
|
98
|
+
'trades/market/hist': 1,
|
99
|
+
},
|
100
|
+
'post': {
|
101
|
+
'http_test': 1,
|
102
|
+
'deposit_channels': 1,
|
103
|
+
'withdraw_channels': 1,
|
104
|
+
'subscription_plans': 1,
|
105
|
+
'send_to': 1,
|
106
|
+
'confirm_token': 1,
|
107
|
+
'kunaid': 1,
|
108
|
+
'withdraw/prerequest': 1,
|
109
|
+
'deposit/prerequest': 1,
|
110
|
+
'deposit/exchange-rates': 1,
|
111
|
+
},
|
112
|
+
},
|
113
|
+
'sign': {
|
114
|
+
'get': {
|
115
|
+
'reset_password/token': 1,
|
116
|
+
},
|
117
|
+
'post': {
|
118
|
+
'signup/google': 1,
|
119
|
+
'signup/resend_confirmation': 1,
|
120
|
+
'signup': 1,
|
121
|
+
'signin': 1,
|
122
|
+
'signin/two_factor': 1,
|
123
|
+
'signin/resend_confirm_device': 1,
|
124
|
+
'signin/confirm_device': 1,
|
125
|
+
'reset_password': 1,
|
126
|
+
'cool-signin': 1,
|
127
|
+
},
|
128
|
+
'put': {
|
129
|
+
'reset_password/token': 1,
|
130
|
+
'signup/code/confirm': 1,
|
131
|
+
},
|
132
|
+
},
|
133
|
+
'private': {
|
134
|
+
'post': {
|
135
|
+
'auth/w/order/submit': 1,
|
136
|
+
'auth/r/orders': 1,
|
137
|
+
'auth/r/orders/market': 1,
|
138
|
+
'auth/r/orders/markets': 1,
|
139
|
+
'auth/api_tokens/delete': 1,
|
140
|
+
'auth/api_tokens/create': 1,
|
141
|
+
'auth/api_tokens': 1,
|
142
|
+
'auth/signin_history/uniq': 1,
|
143
|
+
'auth/signin_history': 1,
|
144
|
+
'auth/disable_withdraw_confirmation': 1,
|
145
|
+
'auth/change_password': 1,
|
146
|
+
'auth/deposit_address': 1,
|
147
|
+
'auth/announcements/accept': 1,
|
148
|
+
'auth/announcements/unaccepted': 1,
|
149
|
+
'auth/otp/deactivate': 1,
|
150
|
+
'auth/otp/activate': 1,
|
151
|
+
'auth/otp/secret': 1,
|
152
|
+
'auth/r/order/market/:order_id/trades': 1,
|
153
|
+
'auth/r/orders/market/hist': 1,
|
154
|
+
'auth/r/orders/hist': 1,
|
155
|
+
'auth/r/orders/hist/markets': 1,
|
156
|
+
'auth/r/orders/details': 1,
|
157
|
+
'auth/assets-history': 1,
|
158
|
+
'auth/assets-history/withdraws': 1,
|
159
|
+
'auth/assets-history/deposits': 1,
|
160
|
+
'auth/r/wallets': 1,
|
161
|
+
'auth/markets/favorites': 1,
|
162
|
+
'auth/markets/favorites/list': 1,
|
163
|
+
'auth/me/update': 1,
|
164
|
+
'auth/me': 1,
|
165
|
+
'auth/fund_sources': 1,
|
166
|
+
'auth/fund_sources/list': 1,
|
167
|
+
'auth/withdraw/resend_confirmation': 1,
|
168
|
+
'auth/withdraw': 1,
|
169
|
+
'auth/withdraw/details': 1,
|
170
|
+
'auth/withdraw/info': 1,
|
171
|
+
'auth/payment_addresses': 1,
|
172
|
+
'auth/deposit/prerequest': 1,
|
173
|
+
'auth/deposit/exchange-rates': 1,
|
174
|
+
'auth/deposit': 1,
|
175
|
+
'auth/deposit/details': 1,
|
176
|
+
'auth/deposit/info': 1,
|
177
|
+
'auth/kuna_codes/count': 1,
|
178
|
+
'auth/kuna_codes/details': 1,
|
179
|
+
'auth/kuna_codes/edit': 1,
|
180
|
+
'auth/kuna_codes/send-pdf': 1,
|
181
|
+
'auth/kuna_codes': 1,
|
182
|
+
'auth/kuna_codes/redeemed-by-me': 1,
|
183
|
+
'auth/kuna_codes/issued-by-me': 1,
|
184
|
+
'auth/payment_requests/invoice': 1,
|
185
|
+
'auth/payment_requests/type': 1,
|
186
|
+
'auth/referral_program/weekly_earnings': 1,
|
187
|
+
'auth/referral_program/stats': 1,
|
188
|
+
'auth/merchant/payout_services': 1,
|
189
|
+
'auth/merchant/withdraw': 1,
|
190
|
+
'auth/merchant/payment_services': 1,
|
191
|
+
'auth/merchant/deposit': 1,
|
192
|
+
'auth/verification/auth_token': 1,
|
193
|
+
'auth/kunaid_purchase/create': 1,
|
194
|
+
'auth/devices/list': 1,
|
195
|
+
'auth/sessions/list': 1,
|
196
|
+
'auth/subscriptions/reactivate': 1,
|
197
|
+
'auth/subscriptions/cancel': 1,
|
198
|
+
'auth/subscriptions/prolong': 1,
|
199
|
+
'auth/subscriptions/create': 1,
|
200
|
+
'auth/subscriptions/list': 1,
|
201
|
+
'auth/kuna_ids/list': 1,
|
202
|
+
'order/cancel/multi': 1,
|
203
|
+
'order/cancel': 1,
|
204
|
+
},
|
205
|
+
'put': {
|
206
|
+
'auth/fund_sources/id': 1,
|
207
|
+
'auth/kuna_codes/redeem': 1,
|
208
|
+
},
|
209
|
+
'delete': {
|
210
|
+
'auth/markets/favorites': 1,
|
211
|
+
'auth/fund_sources': 1,
|
212
|
+
'auth/devices': 1,
|
213
|
+
'auth/devices/list': 1,
|
214
|
+
'auth/sessions/list': 1,
|
215
|
+
'auth/sessions': 1,
|
216
|
+
},
|
217
|
+
},
|
218
|
+
},
|
219
|
+
'public': {
|
220
|
+
'get': [
|
221
|
+
'depth', // Get depth or specified market Both asks and bids are sorted from highest price to lowest.
|
222
|
+
'k_with_pending_trades', // Get K data with pending trades, which are the trades not included in K data yet, because there's delay between trade generated and processed by K data generator
|
223
|
+
'k', // Get OHLC(k line) of specific market
|
224
|
+
'markets', // Get all available markets
|
225
|
+
'order_book', // Get the order book of specified market
|
226
|
+
'order_book/{market}',
|
227
|
+
'tickers', // Get ticker of all markets
|
228
|
+
'tickers/{market}', // Get ticker of specific market
|
229
|
+
'timestamp', // Get server current time, in seconds since Unix epoch
|
230
|
+
'trades', // Get recent trades on market, each trade is included only once Trades are sorted in reverse creation order.
|
231
|
+
'trades/{market}',
|
232
|
+
],
|
233
|
+
},
|
234
|
+
'private': {
|
235
|
+
'get': [
|
236
|
+
'members/me', // Get your profile and accounts info
|
237
|
+
'deposits', // Get your deposits history
|
238
|
+
'deposit', // Get details of specific deposit
|
239
|
+
'deposit_address', // Where to deposit The address field could be empty when a new address is generating (e.g. for bitcoin), you should try again later in that case.
|
240
|
+
'orders', // Get your orders, results is paginated
|
241
|
+
'order', // Get information of specified order
|
242
|
+
'trades/my', // Get your executed trades Trades are sorted in reverse creation order.
|
243
|
+
'withdraws', // Get your cryptocurrency withdraws
|
244
|
+
'withdraw', // Get your cryptocurrency withdraw
|
245
|
+
],
|
246
|
+
'post': [
|
247
|
+
'orders', // Create a Sell/Buy order
|
248
|
+
'orders/multi', // Create multiple sell/buy orders
|
249
|
+
'orders/clear', // Cancel all my orders
|
250
|
+
'order/delete', // Cancel an order
|
251
|
+
'withdraw', // Create a withdraw
|
252
|
+
],
|
253
|
+
},
|
254
|
+
},
|
255
|
+
'fees': {
|
256
|
+
'trading': {
|
257
|
+
'tierBased': false,
|
258
|
+
'percentage': true,
|
259
|
+
'taker': this.parseNumber ('0.0025'),
|
260
|
+
'maker': this.parseNumber ('0.0025'),
|
261
|
+
},
|
262
|
+
'funding': {
|
263
|
+
'withdraw': {
|
264
|
+
'UAH': '1%',
|
265
|
+
'BTC': 0.001,
|
266
|
+
'BCH': 0.001,
|
267
|
+
'ETH': 0.01,
|
268
|
+
'WAVES': 0.01,
|
269
|
+
'GOL': 0.0,
|
270
|
+
'GBG': 0.0,
|
271
|
+
// 'RMC': 0.001 BTC
|
272
|
+
// 'ARN': 0.01 ETH
|
273
|
+
// 'R': 0.01 ETH
|
274
|
+
// 'EVR': 0.01 ETH
|
275
|
+
},
|
276
|
+
'deposit': {
|
277
|
+
// 'UAH': (amount) => amount * 0.001 + 5
|
278
|
+
},
|
279
|
+
},
|
280
|
+
},
|
281
|
+
'commonCurrencies': {
|
282
|
+
'PLA': 'Plair',
|
283
|
+
},
|
284
|
+
'exceptions': {
|
285
|
+
'2002': InsufficientFunds,
|
286
|
+
'2003': OrderNotFound,
|
287
|
+
},
|
288
|
+
});
|
289
|
+
}
|
290
|
+
|
291
|
+
async fetchTime (params = {}) {
|
292
|
+
const response = await this.publicGetTimestamp (params);
|
293
|
+
//
|
294
|
+
// 1594911427
|
295
|
+
//
|
296
|
+
return response * 1000;
|
297
|
+
}
|
298
|
+
|
299
|
+
async fetchMarkets (params = {}) {
|
300
|
+
const quotes = [ 'btc', 'rub', 'uah', 'usd', 'usdt', 'usdc' ];
|
301
|
+
const markets = [];
|
302
|
+
const response = await this.publicGetTickers (params);
|
303
|
+
//
|
304
|
+
// {
|
305
|
+
// shibuah: {
|
306
|
+
// at: '1644463685',
|
307
|
+
// ticker: {
|
308
|
+
// buy: '0.000911',
|
309
|
+
// sell: '0.00092',
|
310
|
+
// low: '0.000872',
|
311
|
+
// high: '0.000963',
|
312
|
+
// last: '0.000911',
|
313
|
+
// vol: '1539278096.0',
|
314
|
+
// price: '1434244.211249'
|
315
|
+
// }
|
316
|
+
// }
|
317
|
+
// }
|
318
|
+
//
|
319
|
+
const ids = Object.keys (response);
|
320
|
+
for (let i = 0; i < ids.length; i++) {
|
321
|
+
const id = ids[i];
|
322
|
+
for (let j = 0; j < quotes.length; j++) {
|
323
|
+
const quoteId = quotes[j];
|
324
|
+
// usd gets matched before usdt in usdtusd USDT/USD
|
325
|
+
// https://github.com/ccxt/ccxt/issues/9868
|
326
|
+
const slicedId = id.slice (1);
|
327
|
+
const index = slicedId.indexOf (quoteId);
|
328
|
+
const slice = slicedId.slice (index);
|
329
|
+
if ((index > 0) && (slice === quoteId)) {
|
330
|
+
// usd gets matched before usdt in usdtusd USDT/USD
|
331
|
+
// https://github.com/ccxt/ccxt/issues/9868
|
332
|
+
const baseId = id[0] + slicedId.replace (quoteId, '');
|
333
|
+
const base = this.safeCurrencyCode (baseId);
|
334
|
+
const quote = this.safeCurrencyCode (quoteId);
|
335
|
+
markets.push ({
|
336
|
+
'id': id,
|
337
|
+
'symbol': base + '/' + quote,
|
338
|
+
'base': base,
|
339
|
+
'quote': quote,
|
340
|
+
'settle': undefined,
|
341
|
+
'baseId': baseId,
|
342
|
+
'quoteId': quoteId,
|
343
|
+
'settleId': undefined,
|
344
|
+
'type': 'spot',
|
345
|
+
'spot': true,
|
346
|
+
'margin': false,
|
347
|
+
'swap': false,
|
348
|
+
'future': false,
|
349
|
+
'option': false,
|
350
|
+
'active': undefined,
|
351
|
+
'contract': false,
|
352
|
+
'linear': undefined,
|
353
|
+
'inverse': undefined,
|
354
|
+
'contractSize': undefined,
|
355
|
+
'expiry': undefined,
|
356
|
+
'expiryDatetime': undefined,
|
357
|
+
'strike': undefined,
|
358
|
+
'optionType': undefined,
|
359
|
+
'precision': {
|
360
|
+
'amount': undefined,
|
361
|
+
'price': undefined,
|
362
|
+
},
|
363
|
+
'limits': {
|
364
|
+
'leverage': {
|
365
|
+
'min': undefined,
|
366
|
+
'max': undefined,
|
367
|
+
},
|
368
|
+
'amount': {
|
369
|
+
'min': undefined,
|
370
|
+
'max': undefined,
|
371
|
+
},
|
372
|
+
'price': {
|
373
|
+
'min': undefined,
|
374
|
+
'max': undefined,
|
375
|
+
},
|
376
|
+
'cost': {
|
377
|
+
'min': undefined,
|
378
|
+
'max': undefined,
|
379
|
+
},
|
380
|
+
},
|
381
|
+
'info': undefined,
|
382
|
+
});
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
return markets;
|
387
|
+
}
|
388
|
+
|
389
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
390
|
+
await this.loadMarkets ();
|
391
|
+
const market = this.market (symbol);
|
392
|
+
const request = {
|
393
|
+
'market': market['id'],
|
394
|
+
};
|
395
|
+
if (limit !== undefined) {
|
396
|
+
request['limit'] = limit; // default = 300
|
397
|
+
}
|
398
|
+
const orderbook = await this.publicGetDepth (this.extend (request, params));
|
399
|
+
const timestamp = this.safeTimestamp (orderbook, 'timestamp');
|
400
|
+
return this.parseOrderBook (orderbook, symbol, timestamp);
|
401
|
+
}
|
402
|
+
|
403
|
+
parseTicker (ticker, market = undefined) {
|
404
|
+
const timestamp = this.safeTimestamp (ticker, 'at');
|
405
|
+
ticker = ticker['ticker'];
|
406
|
+
const symbol = this.safeSymbol (undefined, market);
|
407
|
+
const last = this.safeString (ticker, 'last');
|
408
|
+
return this.safeTicker ({
|
409
|
+
'symbol': symbol,
|
410
|
+
'timestamp': timestamp,
|
411
|
+
'datetime': this.iso8601 (timestamp),
|
412
|
+
'high': this.safeString (ticker, 'high'),
|
413
|
+
'low': this.safeString (ticker, 'low'),
|
414
|
+
'bid': this.safeString (ticker, 'buy'),
|
415
|
+
'bidVolume': undefined,
|
416
|
+
'ask': this.safeString (ticker, 'sell'),
|
417
|
+
'askVolume': undefined,
|
418
|
+
'vwap': undefined,
|
419
|
+
'open': this.safeString (ticker, 'open'),
|
420
|
+
'close': last,
|
421
|
+
'last': last,
|
422
|
+
'previousClose': undefined,
|
423
|
+
'change': undefined,
|
424
|
+
'percentage': undefined,
|
425
|
+
'average': undefined,
|
426
|
+
'baseVolume': this.safeString (ticker, 'vol'),
|
427
|
+
'quoteVolume': undefined,
|
428
|
+
'info': ticker,
|
429
|
+
}, market, false);
|
430
|
+
}
|
431
|
+
|
432
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
433
|
+
await this.loadMarkets ();
|
434
|
+
const response = await this.publicGetTickers (params);
|
435
|
+
const ids = Object.keys (response);
|
436
|
+
const result = {};
|
437
|
+
for (let i = 0; i < ids.length; i++) {
|
438
|
+
const id = ids[i];
|
439
|
+
let market = undefined;
|
440
|
+
let symbol = id;
|
441
|
+
if (id in this.markets_by_id) {
|
442
|
+
market = this.markets_by_id[id];
|
443
|
+
symbol = market['symbol'];
|
444
|
+
} else {
|
445
|
+
let base = id.slice (0, 3);
|
446
|
+
let quote = id.slice (3, 6);
|
447
|
+
base = base.toUpperCase ();
|
448
|
+
quote = quote.toUpperCase ();
|
449
|
+
base = this.safeCurrencyCode (base);
|
450
|
+
quote = this.safeCurrencyCode (quote);
|
451
|
+
symbol = base + '/' + quote;
|
452
|
+
}
|
453
|
+
result[symbol] = this.parseTicker (response[id], market);
|
454
|
+
}
|
455
|
+
return this.filterByArray (result, 'symbol', symbols);
|
456
|
+
}
|
457
|
+
|
458
|
+
async fetchTicker (symbol, params = {}) {
|
459
|
+
await this.loadMarkets ();
|
460
|
+
const market = this.market (symbol);
|
461
|
+
const request = {
|
462
|
+
'market': market['id'],
|
463
|
+
};
|
464
|
+
const response = await this.publicGetTickersMarket (this.extend (request, params));
|
465
|
+
return this.parseTicker (response, market);
|
466
|
+
}
|
467
|
+
|
468
|
+
async fetchL3OrderBook (symbol, limit = undefined, params = {}) {
|
469
|
+
return await this.fetchOrderBook (symbol, limit, params);
|
470
|
+
}
|
471
|
+
|
472
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
473
|
+
await this.loadMarkets ();
|
474
|
+
const market = this.market (symbol);
|
475
|
+
const request = {
|
476
|
+
'market': market['id'],
|
477
|
+
};
|
478
|
+
const response = await this.publicGetTrades (this.extend (request, params));
|
479
|
+
//
|
480
|
+
// [
|
481
|
+
// {
|
482
|
+
// "id":11353466,
|
483
|
+
// "price":"3000.16",
|
484
|
+
// "volume":"0.000397",
|
485
|
+
// "funds":"1.19106352",
|
486
|
+
// "market":"ethusdt",
|
487
|
+
// "created_at":"2022-04-12T18:32:36Z",
|
488
|
+
// "side":null,
|
489
|
+
// "trend":"sell"
|
490
|
+
// },
|
491
|
+
// ]
|
492
|
+
//
|
493
|
+
return this.parseTrades (response, market, since, limit);
|
494
|
+
}
|
495
|
+
|
496
|
+
parseTrade (trade, market = undefined) {
|
497
|
+
//
|
498
|
+
// fetchTrades (public)
|
499
|
+
//
|
500
|
+
// {
|
501
|
+
// "id":11353466,
|
502
|
+
// "price":"3000.16",
|
503
|
+
// "volume":"0.000397",
|
504
|
+
// "funds":"1.19106352",
|
505
|
+
// "market":"ethusdt",
|
506
|
+
// "created_at":"2022-04-12T18:32:36Z",
|
507
|
+
// "side":null,
|
508
|
+
// "trend":"sell"
|
509
|
+
// }
|
510
|
+
//
|
511
|
+
// fetchMyTrades (private)
|
512
|
+
//
|
513
|
+
// {
|
514
|
+
// "id":11353719,
|
515
|
+
// "price":"0.13566",
|
516
|
+
// "volume":"99.0",
|
517
|
+
// "funds":"13.43034",
|
518
|
+
// "market":"dogeusdt",
|
519
|
+
// "created_at":"2022-04-12T18:58:44Z",
|
520
|
+
// "side":"ask",
|
521
|
+
// "order_id":1665670371,
|
522
|
+
// "trend":"buy"
|
523
|
+
// }
|
524
|
+
//
|
525
|
+
const timestamp = this.parse8601 (this.safeString (trade, 'created_at'));
|
526
|
+
let symbol = undefined;
|
527
|
+
if (market) {
|
528
|
+
symbol = market['symbol'];
|
529
|
+
}
|
530
|
+
let side = this.safeString2 (trade, 'side', 'trend');
|
531
|
+
if (side !== undefined) {
|
532
|
+
const sideMap = {
|
533
|
+
'ask': 'sell',
|
534
|
+
'bid': 'buy',
|
535
|
+
};
|
536
|
+
side = this.safeString (sideMap, side, side);
|
537
|
+
}
|
538
|
+
const priceString = this.safeString (trade, 'price');
|
539
|
+
const amountString = this.safeString (trade, 'volume');
|
540
|
+
const costString = this.safeNumber (trade, 'funds');
|
541
|
+
const orderId = this.safeString (trade, 'order_id');
|
542
|
+
const id = this.safeString (trade, 'id');
|
543
|
+
return this.safeTrade ({
|
544
|
+
'id': id,
|
545
|
+
'info': trade,
|
546
|
+
'timestamp': timestamp,
|
547
|
+
'datetime': this.iso8601 (timestamp),
|
548
|
+
'symbol': symbol,
|
549
|
+
'type': undefined,
|
550
|
+
'side': side,
|
551
|
+
'order': orderId,
|
552
|
+
'takerOrMaker': undefined,
|
553
|
+
'price': priceString,
|
554
|
+
'amount': amountString,
|
555
|
+
'cost': costString,
|
556
|
+
'fee': undefined,
|
557
|
+
}, market);
|
558
|
+
}
|
559
|
+
|
560
|
+
async fetchOHLCV (symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
561
|
+
await this.loadMarkets ();
|
562
|
+
const trades = await this.fetchTrades (symbol, since, limit, params);
|
563
|
+
const ohlcvc = this.buildOHLCVC (trades, timeframe, since, limit);
|
564
|
+
const result = [];
|
565
|
+
for (let i = 0; i < ohlcvc.length; i++) {
|
566
|
+
const ohlcv = ohlcvc[i];
|
567
|
+
result.push ([
|
568
|
+
ohlcv[0],
|
569
|
+
ohlcv[1],
|
570
|
+
ohlcv[2],
|
571
|
+
ohlcv[3],
|
572
|
+
ohlcv[4],
|
573
|
+
ohlcv[5],
|
574
|
+
]);
|
575
|
+
}
|
576
|
+
return result;
|
577
|
+
}
|
578
|
+
|
579
|
+
parseBalance (response) {
|
580
|
+
const balances = this.safeValue (response, 'accounts');
|
581
|
+
const result = { 'info': balances };
|
582
|
+
for (let i = 0; i < balances.length; i++) {
|
583
|
+
const balance = balances[i];
|
584
|
+
const currencyId = this.safeString (balance, 'currency');
|
585
|
+
const code = this.safeCurrencyCode (currencyId);
|
586
|
+
const account = this.account ();
|
587
|
+
account['free'] = this.safeString (balance, 'balance');
|
588
|
+
account['used'] = this.safeString (balance, 'locked');
|
589
|
+
result[code] = account;
|
590
|
+
}
|
591
|
+
return this.safeBalance (result);
|
592
|
+
}
|
593
|
+
|
594
|
+
async fetchBalance (params = {}) {
|
595
|
+
await this.loadMarkets ();
|
596
|
+
const response = await this.privateGetMembersMe (params);
|
597
|
+
return this.parseBalance (response);
|
598
|
+
}
|
599
|
+
|
600
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
601
|
+
await this.loadMarkets ();
|
602
|
+
const request = {
|
603
|
+
'market': this.marketId (symbol),
|
604
|
+
'side': side,
|
605
|
+
'volume': amount.toString (),
|
606
|
+
'ord_type': type,
|
607
|
+
};
|
608
|
+
if (type === 'limit') {
|
609
|
+
request['price'] = price.toString ();
|
610
|
+
}
|
611
|
+
const response = await this.privatePostOrders (this.extend (request, params));
|
612
|
+
const marketId = this.safeValue (response, 'market');
|
613
|
+
const market = this.safeValue (this.markets_by_id, marketId);
|
614
|
+
return this.parseOrder (response, market);
|
615
|
+
}
|
616
|
+
|
617
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
618
|
+
await this.loadMarkets ();
|
619
|
+
const request = {
|
620
|
+
'id': id,
|
621
|
+
};
|
622
|
+
const response = await this.privatePostOrderDelete (this.extend (request, params));
|
623
|
+
const order = this.parseOrder (response);
|
624
|
+
const status = order['status'];
|
625
|
+
if (status === 'closed' || status === 'canceled') {
|
626
|
+
throw new OrderNotFound (this.id + ' ' + this.json (order));
|
627
|
+
}
|
628
|
+
return order;
|
629
|
+
}
|
630
|
+
|
631
|
+
parseOrderStatus (status) {
|
632
|
+
const statuses = {
|
633
|
+
'done': 'closed',
|
634
|
+
'wait': 'open',
|
635
|
+
'cancel': 'canceled',
|
636
|
+
};
|
637
|
+
return this.safeString (statuses, status, status);
|
638
|
+
}
|
639
|
+
|
640
|
+
parseOrder (order, market = undefined) {
|
641
|
+
const marketId = this.safeString (order, 'market');
|
642
|
+
const symbol = this.safeSymbol (marketId, market);
|
643
|
+
const timestamp = this.parse8601 (this.safeString (order, 'created_at'));
|
644
|
+
const status = this.parseOrderStatus (this.safeString (order, 'state'));
|
645
|
+
const type = this.safeString (order, 'type');
|
646
|
+
const side = this.safeString (order, 'side');
|
647
|
+
const id = this.safeString (order, 'id');
|
648
|
+
return this.safeOrder ({
|
649
|
+
'id': id,
|
650
|
+
'clientOrderId': undefined,
|
651
|
+
'timestamp': timestamp,
|
652
|
+
'datetime': this.iso8601 (timestamp),
|
653
|
+
'lastTradeTimestamp': undefined,
|
654
|
+
'status': status,
|
655
|
+
'symbol': symbol,
|
656
|
+
'type': type,
|
657
|
+
'timeInForce': undefined,
|
658
|
+
'postOnly': undefined,
|
659
|
+
'side': side,
|
660
|
+
'price': this.safeString (order, 'price'),
|
661
|
+
'stopPrice': undefined,
|
662
|
+
'amount': this.safeString (order, 'volume'),
|
663
|
+
'filled': this.safeString (order, 'executed_volume'),
|
664
|
+
'remaining': this.safeString (order, 'remaining_volume'),
|
665
|
+
'trades': undefined,
|
666
|
+
'fee': undefined,
|
667
|
+
'info': order,
|
668
|
+
'cost': undefined,
|
669
|
+
'average': undefined,
|
670
|
+
}, market);
|
671
|
+
}
|
672
|
+
|
673
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
674
|
+
await this.loadMarkets ();
|
675
|
+
const request = {
|
676
|
+
'id': parseInt (id),
|
677
|
+
};
|
678
|
+
const response = await this.privateGetOrder (this.extend (request, params));
|
679
|
+
return this.parseOrder (response);
|
680
|
+
}
|
681
|
+
|
682
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
683
|
+
if (symbol === undefined) {
|
684
|
+
throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
|
685
|
+
}
|
686
|
+
await this.loadMarkets ();
|
687
|
+
const market = this.market (symbol);
|
688
|
+
const request = {
|
689
|
+
'market': market['id'],
|
690
|
+
};
|
691
|
+
const response = await this.privateGetOrders (this.extend (request, params));
|
692
|
+
// todo emulation of fetchClosedOrders, fetchOrders, fetchOrder
|
693
|
+
// with order cache + fetchOpenOrders
|
694
|
+
// as in BTC-e, Liqui, Yobit, DSX, Tidex, WEX
|
695
|
+
return this.parseOrders (response, market, since, limit);
|
696
|
+
}
|
697
|
+
|
698
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
699
|
+
//
|
700
|
+
// [
|
701
|
+
// {
|
702
|
+
// "id":11353719,
|
703
|
+
// "price":"0.13566",
|
704
|
+
// "volume":"99.0",
|
705
|
+
// "funds":"13.43034",
|
706
|
+
// "market":"dogeusdt",
|
707
|
+
// "created_at":"2022-04-12T18:58:44Z",
|
708
|
+
// "side":"ask",
|
709
|
+
// "order_id":1665670371,
|
710
|
+
// "trend":"buy"
|
711
|
+
// },
|
712
|
+
// ]
|
713
|
+
//
|
714
|
+
if (symbol === undefined) {
|
715
|
+
throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument');
|
716
|
+
}
|
717
|
+
await this.loadMarkets ();
|
718
|
+
const market = this.market (symbol);
|
719
|
+
const request = {
|
720
|
+
'market': market['id'],
|
721
|
+
};
|
722
|
+
const response = await this.privateGetTradesMy (this.extend (request, params));
|
723
|
+
return this.parseTrades (response, market, since, limit);
|
724
|
+
}
|
725
|
+
|
726
|
+
nonce () {
|
727
|
+
return this.milliseconds ();
|
728
|
+
}
|
729
|
+
|
730
|
+
encodeParams (params) {
|
731
|
+
if ('orders' in params) {
|
732
|
+
const orders = params['orders'];
|
733
|
+
let query = this.urlencode (this.keysort (this.omit (params, 'orders')));
|
734
|
+
for (let i = 0; i < orders.length; i++) {
|
735
|
+
const order = orders[i];
|
736
|
+
const keys = Object.keys (order);
|
737
|
+
for (let k = 0; k < keys.length; k++) {
|
738
|
+
const key = keys[k];
|
739
|
+
const value = order[key];
|
740
|
+
query += '&orders%5B%5D%5B' + key + '%5D=' + value.toString ();
|
741
|
+
}
|
742
|
+
}
|
743
|
+
return query;
|
744
|
+
}
|
745
|
+
return this.urlencode (this.keysort (params));
|
746
|
+
}
|
747
|
+
|
748
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
749
|
+
let url = undefined;
|
750
|
+
if (Array.isArray (api)) {
|
751
|
+
const [ version, access ] = api;
|
752
|
+
url = this.urls['api'][version] + '/' + version + '/' + this.implodeParams (path, params);
|
753
|
+
if (access === 'public') {
|
754
|
+
if (method === 'GET') {
|
755
|
+
if (Object.keys (params).length) {
|
756
|
+
url += '?' + this.urlencode (params);
|
757
|
+
}
|
758
|
+
} else if ((method === 'POST') || (method === 'PUT')) {
|
759
|
+
headers = { 'Content-Type': 'application/json' };
|
760
|
+
body = this.json (params);
|
761
|
+
}
|
762
|
+
} else if (access === 'private') {
|
763
|
+
throw new NotSupported (this.id + ' private v3 API is not supported yet');
|
764
|
+
}
|
765
|
+
} else {
|
766
|
+
let request = '/api/' + this.version + '/' + this.implodeParams (path, params);
|
767
|
+
if ('extension' in this.urls) {
|
768
|
+
request += this.urls['extension'];
|
769
|
+
}
|
770
|
+
const query = this.omit (params, this.extractParams (path));
|
771
|
+
url = this.urls['api'][api] + request;
|
772
|
+
if (api === 'public') {
|
773
|
+
if (Object.keys (query).length) {
|
774
|
+
url += '?' + this.urlencode (query);
|
775
|
+
}
|
776
|
+
} else {
|
777
|
+
this.checkRequiredCredentials ();
|
778
|
+
const nonce = this.nonce ().toString ();
|
779
|
+
const query = this.encodeParams (this.extend ({
|
780
|
+
'access_key': this.apiKey,
|
781
|
+
'tonce': nonce,
|
782
|
+
}, params));
|
783
|
+
const auth = method + '|' + request + '|' + query;
|
784
|
+
const signed = this.hmac (this.encode (auth), this.encode (this.secret));
|
785
|
+
const suffix = query + '&signature=' + signed;
|
786
|
+
if (method === 'GET') {
|
787
|
+
url += '?' + suffix;
|
788
|
+
} else {
|
789
|
+
body = suffix;
|
790
|
+
headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
|
791
|
+
}
|
792
|
+
}
|
793
|
+
}
|
794
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
795
|
+
}
|
796
|
+
|
797
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
798
|
+
if (response === undefined) {
|
799
|
+
return;
|
800
|
+
}
|
801
|
+
if (code === 400) {
|
802
|
+
const error = this.safeValue (response, 'error');
|
803
|
+
const errorCode = this.safeString (error, 'code');
|
804
|
+
const feedback = this.id + ' ' + this.json (response);
|
805
|
+
this.throwExactlyMatchedException (this.exceptions, errorCode, feedback);
|
806
|
+
// fallback to default error handler
|
807
|
+
}
|
808
|
+
}
|
809
|
+
};
|