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/itbit.js
ADDED
@@ -0,0 +1,722 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, AuthenticationError, ArgumentsRequired } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class itbit extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'itbit',
|
15
|
+
'name': 'itBit',
|
16
|
+
'countries': [ 'US' ],
|
17
|
+
'rateLimit': 2000,
|
18
|
+
'version': 'v1',
|
19
|
+
'has': {
|
20
|
+
'CORS': true,
|
21
|
+
'spot': true,
|
22
|
+
'margin': false,
|
23
|
+
'swap': false,
|
24
|
+
'future': false,
|
25
|
+
'option': false,
|
26
|
+
'addMargin': false,
|
27
|
+
'cancelOrder': true,
|
28
|
+
'createMarketOrder': undefined,
|
29
|
+
'createOrder': true,
|
30
|
+
'createReduceOnlyOrder': false,
|
31
|
+
'fetchBalance': true,
|
32
|
+
'fetchBorrowRate': false,
|
33
|
+
'fetchBorrowRateHistories': false,
|
34
|
+
'fetchBorrowRateHistory': false,
|
35
|
+
'fetchBorrowRates': false,
|
36
|
+
'fetchBorrowRatesPerSymbol': false,
|
37
|
+
'fetchClosedOrders': true,
|
38
|
+
'fetchFundingHistory': false,
|
39
|
+
'fetchFundingRate': false,
|
40
|
+
'fetchFundingRateHistory': false,
|
41
|
+
'fetchFundingRates': false,
|
42
|
+
'fetchIndexOHLCV': false,
|
43
|
+
'fetchLeverage': false,
|
44
|
+
'fetchLeverageTiers': false,
|
45
|
+
'fetchMarkOHLCV': false,
|
46
|
+
'fetchMyTrades': true,
|
47
|
+
'fetchOpenOrders': true,
|
48
|
+
'fetchOrder': true,
|
49
|
+
'fetchOrderBook': true,
|
50
|
+
'fetchOrders': true,
|
51
|
+
'fetchPosition': false,
|
52
|
+
'fetchPositions': false,
|
53
|
+
'fetchPositionsRisk': false,
|
54
|
+
'fetchPremiumIndexOHLCV': false,
|
55
|
+
'fetchTicker': true,
|
56
|
+
'fetchTrades': true,
|
57
|
+
'fetchTradingFee': false,
|
58
|
+
'fetchTradingFees': false,
|
59
|
+
'fetchTransactions': true,
|
60
|
+
'reduceMargin': false,
|
61
|
+
'setLeverage': false,
|
62
|
+
'setMarginMode': false,
|
63
|
+
'setPositionMode': false,
|
64
|
+
},
|
65
|
+
'urls': {
|
66
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27822159-66153620-60ad-11e7-89e7-005f6d7f3de0.jpg',
|
67
|
+
'api': 'https://api.itbit.com',
|
68
|
+
'www': 'https://www.itbit.com',
|
69
|
+
'doc': [
|
70
|
+
'https://api.itbit.com/docs',
|
71
|
+
'https://www.itbit.com/api',
|
72
|
+
],
|
73
|
+
},
|
74
|
+
'api': {
|
75
|
+
'public': {
|
76
|
+
'get': [
|
77
|
+
'markets/{symbol}/ticker',
|
78
|
+
'markets/{symbol}/order_book',
|
79
|
+
'markets/{symbol}/trades',
|
80
|
+
],
|
81
|
+
},
|
82
|
+
'private': {
|
83
|
+
'get': [
|
84
|
+
'wallets',
|
85
|
+
'wallets/{walletId}',
|
86
|
+
'wallets/{walletId}/balances/{currencyCode}',
|
87
|
+
'wallets/{walletId}/funding_history',
|
88
|
+
'wallets/{walletId}/trades',
|
89
|
+
'wallets/{walletId}/orders',
|
90
|
+
'wallets/{walletId}/orders/{id}',
|
91
|
+
],
|
92
|
+
'post': [
|
93
|
+
'wallet_transfers',
|
94
|
+
'wallets',
|
95
|
+
'wallets/{walletId}/cryptocurrency_deposits',
|
96
|
+
'wallets/{walletId}/cryptocurrency_withdrawals',
|
97
|
+
'wallets/{walletId}/orders',
|
98
|
+
'wire_withdrawal',
|
99
|
+
],
|
100
|
+
'delete': [
|
101
|
+
'wallets/{walletId}/orders/{id}',
|
102
|
+
],
|
103
|
+
},
|
104
|
+
},
|
105
|
+
'markets': {
|
106
|
+
'BTC/USD': { 'id': 'XBTUSD', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'XBT', 'quoteId': 'USD', 'type': 'spot', 'spot': true },
|
107
|
+
'BTC/SGD': { 'id': 'XBTSGD', 'symbol': 'BTC/SGD', 'base': 'BTC', 'quote': 'SGD', 'baseId': 'XBT', 'quoteId': 'SGD', 'type': 'spot', 'spot': true },
|
108
|
+
'BTC/EUR': { 'id': 'XBTEUR', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'XBT', 'quoteId': 'EUR', 'type': 'spot', 'spot': true },
|
109
|
+
'ETH/USD': { 'id': 'ETHUSD', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'ETH', 'quoteId': 'USD', 'type': 'spot', 'spot': true },
|
110
|
+
'ETH/EUR': { 'id': 'ETHEUR', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'ETH', 'quoteId': 'EUR', 'type': 'spot', 'spot': true },
|
111
|
+
'ETH/SGD': { 'id': 'ETHSGD', 'symbol': 'ETH/SGD', 'base': 'ETH', 'quote': 'SGD', 'baseId': 'ETH', 'quoteId': 'SGD', 'type': 'spot', 'spot': true },
|
112
|
+
'PAXGUSD': { 'id': 'PAXGUSD', 'symbol': 'PAXG/USD', 'base': 'PAXG', 'quote': 'USD', 'baseId': 'PAXG', 'quoteId': 'USD', 'type': 'spot', 'spot': true },
|
113
|
+
'BCHUSD': { 'id': 'BCHUSD', 'symbol': 'BCH/USD', 'base': 'BCH', 'quote': 'USD', 'baseId': 'BCH', 'quoteId': 'USD', 'type': 'spot', 'spot': true },
|
114
|
+
'LTCUSD': { 'id': 'LTCUSD', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'LTC', 'quoteId': 'USD', 'type': 'spot', 'spot': true },
|
115
|
+
},
|
116
|
+
'fees': {
|
117
|
+
'trading': {
|
118
|
+
'maker': -0.03 / 100,
|
119
|
+
'taker': 0.35 / 100,
|
120
|
+
},
|
121
|
+
},
|
122
|
+
'commonCurrencies': {
|
123
|
+
'XBT': 'BTC',
|
124
|
+
},
|
125
|
+
});
|
126
|
+
}
|
127
|
+
|
128
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
129
|
+
await this.loadMarkets ();
|
130
|
+
const request = {
|
131
|
+
'symbol': this.marketId (symbol),
|
132
|
+
};
|
133
|
+
const orderbook = await this.publicGetMarketsSymbolOrderBook (this.extend (request, params));
|
134
|
+
return this.parseOrderBook (orderbook, symbol);
|
135
|
+
}
|
136
|
+
|
137
|
+
parseTicker (ticker, market = undefined) {
|
138
|
+
//
|
139
|
+
// {
|
140
|
+
// "pair":"XBTUSD",
|
141
|
+
// "bid":"36734.50",
|
142
|
+
// "bidAmt":"0.01000000",
|
143
|
+
// "ask":"36734.75",
|
144
|
+
// "askAmt":"0.30750480",
|
145
|
+
// "lastPrice":"36721.75",
|
146
|
+
// "lastAmt":"0.00070461",
|
147
|
+
// "volume24h":"275.50596346",
|
148
|
+
// "volumeToday":"118.19025141",
|
149
|
+
// "high24h":"37510.50",
|
150
|
+
// "low24h":"35542.75",
|
151
|
+
// "highToday":"37510.50",
|
152
|
+
// "lowToday":"36176.50",
|
153
|
+
// "openToday":"37156.50",
|
154
|
+
// "vwapToday":"37008.22463903",
|
155
|
+
// "vwap24h":"36580.27146808",
|
156
|
+
// "serverTimeUTC":"2022-01-28T14:46:32.4472864Z"
|
157
|
+
// }
|
158
|
+
//
|
159
|
+
const symbol = this.safeSymbol (undefined, market);
|
160
|
+
const serverTimeUTC = this.safeString (ticker, 'serverTimeUTC');
|
161
|
+
if (!serverTimeUTC) {
|
162
|
+
throw new ExchangeError (this.id + ' fetchTicker() returned a bad response: ' + this.json (ticker));
|
163
|
+
}
|
164
|
+
const timestamp = this.parse8601 (serverTimeUTC);
|
165
|
+
const vwap = this.safeString (ticker, 'vwap24h');
|
166
|
+
const baseVolume = this.safeString (ticker, 'volume24h');
|
167
|
+
const quoteVolume = Precise.stringMul (baseVolume, vwap);
|
168
|
+
const last = this.safeString (ticker, 'lastPrice');
|
169
|
+
return this.safeTicker ({
|
170
|
+
'symbol': symbol,
|
171
|
+
'timestamp': timestamp,
|
172
|
+
'datetime': this.iso8601 (timestamp),
|
173
|
+
'high': this.safeString (ticker, 'high24h'),
|
174
|
+
'low': this.safeString (ticker, 'low24h'),
|
175
|
+
'bid': this.safeString (ticker, 'bid'),
|
176
|
+
'bidVolume': undefined,
|
177
|
+
'ask': this.safeString (ticker, 'ask'),
|
178
|
+
'askVolume': undefined,
|
179
|
+
'vwap': vwap,
|
180
|
+
'open': this.safeString (ticker, 'openToday'),
|
181
|
+
'close': last,
|
182
|
+
'last': last,
|
183
|
+
'previousClose': undefined,
|
184
|
+
'change': undefined,
|
185
|
+
'percentage': undefined,
|
186
|
+
'average': undefined,
|
187
|
+
'baseVolume': baseVolume,
|
188
|
+
'quoteVolume': quoteVolume,
|
189
|
+
'info': ticker,
|
190
|
+
}, market, false);
|
191
|
+
}
|
192
|
+
|
193
|
+
async fetchTicker (symbol, params = {}) {
|
194
|
+
await this.loadMarkets ();
|
195
|
+
const market = this.market (symbol);
|
196
|
+
const request = {
|
197
|
+
'symbol': market['id'],
|
198
|
+
};
|
199
|
+
const ticker = await this.publicGetMarketsSymbolTicker (this.extend (request, params));
|
200
|
+
//
|
201
|
+
// {
|
202
|
+
// "pair":"XBTUSD",
|
203
|
+
// "bid":"36734.50",
|
204
|
+
// "bidAmt":"0.01000000",
|
205
|
+
// "ask":"36734.75",
|
206
|
+
// "askAmt":"0.30750480",
|
207
|
+
// "lastPrice":"36721.75",
|
208
|
+
// "lastAmt":"0.00070461",
|
209
|
+
// "volume24h":"275.50596346",
|
210
|
+
// "volumeToday":"118.19025141",
|
211
|
+
// "high24h":"37510.50",
|
212
|
+
// "low24h":"35542.75",
|
213
|
+
// "highToday":"37510.50",
|
214
|
+
// "lowToday":"36176.50",
|
215
|
+
// "openToday":"37156.50",
|
216
|
+
// "vwapToday":"37008.22463903",
|
217
|
+
// "vwap24h":"36580.27146808",
|
218
|
+
// "serverTimeUTC":"2022-01-28T14:46:32.4472864Z"
|
219
|
+
// }
|
220
|
+
//
|
221
|
+
return this.parseTicker (ticker, market);
|
222
|
+
}
|
223
|
+
|
224
|
+
parseTrade (trade, market = undefined) {
|
225
|
+
//
|
226
|
+
// fetchTrades (public)
|
227
|
+
//
|
228
|
+
// {
|
229
|
+
// timestamp: "2015-05-22T17:45:34.7570000Z",
|
230
|
+
// matchNumber: "5CR1JEUBBM8J",
|
231
|
+
// price: "351.45000000",
|
232
|
+
// amount: "0.00010000"
|
233
|
+
// }
|
234
|
+
//
|
235
|
+
// fetchMyTrades (private)
|
236
|
+
//
|
237
|
+
// {
|
238
|
+
// "orderId": "248ffda4-83a0-4033-a5bb-8929d523f59f",
|
239
|
+
// "timestamp": "2015-05-11T14:48:01.9870000Z",
|
240
|
+
// "instrument": "XBTUSD",
|
241
|
+
// "direction": "buy", // buy or sell
|
242
|
+
// "currency1": "XBT", // base currency
|
243
|
+
// "currency1Amount": "0.00010000", // order amount in base currency
|
244
|
+
// "currency2": "USD", // quote currency
|
245
|
+
// "currency2Amount": "0.0250530000000000", // order cost in quote currency
|
246
|
+
// "rate": "250.53000000",
|
247
|
+
// "commissionPaid": "0.00000000", // net trade fee paid after using any available rebate balance
|
248
|
+
// "commissionCurrency": "USD",
|
249
|
+
// "rebatesApplied": "-0.000125265", // negative values represent amount of rebate balance used for trades removing liquidity from order book; positive values represent amount of rebate balance earned from trades adding liquidity to order book
|
250
|
+
// "rebateCurrency": "USD",
|
251
|
+
// "executionId": "23132"
|
252
|
+
// }
|
253
|
+
//
|
254
|
+
const id = this.safeString2 (trade, 'executionId', 'matchNumber');
|
255
|
+
const timestamp = this.parse8601 (this.safeString (trade, 'timestamp'));
|
256
|
+
const side = this.safeString (trade, 'direction');
|
257
|
+
const orderId = this.safeString (trade, 'orderId');
|
258
|
+
let feeCost = this.safeNumber (trade, 'commissionPaid');
|
259
|
+
const feeCurrencyId = this.safeString (trade, 'commissionCurrency');
|
260
|
+
const feeCurrency = this.safeCurrencyCode (feeCurrencyId);
|
261
|
+
let rebatesApplied = this.safeNumber (trade, 'rebatesApplied');
|
262
|
+
if (rebatesApplied !== undefined) {
|
263
|
+
rebatesApplied = -rebatesApplied;
|
264
|
+
}
|
265
|
+
const rebateCurrencyId = this.safeString (trade, 'rebateCurrency');
|
266
|
+
const rebateCurrency = this.safeCurrencyCode (rebateCurrencyId);
|
267
|
+
const priceString = this.safeString2 (trade, 'price', 'rate');
|
268
|
+
const amountString = this.safeString2 (trade, 'currency1Amount', 'amount');
|
269
|
+
const price = this.parseNumber (priceString);
|
270
|
+
const amount = this.parseNumber (amountString);
|
271
|
+
const cost = this.parseNumber (Precise.stringMul (priceString, amountString));
|
272
|
+
let symbol = undefined;
|
273
|
+
const marketId = this.safeString (trade, 'instrument');
|
274
|
+
if (marketId !== undefined) {
|
275
|
+
if (marketId in this.markets_by_id) {
|
276
|
+
market = this.markets_by_id[marketId];
|
277
|
+
} else {
|
278
|
+
const baseId = this.safeString (trade, 'currency1');
|
279
|
+
const quoteId = this.safeString (trade, 'currency2');
|
280
|
+
const base = this.safeCurrencyCode (baseId);
|
281
|
+
const quote = this.safeCurrencyCode (quoteId);
|
282
|
+
symbol = base + '/' + quote;
|
283
|
+
}
|
284
|
+
}
|
285
|
+
if (symbol === undefined) {
|
286
|
+
if (market !== undefined) {
|
287
|
+
symbol = market['symbol'];
|
288
|
+
}
|
289
|
+
}
|
290
|
+
const result = {
|
291
|
+
'info': trade,
|
292
|
+
'id': id,
|
293
|
+
'timestamp': timestamp,
|
294
|
+
'datetime': this.iso8601 (timestamp),
|
295
|
+
'symbol': symbol,
|
296
|
+
'order': orderId,
|
297
|
+
'type': undefined,
|
298
|
+
'side': side,
|
299
|
+
'takerOrMaker': undefined,
|
300
|
+
'price': price,
|
301
|
+
'amount': amount,
|
302
|
+
'cost': cost,
|
303
|
+
'fee': undefined,
|
304
|
+
};
|
305
|
+
if (feeCost !== undefined) {
|
306
|
+
if (rebatesApplied !== undefined) {
|
307
|
+
if (feeCurrency === rebateCurrency) {
|
308
|
+
feeCost = this.sum (feeCost, rebatesApplied);
|
309
|
+
result['fee'] = {
|
310
|
+
'cost': feeCost,
|
311
|
+
'currency': feeCurrency,
|
312
|
+
};
|
313
|
+
} else {
|
314
|
+
result['fees'] = [
|
315
|
+
{
|
316
|
+
'cost': feeCost,
|
317
|
+
'currency': feeCurrency,
|
318
|
+
},
|
319
|
+
{
|
320
|
+
'cost': rebatesApplied,
|
321
|
+
'currency': rebateCurrency,
|
322
|
+
},
|
323
|
+
];
|
324
|
+
}
|
325
|
+
} else {
|
326
|
+
result['fee'] = {
|
327
|
+
'cost': feeCost,
|
328
|
+
'currency': feeCurrency,
|
329
|
+
};
|
330
|
+
}
|
331
|
+
}
|
332
|
+
if (!('fee' in result)) {
|
333
|
+
if (!('fees' in result)) {
|
334
|
+
result['fee'] = undefined;
|
335
|
+
}
|
336
|
+
}
|
337
|
+
return result;
|
338
|
+
}
|
339
|
+
|
340
|
+
async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) {
|
341
|
+
await this.loadMarkets ();
|
342
|
+
const walletId = this.safeString (params, 'walletId');
|
343
|
+
if (walletId === undefined) {
|
344
|
+
throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a walletId parameter');
|
345
|
+
}
|
346
|
+
const request = {
|
347
|
+
'walletId': walletId,
|
348
|
+
};
|
349
|
+
if (limit !== undefined) {
|
350
|
+
request['perPage'] = limit; // default 50, max 50
|
351
|
+
}
|
352
|
+
const response = await this.privateGetWalletsWalletIdFundingHistory (this.extend (request, params));
|
353
|
+
// { bankName: 'USBC (usd)',
|
354
|
+
// withdrawalId: 94740,
|
355
|
+
// holdingPeriodCompletionDate: '2018-04-16T07:57:05.9606869',
|
356
|
+
// time: '2018-04-16T07:57:05.9600000',
|
357
|
+
// currency: 'USD',
|
358
|
+
// transactionType: 'Withdrawal',
|
359
|
+
// amount: '2186.72000000',
|
360
|
+
// walletName: 'Wallet',
|
361
|
+
// status: 'completed' },
|
362
|
+
//
|
363
|
+
// { "time": "2018-01-02T19:52:22.4176503",
|
364
|
+
// "amount": "0.50000000",
|
365
|
+
// "status": "completed",
|
366
|
+
// "txnHash": "1b6fff67ed83cb9e9a38ca4976981fc047322bc088430508fe764a127d3ace95",
|
367
|
+
// "currency": "XBT",
|
368
|
+
// "walletName": "Wallet",
|
369
|
+
// "transactionType": "Deposit",
|
370
|
+
// "destinationAddress": "3AAWTH9et4e8o51YKp9qPpmujrNXKwHWNX"}
|
371
|
+
const items = response['fundingHistory'];
|
372
|
+
const result = [];
|
373
|
+
for (let i = 0; i < items.length; i++) {
|
374
|
+
const item = items[i];
|
375
|
+
const time = this.safeString (item, 'time');
|
376
|
+
const timestamp = this.parse8601 (time);
|
377
|
+
const currency = this.safeString (item, 'currency');
|
378
|
+
const destinationAddress = this.safeString (item, 'destinationAddress');
|
379
|
+
const txnHash = this.safeString (item, 'txnHash');
|
380
|
+
const transactionType = this.safeStringLower (item, 'transactionType');
|
381
|
+
const transactionStatus = this.safeString (item, 'status');
|
382
|
+
const status = this.parseTransferStatus (transactionStatus);
|
383
|
+
result.push ({
|
384
|
+
'id': this.safeString (item, 'withdrawalId'),
|
385
|
+
'timestamp': timestamp,
|
386
|
+
'datetime': this.iso8601 (timestamp),
|
387
|
+
'currency': this.safeCurrencyCode (currency),
|
388
|
+
'address': destinationAddress,
|
389
|
+
'tag': undefined,
|
390
|
+
'txid': txnHash,
|
391
|
+
'type': transactionType,
|
392
|
+
'status': status,
|
393
|
+
'amount': this.safeNumber (item, 'amount'),
|
394
|
+
'fee': undefined,
|
395
|
+
'info': item,
|
396
|
+
});
|
397
|
+
}
|
398
|
+
return result;
|
399
|
+
}
|
400
|
+
|
401
|
+
parseTransferStatus (status) {
|
402
|
+
const options = {
|
403
|
+
'cancelled': 'canceled',
|
404
|
+
'completed': 'ok',
|
405
|
+
};
|
406
|
+
return this.safeString (options, status, 'pending');
|
407
|
+
}
|
408
|
+
|
409
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
410
|
+
await this.loadMarkets ();
|
411
|
+
const walletId = this.safeString (params, 'walletId');
|
412
|
+
if (walletId === undefined) {
|
413
|
+
throw new ExchangeError (this.id + ' fetchMyTrades() requires a walletId parameter');
|
414
|
+
}
|
415
|
+
const request = {
|
416
|
+
'walletId': walletId,
|
417
|
+
};
|
418
|
+
if (since !== undefined) {
|
419
|
+
request['rangeStart'] = this.ymdhms (since, 'T');
|
420
|
+
}
|
421
|
+
if (limit !== undefined) {
|
422
|
+
request['perPage'] = limit; // default 50, max 50
|
423
|
+
}
|
424
|
+
const response = await this.privateGetWalletsWalletIdTrades (this.extend (request, params));
|
425
|
+
//
|
426
|
+
// {
|
427
|
+
// "totalNumberOfRecords": "2",
|
428
|
+
// "currentPageNumber": "1",
|
429
|
+
// "latestExecutionId": "332", // most recent execution at time of response
|
430
|
+
// "recordsPerPage": "50",
|
431
|
+
// "tradingHistory": [
|
432
|
+
// {
|
433
|
+
// "orderId": "248ffda4-83a0-4033-a5bb-8929d523f59f",
|
434
|
+
// "timestamp": "2015-05-11T14:48:01.9870000Z",
|
435
|
+
// "instrument": "XBTUSD",
|
436
|
+
// "direction": "buy", // buy or sell
|
437
|
+
// "currency1": "XBT", // base currency
|
438
|
+
// "currency1Amount": "0.00010000", // order amount in base currency
|
439
|
+
// "currency2": "USD", // quote currency
|
440
|
+
// "currency2Amount": "0.0250530000000000", // order cost in quote currency
|
441
|
+
// "rate": "250.53000000",
|
442
|
+
// "commissionPaid": "0.00000000", // net trade fee paid after using any available rebate balance
|
443
|
+
// "commissionCurrency": "USD",
|
444
|
+
// "rebatesApplied": "-0.000125265", // negative values represent amount of rebate balance used for trades removing liquidity from order book; positive values represent amount of rebate balance earned from trades adding liquidity to order book
|
445
|
+
// "rebateCurrency": "USD",
|
446
|
+
// "executionId": "23132"
|
447
|
+
// },
|
448
|
+
// ],
|
449
|
+
// }
|
450
|
+
//
|
451
|
+
const trades = this.safeValue (response, 'tradingHistory', []);
|
452
|
+
let market = undefined;
|
453
|
+
if (symbol !== undefined) {
|
454
|
+
market = this.market (symbol);
|
455
|
+
}
|
456
|
+
return this.parseTrades (trades, market, since, limit);
|
457
|
+
}
|
458
|
+
|
459
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
460
|
+
await this.loadMarkets ();
|
461
|
+
const market = this.market (symbol);
|
462
|
+
const request = {
|
463
|
+
'symbol': market['id'],
|
464
|
+
};
|
465
|
+
const response = await this.publicGetMarketsSymbolTrades (this.extend (request, params));
|
466
|
+
//
|
467
|
+
// {
|
468
|
+
// count: 3,
|
469
|
+
// recentTrades: [
|
470
|
+
// {
|
471
|
+
// timestamp: "2015-05-22T17:45:34.7570000Z",
|
472
|
+
// matchNumber: "5CR1JEUBBM8J",
|
473
|
+
// price: "351.45000000",
|
474
|
+
// amount: "0.00010000"
|
475
|
+
// },
|
476
|
+
// ]
|
477
|
+
// }
|
478
|
+
//
|
479
|
+
const trades = this.safeValue (response, 'recentTrades', []);
|
480
|
+
return this.parseTrades (trades, market, since, limit);
|
481
|
+
}
|
482
|
+
|
483
|
+
parseBalance (response) {
|
484
|
+
const balances = response[0]['balances'];
|
485
|
+
const result = { 'info': response };
|
486
|
+
for (let i = 0; i < balances.length; i++) {
|
487
|
+
const balance = balances[i];
|
488
|
+
const currencyId = this.safeString (balance, 'currency');
|
489
|
+
const code = this.safeCurrencyCode (currencyId);
|
490
|
+
const account = this.account ();
|
491
|
+
account['free'] = this.safeString (balance, 'availableBalance');
|
492
|
+
account['total'] = this.safeString (balance, 'totalBalance');
|
493
|
+
result[code] = account;
|
494
|
+
}
|
495
|
+
return this.safeBalance (result);
|
496
|
+
}
|
497
|
+
|
498
|
+
async fetchBalance (params = {}) {
|
499
|
+
await this.loadMarkets ();
|
500
|
+
const response = await this.fetchWallets (params);
|
501
|
+
return this.parseBalance (response);
|
502
|
+
}
|
503
|
+
|
504
|
+
async fetchWallets (params = {}) {
|
505
|
+
await this.loadMarkets ();
|
506
|
+
if (!this.uid) {
|
507
|
+
throw new AuthenticationError (this.id + ' fetchWallets() requires uid API credential');
|
508
|
+
}
|
509
|
+
const request = {
|
510
|
+
'userId': this.uid,
|
511
|
+
};
|
512
|
+
return await this.privateGetWallets (this.extend (request, params));
|
513
|
+
}
|
514
|
+
|
515
|
+
async fetchWallet (walletId, params = {}) {
|
516
|
+
await this.loadMarkets ();
|
517
|
+
const request = {
|
518
|
+
'walletId': walletId,
|
519
|
+
};
|
520
|
+
return await this.privateGetWalletsWalletId (this.extend (request, params));
|
521
|
+
}
|
522
|
+
|
523
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
524
|
+
const request = {
|
525
|
+
'status': 'open',
|
526
|
+
};
|
527
|
+
return await this.fetchOrders (symbol, since, limit, this.extend (request, params));
|
528
|
+
}
|
529
|
+
|
530
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
531
|
+
const request = {
|
532
|
+
'status': 'filled',
|
533
|
+
};
|
534
|
+
return await this.fetchOrders (symbol, since, limit, this.extend (request, params));
|
535
|
+
}
|
536
|
+
|
537
|
+
async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
538
|
+
await this.loadMarkets ();
|
539
|
+
let market = undefined;
|
540
|
+
if (symbol !== undefined) {
|
541
|
+
market = this.market (symbol);
|
542
|
+
}
|
543
|
+
const walletIdInParams = ('walletId' in params);
|
544
|
+
if (!walletIdInParams) {
|
545
|
+
throw new ExchangeError (this.id + ' fetchOrders() requires a walletId parameter');
|
546
|
+
}
|
547
|
+
const walletId = params['walletId'];
|
548
|
+
const request = {
|
549
|
+
'walletId': walletId,
|
550
|
+
};
|
551
|
+
const response = await this.privateGetWalletsWalletIdOrders (this.extend (request, params));
|
552
|
+
return this.parseOrders (response, market, since, limit);
|
553
|
+
}
|
554
|
+
|
555
|
+
parseOrderStatus (status) {
|
556
|
+
const statuses = {
|
557
|
+
'submitted': 'open', // order pending book entry
|
558
|
+
'open': 'open',
|
559
|
+
'filled': 'closed',
|
560
|
+
'cancelled': 'canceled',
|
561
|
+
'rejected': 'canceled',
|
562
|
+
};
|
563
|
+
return this.safeString (statuses, status, status);
|
564
|
+
}
|
565
|
+
|
566
|
+
parseOrder (order, market = undefined) {
|
567
|
+
//
|
568
|
+
// {
|
569
|
+
// "id": "13d6af57-8b0b-41e5-af30-becf0bcc574d",
|
570
|
+
// "walletId": "7e037345-1288-4c39-12fe-d0f99a475a98",
|
571
|
+
// "side": "buy",
|
572
|
+
// "instrument": "XBTUSD",
|
573
|
+
// "type": "limit",
|
574
|
+
// "currency": "XBT",
|
575
|
+
// "amount": "2.50000000",
|
576
|
+
// "displayAmount": "2.50000000",
|
577
|
+
// "price": "650.00000000",
|
578
|
+
// "volumeWeightedAveragePrice": "0.00000000",
|
579
|
+
// "amountFilled": "0.00000000",
|
580
|
+
// "createdTime": "2014-02-11T17:05:15Z",
|
581
|
+
// "status": "submitted",
|
582
|
+
// "funds": null,
|
583
|
+
// "metadata": {},
|
584
|
+
// "clientOrderIdentifier": null,
|
585
|
+
// "postOnly": "False"
|
586
|
+
// }
|
587
|
+
//
|
588
|
+
const side = this.safeString (order, 'side');
|
589
|
+
const type = this.safeString (order, 'type');
|
590
|
+
const symbol = this.markets_by_id[order['instrument']]['symbol'];
|
591
|
+
const timestamp = this.parse8601 (order['createdTime']);
|
592
|
+
const amount = this.safeString (order, 'amount');
|
593
|
+
const filled = this.safeString (order, 'amountFilled');
|
594
|
+
const fee = undefined;
|
595
|
+
const price = this.safeString (order, 'price');
|
596
|
+
const average = this.safeString (order, 'volumeWeightedAveragePrice');
|
597
|
+
const clientOrderId = this.safeString (order, 'clientOrderIdentifier');
|
598
|
+
const id = this.safeString (order, 'id');
|
599
|
+
const postOnlyString = this.safeString (order, 'postOnly');
|
600
|
+
const postOnly = (postOnlyString === 'True');
|
601
|
+
return this.safeOrder ({
|
602
|
+
'id': id,
|
603
|
+
'clientOrderId': clientOrderId,
|
604
|
+
'info': order,
|
605
|
+
'timestamp': timestamp,
|
606
|
+
'datetime': this.iso8601 (timestamp),
|
607
|
+
'lastTradeTimestamp': undefined,
|
608
|
+
'status': this.parseOrderStatus (this.safeString (order, 'status')),
|
609
|
+
'symbol': symbol,
|
610
|
+
'type': type,
|
611
|
+
'timeInForce': undefined,
|
612
|
+
'postOnly': postOnly,
|
613
|
+
'side': side,
|
614
|
+
'price': price,
|
615
|
+
'stopPrice': undefined,
|
616
|
+
'cost': undefined,
|
617
|
+
'average': average,
|
618
|
+
'amount': amount,
|
619
|
+
'filled': filled,
|
620
|
+
'remaining': undefined,
|
621
|
+
'fee': fee,
|
622
|
+
// 'trades': this.parseTrades (order['trades'], market),
|
623
|
+
'trades': undefined,
|
624
|
+
}, market);
|
625
|
+
}
|
626
|
+
|
627
|
+
nonce () {
|
628
|
+
return this.milliseconds ();
|
629
|
+
}
|
630
|
+
|
631
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
632
|
+
await this.loadMarkets ();
|
633
|
+
if (type === 'market') {
|
634
|
+
throw new ExchangeError (this.id + ' createOrder() allows limit orders only');
|
635
|
+
}
|
636
|
+
const walletIdInParams = ('walletId' in params);
|
637
|
+
if (!walletIdInParams) {
|
638
|
+
throw new ExchangeError (this.id + ' createOrder() requires a walletId parameter');
|
639
|
+
}
|
640
|
+
amount = amount.toString ();
|
641
|
+
price = price.toString ();
|
642
|
+
const market = this.market (symbol);
|
643
|
+
const request = {
|
644
|
+
'side': side,
|
645
|
+
'type': type,
|
646
|
+
'currency': market['id'].replace (market['quote'], ''),
|
647
|
+
'amount': amount,
|
648
|
+
'display': amount,
|
649
|
+
'price': price,
|
650
|
+
'instrument': market['id'],
|
651
|
+
};
|
652
|
+
const response = await this.privatePostWalletsWalletIdOrders (this.extend (request, params));
|
653
|
+
return {
|
654
|
+
'info': response,
|
655
|
+
'id': response['id'],
|
656
|
+
};
|
657
|
+
}
|
658
|
+
|
659
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
660
|
+
await this.loadMarkets ();
|
661
|
+
const walletIdInParams = ('walletId' in params);
|
662
|
+
if (!walletIdInParams) {
|
663
|
+
throw new ExchangeError (this.id + ' fetchOrder() requires a walletId parameter');
|
664
|
+
}
|
665
|
+
const request = {
|
666
|
+
'id': id,
|
667
|
+
};
|
668
|
+
const response = await this.privateGetWalletsWalletIdOrdersId (this.extend (request, params));
|
669
|
+
return this.parseOrder (response);
|
670
|
+
}
|
671
|
+
|
672
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
673
|
+
const walletIdInParams = ('walletId' in params);
|
674
|
+
if (!walletIdInParams) {
|
675
|
+
throw new ExchangeError (this.id + ' cancelOrder() requires a walletId parameter');
|
676
|
+
}
|
677
|
+
const request = {
|
678
|
+
'id': id,
|
679
|
+
};
|
680
|
+
return await this.privateDeleteWalletsWalletIdOrdersId (this.extend (request, params));
|
681
|
+
}
|
682
|
+
|
683
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
684
|
+
let url = this.urls['api'] + '/' + this.version + '/' + this.implodeParams (path, params);
|
685
|
+
const query = this.omit (params, this.extractParams (path));
|
686
|
+
if (method === 'GET' && Object.keys (query).length) {
|
687
|
+
url += '?' + this.urlencode (query);
|
688
|
+
}
|
689
|
+
if (method === 'POST' && Object.keys (query).length) {
|
690
|
+
body = this.json (query);
|
691
|
+
}
|
692
|
+
if (api === 'private') {
|
693
|
+
this.checkRequiredCredentials ();
|
694
|
+
const nonce = this.nonce ().toString ();
|
695
|
+
const timestamp = nonce;
|
696
|
+
const authBody = (method === 'POST') ? body : '';
|
697
|
+
const auth = [ method, url, authBody, nonce, timestamp ];
|
698
|
+
const message = nonce + this.json (auth).replace ('\\/', '/');
|
699
|
+
const hash = this.hash (this.encode (message), 'sha256', 'binary');
|
700
|
+
const binaryUrl = this.stringToBinary (this.encode (url));
|
701
|
+
const binhash = this.binaryConcat (binaryUrl, hash);
|
702
|
+
const signature = this.hmac (binhash, this.encode (this.secret), 'sha512', 'base64');
|
703
|
+
headers = {
|
704
|
+
'Authorization': this.apiKey + ':' + signature,
|
705
|
+
'Content-Type': 'application/json',
|
706
|
+
'X-Auth-Timestamp': timestamp,
|
707
|
+
'X-Auth-Nonce': nonce,
|
708
|
+
};
|
709
|
+
}
|
710
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
711
|
+
}
|
712
|
+
|
713
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
714
|
+
if (response === undefined) {
|
715
|
+
return;
|
716
|
+
}
|
717
|
+
const code = this.safeString (response, 'code');
|
718
|
+
if (code !== undefined) {
|
719
|
+
throw new ExchangeError (this.id + ' ' + this.json (response));
|
720
|
+
}
|
721
|
+
}
|
722
|
+
};
|