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/mercado.js
ADDED
@@ -0,0 +1,771 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { ExchangeError, ArgumentsRequired, InvalidOrder } = require ('./base/errors');
|
7
|
+
|
8
|
+
// ---------------------------------------------------------------------------
|
9
|
+
|
10
|
+
module.exports = class mercado extends Exchange {
|
11
|
+
describe () {
|
12
|
+
return this.deepExtend (super.describe (), {
|
13
|
+
'id': 'mercado',
|
14
|
+
'name': 'Mercado Bitcoin',
|
15
|
+
'countries': [ 'BR' ], // Brazil
|
16
|
+
'rateLimit': 1000,
|
17
|
+
'version': 'v3',
|
18
|
+
'has': {
|
19
|
+
'CORS': true,
|
20
|
+
'spot': true,
|
21
|
+
'margin': false,
|
22
|
+
'swap': false,
|
23
|
+
'future': false,
|
24
|
+
'option': false,
|
25
|
+
'addMargin': false,
|
26
|
+
'cancelOrder': true,
|
27
|
+
'createMarketOrder': true,
|
28
|
+
'createOrder': true,
|
29
|
+
'createReduceOnlyOrder': false,
|
30
|
+
'fetchBalance': true,
|
31
|
+
'fetchBorrowRate': false,
|
32
|
+
'fetchBorrowRateHistory': false,
|
33
|
+
'fetchBorrowRates': false,
|
34
|
+
'fetchBorrowRatesPerSymbol': false,
|
35
|
+
'fetchFundingHistory': false,
|
36
|
+
'fetchFundingRate': false,
|
37
|
+
'fetchFundingRateHistory': false,
|
38
|
+
'fetchFundingRates': false,
|
39
|
+
'fetchIndexOHLCV': false,
|
40
|
+
'fetchLeverage': false,
|
41
|
+
'fetchLeverageTiers': false,
|
42
|
+
'fetchMarkets': true,
|
43
|
+
'fetchMarkOHLCV': false,
|
44
|
+
'fetchMyTrades': 'emulated',
|
45
|
+
'fetchOHLCV': true,
|
46
|
+
'fetchOpenOrders': true,
|
47
|
+
'fetchOrder': true,
|
48
|
+
'fetchOrderBook': true,
|
49
|
+
'fetchOrders': true,
|
50
|
+
'fetchPosition': false,
|
51
|
+
'fetchPositions': false,
|
52
|
+
'fetchPositionsRisk': false,
|
53
|
+
'fetchPremiumIndexOHLCV': false,
|
54
|
+
'fetchTicker': true,
|
55
|
+
'fetchTickers': undefined,
|
56
|
+
'fetchTrades': true,
|
57
|
+
'fetchTradingFee': false,
|
58
|
+
'fetchTradingFees': false,
|
59
|
+
'reduceMargin': false,
|
60
|
+
'setLeverage': false,
|
61
|
+
'setMarginMode': false,
|
62
|
+
'setPositionMode': false,
|
63
|
+
'withdraw': true,
|
64
|
+
},
|
65
|
+
'timeframes': {
|
66
|
+
'1m': '1m',
|
67
|
+
'5m': '5m',
|
68
|
+
'15m': '15m',
|
69
|
+
'30m': '30m',
|
70
|
+
'1h': '1h',
|
71
|
+
'6h': '6h',
|
72
|
+
'12h': '12h',
|
73
|
+
'1d': '1d',
|
74
|
+
'3d': '3d',
|
75
|
+
'1w': '1w',
|
76
|
+
'2w': '2w',
|
77
|
+
},
|
78
|
+
'urls': {
|
79
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/27837060-e7c58714-60ea-11e7-9192-f05e86adb83f.jpg',
|
80
|
+
'api': {
|
81
|
+
'public': 'https://www.mercadobitcoin.net/api',
|
82
|
+
'private': 'https://www.mercadobitcoin.net/tapi',
|
83
|
+
'v4Public': 'https://www.mercadobitcoin.com.br/v4',
|
84
|
+
},
|
85
|
+
'www': 'https://www.mercadobitcoin.com.br',
|
86
|
+
'doc': [
|
87
|
+
'https://www.mercadobitcoin.com.br/api-doc',
|
88
|
+
'https://www.mercadobitcoin.com.br/trade-api',
|
89
|
+
],
|
90
|
+
},
|
91
|
+
'api': {
|
92
|
+
'public': {
|
93
|
+
'get': [
|
94
|
+
'coins',
|
95
|
+
'{coin}/orderbook/', // last slash critical
|
96
|
+
'{coin}/ticker/',
|
97
|
+
'{coin}/trades/',
|
98
|
+
'{coin}/trades/{from}/',
|
99
|
+
'{coin}/trades/{from}/{to}',
|
100
|
+
'{coin}/day-summary/{year}/{month}/{day}/',
|
101
|
+
],
|
102
|
+
},
|
103
|
+
'private': {
|
104
|
+
'post': [
|
105
|
+
'cancel_order',
|
106
|
+
'get_account_info',
|
107
|
+
'get_order',
|
108
|
+
'get_withdrawal',
|
109
|
+
'list_system_messages',
|
110
|
+
'list_orders',
|
111
|
+
'list_orderbook',
|
112
|
+
'place_buy_order',
|
113
|
+
'place_sell_order',
|
114
|
+
'place_market_buy_order',
|
115
|
+
'place_market_sell_order',
|
116
|
+
'withdraw_coin',
|
117
|
+
],
|
118
|
+
},
|
119
|
+
'v4Public': {
|
120
|
+
'get': [
|
121
|
+
'{coin}/candle/',
|
122
|
+
],
|
123
|
+
},
|
124
|
+
},
|
125
|
+
'fees': {
|
126
|
+
'trading': {
|
127
|
+
'maker': 0.003,
|
128
|
+
'taker': 0.007,
|
129
|
+
},
|
130
|
+
},
|
131
|
+
'options': {
|
132
|
+
'limits': {
|
133
|
+
'BTC': 0.001,
|
134
|
+
'BCH': 0.001,
|
135
|
+
'ETH': 0.01,
|
136
|
+
'LTC': 0.01,
|
137
|
+
'XRP': 0.1,
|
138
|
+
},
|
139
|
+
},
|
140
|
+
});
|
141
|
+
}
|
142
|
+
|
143
|
+
async fetchMarkets (params = {}) {
|
144
|
+
const response = await this.publicGetCoins (params);
|
145
|
+
//
|
146
|
+
// [
|
147
|
+
// "BCH",
|
148
|
+
// "BTC",
|
149
|
+
// "ETH",
|
150
|
+
// "LTC",
|
151
|
+
// "XRP",
|
152
|
+
// "MBPRK01",
|
153
|
+
// "MBPRK02",
|
154
|
+
// "MBPRK03",
|
155
|
+
// "MBPRK04",
|
156
|
+
// "MBCONS01",
|
157
|
+
// "USDC",
|
158
|
+
// "WBX",
|
159
|
+
// "CHZ",
|
160
|
+
// "MBCONS02",
|
161
|
+
// "PAXG",
|
162
|
+
// "MBVASCO01",
|
163
|
+
// "LINK"
|
164
|
+
// ]
|
165
|
+
//
|
166
|
+
const result = [];
|
167
|
+
const amountLimits = this.safeValue (this.options, 'limits', {});
|
168
|
+
for (let i = 0; i < response.length; i++) {
|
169
|
+
const coin = response[i];
|
170
|
+
const baseId = coin;
|
171
|
+
const quoteId = 'BRL';
|
172
|
+
const base = this.safeCurrencyCode (baseId);
|
173
|
+
const quote = this.safeCurrencyCode (quoteId);
|
174
|
+
const id = quote + base;
|
175
|
+
const priceLimit = '1e-5';
|
176
|
+
result.push ({
|
177
|
+
'id': id,
|
178
|
+
'symbol': base + '/' + quote,
|
179
|
+
'base': base,
|
180
|
+
'quote': quote,
|
181
|
+
'settle': undefined,
|
182
|
+
'baseId': baseId,
|
183
|
+
'quoteId': quoteId,
|
184
|
+
'settleId': undefined,
|
185
|
+
'type': 'spot',
|
186
|
+
'spot': true,
|
187
|
+
'margin': false,
|
188
|
+
'swap': false,
|
189
|
+
'future': false,
|
190
|
+
'option': false,
|
191
|
+
'active': undefined,
|
192
|
+
'contract': false,
|
193
|
+
'linear': undefined,
|
194
|
+
'inverse': undefined,
|
195
|
+
'contractSize': undefined,
|
196
|
+
'expiry': undefined,
|
197
|
+
'expiryDatetime': undefined,
|
198
|
+
'strike': undefined,
|
199
|
+
'optionType': undefined,
|
200
|
+
'precision': {
|
201
|
+
'amount': parseInt ('8'),
|
202
|
+
'price': parseInt ('5'),
|
203
|
+
},
|
204
|
+
'limits': {
|
205
|
+
'leverage': {
|
206
|
+
'min': undefined,
|
207
|
+
'max': undefined,
|
208
|
+
},
|
209
|
+
'amount': {
|
210
|
+
'min': this.safeNumber (amountLimits, baseId),
|
211
|
+
'max': undefined,
|
212
|
+
},
|
213
|
+
'price': {
|
214
|
+
'min': this.parseNumber (priceLimit),
|
215
|
+
'max': undefined,
|
216
|
+
},
|
217
|
+
'cost': {
|
218
|
+
'min': undefined,
|
219
|
+
'max': undefined,
|
220
|
+
},
|
221
|
+
},
|
222
|
+
'info': coin,
|
223
|
+
});
|
224
|
+
}
|
225
|
+
return result;
|
226
|
+
}
|
227
|
+
|
228
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
229
|
+
await this.loadMarkets ();
|
230
|
+
const market = this.market (symbol);
|
231
|
+
const request = {
|
232
|
+
'coin': market['base'],
|
233
|
+
};
|
234
|
+
const response = await this.publicGetCoinOrderbook (this.extend (request, params));
|
235
|
+
return this.parseOrderBook (response, symbol);
|
236
|
+
}
|
237
|
+
|
238
|
+
parseTicker (ticker, market = undefined) {
|
239
|
+
//
|
240
|
+
// {
|
241
|
+
// "high":"103.96000000",
|
242
|
+
// "low":"95.00000000",
|
243
|
+
// "vol":"2227.67806598",
|
244
|
+
// "last":"97.91591000",
|
245
|
+
// "buy":"95.52760000",
|
246
|
+
// "sell":"97.91475000",
|
247
|
+
// "open":"99.79955000",
|
248
|
+
// "date":1643382606
|
249
|
+
// }
|
250
|
+
//
|
251
|
+
const symbol = this.safeSymbol (undefined, market);
|
252
|
+
const timestamp = this.safeTimestamp (ticker, 'date');
|
253
|
+
const last = this.safeString (ticker, 'last');
|
254
|
+
return this.safeTicker ({
|
255
|
+
'symbol': symbol,
|
256
|
+
'timestamp': timestamp,
|
257
|
+
'datetime': this.iso8601 (timestamp),
|
258
|
+
'high': this.safeString (ticker, 'high'),
|
259
|
+
'low': this.safeString (ticker, 'low'),
|
260
|
+
'bid': this.safeString (ticker, 'buy'),
|
261
|
+
'bidVolume': undefined,
|
262
|
+
'ask': this.safeString (ticker, 'sell'),
|
263
|
+
'askVolume': undefined,
|
264
|
+
'vwap': undefined,
|
265
|
+
'open': undefined,
|
266
|
+
'close': last,
|
267
|
+
'last': last,
|
268
|
+
'previousClose': undefined,
|
269
|
+
'change': undefined,
|
270
|
+
'percentage': undefined,
|
271
|
+
'average': undefined,
|
272
|
+
'baseVolume': this.safeString (ticker, 'vol'),
|
273
|
+
'quoteVolume': undefined,
|
274
|
+
'info': ticker,
|
275
|
+
}, market, false);
|
276
|
+
}
|
277
|
+
|
278
|
+
async fetchTicker (symbol, params = {}) {
|
279
|
+
await this.loadMarkets ();
|
280
|
+
const market = this.market (symbol);
|
281
|
+
const request = {
|
282
|
+
'coin': market['base'],
|
283
|
+
};
|
284
|
+
const response = await this.publicGetCoinTicker (this.extend (request, params));
|
285
|
+
const ticker = this.safeValue (response, 'ticker', {});
|
286
|
+
//
|
287
|
+
// {
|
288
|
+
// "ticker": {
|
289
|
+
// "high":"1549.82293000",
|
290
|
+
// "low":"1503.00011000",
|
291
|
+
// "vol":"81.82827101",
|
292
|
+
// "last":"1533.15000000",
|
293
|
+
// "buy":"1533.21018000",
|
294
|
+
// "sell":"1540.09000000",
|
295
|
+
// "open":"1524.71089000",
|
296
|
+
// "date":1643691671
|
297
|
+
// }
|
298
|
+
// }
|
299
|
+
//
|
300
|
+
return this.parseTicker (ticker, market);
|
301
|
+
}
|
302
|
+
|
303
|
+
parseTrade (trade, market = undefined) {
|
304
|
+
const timestamp = this.safeTimestamp2 (trade, 'date', 'executed_timestamp');
|
305
|
+
market = this.safeMarket (undefined, market);
|
306
|
+
const id = this.safeString2 (trade, 'tid', 'operation_id');
|
307
|
+
const type = undefined;
|
308
|
+
const side = this.safeString (trade, 'type');
|
309
|
+
const price = this.safeString (trade, 'price');
|
310
|
+
const amount = this.safeString2 (trade, 'amount', 'quantity');
|
311
|
+
const feeCost = this.safeString (trade, 'fee_rate');
|
312
|
+
let fee = undefined;
|
313
|
+
if (feeCost !== undefined) {
|
314
|
+
fee = {
|
315
|
+
'cost': feeCost,
|
316
|
+
'currency': undefined,
|
317
|
+
};
|
318
|
+
}
|
319
|
+
return this.safeTrade ({
|
320
|
+
'id': id,
|
321
|
+
'info': trade,
|
322
|
+
'timestamp': timestamp,
|
323
|
+
'datetime': this.iso8601 (timestamp),
|
324
|
+
'symbol': market['symbol'],
|
325
|
+
'order': undefined,
|
326
|
+
'type': type,
|
327
|
+
'side': side,
|
328
|
+
'takerOrMaker': undefined,
|
329
|
+
'price': price,
|
330
|
+
'amount': amount,
|
331
|
+
'cost': undefined,
|
332
|
+
'fee': fee,
|
333
|
+
}, market);
|
334
|
+
}
|
335
|
+
|
336
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
337
|
+
await this.loadMarkets ();
|
338
|
+
const market = this.market (symbol);
|
339
|
+
let method = 'publicGetCoinTrades';
|
340
|
+
const request = {
|
341
|
+
'coin': market['base'],
|
342
|
+
};
|
343
|
+
if (since !== undefined) {
|
344
|
+
method += 'From';
|
345
|
+
request['from'] = parseInt (since / 1000);
|
346
|
+
}
|
347
|
+
const to = this.safeInteger (params, 'to');
|
348
|
+
if (to !== undefined) {
|
349
|
+
method += 'To';
|
350
|
+
}
|
351
|
+
const response = await this[method] (this.extend (request, params));
|
352
|
+
return this.parseTrades (response, market, since, limit);
|
353
|
+
}
|
354
|
+
|
355
|
+
parseBalance (response) {
|
356
|
+
const data = this.safeValue (response, 'response_data', {});
|
357
|
+
const balances = this.safeValue (data, 'balance', {});
|
358
|
+
const result = { 'info': response };
|
359
|
+
const currencyIds = Object.keys (balances);
|
360
|
+
for (let i = 0; i < currencyIds.length; i++) {
|
361
|
+
const currencyId = currencyIds[i];
|
362
|
+
const code = this.safeCurrencyCode (currencyId);
|
363
|
+
if (currencyId in balances) {
|
364
|
+
const balance = this.safeValue (balances, currencyId, {});
|
365
|
+
const account = this.account ();
|
366
|
+
account['free'] = this.safeString (balance, 'available');
|
367
|
+
account['total'] = this.safeString (balance, 'total');
|
368
|
+
result[code] = account;
|
369
|
+
}
|
370
|
+
}
|
371
|
+
return this.safeBalance (result);
|
372
|
+
}
|
373
|
+
|
374
|
+
async fetchBalance (params = {}) {
|
375
|
+
await this.loadMarkets ();
|
376
|
+
const response = await this.privatePostGetAccountInfo (params);
|
377
|
+
return this.parseBalance (response);
|
378
|
+
}
|
379
|
+
|
380
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
381
|
+
await this.loadMarkets ();
|
382
|
+
const request = {
|
383
|
+
'coin_pair': this.marketId (symbol),
|
384
|
+
};
|
385
|
+
let method = this.capitalize (side) + 'Order';
|
386
|
+
if (type === 'limit') {
|
387
|
+
method = 'privatePostPlace' + method;
|
388
|
+
request['limit_price'] = this.priceToPrecision (symbol, price);
|
389
|
+
request['quantity'] = this.amountToPrecision (symbol, amount);
|
390
|
+
} else {
|
391
|
+
method = 'privatePostPlaceMarket' + method;
|
392
|
+
if (side === 'buy') {
|
393
|
+
if (price === undefined) {
|
394
|
+
throw new InvalidOrder (this.id + ' createOrder() requires the price argument with market buy orders to calculate total order cost (amount to spend), where cost = amount * price. Supply a price argument to createOrder() call if you want the cost to be calculated for you from price and amount');
|
395
|
+
}
|
396
|
+
request['cost'] = this.priceToPrecision (symbol, amount * price);
|
397
|
+
} else {
|
398
|
+
request['quantity'] = this.amountToPrecision (symbol, amount);
|
399
|
+
}
|
400
|
+
}
|
401
|
+
const response = await this[method] (this.extend (request, params));
|
402
|
+
// TODO: replace this with a call to parseOrder for unification
|
403
|
+
return {
|
404
|
+
'info': response,
|
405
|
+
'id': response['response_data']['order']['order_id'].toString (),
|
406
|
+
};
|
407
|
+
}
|
408
|
+
|
409
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
410
|
+
if (symbol === undefined) {
|
411
|
+
throw new ArgumentsRequired (this.id + ' cancelOrder() requires a symbol argument');
|
412
|
+
}
|
413
|
+
await this.loadMarkets ();
|
414
|
+
const market = this.market (symbol);
|
415
|
+
const request = {
|
416
|
+
'coin_pair': market['id'],
|
417
|
+
'order_id': id,
|
418
|
+
};
|
419
|
+
const response = await this.privatePostCancelOrder (this.extend (request, params));
|
420
|
+
//
|
421
|
+
// {
|
422
|
+
// response_data: {
|
423
|
+
// order: {
|
424
|
+
// order_id: 2176769,
|
425
|
+
// coin_pair: 'BRLBCH',
|
426
|
+
// order_type: 2,
|
427
|
+
// status: 3,
|
428
|
+
// has_fills: false,
|
429
|
+
// quantity: '0.10000000',
|
430
|
+
// limit_price: '1996.15999',
|
431
|
+
// executed_quantity: '0.00000000',
|
432
|
+
// executed_price_avg: '0.00000',
|
433
|
+
// fee: '0.00000000',
|
434
|
+
// created_timestamp: '1536956488',
|
435
|
+
// updated_timestamp: '1536956499',
|
436
|
+
// operations: []
|
437
|
+
// }
|
438
|
+
// },
|
439
|
+
// status_code: 100,
|
440
|
+
// server_unix_timestamp: '1536956499'
|
441
|
+
// }
|
442
|
+
//
|
443
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
444
|
+
const order = this.safeValue (responseData, 'order', {});
|
445
|
+
return this.parseOrder (order, market);
|
446
|
+
}
|
447
|
+
|
448
|
+
parseOrderStatus (status) {
|
449
|
+
const statuses = {
|
450
|
+
'2': 'open',
|
451
|
+
'3': 'canceled',
|
452
|
+
'4': 'closed',
|
453
|
+
};
|
454
|
+
return this.safeString (statuses, status, status);
|
455
|
+
}
|
456
|
+
|
457
|
+
parseOrder (order, market = undefined) {
|
458
|
+
//
|
459
|
+
// {
|
460
|
+
// "order_id": 4,
|
461
|
+
// "coin_pair": "BRLBTC",
|
462
|
+
// "order_type": 1,
|
463
|
+
// "status": 2,
|
464
|
+
// "has_fills": true,
|
465
|
+
// "quantity": "2.00000000",
|
466
|
+
// "limit_price": "900.00000",
|
467
|
+
// "executed_quantity": "1.00000000",
|
468
|
+
// "executed_price_avg": "900.00000",
|
469
|
+
// "fee": "0.00300000",
|
470
|
+
// "created_timestamp": "1453838494",
|
471
|
+
// "updated_timestamp": "1453838494",
|
472
|
+
// "operations": [
|
473
|
+
// {
|
474
|
+
// "operation_id": 1,
|
475
|
+
// "quantity": "1.00000000",
|
476
|
+
// "price": "900.00000",
|
477
|
+
// "fee_rate": "0.30",
|
478
|
+
// "executed_timestamp": "1453838494",
|
479
|
+
// },
|
480
|
+
// ],
|
481
|
+
// }
|
482
|
+
//
|
483
|
+
const id = this.safeString (order, 'order_id');
|
484
|
+
const order_type = this.safeString (order, 'order_type');
|
485
|
+
let side = undefined;
|
486
|
+
if ('order_type' in order) {
|
487
|
+
side = (order_type === '1') ? 'buy' : 'sell';
|
488
|
+
}
|
489
|
+
const status = this.parseOrderStatus (this.safeString (order, 'status'));
|
490
|
+
const marketId = this.safeString (order, 'coin_pair');
|
491
|
+
market = this.safeMarket (marketId, market);
|
492
|
+
const timestamp = this.safeTimestamp (order, 'created_timestamp');
|
493
|
+
const fee = {
|
494
|
+
'cost': this.safeString (order, 'fee'),
|
495
|
+
'currency': market['quote'],
|
496
|
+
};
|
497
|
+
const price = this.safeString (order, 'limit_price');
|
498
|
+
// price = this.safeNumber (order, 'executed_price_avg', price);
|
499
|
+
const average = this.safeString (order, 'executed_price_avg');
|
500
|
+
const amount = this.safeString (order, 'quantity');
|
501
|
+
const filled = this.safeString (order, 'executed_quantity');
|
502
|
+
const lastTradeTimestamp = this.safeTimestamp (order, 'updated_timestamp');
|
503
|
+
const rawTrades = this.safeValue (order, 'operations', []);
|
504
|
+
return this.safeOrder ({
|
505
|
+
'info': order,
|
506
|
+
'id': id,
|
507
|
+
'clientOrderId': undefined,
|
508
|
+
'timestamp': timestamp,
|
509
|
+
'datetime': this.iso8601 (timestamp),
|
510
|
+
'lastTradeTimestamp': lastTradeTimestamp,
|
511
|
+
'symbol': market['symbol'],
|
512
|
+
'type': 'limit',
|
513
|
+
'timeInForce': undefined,
|
514
|
+
'postOnly': undefined,
|
515
|
+
'side': side,
|
516
|
+
'price': price,
|
517
|
+
'stopPrice': undefined,
|
518
|
+
'cost': undefined,
|
519
|
+
'average': average,
|
520
|
+
'amount': amount,
|
521
|
+
'filled': filled,
|
522
|
+
'remaining': undefined,
|
523
|
+
'status': status,
|
524
|
+
'fee': fee,
|
525
|
+
'trades': rawTrades,
|
526
|
+
}, market);
|
527
|
+
}
|
528
|
+
|
529
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
530
|
+
if (symbol === undefined) {
|
531
|
+
throw new ArgumentsRequired (this.id + ' fetchOrder() requires a symbol argument');
|
532
|
+
}
|
533
|
+
await this.loadMarkets ();
|
534
|
+
const market = this.market (symbol);
|
535
|
+
const request = {
|
536
|
+
'coin_pair': market['id'],
|
537
|
+
'order_id': parseInt (id),
|
538
|
+
};
|
539
|
+
const response = await this.privatePostGetOrder (this.extend (request, params));
|
540
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
541
|
+
const order = this.safeValue (responseData, 'order');
|
542
|
+
return this.parseOrder (order, market);
|
543
|
+
}
|
544
|
+
|
545
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
546
|
+
[ tag, params ] = this.handleWithdrawTagAndParams (tag, params);
|
547
|
+
this.checkAddress (address);
|
548
|
+
await this.loadMarkets ();
|
549
|
+
const currency = this.currency (code);
|
550
|
+
const request = {
|
551
|
+
'coin': currency['id'],
|
552
|
+
'quantity': amount.toFixed (10),
|
553
|
+
'address': address,
|
554
|
+
};
|
555
|
+
if (code === 'BRL') {
|
556
|
+
const account_ref = ('account_ref' in params);
|
557
|
+
if (!account_ref) {
|
558
|
+
throw new ArgumentsRequired (this.id + ' withdraw() requires account_ref parameter to withdraw ' + code);
|
559
|
+
}
|
560
|
+
} else if (code !== 'LTC') {
|
561
|
+
const tx_fee = ('tx_fee' in params);
|
562
|
+
if (!tx_fee) {
|
563
|
+
throw new ArgumentsRequired (this.id + ' withdraw() requires tx_fee parameter to withdraw ' + code);
|
564
|
+
}
|
565
|
+
if (code === 'XRP') {
|
566
|
+
if (tag === undefined) {
|
567
|
+
if (!('destination_tag' in params)) {
|
568
|
+
throw new ArgumentsRequired (this.id + ' withdraw() requires a tag argument or destination_tag parameter to withdraw ' + code);
|
569
|
+
}
|
570
|
+
} else {
|
571
|
+
request['destination_tag'] = tag;
|
572
|
+
}
|
573
|
+
}
|
574
|
+
}
|
575
|
+
const response = await this.privatePostWithdrawCoin (this.extend (request, params));
|
576
|
+
//
|
577
|
+
// {
|
578
|
+
// "response_data": {
|
579
|
+
// "withdrawal": {
|
580
|
+
// "id": 1,
|
581
|
+
// "coin": "BRL",
|
582
|
+
// "quantity": "300.56",
|
583
|
+
// "net_quantity": "291.68",
|
584
|
+
// "fee": "8.88",
|
585
|
+
// "account": "bco: 341, ag: 1111, cta: 23456-X",
|
586
|
+
// "status": 1,
|
587
|
+
// "created_timestamp": "1453912088",
|
588
|
+
// "updated_timestamp": "1453912088"
|
589
|
+
// }
|
590
|
+
// },
|
591
|
+
// "status_code": 100,
|
592
|
+
// "server_unix_timestamp": "1453912088"
|
593
|
+
// }
|
594
|
+
//
|
595
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
596
|
+
const withdrawal = this.safeValue (responseData, 'withdrawal');
|
597
|
+
return this.parseTransaction (withdrawal, currency);
|
598
|
+
}
|
599
|
+
|
600
|
+
parseTransaction (transaction, currency = undefined) {
|
601
|
+
//
|
602
|
+
// {
|
603
|
+
// "id": 1,
|
604
|
+
// "coin": "BRL",
|
605
|
+
// "quantity": "300.56",
|
606
|
+
// "net_quantity": "291.68",
|
607
|
+
// "fee": "8.88",
|
608
|
+
// "account": "bco: 341, ag: 1111, cta: 23456-X",
|
609
|
+
// "status": 1,
|
610
|
+
// "created_timestamp": "1453912088",
|
611
|
+
// "updated_timestamp": "1453912088"
|
612
|
+
// }
|
613
|
+
//
|
614
|
+
currency = this.safeCurrency (undefined, currency);
|
615
|
+
return {
|
616
|
+
'id': this.safeString (transaction, 'id'),
|
617
|
+
'txid': undefined,
|
618
|
+
'timestamp': undefined,
|
619
|
+
'datetime': undefined,
|
620
|
+
'network': undefined,
|
621
|
+
'addressFrom': undefined,
|
622
|
+
'address': undefined,
|
623
|
+
'addressTo': undefined,
|
624
|
+
'amount': undefined,
|
625
|
+
'type': undefined,
|
626
|
+
'currency': currency['code'],
|
627
|
+
'status': undefined,
|
628
|
+
'updated': undefined,
|
629
|
+
'tagFrom': undefined,
|
630
|
+
'tag': undefined,
|
631
|
+
'tagTo': undefined,
|
632
|
+
'comment': undefined,
|
633
|
+
'fee': undefined,
|
634
|
+
'info': transaction,
|
635
|
+
};
|
636
|
+
}
|
637
|
+
|
638
|
+
parseOHLCV (ohlcv, market = undefined) {
|
639
|
+
return [
|
640
|
+
this.safeTimestamp (ohlcv, 'timestamp'),
|
641
|
+
this.safeNumber (ohlcv, 'open'),
|
642
|
+
this.safeNumber (ohlcv, 'high'),
|
643
|
+
this.safeNumber (ohlcv, 'low'),
|
644
|
+
this.safeNumber (ohlcv, 'close'),
|
645
|
+
this.safeNumber (ohlcv, 'volume'),
|
646
|
+
];
|
647
|
+
}
|
648
|
+
|
649
|
+
async fetchOHLCV (symbol, timeframe = '5m', since = undefined, limit = undefined, params = {}) {
|
650
|
+
await this.loadMarkets ();
|
651
|
+
const market = this.market (symbol);
|
652
|
+
const request = {
|
653
|
+
'precision': this.timeframes[timeframe],
|
654
|
+
'coin': market['id'].toLowerCase (),
|
655
|
+
};
|
656
|
+
if (limit !== undefined && since !== undefined) {
|
657
|
+
request['from'] = parseInt (since / 1000);
|
658
|
+
request['to'] = this.sum (request['from'], limit * this.parseTimeframe (timeframe));
|
659
|
+
} else if (since !== undefined) {
|
660
|
+
request['from'] = parseInt (since / 1000);
|
661
|
+
request['to'] = this.sum (this.seconds (), 1);
|
662
|
+
} else if (limit !== undefined) {
|
663
|
+
request['to'] = this.seconds ();
|
664
|
+
request['from'] = request['to'] - (limit * this.parseTimeframe (timeframe));
|
665
|
+
}
|
666
|
+
const response = await this.v4PublicGetCoinCandle (this.extend (request, params));
|
667
|
+
const candles = this.safeValue (response, 'candles', []);
|
668
|
+
return this.parseOHLCVs (candles, market, timeframe, since, limit);
|
669
|
+
}
|
670
|
+
|
671
|
+
async fetchOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
672
|
+
if (symbol === undefined) {
|
673
|
+
throw new ArgumentsRequired (this.id + ' fetchOrders() requires a symbol argument');
|
674
|
+
}
|
675
|
+
await this.loadMarkets ();
|
676
|
+
const market = this.market (symbol);
|
677
|
+
const request = {
|
678
|
+
'coin_pair': market['id'],
|
679
|
+
};
|
680
|
+
const response = await this.privatePostListOrders (this.extend (request, params));
|
681
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
682
|
+
const orders = this.safeValue (responseData, 'orders', []);
|
683
|
+
return this.parseOrders (orders, market, since, limit);
|
684
|
+
}
|
685
|
+
|
686
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
687
|
+
if (symbol === undefined) {
|
688
|
+
throw new ArgumentsRequired (this.id + ' fetchOpenOrders() requires a symbol argument');
|
689
|
+
}
|
690
|
+
await this.loadMarkets ();
|
691
|
+
const market = this.market (symbol);
|
692
|
+
const request = {
|
693
|
+
'coin_pair': market['id'],
|
694
|
+
'status_list': '[2]', // open only
|
695
|
+
};
|
696
|
+
const response = await this.privatePostListOrders (this.extend (request, params));
|
697
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
698
|
+
const orders = this.safeValue (responseData, 'orders', []);
|
699
|
+
return this.parseOrders (orders, market, since, limit);
|
700
|
+
}
|
701
|
+
|
702
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
703
|
+
if (symbol === undefined) {
|
704
|
+
throw new ArgumentsRequired (this.id + ' fetchMyTrades() requires a symbol argument');
|
705
|
+
}
|
706
|
+
await this.loadMarkets ();
|
707
|
+
const market = this.market (symbol);
|
708
|
+
const request = {
|
709
|
+
'coin_pair': market['id'],
|
710
|
+
'has_fills': true,
|
711
|
+
};
|
712
|
+
const response = await this.privatePostListOrders (this.extend (request, params));
|
713
|
+
const responseData = this.safeValue (response, 'response_data', {});
|
714
|
+
const ordersRaw = this.safeValue (responseData, 'orders', []);
|
715
|
+
const orders = this.parseOrders (ordersRaw, market, since, limit);
|
716
|
+
const trades = this.ordersToTrades (orders);
|
717
|
+
return this.filterBySymbolSinceLimit (trades, market['symbol'], since, limit);
|
718
|
+
}
|
719
|
+
|
720
|
+
ordersToTrades (orders) {
|
721
|
+
const result = [];
|
722
|
+
for (let i = 0; i < orders.length; i++) {
|
723
|
+
const trades = this.safeValue (orders[i], 'trades', []);
|
724
|
+
for (let y = 0; y < trades.length; y++) {
|
725
|
+
result.push (trades[y]);
|
726
|
+
}
|
727
|
+
}
|
728
|
+
return result;
|
729
|
+
}
|
730
|
+
|
731
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
732
|
+
let url = this.urls['api'][api] + '/';
|
733
|
+
const query = this.omit (params, this.extractParams (path));
|
734
|
+
if (api === 'public' || (api === 'v4Public')) {
|
735
|
+
url += this.implodeParams (path, params);
|
736
|
+
if (Object.keys (query).length) {
|
737
|
+
url += '?' + this.urlencode (query);
|
738
|
+
}
|
739
|
+
} else {
|
740
|
+
this.checkRequiredCredentials ();
|
741
|
+
url += this.version + '/';
|
742
|
+
const nonce = this.nonce ();
|
743
|
+
body = this.urlencode (this.extend ({
|
744
|
+
'tapi_method': path,
|
745
|
+
'tapi_nonce': nonce,
|
746
|
+
}, params));
|
747
|
+
const auth = '/tapi/' + this.version + '/' + '?' + body;
|
748
|
+
headers = {
|
749
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
750
|
+
'TAPI-ID': this.apiKey,
|
751
|
+
'TAPI-MAC': this.hmac (this.encode (auth), this.encode (this.secret), 'sha512'),
|
752
|
+
};
|
753
|
+
}
|
754
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
755
|
+
}
|
756
|
+
|
757
|
+
handleErrors (httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
758
|
+
if (response === undefined) {
|
759
|
+
return;
|
760
|
+
}
|
761
|
+
//
|
762
|
+
// todo add a unified standard handleErrors with this.exceptions in describe()
|
763
|
+
//
|
764
|
+
// {"status":503,"message":"Maintenancing, try again later","result":null}
|
765
|
+
//
|
766
|
+
const errorMessage = this.safeValue (response, 'error_message');
|
767
|
+
if (errorMessage !== undefined) {
|
768
|
+
throw new ExchangeError (this.id + ' ' + this.json (response));
|
769
|
+
}
|
770
|
+
}
|
771
|
+
};
|