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/lykke.js
ADDED
@@ -0,0 +1,1147 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
// ---------------------------------------------------------------------------
|
4
|
+
|
5
|
+
const Exchange = require ('./base/Exchange');
|
6
|
+
const { NotSupported, ExchangeError, BadRequest, InsufficientFunds, InvalidOrder, DuplicateOrderId } = require ('./base/errors');
|
7
|
+
const Precise = require ('./base/Precise');
|
8
|
+
|
9
|
+
// ---------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = class lykke extends Exchange {
|
12
|
+
describe () {
|
13
|
+
return this.deepExtend (super.describe (), {
|
14
|
+
'id': 'lykke',
|
15
|
+
'name': 'Lykke',
|
16
|
+
'countries': [ 'UK' ],
|
17
|
+
'version': '2',
|
18
|
+
// 300 requests per minute per method => 60000ms / 300 = 200 (/api/orders/*)
|
19
|
+
// 120 requests per minute per method => ( 60000ms / rateLimit ) / 120 = cost = 2.5 (/api/*)
|
20
|
+
'rateLimit': 200, // TODO: optim\ize https://lykkecity.github.io/Trading-API/#request-rate-limits
|
21
|
+
'has': {
|
22
|
+
'CORS': undefined,
|
23
|
+
'spot': true,
|
24
|
+
'margin': false,
|
25
|
+
'swap': false,
|
26
|
+
'future': false,
|
27
|
+
'option': false,
|
28
|
+
'cancelAllOrders': true,
|
29
|
+
'cancelOrder': true,
|
30
|
+
'createOrder': true,
|
31
|
+
'editOrder': false,
|
32
|
+
'fetchBalance': true,
|
33
|
+
'fetchBorrowRate': false,
|
34
|
+
'fetchBorrowRateHistories': false,
|
35
|
+
'fetchBorrowRateHistory': false,
|
36
|
+
'fetchBorrowRates': false,
|
37
|
+
'fetchClosedOrders': true,
|
38
|
+
'fetchCurrencies': true,
|
39
|
+
'fetchDepositAddress': true,
|
40
|
+
'fetchDeposits': false,
|
41
|
+
'fetchFundingFees': false,
|
42
|
+
'fetchFundingHistory': false,
|
43
|
+
'fetchFundingRate': false,
|
44
|
+
'fetchFundingRateHistory': false,
|
45
|
+
'fetchFundingRates': false,
|
46
|
+
'fetchIndexOHLCV': false,
|
47
|
+
'fetchMarkets': true,
|
48
|
+
'fetchMarkOHLCV': false,
|
49
|
+
'fetchMyTrades': true,
|
50
|
+
'fetchOHLCV': 'emulated',
|
51
|
+
'fetchOpenOrders': true,
|
52
|
+
'fetchOrder': true,
|
53
|
+
'fetchOrderBook': true,
|
54
|
+
'fetchOrders': false,
|
55
|
+
'fetchOrderTrades': false,
|
56
|
+
'fetchPositions': false,
|
57
|
+
'fetchPremiumIndexOHLCV': false,
|
58
|
+
'fetchTicker': true,
|
59
|
+
'fetchTickers': true,
|
60
|
+
'fetchTime': false,
|
61
|
+
'fetchTrades': true,
|
62
|
+
'fetchTradingFee': false,
|
63
|
+
'fetchTradingFees': false,
|
64
|
+
'fetchTransactions': true,
|
65
|
+
'fetchWithdrawals': false,
|
66
|
+
'setLeverage': false,
|
67
|
+
'setMarginMode': false,
|
68
|
+
'withdraw': true,
|
69
|
+
},
|
70
|
+
'requiredCredentials': {
|
71
|
+
'apiKey': true,
|
72
|
+
'secret': false,
|
73
|
+
},
|
74
|
+
'urls': {
|
75
|
+
'logo': 'https://user-images.githubusercontent.com/1294454/155840500-1ea4fdf0-47c0-4daa-9597-c6c1cd51b9ec.jpg',
|
76
|
+
'api': {
|
77
|
+
'public': 'https://hft-apiv2.lykke.com/api',
|
78
|
+
'private': 'https://hft-apiv2.lykke.com/api',
|
79
|
+
},
|
80
|
+
'www': 'https://www.lykke.com',
|
81
|
+
'doc': [
|
82
|
+
'https://hft-apiv2.lykke.com/swagger/ui/index.html',
|
83
|
+
'https://lykkecity.github.io/Trading-API',
|
84
|
+
],
|
85
|
+
'fees': 'https://support.lykke.com/hc/en-us/articles/115002141125-What-are-the-fees-and-charges-', // zero fee
|
86
|
+
},
|
87
|
+
'api': {
|
88
|
+
'public': {
|
89
|
+
'get': {
|
90
|
+
'assetpairs': 2.5,
|
91
|
+
'assetpairs/{id}': 2.5,
|
92
|
+
'assets': 2.5,
|
93
|
+
'assets/{id}': 2.5,
|
94
|
+
'isalive': 2.5,
|
95
|
+
'orderbooks': 2.5,
|
96
|
+
'tickers': 2.5,
|
97
|
+
'prices': 2.5,
|
98
|
+
'trades/public/{assetPairId}': 2.5,
|
99
|
+
},
|
100
|
+
},
|
101
|
+
'private': {
|
102
|
+
'get': {
|
103
|
+
'balance': 2.5,
|
104
|
+
'trades': 2.5,
|
105
|
+
'trades/order/{orderId}': 2.5,
|
106
|
+
'orders/active': 1,
|
107
|
+
'orders/closed': 1,
|
108
|
+
'orders/{orderId}': 1,
|
109
|
+
'operations': 2.5,
|
110
|
+
'operations/deposits/addresses': 2.5,
|
111
|
+
'operations/deposits/addresses/{assetId}': 2.5,
|
112
|
+
},
|
113
|
+
'post': {
|
114
|
+
'orders/limit': 1,
|
115
|
+
'orders/market': 1,
|
116
|
+
'orders/bulk': 1,
|
117
|
+
'operations/withdrawals': 2.5,
|
118
|
+
'operations/deposits/addresses': 2.5,
|
119
|
+
},
|
120
|
+
'delete': {
|
121
|
+
'orders': 1,
|
122
|
+
'orders/{orderId}': 1,
|
123
|
+
},
|
124
|
+
},
|
125
|
+
},
|
126
|
+
'fees': {
|
127
|
+
'trading': {
|
128
|
+
'tierBased': false,
|
129
|
+
'percentage': true,
|
130
|
+
'maker': 0, // https://support.lykke.com/hc/en-us/articles/115002141125-What-are-the-fees-and-min-amounts-
|
131
|
+
'taker': 0,
|
132
|
+
},
|
133
|
+
},
|
134
|
+
'exceptions': {
|
135
|
+
'exact': {
|
136
|
+
'1001': ExchangeError,
|
137
|
+
'1100': ExchangeError,
|
138
|
+
'1101': ExchangeError,
|
139
|
+
'2000': BadRequest,
|
140
|
+
'2001': InsufficientFunds,
|
141
|
+
'2202': DuplicateOrderId,
|
142
|
+
'2003': ExchangeError,
|
143
|
+
'2004': NotSupported,
|
144
|
+
'2005': ExchangeError,
|
145
|
+
'2006': InsufficientFunds,
|
146
|
+
'2007': InsufficientFunds,
|
147
|
+
'2008': InsufficientFunds,
|
148
|
+
'2009': ExchangeError,
|
149
|
+
'2010': InsufficientFunds,
|
150
|
+
'2011': InvalidOrder,
|
151
|
+
'2012': InvalidOrder,
|
152
|
+
'2013': InvalidOrder,
|
153
|
+
'2014': InvalidOrder,
|
154
|
+
'2015': InvalidOrder,
|
155
|
+
'2016': InvalidOrder,
|
156
|
+
'2017': InvalidOrder,
|
157
|
+
'2018': InvalidOrder,
|
158
|
+
'2019': InvalidOrder,
|
159
|
+
'2020': InvalidOrder,
|
160
|
+
'2021': InvalidOrder,
|
161
|
+
'2022': InvalidOrder,
|
162
|
+
'2023': ExchangeError,
|
163
|
+
},
|
164
|
+
'broad': {},
|
165
|
+
},
|
166
|
+
'commonCurrencies': {
|
167
|
+
},
|
168
|
+
});
|
169
|
+
}
|
170
|
+
|
171
|
+
async fetchCurrencies (params = {}) {
|
172
|
+
const response = await this.publicGetAssets (params);
|
173
|
+
const currencies = this.safeValue (response, 'payload', []);
|
174
|
+
//
|
175
|
+
// {
|
176
|
+
// "payload":[
|
177
|
+
// {
|
178
|
+
// "assetId":"115a60c2-0da1-40f9-a7f2-41da723b9074",
|
179
|
+
// "name":"Monaco Token",
|
180
|
+
// "symbol":"MCO",
|
181
|
+
// "accuracy":6,
|
182
|
+
// "multiplierPower":8,
|
183
|
+
// "assetAddress":"",
|
184
|
+
// "blockchainIntegrationLayerId":"",
|
185
|
+
// "blockchain":"ethereum",
|
186
|
+
// "type":"erc20Token",
|
187
|
+
// "isTradable":true,
|
188
|
+
// "isTrusted":true,
|
189
|
+
// "kycNeeded":false,
|
190
|
+
// "blockchainWithdrawal":true,
|
191
|
+
// "cashoutMinimalAmount":0.1,
|
192
|
+
// "lowVolumeAmount":null,
|
193
|
+
// "lykkeEntityId":"LYKKE NL",
|
194
|
+
// "siriusAssetId":0,
|
195
|
+
// "siriusBlockchainId":null,
|
196
|
+
// "blockchainIntegrationType":"none",
|
197
|
+
// "blockchainDepositEnabled":false,
|
198
|
+
// "isDisabled":false
|
199
|
+
// }
|
200
|
+
// ],
|
201
|
+
// "error":null
|
202
|
+
// }
|
203
|
+
//
|
204
|
+
const result = {};
|
205
|
+
for (let i = 0; i < currencies.length; i++) {
|
206
|
+
const currency = currencies[i];
|
207
|
+
const id = this.safeString (currency, 'assetId');
|
208
|
+
const code = this.safeString (currency, 'symbol');
|
209
|
+
const name = this.safeString (currency, 'name');
|
210
|
+
const type = this.safeString (currency, 'type');
|
211
|
+
const deposit = this.safeValue (currency, 'blockchainDepositEnabled');
|
212
|
+
const withdraw = this.safeValue (currency, 'blockchainWithdrawal');
|
213
|
+
const isDisabled = this.safeValue (currency, 'isDisabled');
|
214
|
+
const active = !isDisabled;
|
215
|
+
result[code] = {
|
216
|
+
'id': id,
|
217
|
+
'code': code,
|
218
|
+
'info': currency,
|
219
|
+
'type': type,
|
220
|
+
'name': name,
|
221
|
+
'active': active,
|
222
|
+
'deposit': deposit,
|
223
|
+
'withdraw': withdraw,
|
224
|
+
'fee': undefined,
|
225
|
+
'precision': this.safeInteger (currency, 'accuracy'),
|
226
|
+
'limits': {
|
227
|
+
'withdraw': {
|
228
|
+
'min': this.safeValue (currency, 'cashoutMinimalAmount'),
|
229
|
+
'max': undefined,
|
230
|
+
},
|
231
|
+
'amount': {
|
232
|
+
'min': this.safeValue (currency, 'lowVolumeAmount'),
|
233
|
+
'max': undefined,
|
234
|
+
},
|
235
|
+
},
|
236
|
+
};
|
237
|
+
}
|
238
|
+
return result;
|
239
|
+
}
|
240
|
+
|
241
|
+
async fetchMarkets (params = {}) {
|
242
|
+
const response = await this.publicGetAssetpairs (params);
|
243
|
+
const markets = this.safeValue (response, 'payload', []);
|
244
|
+
//
|
245
|
+
// {
|
246
|
+
// "payload":[
|
247
|
+
// {
|
248
|
+
// "assetPairId":"AAVEBTC",
|
249
|
+
// "baseAssetId":"c9e55548-dae5-44fc-bebd-e72249cb19f3",
|
250
|
+
// "quoteAssetId":"BTC",
|
251
|
+
// "name":"AAVE/BTC",
|
252
|
+
// "priceAccuracy":6,
|
253
|
+
// "baseAssetAccuracy":6,
|
254
|
+
// "quoteAssetAccuracy":8,
|
255
|
+
// "minVolume":0.001,
|
256
|
+
// "minOppositeVolume":0.0001
|
257
|
+
// }
|
258
|
+
// ],
|
259
|
+
// "error":null
|
260
|
+
// }
|
261
|
+
//
|
262
|
+
const result = [];
|
263
|
+
for (let i = 0; i < markets.length; i++) {
|
264
|
+
const market = markets[i];
|
265
|
+
const id = this.safeString (market, 'assetPairId');
|
266
|
+
const name = this.safeString (market, 'name');
|
267
|
+
const baseAssetId = this.safeString (market, 'baseAssetId');
|
268
|
+
const quoteAssetId = this.safeString (market, 'quoteAssetId');
|
269
|
+
const [ baseId, quoteId ] = name.split ('/');
|
270
|
+
const base = this.safeCurrencyCode (baseId);
|
271
|
+
const quote = this.safeCurrencyCode (quoteId);
|
272
|
+
const symbol = base + '/' + quote;
|
273
|
+
const precision = {
|
274
|
+
'price': this.safeInteger (market, 'priceAccuracy'),
|
275
|
+
'amount': this.safeInteger (market, 'baseAssetAccuracy'),
|
276
|
+
};
|
277
|
+
result.push ({
|
278
|
+
'id': id,
|
279
|
+
'symbol': symbol,
|
280
|
+
'base': base,
|
281
|
+
'quote': quote,
|
282
|
+
'baseId': baseAssetId,
|
283
|
+
'quoteId': quoteAssetId,
|
284
|
+
'settle': undefined,
|
285
|
+
'settleId': undefined,
|
286
|
+
'type': 'spot',
|
287
|
+
'spot': true,
|
288
|
+
'margin': false,
|
289
|
+
'swap': false,
|
290
|
+
'future': false,
|
291
|
+
'option': false,
|
292
|
+
'contract': false,
|
293
|
+
'active': true,
|
294
|
+
'info': market,
|
295
|
+
'linear': undefined,
|
296
|
+
'inverse': undefined,
|
297
|
+
'contractSize': undefined,
|
298
|
+
'expiry': undefined,
|
299
|
+
'expiryDatetime': undefined,
|
300
|
+
'strike': undefined,
|
301
|
+
'optionType': undefined,
|
302
|
+
'precision': precision,
|
303
|
+
'limits': {
|
304
|
+
'amount': {
|
305
|
+
'min': this.safeNumber (market, 'minVolume'),
|
306
|
+
'max': undefined,
|
307
|
+
},
|
308
|
+
'price': {
|
309
|
+
'min': undefined,
|
310
|
+
'max': undefined,
|
311
|
+
},
|
312
|
+
'cost': {
|
313
|
+
'min': this.safeNumber (market, 'minOppositeVolume'),
|
314
|
+
'max': undefined,
|
315
|
+
},
|
316
|
+
'leverage': {
|
317
|
+
'min': undefined,
|
318
|
+
'max': undefined,
|
319
|
+
},
|
320
|
+
},
|
321
|
+
});
|
322
|
+
}
|
323
|
+
return result;
|
324
|
+
}
|
325
|
+
|
326
|
+
parseTicker (ticker, market = undefined) {
|
327
|
+
//
|
328
|
+
// fetchTickers
|
329
|
+
//
|
330
|
+
// publicGetTickers
|
331
|
+
//
|
332
|
+
// {
|
333
|
+
// "assetPairId":"BTCUSD",
|
334
|
+
// "volumeBase":2.56905016,
|
335
|
+
// "volumeQuote":95653.8730,
|
336
|
+
// "priceChange":-0.0367945778541765034194707584,
|
337
|
+
// "lastPrice":36840.0,
|
338
|
+
// "high":38371.645,
|
339
|
+
// "low":35903.356,
|
340
|
+
// "timestamp":1643295740729
|
341
|
+
// }
|
342
|
+
//
|
343
|
+
// fetchTicker
|
344
|
+
//
|
345
|
+
// publicGetTickers
|
346
|
+
//
|
347
|
+
// {
|
348
|
+
// "assetPairId":"BTCUSD",
|
349
|
+
// "volumeBase":2.56905016,
|
350
|
+
// "volumeQuote":95653.8730,
|
351
|
+
// "priceChange":-0.0367945778541765034194707584,
|
352
|
+
// "lastPrice":36840.0,
|
353
|
+
// "high":38371.645,
|
354
|
+
// "low":35903.356,
|
355
|
+
// "timestamp":1643295740729
|
356
|
+
// }
|
357
|
+
//
|
358
|
+
// publicGetPrices
|
359
|
+
//
|
360
|
+
// {
|
361
|
+
// "assetPairId":"BTCUSD",
|
362
|
+
// "bid":36181.521,
|
363
|
+
// "ask":36244.492,
|
364
|
+
// "timestamp":1643305510990
|
365
|
+
// }
|
366
|
+
//
|
367
|
+
const timestamp = this.safeInteger (ticker, 'timestamp');
|
368
|
+
const marketId = this.safeString (ticker, 'assetPairId');
|
369
|
+
market = this.safeMarket (marketId, market);
|
370
|
+
const close = this.safeString (ticker, 'lastPrice');
|
371
|
+
return this.safeTicker ({
|
372
|
+
'symbol': this.safeString (market, 'symbol'),
|
373
|
+
'timestamp': timestamp,
|
374
|
+
'datetime': this.iso8601 (timestamp),
|
375
|
+
'high': this.safeString (ticker, 'high'),
|
376
|
+
'low': this.safeString (ticker, 'low'),
|
377
|
+
'bid': this.safeString (ticker, 'bid'),
|
378
|
+
'bidVolume': undefined,
|
379
|
+
'ask': this.safeString (ticker, 'ask'),
|
380
|
+
'askVolume': undefined,
|
381
|
+
'vwap': undefined,
|
382
|
+
'open': undefined,
|
383
|
+
'close': close,
|
384
|
+
'last': close,
|
385
|
+
'previousClose': undefined,
|
386
|
+
'change': this.safeString (ticker, 'priceChange'),
|
387
|
+
'percentage': undefined,
|
388
|
+
'average': undefined,
|
389
|
+
'baseVolume': this.safeString (ticker, 'volumeBase'),
|
390
|
+
'quoteVolume': this.safeString (ticker, 'volumeQuote'),
|
391
|
+
'info': ticker,
|
392
|
+
}, market, false);
|
393
|
+
}
|
394
|
+
|
395
|
+
async fetchTicker (symbol, params = {}) {
|
396
|
+
await this.loadMarkets ();
|
397
|
+
const market = this.market (symbol);
|
398
|
+
const request = {
|
399
|
+
'assetPairIds': market['id'],
|
400
|
+
};
|
401
|
+
// publicGetTickers or publicGetPrices
|
402
|
+
const method = this.safeString (this.options, 'fetchTickerMethod', 'publicGetTickers');
|
403
|
+
const response = await this[method] (this.extend (request, params));
|
404
|
+
const ticker = this.safeValue (response, 'payload', []);
|
405
|
+
//
|
406
|
+
// publicGetTickers
|
407
|
+
//
|
408
|
+
// {
|
409
|
+
// "payload":[
|
410
|
+
// {
|
411
|
+
// "assetPairId":"BTCUSD",
|
412
|
+
// "volumeBase":0.78056880,
|
413
|
+
// "volumeQuote":29782.5169,
|
414
|
+
// "priceChange":0.0436602362590968619931324699,
|
415
|
+
// "lastPrice":38626.885,
|
416
|
+
// "high":38742.896,
|
417
|
+
// "low":36872.498,
|
418
|
+
// "timestamp":1643687822840
|
419
|
+
// }
|
420
|
+
// ],
|
421
|
+
// "error":null
|
422
|
+
// }
|
423
|
+
//
|
424
|
+
// publicGetPrices
|
425
|
+
//
|
426
|
+
// {
|
427
|
+
// "payload":[
|
428
|
+
// {
|
429
|
+
// "assetPairId":"BTCUSD",
|
430
|
+
// "bid":38597.936,
|
431
|
+
// "ask":38640.311,
|
432
|
+
// "timestamp":1643688350847
|
433
|
+
// }
|
434
|
+
// ],
|
435
|
+
// "error":null
|
436
|
+
// }
|
437
|
+
//
|
438
|
+
return this.parseTicker (this.safeValue (ticker, 0, {}), market);
|
439
|
+
}
|
440
|
+
|
441
|
+
async fetchTickers (symbols = undefined, params = {}) {
|
442
|
+
await this.loadMarkets ();
|
443
|
+
const response = await this.publicGetTickers (params);
|
444
|
+
const tickers = this.safeValue (response, 'payload', []);
|
445
|
+
//
|
446
|
+
// {
|
447
|
+
// "payload":[
|
448
|
+
// {
|
449
|
+
// "assetPairId":"BTCUSD",
|
450
|
+
// "volumeBase":0.78056880,
|
451
|
+
// "volumeQuote":29782.5169,
|
452
|
+
// "priceChange":0.0436602362590968619931324699,
|
453
|
+
// "lastPrice":38626.885,
|
454
|
+
// "high":38742.896,
|
455
|
+
// "low":36872.498,
|
456
|
+
// "timestamp":1643687822840
|
457
|
+
// }
|
458
|
+
// ],
|
459
|
+
// "error":null
|
460
|
+
// }
|
461
|
+
//
|
462
|
+
return this.parseTickers (tickers, symbols);
|
463
|
+
}
|
464
|
+
|
465
|
+
async fetchOrderBook (symbol, limit = undefined, params = {}) {
|
466
|
+
await this.loadMarkets ();
|
467
|
+
const request = {
|
468
|
+
'assetPairId': this.marketId (symbol),
|
469
|
+
};
|
470
|
+
if (limit !== undefined) {
|
471
|
+
request['depth'] = limit; // default 0
|
472
|
+
}
|
473
|
+
const response = await this.publicGetOrderbooks (this.extend (request, params));
|
474
|
+
const payload = this.safeValue (response, 'payload', []);
|
475
|
+
//
|
476
|
+
// {
|
477
|
+
// "payload":[
|
478
|
+
// {
|
479
|
+
// assetPairId: 'BTCUSD',
|
480
|
+
// timestamp: '1643298038203',
|
481
|
+
// bids: [
|
482
|
+
// {
|
483
|
+
// "v":0.59034382,
|
484
|
+
// "p":36665.329
|
485
|
+
// }
|
486
|
+
// ],
|
487
|
+
// asks: [
|
488
|
+
// {
|
489
|
+
// "v":-0.003,
|
490
|
+
// "p":36729.686
|
491
|
+
// }
|
492
|
+
// ]
|
493
|
+
// }
|
494
|
+
// ],
|
495
|
+
// "error":null
|
496
|
+
// }
|
497
|
+
//
|
498
|
+
const orderbook = this.safeValue (payload, 0, {});
|
499
|
+
const timestamp = this.safeString (orderbook, 'timestamp');
|
500
|
+
return this.parseOrderBook (orderbook, symbol, timestamp, 'bids', 'asks', 'p', 'v');
|
501
|
+
}
|
502
|
+
|
503
|
+
parseTrade (trade, market) {
|
504
|
+
//
|
505
|
+
// public fetchTrades
|
506
|
+
//
|
507
|
+
// {
|
508
|
+
// "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
|
509
|
+
// "assetPairId":"BTCUSD",
|
510
|
+
// "timestamp":1643345958414,
|
511
|
+
// "volume":0.00010996,
|
512
|
+
// "price":37205.723,
|
513
|
+
// "side":"buy"
|
514
|
+
// }
|
515
|
+
//
|
516
|
+
// private fetchMyTrades
|
517
|
+
// {
|
518
|
+
// "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
|
519
|
+
// "timestamp":1644155923357,
|
520
|
+
// "assetPairId":"BCHEUR",
|
521
|
+
// "orderId":"1b367978-7e4f-454b-b870-64040d484443",
|
522
|
+
// "role":"Taker",
|
523
|
+
// "side":"sell",
|
524
|
+
// "price":280.569,
|
525
|
+
// "baseVolume":0.01,
|
526
|
+
// "quoteVolume":2.8056,
|
527
|
+
// "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
528
|
+
// "quoteAssetId":"EUR",
|
529
|
+
// "fee":null
|
530
|
+
// }
|
531
|
+
//
|
532
|
+
const marketId = this.safeString (trade, 'assetPairId');
|
533
|
+
market = this.safeMarket (marketId, market);
|
534
|
+
const symbol = market['symbol'];
|
535
|
+
const id = this.safeString2 (trade, 'id', 'id');
|
536
|
+
const orderId = this.safeString (trade, 'orderId');
|
537
|
+
const timestamp = this.safeInteger (trade, 'timestamp');
|
538
|
+
const price = this.safeString2 (trade, 'price', 'price');
|
539
|
+
let amount = this.safeString2 (trade, 'volume', 'amount');
|
540
|
+
if (amount === undefined) {
|
541
|
+
amount = this.safeString2 (trade, 'baseVolume', 'amount');
|
542
|
+
}
|
543
|
+
const side = this.safeStringLower (trade, 'side');
|
544
|
+
const fee = {
|
545
|
+
'cost': this.parseNumber ('0'), // There are no fees for trading.
|
546
|
+
'currency': market['quote'],
|
547
|
+
};
|
548
|
+
return this.safeTrade ({
|
549
|
+
'id': id,
|
550
|
+
'info': trade,
|
551
|
+
'timestamp': timestamp,
|
552
|
+
'datetime': this.iso8601 (timestamp),
|
553
|
+
'symbol': symbol,
|
554
|
+
'type': undefined,
|
555
|
+
'order': orderId,
|
556
|
+
'side': side,
|
557
|
+
'takerOrMaker': undefined,
|
558
|
+
'price': price,
|
559
|
+
'amount': amount,
|
560
|
+
'cost': undefined,
|
561
|
+
'fee': fee,
|
562
|
+
}, market);
|
563
|
+
}
|
564
|
+
|
565
|
+
async fetchTrades (symbol, since = undefined, limit = undefined, params = {}) {
|
566
|
+
await this.loadMarkets ();
|
567
|
+
const market = this.market (symbol);
|
568
|
+
const request = {
|
569
|
+
'assetPairId': market['id'],
|
570
|
+
// 'offset': 0,
|
571
|
+
};
|
572
|
+
if (limit !== undefined) {
|
573
|
+
request['take'] = limit;
|
574
|
+
}
|
575
|
+
const response = await this.publicGetTradesPublicAssetPairId (this.extend (request, params));
|
576
|
+
const result = this.safeValue (response, 'payload', []);
|
577
|
+
//
|
578
|
+
// {
|
579
|
+
// "payload":[
|
580
|
+
// {
|
581
|
+
// "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
|
582
|
+
// "assetPairId":"BTCUSD",
|
583
|
+
// "timestamp":1643345958414,
|
584
|
+
// "volume":0.00010996,
|
585
|
+
// "price":37205.723,
|
586
|
+
// "side":"buy"
|
587
|
+
// }
|
588
|
+
// ],
|
589
|
+
// "error":null
|
590
|
+
// }
|
591
|
+
//
|
592
|
+
return this.parseTrades (result, market, since, limit);
|
593
|
+
}
|
594
|
+
|
595
|
+
parseBalance (response) {
|
596
|
+
//
|
597
|
+
// [
|
598
|
+
// {
|
599
|
+
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
600
|
+
// "available":0.1,
|
601
|
+
// "reserved":0.0,
|
602
|
+
// "timestamp":1644146723620
|
603
|
+
// }
|
604
|
+
// ]
|
605
|
+
//
|
606
|
+
const result = { 'info': response };
|
607
|
+
for (let i = 0; i < response.length; i++) {
|
608
|
+
const balance = response[i];
|
609
|
+
const currencyId = this.safeString (balance, 'assetId');
|
610
|
+
const code = this.safeCurrencyCode (currencyId);
|
611
|
+
const account = this.account ();
|
612
|
+
const free = this.safeString (balance, 'available');
|
613
|
+
const used = this.safeString (balance, 'reserved');
|
614
|
+
account['free'] = free;
|
615
|
+
account['used'] = used;
|
616
|
+
result[code] = account;
|
617
|
+
}
|
618
|
+
return this.safeBalance (result);
|
619
|
+
}
|
620
|
+
|
621
|
+
async fetchBalance (params = {}) {
|
622
|
+
await this.loadMarkets ();
|
623
|
+
const response = await this.privateGetBalance (params);
|
624
|
+
const payload = this.safeValue (response, 'payload', []);
|
625
|
+
//
|
626
|
+
// {
|
627
|
+
// "payload":[
|
628
|
+
// {
|
629
|
+
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
630
|
+
// "available":0.1,
|
631
|
+
// "reserved":0.0,
|
632
|
+
// "timestamp":1644146723620
|
633
|
+
// }
|
634
|
+
// ],
|
635
|
+
// "error":null
|
636
|
+
// }
|
637
|
+
//
|
638
|
+
return this.parseBalance (payload);
|
639
|
+
}
|
640
|
+
|
641
|
+
parseOrderStatus (status) {
|
642
|
+
const statuses = {
|
643
|
+
'Open': 'open',
|
644
|
+
'Pending': 'open',
|
645
|
+
'InOrderBook': 'open',
|
646
|
+
'Processing': 'open',
|
647
|
+
'Matched': 'closed',
|
648
|
+
'Cancelled': 'canceled',
|
649
|
+
'Rejected': 'rejected',
|
650
|
+
'Replaced': 'canceled',
|
651
|
+
'Placed': 'open',
|
652
|
+
};
|
653
|
+
return this.safeString (statuses, status, status);
|
654
|
+
}
|
655
|
+
|
656
|
+
parseOrder (order, market = undefined) {
|
657
|
+
//
|
658
|
+
// {
|
659
|
+
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
660
|
+
// "timestamp":1644155923357,
|
661
|
+
// "lastTradeTimestamp":1644155923357,
|
662
|
+
// "status":"Matched",
|
663
|
+
// "assetPairId":"BCHEUR",
|
664
|
+
// "type":"Market",
|
665
|
+
// "side":"Sell",
|
666
|
+
// "price":280.569,
|
667
|
+
// "volume":0.01,
|
668
|
+
// "filledVolume":0.01,
|
669
|
+
// "remainingVolume":0.0,
|
670
|
+
// "cost":2.80569
|
671
|
+
// }
|
672
|
+
//
|
673
|
+
const id = this.safeString (order, 'id');
|
674
|
+
const status = this.parseOrderStatus (this.safeString (order, 'status'));
|
675
|
+
const marketId = this.safeString (order, 'assetPairId');
|
676
|
+
const symbol = this.safeSymbol (marketId, market);
|
677
|
+
const type = this.safeStringLower (order, 'type');
|
678
|
+
const lastTradeTimestamp = this.safeInteger (order, 'lastTradeTimestamp');
|
679
|
+
const timestamp = this.safeInteger (order, 'timestamp');
|
680
|
+
const price = this.safeString (order, 'price');
|
681
|
+
const side = this.safeStringLower (order, 'side');
|
682
|
+
const amount = this.safeString (order, 'volume');
|
683
|
+
const remaining = this.safeString (order, 'remainingVolume');
|
684
|
+
const filled = this.safeString (order, 'filledVolume');
|
685
|
+
const cost = this.safeString (order, 'cost');
|
686
|
+
return this.safeOrder ({
|
687
|
+
'info': order,
|
688
|
+
'id': id,
|
689
|
+
'clientOrderId': undefined,
|
690
|
+
'timestamp': timestamp,
|
691
|
+
'datetime': this.iso8601 (timestamp),
|
692
|
+
'lastTradeTimestamp': lastTradeTimestamp,
|
693
|
+
'symbol': symbol,
|
694
|
+
'type': type,
|
695
|
+
'timeInForce': undefined,
|
696
|
+
'postOnly': undefined,
|
697
|
+
'side': side,
|
698
|
+
'price': price,
|
699
|
+
'stopPrice': undefined,
|
700
|
+
'amount': amount,
|
701
|
+
'cost': cost,
|
702
|
+
'average': undefined,
|
703
|
+
'filled': filled,
|
704
|
+
'remaining': remaining,
|
705
|
+
'status': status,
|
706
|
+
'fee': undefined,
|
707
|
+
'trades': undefined,
|
708
|
+
}, market);
|
709
|
+
}
|
710
|
+
|
711
|
+
async createOrder (symbol, type, side, amount, price = undefined, params = {}) {
|
712
|
+
await this.loadMarkets ();
|
713
|
+
const market = this.market (symbol);
|
714
|
+
const query = {
|
715
|
+
'assetPairId': market['id'],
|
716
|
+
'side': this.capitalize (side),
|
717
|
+
'volume': parseFloat (this.amountToPrecision (symbol, amount)),
|
718
|
+
};
|
719
|
+
if (type === 'limit') {
|
720
|
+
query['price'] = parseFloat (this.priceToPrecision (symbol, price));
|
721
|
+
}
|
722
|
+
const method = 'privatePostOrders' + this.capitalize (type);
|
723
|
+
const result = await this[method] (this.extend (query, params));
|
724
|
+
//
|
725
|
+
// market
|
726
|
+
//
|
727
|
+
// {
|
728
|
+
// "payload":{
|
729
|
+
// "orderId":"2b98ec26-8410-49b6-9f37-1fb2150e2299",
|
730
|
+
// "price":280.699
|
731
|
+
// },
|
732
|
+
// "error":null
|
733
|
+
// }
|
734
|
+
//
|
735
|
+
// limit
|
736
|
+
//
|
737
|
+
// {
|
738
|
+
// "payload":{
|
739
|
+
// "orderId":"27be8802-30be-40ca-bf40-ec886b309c5b"
|
740
|
+
// },
|
741
|
+
// "error":null
|
742
|
+
// }
|
743
|
+
//
|
744
|
+
const payload = this.safeValue (result, 'payload');
|
745
|
+
const id = this.safeString (payload, 'orderId');
|
746
|
+
if (type === 'market') {
|
747
|
+
price = this.safeNumber (payload, 'price');
|
748
|
+
}
|
749
|
+
return {
|
750
|
+
'id': id,
|
751
|
+
'info': result,
|
752
|
+
'clientOrderId': undefined,
|
753
|
+
'timestamp': undefined,
|
754
|
+
'datetime': undefined,
|
755
|
+
'lastTradeTimestamp': undefined,
|
756
|
+
'symbol': symbol,
|
757
|
+
'type': type,
|
758
|
+
'side': side,
|
759
|
+
'price': price,
|
760
|
+
'amount': amount,
|
761
|
+
'cost': undefined,
|
762
|
+
'average': undefined,
|
763
|
+
'filled': undefined,
|
764
|
+
'remaining': undefined,
|
765
|
+
'status': undefined,
|
766
|
+
'fee': undefined,
|
767
|
+
'trades': undefined,
|
768
|
+
};
|
769
|
+
}
|
770
|
+
|
771
|
+
async cancelOrder (id, symbol = undefined, params = {}) {
|
772
|
+
const request = {
|
773
|
+
'orderId': id,
|
774
|
+
};
|
775
|
+
//
|
776
|
+
// {
|
777
|
+
// "payload":null,
|
778
|
+
// "error":null
|
779
|
+
// }
|
780
|
+
//
|
781
|
+
return await this.privateDeleteOrdersOrderId (this.extend (request, params));
|
782
|
+
}
|
783
|
+
|
784
|
+
async cancelAllOrders (symbol = undefined, params = {}) {
|
785
|
+
await this.loadMarkets ();
|
786
|
+
const request = {
|
787
|
+
// 'side': 'Buy',
|
788
|
+
};
|
789
|
+
let market = undefined;
|
790
|
+
if (symbol !== undefined) {
|
791
|
+
market = this.market (symbol);
|
792
|
+
request['assetPairId'] = market['id'];
|
793
|
+
}
|
794
|
+
//
|
795
|
+
// {
|
796
|
+
// "payload":null,
|
797
|
+
// "error":null
|
798
|
+
// }
|
799
|
+
//
|
800
|
+
return await this.privateDeleteOrders (this.extend (request, params));
|
801
|
+
}
|
802
|
+
|
803
|
+
async fetchOrder (id, symbol = undefined, params = {}) {
|
804
|
+
await this.loadMarkets ();
|
805
|
+
const request = {
|
806
|
+
'orderId': id,
|
807
|
+
};
|
808
|
+
const response = await this.privateGetOrdersOrderId (this.extend (request, params));
|
809
|
+
const payload = this.safeValue (response, 'payload');
|
810
|
+
//
|
811
|
+
// {
|
812
|
+
// "payload":{
|
813
|
+
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
814
|
+
// "timestamp":1644155923357,
|
815
|
+
// "lastTradeTimestamp":1644155923357,
|
816
|
+
// "status":"Matched",
|
817
|
+
// "assetPairId":"BCHEUR",
|
818
|
+
// "type":"Market",
|
819
|
+
// "side":"Sell",
|
820
|
+
// "price":280.569,
|
821
|
+
// "volume":0.01,
|
822
|
+
// "filledVolume":0.01,
|
823
|
+
// "remainingVolume":0.0,
|
824
|
+
// "cost":2.80569
|
825
|
+
// },
|
826
|
+
// "error":null
|
827
|
+
// }
|
828
|
+
//
|
829
|
+
return this.parseOrder (payload);
|
830
|
+
}
|
831
|
+
|
832
|
+
async fetchOpenOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
833
|
+
await this.loadMarkets ();
|
834
|
+
let market = undefined;
|
835
|
+
if (symbol !== undefined) {
|
836
|
+
market = this.market (symbol);
|
837
|
+
}
|
838
|
+
const request = {
|
839
|
+
// 'offset': 0,
|
840
|
+
// 'take': 1,
|
841
|
+
};
|
842
|
+
if (limit !== undefined) {
|
843
|
+
request['take'] = limit;
|
844
|
+
}
|
845
|
+
const response = await this.privateGetOrdersActive (this.extend (request, params));
|
846
|
+
const payload = this.safeValue (response, 'payload');
|
847
|
+
//
|
848
|
+
// {
|
849
|
+
// "payload":[
|
850
|
+
// {
|
851
|
+
// "id":"b26f58f5-8542-4b4c-9815-91562b523cc3",
|
852
|
+
// "timestamp":1644157177155,
|
853
|
+
// "lastTradeTimestamp":null,
|
854
|
+
// "status":"Placed",
|
855
|
+
// "assetPairId":"BCHEUR",
|
856
|
+
// "type":"Limit",
|
857
|
+
// "side":"Sell",
|
858
|
+
// "price":666.666,
|
859
|
+
// "volume":0.01,
|
860
|
+
// "filledVolume":0.00,
|
861
|
+
// "remainingVolume":0.01,
|
862
|
+
// "cost":0.00000
|
863
|
+
// }
|
864
|
+
// ],
|
865
|
+
// "error":null
|
866
|
+
// }
|
867
|
+
//
|
868
|
+
return this.parseOrders (payload, market, since, limit);
|
869
|
+
}
|
870
|
+
|
871
|
+
async fetchClosedOrders (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
872
|
+
await this.loadMarkets ();
|
873
|
+
let market = undefined;
|
874
|
+
if (symbol !== undefined) {
|
875
|
+
market = this.market (symbol);
|
876
|
+
}
|
877
|
+
const request = {
|
878
|
+
// 'offset': 0,
|
879
|
+
// 'take': 1,
|
880
|
+
};
|
881
|
+
if (limit !== undefined) {
|
882
|
+
request['take'] = limit;
|
883
|
+
}
|
884
|
+
const response = await this.privateGetOrdersClosed (this.extend (request, params));
|
885
|
+
const payload = this.safeValue (response, 'payload');
|
886
|
+
//
|
887
|
+
// {
|
888
|
+
// "payload":[
|
889
|
+
// {
|
890
|
+
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
891
|
+
// "timestamp":1644155923357,
|
892
|
+
// "lastTradeTimestamp":1644155923357,
|
893
|
+
// "status":"Matched",
|
894
|
+
// "assetPairId":"BCHEUR",
|
895
|
+
// "type":"Market",
|
896
|
+
// "side":"Sell",
|
897
|
+
// "price":280.569,
|
898
|
+
// "volume":0.01,
|
899
|
+
// "filledVolume":0.01,
|
900
|
+
// "remainingVolume":0.0,
|
901
|
+
// "cost":2.80569
|
902
|
+
// }
|
903
|
+
// ],
|
904
|
+
// "error":null
|
905
|
+
// }
|
906
|
+
//
|
907
|
+
return this.parseOrders (payload, market, since, limit);
|
908
|
+
}
|
909
|
+
|
910
|
+
async fetchMyTrades (symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
911
|
+
await this.loadMarkets ();
|
912
|
+
const request = {
|
913
|
+
// 'side': 'buy',
|
914
|
+
// 'offset': 0,
|
915
|
+
// 'take': 1,
|
916
|
+
// 'to': 0,
|
917
|
+
};
|
918
|
+
let market = undefined;
|
919
|
+
if (limit !== undefined) {
|
920
|
+
request['take'] = limit; // How many maximum items have to be returned, max 1000 default 100.
|
921
|
+
}
|
922
|
+
if (symbol !== undefined) {
|
923
|
+
market = this.market (symbol);
|
924
|
+
request['assetPairId'] = market['id'];
|
925
|
+
}
|
926
|
+
if (since !== undefined) {
|
927
|
+
request['from'] = since;
|
928
|
+
}
|
929
|
+
const response = await this.privateGetTrades (this.extend (request, params));
|
930
|
+
const payload = this.safeValue (response, 'payload');
|
931
|
+
//
|
932
|
+
// {
|
933
|
+
// "payload":[
|
934
|
+
// {
|
935
|
+
// "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
|
936
|
+
// "timestamp":1644155923357,
|
937
|
+
// "assetPairId":"BCHEUR",
|
938
|
+
// "orderId":"1b367978-7e4f-454b-b870-64040d484443",
|
939
|
+
// "role":"Taker",
|
940
|
+
// "side":"sell",
|
941
|
+
// "price":280.569,
|
942
|
+
// "baseVolume":0.01,
|
943
|
+
// "quoteVolume":2.8056,
|
944
|
+
// "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
945
|
+
// "quoteAssetId":"EUR",
|
946
|
+
// "fee":null
|
947
|
+
// }
|
948
|
+
// ],
|
949
|
+
// "error":null
|
950
|
+
// }
|
951
|
+
//
|
952
|
+
return this.parseTrades (payload, market, since, limit);
|
953
|
+
}
|
954
|
+
|
955
|
+
parseBidAsk (bidask, priceKey = 0, amountKey = 1) {
|
956
|
+
const price = this.safeString (bidask, priceKey);
|
957
|
+
const amount = Precise.stringAbs (this.safeString (bidask, amountKey));
|
958
|
+
return [ this.parseNumber (price), this.parseNumber (amount) ];
|
959
|
+
}
|
960
|
+
|
961
|
+
async fetchDepositAddress (code, params = {}) {
|
962
|
+
await this.loadMarkets ();
|
963
|
+
const currency = this.currency (code);
|
964
|
+
const request = {
|
965
|
+
'assetId': this.safeString (currency, 'id'),
|
966
|
+
};
|
967
|
+
const response = await this.privateGetOperationsDepositsAddressesAssetId (this.extend (request, params));
|
968
|
+
//
|
969
|
+
// {
|
970
|
+
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
971
|
+
// "symbol":"BCH",
|
972
|
+
// "address":null,
|
973
|
+
// "baseAddress":null,
|
974
|
+
// "addressExtension":null,
|
975
|
+
// "state":"Active"
|
976
|
+
// }
|
977
|
+
//
|
978
|
+
const address = this.safeString (response, 'baseAddress');
|
979
|
+
const tag = this.safeString (response, 'addressExtension');
|
980
|
+
this.checkAddress (address);
|
981
|
+
return {
|
982
|
+
'currency': code,
|
983
|
+
'address': address,
|
984
|
+
'tag': tag,
|
985
|
+
'network': undefined,
|
986
|
+
'info': response,
|
987
|
+
};
|
988
|
+
}
|
989
|
+
|
990
|
+
parseTransaction (transaction, currency = undefined) {
|
991
|
+
//
|
992
|
+
// withdraw
|
993
|
+
// "3035b1ad-2005-4587-a986-1f7966be78e0"
|
994
|
+
//
|
995
|
+
// fetchTransactions
|
996
|
+
// {
|
997
|
+
// "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
|
998
|
+
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
999
|
+
// "totalVolume":0.1,
|
1000
|
+
// "fee":0.0,
|
1001
|
+
// "type":"deposit",
|
1002
|
+
// "timestamp":1644146723620
|
1003
|
+
// }
|
1004
|
+
//
|
1005
|
+
let id = undefined;
|
1006
|
+
let assetId = undefined;
|
1007
|
+
let code = undefined;
|
1008
|
+
let amount = undefined;
|
1009
|
+
let fee = undefined;
|
1010
|
+
let type = undefined;
|
1011
|
+
let timestamp = undefined;
|
1012
|
+
if (typeof transaction === 'string') {
|
1013
|
+
id = transaction;
|
1014
|
+
} else {
|
1015
|
+
id = this.safeString (transaction, 'operationId');
|
1016
|
+
assetId = this.safeString (transaction, 'assetId');
|
1017
|
+
code = this.safeCurrencyCode (assetId, currency);
|
1018
|
+
amount = this.safeNumber (transaction, 'totalVolume');
|
1019
|
+
type = this.safeString (transaction, 'type');
|
1020
|
+
timestamp = this.safeInteger (transaction, 'timestamp');
|
1021
|
+
const feeCost = this.safeNumber (transaction, 'fee');
|
1022
|
+
fee = {
|
1023
|
+
'currency': code,
|
1024
|
+
'cost': feeCost,
|
1025
|
+
};
|
1026
|
+
}
|
1027
|
+
return {
|
1028
|
+
'info': transaction,
|
1029
|
+
'id': id,
|
1030
|
+
'txid': undefined,
|
1031
|
+
'timestamp': timestamp,
|
1032
|
+
'datetime': this.iso8601 (timestamp),
|
1033
|
+
'network': undefined,
|
1034
|
+
'addressFrom': undefined,
|
1035
|
+
'address': undefined,
|
1036
|
+
'addressTo': undefined,
|
1037
|
+
'tagFrom': undefined,
|
1038
|
+
'tag': undefined,
|
1039
|
+
'tagTo': undefined,
|
1040
|
+
'type': type,
|
1041
|
+
'amount': amount,
|
1042
|
+
'currency': code,
|
1043
|
+
'status': undefined,
|
1044
|
+
'updated': undefined,
|
1045
|
+
'fee': fee,
|
1046
|
+
};
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
async fetchTransactions (code = undefined, since = undefined, limit = undefined, params = {}) {
|
1050
|
+
await this.loadMarkets ();
|
1051
|
+
const request = {
|
1052
|
+
// 'offset': 0,
|
1053
|
+
// 'take': 1,
|
1054
|
+
};
|
1055
|
+
if (limit !== undefined) {
|
1056
|
+
request['take'] = limit;
|
1057
|
+
}
|
1058
|
+
const response = await this.privateGetOperations (this.extend (request, params));
|
1059
|
+
const payload = this.safeValue (response, 'payload', []);
|
1060
|
+
//
|
1061
|
+
// {
|
1062
|
+
// "payload":[
|
1063
|
+
// {
|
1064
|
+
// "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
|
1065
|
+
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
1066
|
+
// "totalVolume":0.1,
|
1067
|
+
// "fee":0.0,
|
1068
|
+
// "type":"deposit",
|
1069
|
+
// "timestamp":1644146723620
|
1070
|
+
// }
|
1071
|
+
// ],
|
1072
|
+
// "error":null
|
1073
|
+
// }
|
1074
|
+
//
|
1075
|
+
let currency = undefined;
|
1076
|
+
if (code !== undefined) {
|
1077
|
+
currency = this.currency (code);
|
1078
|
+
}
|
1079
|
+
return this.parseTransactions (payload, currency, since, limit);
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
async withdraw (code, amount, address, tag = undefined, params = {}) {
|
1083
|
+
await this.loadMarkets ();
|
1084
|
+
this.checkAddress (address);
|
1085
|
+
const currency = this.currency (code);
|
1086
|
+
const request = {
|
1087
|
+
'assetId': currency['id'],
|
1088
|
+
'volume': parseFloat (this.currencyToPrecision (code, amount)),
|
1089
|
+
'destinationAddress': address,
|
1090
|
+
// 'destinationAddressExtension': tag,
|
1091
|
+
};
|
1092
|
+
if (tag !== undefined) {
|
1093
|
+
request['destinationAddressExtension'] = tag;
|
1094
|
+
}
|
1095
|
+
const response = await this.privatePostOperationsWithdrawals (this.extend (request, params));
|
1096
|
+
//
|
1097
|
+
// "3035b1ad-2005-4587-a986-1f7966be78e0"
|
1098
|
+
//
|
1099
|
+
return this.parseTransaction (response, currency);
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
sign (path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
1103
|
+
let url = this.urls['api'][api] + '/' + this.implodeParams (path, params);
|
1104
|
+
const query = this.omit (params, this.extractParams (path));
|
1105
|
+
headers = {
|
1106
|
+
'Accept': 'application/json',
|
1107
|
+
'Content-Type': 'application/json',
|
1108
|
+
};
|
1109
|
+
if (api === 'public') {
|
1110
|
+
if (Object.keys (query).length) {
|
1111
|
+
url += '?' + this.urlencode (query);
|
1112
|
+
}
|
1113
|
+
} else if (api === 'private') {
|
1114
|
+
if ((method === 'GET') || (method === 'DELETE')) {
|
1115
|
+
if (Object.keys (query).length) {
|
1116
|
+
url += '?' + this.urlencode (query);
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
this.checkRequiredCredentials ();
|
1120
|
+
headers['Authorization'] = 'Bearer ' + this.apiKey;
|
1121
|
+
if (method === 'POST') {
|
1122
|
+
if (Object.keys (params).length) {
|
1123
|
+
body = this.json (params);
|
1124
|
+
}
|
1125
|
+
}
|
1126
|
+
if (path === 'operations/withdrawals') {
|
1127
|
+
headers['X-Request-ID'] = this.uuid ();
|
1128
|
+
}
|
1129
|
+
}
|
1130
|
+
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
handleErrors (code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
1134
|
+
if (response === undefined) {
|
1135
|
+
return;
|
1136
|
+
}
|
1137
|
+
const error = this.safeValue (response, 'error', {});
|
1138
|
+
const errorCode = this.safeString (error, 'code');
|
1139
|
+
if ((errorCode !== undefined) && (errorCode !== '0')) {
|
1140
|
+
const feedback = this.id + ' ' + body;
|
1141
|
+
const message = this.safeString (error, 'message');
|
1142
|
+
this.throwExactlyMatchedException (this.exceptions['exact'], errorCode, feedback);
|
1143
|
+
this.throwBroadlyMatchedException (this.exceptions['broad'], message, feedback);
|
1144
|
+
throw new ExchangeError (feedback);
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
};
|