ccxt 4.4.53 → 4.4.57
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/README.md +224 -142
- package/dist/ccxt.browser.min.js +8 -8
- package/dist/cjs/ccxt.js +1 -4
- package/dist/cjs/src/ace.js +3 -0
- package/dist/cjs/src/alpaca.js +5 -0
- package/dist/cjs/src/ascendex.js +2 -1
- package/dist/cjs/src/base/Exchange.js +114 -56
- package/dist/cjs/src/bigone.js +5 -0
- package/dist/cjs/src/binance.js +53 -53
- package/dist/cjs/src/bingx.js +27 -30
- package/dist/cjs/src/bit2c.js +3 -0
- package/dist/cjs/src/bitbank.js +3 -0
- package/dist/cjs/src/bitbns.js +3 -0
- package/dist/cjs/src/bitfinex.js +7 -2
- package/dist/cjs/src/bitflyer.js +5 -0
- package/dist/cjs/src/bitget.js +9 -5
- package/dist/cjs/src/bithumb.js +2 -0
- package/dist/cjs/src/bitmart.js +20 -8
- package/dist/cjs/src/bitmex.js +99 -93
- package/dist/cjs/src/bitopro.js +5 -0
- package/dist/cjs/src/bitrue.js +4 -0
- package/dist/cjs/src/bitso.js +3 -0
- package/dist/cjs/src/bitstamp.js +3 -0
- package/dist/cjs/src/bitteam.js +5 -0
- package/dist/cjs/src/bitvavo.js +4 -0
- package/dist/cjs/src/blockchaincom.js +5 -1
- package/dist/cjs/src/blofin.js +3 -0
- package/dist/cjs/src/btcalpha.js +5 -0
- package/dist/cjs/src/btcbox.js +3 -3
- package/dist/cjs/src/btcmarkets.js +5 -0
- package/dist/cjs/src/btcturk.js +3 -0
- package/dist/cjs/src/bybit.js +12 -2
- package/dist/cjs/src/cex.js +2 -0
- package/dist/cjs/src/coinbase.js +16 -8
- package/dist/cjs/src/coinbaseexchange.js +5 -0
- package/dist/cjs/src/coinbaseinternational.js +7 -3
- package/dist/cjs/src/coincatch.js +4 -1
- package/dist/cjs/src/coincheck.js +2 -0
- package/dist/cjs/src/coinex.js +5 -1
- package/dist/cjs/src/coinlist.js +5 -0
- package/dist/cjs/src/coinmate.js +5 -1
- package/dist/cjs/src/coinmetro.js +9 -5
- package/dist/cjs/src/coinone.js +4 -1
- package/dist/cjs/src/coinsph.js +5 -1
- package/dist/cjs/src/coinspot.js +2 -1
- package/dist/cjs/src/cryptocom.js +5 -0
- package/dist/cjs/src/currencycom.js +4 -1
- package/dist/cjs/src/defx.js +5 -0
- package/dist/cjs/src/delta.js +3 -0
- package/dist/cjs/src/deribit.js +14 -32
- package/dist/cjs/src/digifinex.js +10 -5
- package/dist/cjs/src/ellipx.js +9 -5
- package/dist/cjs/src/exmo.js +5 -2
- package/dist/cjs/src/gate.js +4 -0
- package/dist/cjs/src/gemini.js +3 -0
- package/dist/cjs/src/hashkey.js +5 -4
- package/dist/cjs/src/hitbtc.js +4 -0
- package/dist/cjs/src/hollaex.js +6 -1
- package/dist/cjs/src/htx.js +9 -1
- package/dist/cjs/src/huobijp.js +5 -0
- package/dist/cjs/src/hyperliquid.js +9 -4
- package/dist/cjs/src/idex.js +6 -2
- package/dist/cjs/src/independentreserve.js +4 -0
- package/dist/cjs/src/indodax.js +3 -0
- package/dist/cjs/src/kraken.js +7 -5
- package/dist/cjs/src/krakenfutures.js +5 -2
- package/dist/cjs/src/kucoin.js +15 -7
- package/dist/cjs/src/kucoinfutures.js +5 -1
- package/dist/cjs/src/kuna.js +3 -0
- package/dist/cjs/src/latoken.js +4 -0
- package/dist/cjs/src/lbank.js +6 -1
- package/dist/cjs/src/luno.js +7 -2
- package/dist/cjs/src/mercado.js +5 -1
- package/dist/cjs/src/mexc.js +10 -9
- package/dist/cjs/src/ndax.js +7 -2
- package/dist/cjs/src/novadax.js +6 -1
- package/dist/cjs/src/oceanex.js +4 -0
- package/dist/cjs/src/okcoin.js +6 -2
- package/dist/cjs/src/okx.js +18 -4
- package/dist/cjs/src/onetrading.js +5 -1
- package/dist/cjs/src/oxfun.js +3 -0
- package/dist/cjs/src/p2b.js +3 -0
- package/dist/cjs/src/paradex.js +9 -3
- package/dist/cjs/src/phemex.js +12 -5
- package/dist/cjs/src/poloniex.js +6 -3
- package/dist/cjs/src/poloniexfutures.js +5 -1
- package/dist/cjs/src/pro/binance.js +2 -2
- package/dist/cjs/src/pro/bitcoincom.js +1 -4
- package/dist/cjs/src/pro/bitget.js +3 -3
- package/dist/cjs/src/pro/bitopro.js +1 -1
- package/dist/cjs/src/pro/bybit.js +10 -2
- package/dist/cjs/src/pro/cex.js +1 -1
- package/dist/cjs/src/pro/coincatch.js +3 -3
- package/dist/cjs/src/pro/mexc.js +3 -3
- package/dist/cjs/src/pro/okx.js +1 -1
- package/dist/cjs/src/probit.js +5 -1
- package/dist/cjs/src/timex.js +5 -1
- package/dist/cjs/src/tokocrypto.js +6 -1
- package/dist/cjs/src/tradeogre.js +2 -0
- package/dist/cjs/src/upbit.js +3 -0
- package/dist/cjs/src/vertex.js +6 -2
- package/dist/cjs/src/wavesexchange.js +24 -4
- package/dist/cjs/src/wazirx.js +2 -0
- package/dist/cjs/src/whitebit.js +5 -4
- package/dist/cjs/src/woo.js +15 -5
- package/dist/cjs/src/woofipro.js +25 -9
- package/dist/cjs/src/xt.js +5 -0
- package/dist/cjs/src/yobit.js +4 -1
- package/dist/cjs/src/zaif.js +2 -0
- package/dist/cjs/src/zonda.js +3 -1
- package/js/ccxt.d.ts +3 -6
- package/js/ccxt.js +2 -4
- package/js/src/abstract/binance.d.ts +0 -1
- package/js/src/abstract/binancecoinm.d.ts +0 -1
- package/js/src/abstract/binanceus.d.ts +0 -1
- package/js/src/abstract/binanceusdm.d.ts +0 -1
- package/js/src/ace.js +3 -0
- package/js/src/alpaca.js +5 -0
- package/js/src/ascendex.js +2 -1
- package/js/src/base/Exchange.d.ts +7 -3
- package/js/src/base/Exchange.js +114 -56
- package/js/src/base/types.d.ts +2 -0
- package/js/src/bigone.d.ts +1 -1
- package/js/src/bigone.js +5 -0
- package/js/src/binance.d.ts +30 -32
- package/js/src/binance.js +53 -53
- package/js/src/bingx.d.ts +1 -1
- package/js/src/bingx.js +27 -30
- package/js/src/bit2c.js +3 -0
- package/js/src/bitbank.js +3 -0
- package/js/src/bitbns.js +3 -0
- package/js/src/bitfinex.js +7 -2
- package/js/src/bitflyer.js +5 -0
- package/js/src/bitget.js +9 -5
- package/js/src/bithumb.js +2 -0
- package/js/src/bitmart.d.ts +5 -5
- package/js/src/bitmart.js +20 -8
- package/js/src/bitmex.js +99 -93
- package/js/src/bitopro.d.ts +2 -2
- package/js/src/bitopro.js +5 -0
- package/js/src/bitrue.js +4 -0
- package/js/src/bitso.d.ts +2 -2
- package/js/src/bitso.js +3 -0
- package/js/src/bitstamp.js +3 -0
- package/js/src/bitteam.js +5 -0
- package/js/src/bitvavo.js +4 -0
- package/js/src/blockchaincom.js +5 -1
- package/js/src/blofin.js +3 -0
- package/js/src/btcalpha.js +5 -0
- package/js/src/btcbox.js +3 -3
- package/js/src/btcmarkets.js +5 -0
- package/js/src/btcturk.js +3 -0
- package/js/src/bybit.d.ts +3 -3
- package/js/src/bybit.js +12 -2
- package/js/src/cex.js +2 -0
- package/js/src/coinbase.d.ts +4 -4
- package/js/src/coinbase.js +16 -8
- package/js/src/coinbaseexchange.js +5 -0
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/coinbaseinternational.js +7 -3
- package/js/src/coincatch.js +4 -1
- package/js/src/coincheck.js +2 -0
- package/js/src/coinex.d.ts +1 -1
- package/js/src/coinex.js +5 -1
- package/js/src/coinlist.js +5 -0
- package/js/src/coinmate.js +5 -1
- package/js/src/coinmetro.js +9 -5
- package/js/src/coinone.js +4 -1
- package/js/src/coinsph.js +5 -1
- package/js/src/coinspot.js +2 -1
- package/js/src/cryptocom.js +5 -0
- package/js/src/currencycom.js +4 -1
- package/js/src/defx.js +5 -0
- package/js/src/delta.js +3 -0
- package/js/src/deribit.d.ts +4 -2
- package/js/src/deribit.js +14 -32
- package/js/src/digifinex.js +10 -5
- package/js/src/ellipx.d.ts +1 -1
- package/js/src/ellipx.js +9 -5
- package/js/src/exmo.d.ts +3 -3
- package/js/src/exmo.js +5 -2
- package/js/src/gate.js +4 -0
- package/js/src/gemini.js +3 -0
- package/js/src/hashkey.js +5 -4
- package/js/src/hitbtc.d.ts +2 -2
- package/js/src/hitbtc.js +4 -0
- package/js/src/hollaex.d.ts +2 -2
- package/js/src/hollaex.js +6 -1
- package/js/src/htx.js +9 -1
- package/js/src/huobijp.js +5 -0
- package/js/src/hyperliquid.d.ts +1 -1
- package/js/src/hyperliquid.js +9 -4
- package/js/src/idex.d.ts +1 -1
- package/js/src/idex.js +6 -2
- package/js/src/independentreserve.js +4 -0
- package/js/src/indodax.js +3 -0
- package/js/src/kraken.js +7 -5
- package/js/src/krakenfutures.js +5 -2
- package/js/src/kucoin.d.ts +2 -1
- package/js/src/kucoin.js +15 -7
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/kucoinfutures.js +5 -1
- package/js/src/kuna.js +3 -0
- package/js/src/latoken.js +4 -0
- package/js/src/lbank.js +6 -1
- package/js/src/luno.d.ts +1 -1
- package/js/src/luno.js +7 -2
- package/js/src/mercado.js +5 -1
- package/js/src/mexc.js +10 -9
- package/js/src/ndax.js +7 -2
- package/js/src/novadax.js +6 -1
- package/js/src/oceanex.d.ts +2 -2
- package/js/src/oceanex.js +4 -0
- package/js/src/okcoin.js +6 -2
- package/js/src/okx.js +18 -4
- package/js/src/onetrading.js +5 -1
- package/js/src/oxfun.js +3 -0
- package/js/src/p2b.js +3 -0
- package/js/src/paradex.js +9 -3
- package/js/src/phemex.d.ts +1 -1
- package/js/src/phemex.js +12 -5
- package/js/src/poloniex.js +6 -3
- package/js/src/poloniexfutures.d.ts +1 -1
- package/js/src/poloniexfutures.js +5 -1
- package/js/src/pro/binance.js +2 -2
- package/js/src/pro/bitcoincom.js +1 -4
- package/js/src/pro/bitget.js +3 -3
- package/js/src/pro/bitopro.js +1 -1
- package/js/src/pro/bybit.js +10 -2
- package/js/src/pro/cex.js +1 -1
- package/js/src/pro/coincatch.js +3 -3
- package/js/src/pro/mexc.js +3 -3
- package/js/src/pro/okx.js +1 -1
- package/js/src/probit.js +5 -1
- package/js/src/static_dependencies/node-fetch/headers.d.ts +5 -0
- package/js/src/static_dependencies/proxies/agent-base/helpers.d.ts +1 -0
- package/js/src/static_dependencies/proxies/https-proxy-agent/parse-proxy-response.d.ts +1 -0
- package/js/src/timex.js +5 -1
- package/js/src/tokocrypto.js +6 -1
- package/js/src/tradeogre.js +2 -0
- package/js/src/upbit.d.ts +2 -2
- package/js/src/upbit.js +3 -0
- package/js/src/vertex.js +6 -2
- package/js/src/wavesexchange.d.ts +2 -1
- package/js/src/wavesexchange.js +24 -4
- package/js/src/wazirx.js +2 -0
- package/js/src/whitebit.js +5 -4
- package/js/src/woo.d.ts +1 -1
- package/js/src/woo.js +15 -5
- package/js/src/woofipro.d.ts +1 -1
- package/js/src/woofipro.js +25 -9
- package/js/src/xt.js +5 -0
- package/js/src/yobit.d.ts +2 -2
- package/js/src/yobit.js +4 -1
- package/js/src/zaif.js +2 -0
- package/js/src/zonda.js +3 -1
- package/package.json +25 -7
- package/dist/cjs/src/abstract/lykke.js +0 -9
- package/dist/cjs/src/lykke.js +0 -1401
- package/js/src/abstract/lykke.d.ts +0 -32
- package/js/src/abstract/lykke.js +0 -11
- package/js/src/lykke.d.ts +0 -212
- package/js/src/lykke.js +0 -1402
package/dist/cjs/src/lykke.js
DELETED
|
@@ -1,1401 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var lykke$1 = require('./abstract/lykke.js');
|
|
4
|
-
var errors = require('./base/errors.js');
|
|
5
|
-
var Precise = require('./base/Precise.js');
|
|
6
|
-
var number = require('./base/functions/number.js');
|
|
7
|
-
|
|
8
|
-
// ----------------------------------------------------------------------------
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
/**
|
|
11
|
-
* @class lykke
|
|
12
|
-
* @augments Exchange
|
|
13
|
-
*/
|
|
14
|
-
class lykke extends lykke$1 {
|
|
15
|
-
describe() {
|
|
16
|
-
return this.deepExtend(super.describe(), {
|
|
17
|
-
'id': 'lykke',
|
|
18
|
-
'name': 'Lykke',
|
|
19
|
-
'countries': ['UK'],
|
|
20
|
-
'version': '2',
|
|
21
|
-
// 300 requests per minute per method => 60000ms / 300 = 200 (/api/orders/*)
|
|
22
|
-
// 120 requests per minute per method => ( 60000ms / rateLimit ) / 120 = cost = 2.5 (/api/*)
|
|
23
|
-
'rateLimit': 200,
|
|
24
|
-
'has': {
|
|
25
|
-
'CORS': undefined,
|
|
26
|
-
'spot': true,
|
|
27
|
-
'margin': false,
|
|
28
|
-
'swap': false,
|
|
29
|
-
'future': false,
|
|
30
|
-
'option': false,
|
|
31
|
-
'cancelAllOrders': true,
|
|
32
|
-
'cancelOrder': true,
|
|
33
|
-
'createOrder': true,
|
|
34
|
-
'createStopLimitOrder': false,
|
|
35
|
-
'createStopMarketOrder': false,
|
|
36
|
-
'createStopOrder': false,
|
|
37
|
-
'editOrder': false,
|
|
38
|
-
'fetchBalance': true,
|
|
39
|
-
'fetchBorrowRateHistories': false,
|
|
40
|
-
'fetchBorrowRateHistory': false,
|
|
41
|
-
'fetchClosedOrders': true,
|
|
42
|
-
'fetchCrossBorrowRate': false,
|
|
43
|
-
'fetchCrossBorrowRates': false,
|
|
44
|
-
'fetchCurrencies': true,
|
|
45
|
-
'fetchDepositAddress': true,
|
|
46
|
-
'fetchDepositAddresses': false,
|
|
47
|
-
'fetchDepositAddressesByNetwork': false,
|
|
48
|
-
'fetchDeposits': false,
|
|
49
|
-
'fetchDepositsWithdrawals': true,
|
|
50
|
-
'fetchFundingHistory': false,
|
|
51
|
-
'fetchFundingRate': false,
|
|
52
|
-
'fetchFundingRateHistory': false,
|
|
53
|
-
'fetchFundingRates': false,
|
|
54
|
-
'fetchIndexOHLCV': false,
|
|
55
|
-
'fetchIsolatedBorrowRate': false,
|
|
56
|
-
'fetchIsolatedBorrowRates': false,
|
|
57
|
-
'fetchMarginMode': false,
|
|
58
|
-
'fetchMarkets': true,
|
|
59
|
-
'fetchMarkOHLCV': false,
|
|
60
|
-
'fetchMyTrades': true,
|
|
61
|
-
'fetchOHLCV': undefined,
|
|
62
|
-
'fetchOpenInterestHistory': false,
|
|
63
|
-
'fetchOpenOrders': true,
|
|
64
|
-
'fetchOrder': true,
|
|
65
|
-
'fetchOrderBook': true,
|
|
66
|
-
'fetchOrders': false,
|
|
67
|
-
'fetchOrderTrades': false,
|
|
68
|
-
'fetchPosition': false,
|
|
69
|
-
'fetchPositionHistory': false,
|
|
70
|
-
'fetchPositionMode': false,
|
|
71
|
-
'fetchPositions': false,
|
|
72
|
-
'fetchPositionsForSymbol': false,
|
|
73
|
-
'fetchPositionsHistory': false,
|
|
74
|
-
'fetchPositionsRisk': false,
|
|
75
|
-
'fetchPremiumIndexOHLCV': false,
|
|
76
|
-
'fetchTicker': true,
|
|
77
|
-
'fetchTickers': true,
|
|
78
|
-
'fetchTime': false,
|
|
79
|
-
'fetchTrades': true,
|
|
80
|
-
'fetchTradingFee': false,
|
|
81
|
-
'fetchTradingFees': false,
|
|
82
|
-
'fetchTransactionFees': false,
|
|
83
|
-
'fetchTransactions': 'emulated',
|
|
84
|
-
'fetchWithdrawals': false,
|
|
85
|
-
'setLeverage': false,
|
|
86
|
-
'setMarginMode': false,
|
|
87
|
-
'withdraw': true,
|
|
88
|
-
},
|
|
89
|
-
'requiredCredentials': {
|
|
90
|
-
'apiKey': true,
|
|
91
|
-
'secret': false,
|
|
92
|
-
},
|
|
93
|
-
'urls': {
|
|
94
|
-
'logo': 'https://user-images.githubusercontent.com/1294454/155840500-1ea4fdf0-47c0-4daa-9597-c6c1cd51b9ec.jpg',
|
|
95
|
-
'api': {
|
|
96
|
-
'public': 'https://hft-apiv2.lykke.com/api',
|
|
97
|
-
'private': 'https://hft-apiv2.lykke.com/api',
|
|
98
|
-
},
|
|
99
|
-
'www': 'https://www.lykke.com',
|
|
100
|
-
'doc': [
|
|
101
|
-
'https://hft-apiv2.lykke.com/swagger/ui/index.html',
|
|
102
|
-
'https://lykkecity.github.io/Trading-API',
|
|
103
|
-
],
|
|
104
|
-
'fees': 'https://support.lykke.com/hc/en-us/articles/115002141125-What-are-the-fees-and-charges-', // zero fee
|
|
105
|
-
},
|
|
106
|
-
'api': {
|
|
107
|
-
'public': {
|
|
108
|
-
'get': {
|
|
109
|
-
'assetpairs': 2.5,
|
|
110
|
-
'assetpairs/{id}': 2.5,
|
|
111
|
-
'assets': 2.5,
|
|
112
|
-
'assets/{id}': 2.5,
|
|
113
|
-
'isalive': 2.5,
|
|
114
|
-
'orderbooks': 2.5,
|
|
115
|
-
'tickers': 2.5,
|
|
116
|
-
'prices': 2.5,
|
|
117
|
-
'trades/public/{assetPairId}': 2.5,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
'private': {
|
|
121
|
-
'get': {
|
|
122
|
-
'balance': 2.5,
|
|
123
|
-
'trades': 2.5,
|
|
124
|
-
'trades/order/{orderId}': 2.5,
|
|
125
|
-
'orders/active': 1,
|
|
126
|
-
'orders/closed': 1,
|
|
127
|
-
'orders/{orderId}': 1,
|
|
128
|
-
'operations': 2.5,
|
|
129
|
-
'operations/deposits/addresses': 2.5,
|
|
130
|
-
'operations/deposits/addresses/{assetId}': 2.5,
|
|
131
|
-
},
|
|
132
|
-
'post': {
|
|
133
|
-
'orders/limit': 1,
|
|
134
|
-
'orders/market': 1,
|
|
135
|
-
'orders/bulk': 1,
|
|
136
|
-
'operations/withdrawals': 2.5,
|
|
137
|
-
'operations/deposits/addresses': 2.5,
|
|
138
|
-
},
|
|
139
|
-
'delete': {
|
|
140
|
-
'orders': 1,
|
|
141
|
-
'orders/{orderId}': 1,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
'fees': {
|
|
146
|
-
'trading': {
|
|
147
|
-
'tierBased': false,
|
|
148
|
-
'percentage': true,
|
|
149
|
-
'maker': 0,
|
|
150
|
-
'taker': 0,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
'precisionMode': number.TICK_SIZE,
|
|
154
|
-
'exceptions': {
|
|
155
|
-
'exact': {
|
|
156
|
-
'1001': errors.ExchangeError,
|
|
157
|
-
'1100': errors.ExchangeError,
|
|
158
|
-
'1101': errors.ExchangeError,
|
|
159
|
-
'2000': errors.BadRequest,
|
|
160
|
-
'2001': errors.InsufficientFunds,
|
|
161
|
-
'2202': errors.DuplicateOrderId,
|
|
162
|
-
'2003': errors.ExchangeError,
|
|
163
|
-
'2004': errors.NotSupported,
|
|
164
|
-
'2005': errors.ExchangeError,
|
|
165
|
-
'2006': errors.InsufficientFunds,
|
|
166
|
-
'2007': errors.InsufficientFunds,
|
|
167
|
-
'2008': errors.InsufficientFunds,
|
|
168
|
-
'2009': errors.ExchangeError,
|
|
169
|
-
'2010': errors.InsufficientFunds,
|
|
170
|
-
'2011': errors.InvalidOrder,
|
|
171
|
-
'2012': errors.InvalidOrder,
|
|
172
|
-
'2013': errors.InvalidOrder,
|
|
173
|
-
'2014': errors.InvalidOrder,
|
|
174
|
-
'2015': errors.InvalidOrder,
|
|
175
|
-
'2016': errors.InvalidOrder,
|
|
176
|
-
'2017': errors.InvalidOrder,
|
|
177
|
-
'2018': errors.InvalidOrder,
|
|
178
|
-
'2019': errors.InvalidOrder,
|
|
179
|
-
'2020': errors.InvalidOrder,
|
|
180
|
-
'2021': errors.InvalidOrder,
|
|
181
|
-
'2022': errors.InvalidOrder,
|
|
182
|
-
'2023': errors.ExchangeError,
|
|
183
|
-
},
|
|
184
|
-
'broad': {},
|
|
185
|
-
},
|
|
186
|
-
'commonCurrencies': {},
|
|
187
|
-
'features': {
|
|
188
|
-
'spot': {
|
|
189
|
-
'sandbox': false,
|
|
190
|
-
'createOrder': {
|
|
191
|
-
'marginMode': false,
|
|
192
|
-
'triggerPrice': false,
|
|
193
|
-
'triggerPriceType': undefined,
|
|
194
|
-
'triggerDirection': false,
|
|
195
|
-
'stopLossPrice': false,
|
|
196
|
-
'takeProfitPrice': false,
|
|
197
|
-
'attachedStopLossTakeProfit': undefined,
|
|
198
|
-
'timeInForce': {
|
|
199
|
-
'IOC': false,
|
|
200
|
-
'FOK': false,
|
|
201
|
-
'PO': false,
|
|
202
|
-
'GTD': false,
|
|
203
|
-
},
|
|
204
|
-
'hedged': false,
|
|
205
|
-
'trailing': false,
|
|
206
|
-
'leverage': false,
|
|
207
|
-
'marketBuyByCost': false,
|
|
208
|
-
'marketBuyRequiresPrice': false,
|
|
209
|
-
'selfTradePrevention': false,
|
|
210
|
-
'iceberg': false,
|
|
211
|
-
},
|
|
212
|
-
'createOrders': undefined,
|
|
213
|
-
'fetchMyTrades': {
|
|
214
|
-
'marginMode': false,
|
|
215
|
-
'limit': 1000,
|
|
216
|
-
'daysBack': 100000,
|
|
217
|
-
'untilDays': 100000, // todo
|
|
218
|
-
},
|
|
219
|
-
'fetchOrder': {
|
|
220
|
-
'marginMode': false,
|
|
221
|
-
'trigger': false,
|
|
222
|
-
'trailing': false,
|
|
223
|
-
},
|
|
224
|
-
'fetchOpenOrders': {
|
|
225
|
-
'marginMode': false,
|
|
226
|
-
'limit': 1000,
|
|
227
|
-
'trigger': false,
|
|
228
|
-
'trailing': false,
|
|
229
|
-
},
|
|
230
|
-
'fetchOrders': undefined,
|
|
231
|
-
'fetchClosedOrders': {
|
|
232
|
-
'marginMode': false,
|
|
233
|
-
'limit': 1000,
|
|
234
|
-
'daysBack': undefined,
|
|
235
|
-
'daysBackCanceled': undefined,
|
|
236
|
-
'untilDays': undefined,
|
|
237
|
-
'trigger': false,
|
|
238
|
-
'trailing': false,
|
|
239
|
-
},
|
|
240
|
-
'fetchOHLCV': undefined,
|
|
241
|
-
},
|
|
242
|
-
'swap': {
|
|
243
|
-
'linear': undefined,
|
|
244
|
-
'inverse': undefined,
|
|
245
|
-
},
|
|
246
|
-
'future': {
|
|
247
|
-
'linear': undefined,
|
|
248
|
-
'inverse': undefined,
|
|
249
|
-
},
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* @method
|
|
255
|
-
* @name lykke#fetchCurrencies
|
|
256
|
-
* @description fetches all available currencies on an exchange
|
|
257
|
-
* @see https://lykkecity.github.io/Trading-API/#get-all-assets
|
|
258
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
259
|
-
* @returns {object} an associative dictionary of currencies
|
|
260
|
-
*/
|
|
261
|
-
async fetchCurrencies(params = {}) {
|
|
262
|
-
const response = await this.publicGetAssets(params);
|
|
263
|
-
const currencies = this.safeValue(response, 'payload', []);
|
|
264
|
-
//
|
|
265
|
-
// {
|
|
266
|
-
// "payload":[
|
|
267
|
-
// {
|
|
268
|
-
// "assetId":"115a60c2-0da1-40f9-a7f2-41da723b9075",
|
|
269
|
-
// "name":"Monaco Token",
|
|
270
|
-
// "symbol":"MCO",
|
|
271
|
-
// "accuracy":6,
|
|
272
|
-
// "multiplierPower":8,
|
|
273
|
-
// "assetAddress":"",
|
|
274
|
-
// "blockchainIntegrationLayerId":"",
|
|
275
|
-
// "blockchain":"ethereum",
|
|
276
|
-
// "type":"erc20Token",
|
|
277
|
-
// "isTradable":true,
|
|
278
|
-
// "isTrusted":true,
|
|
279
|
-
// "kycNeeded":false,
|
|
280
|
-
// "blockchainWithdrawal":true,
|
|
281
|
-
// "cashoutMinimalAmount":0.1,
|
|
282
|
-
// "lowVolumeAmount":null,
|
|
283
|
-
// "lykkeEntityId":"LYKKE NL",
|
|
284
|
-
// "siriusAssetId":0,
|
|
285
|
-
// "siriusBlockchainId":null,
|
|
286
|
-
// "blockchainIntegrationType":"none",
|
|
287
|
-
// "blockchainDepositEnabled":false,
|
|
288
|
-
// "isDisabled":false
|
|
289
|
-
// }
|
|
290
|
-
// ],
|
|
291
|
-
// "error":null
|
|
292
|
-
// }
|
|
293
|
-
//
|
|
294
|
-
const result = {};
|
|
295
|
-
for (let i = 0; i < currencies.length; i++) {
|
|
296
|
-
const currency = currencies[i];
|
|
297
|
-
const id = this.safeString(currency, 'assetId');
|
|
298
|
-
const code = this.safeString(currency, 'symbol');
|
|
299
|
-
const name = this.safeString(currency, 'name');
|
|
300
|
-
const rawType = this.safeString(currency, 'type');
|
|
301
|
-
const type = (rawType === 'erc20Token') ? 'crypto' : 'other';
|
|
302
|
-
const deposit = this.safeValue(currency, 'blockchainDepositEnabled');
|
|
303
|
-
const withdraw = this.safeValue(currency, 'blockchainWithdrawal');
|
|
304
|
-
const isDisabled = this.safeValue(currency, 'isDisabled');
|
|
305
|
-
const active = !isDisabled;
|
|
306
|
-
result[code] = {
|
|
307
|
-
'id': id,
|
|
308
|
-
'code': code,
|
|
309
|
-
'info': currency,
|
|
310
|
-
'type': type,
|
|
311
|
-
'name': name,
|
|
312
|
-
'active': active,
|
|
313
|
-
'deposit': deposit,
|
|
314
|
-
'withdraw': withdraw,
|
|
315
|
-
'fee': undefined,
|
|
316
|
-
'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'accuracy'))),
|
|
317
|
-
'limits': {
|
|
318
|
-
'withdraw': {
|
|
319
|
-
'min': this.safeValue(currency, 'cashoutMinimalAmount'),
|
|
320
|
-
'max': undefined,
|
|
321
|
-
},
|
|
322
|
-
'amount': {
|
|
323
|
-
'min': this.safeValue(currency, 'lowVolumeAmount'),
|
|
324
|
-
'max': undefined,
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
'networks': {},
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
return result;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* @method
|
|
334
|
-
* @name lykke#fetchMarkets
|
|
335
|
-
* @description retrieves data on all markets for lykke
|
|
336
|
-
* @see https://lykkecity.github.io/Trading-API/#get-asset-by-id
|
|
337
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
338
|
-
* @returns {object[]} an array of objects representing market data
|
|
339
|
-
*/
|
|
340
|
-
async fetchMarkets(params = {}) {
|
|
341
|
-
const response = await this.publicGetAssetpairs(params);
|
|
342
|
-
const markets = this.safeValue(response, 'payload', []);
|
|
343
|
-
//
|
|
344
|
-
// {
|
|
345
|
-
// "payload":[
|
|
346
|
-
// {
|
|
347
|
-
// "assetPairId":"AAVEBTC",
|
|
348
|
-
// "baseAssetId":"c9e55548-dae5-44fc-bebd-e72249cb19f3",
|
|
349
|
-
// "quoteAssetId":"BTC",
|
|
350
|
-
// "name":"AAVE/BTC",
|
|
351
|
-
// "priceAccuracy":6,
|
|
352
|
-
// "baseAssetAccuracy":6,
|
|
353
|
-
// "quoteAssetAccuracy":8,
|
|
354
|
-
// "minVolume":0.001,
|
|
355
|
-
// "minOppositeVolume":0.0001
|
|
356
|
-
// }
|
|
357
|
-
// ],
|
|
358
|
-
// "error":null
|
|
359
|
-
// }
|
|
360
|
-
//
|
|
361
|
-
const result = [];
|
|
362
|
-
for (let i = 0; i < markets.length; i++) {
|
|
363
|
-
const market = markets[i];
|
|
364
|
-
const id = this.safeString(market, 'assetPairId');
|
|
365
|
-
const name = this.safeString(market, 'name');
|
|
366
|
-
const baseAssetId = this.safeString(market, 'baseAssetId');
|
|
367
|
-
const quoteAssetId = this.safeString(market, 'quoteAssetId');
|
|
368
|
-
const [baseId, quoteId] = name.split('/');
|
|
369
|
-
const base = this.safeCurrencyCode(baseId);
|
|
370
|
-
const quote = this.safeCurrencyCode(quoteId);
|
|
371
|
-
const symbol = base + '/' + quote;
|
|
372
|
-
result.push({
|
|
373
|
-
'id': id,
|
|
374
|
-
'symbol': symbol,
|
|
375
|
-
'base': base,
|
|
376
|
-
'quote': quote,
|
|
377
|
-
'baseId': baseAssetId,
|
|
378
|
-
'quoteId': quoteAssetId,
|
|
379
|
-
'settle': undefined,
|
|
380
|
-
'settleId': undefined,
|
|
381
|
-
'type': 'spot',
|
|
382
|
-
'spot': true,
|
|
383
|
-
'margin': false,
|
|
384
|
-
'swap': false,
|
|
385
|
-
'future': false,
|
|
386
|
-
'option': false,
|
|
387
|
-
'contract': false,
|
|
388
|
-
'active': true,
|
|
389
|
-
'linear': undefined,
|
|
390
|
-
'inverse': undefined,
|
|
391
|
-
'contractSize': undefined,
|
|
392
|
-
'expiry': undefined,
|
|
393
|
-
'expiryDatetime': undefined,
|
|
394
|
-
'strike': undefined,
|
|
395
|
-
'optionType': undefined,
|
|
396
|
-
'precision': {
|
|
397
|
-
'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'baseAssetAccuracy'))),
|
|
398
|
-
'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'priceAccuracy'))),
|
|
399
|
-
},
|
|
400
|
-
'limits': {
|
|
401
|
-
'amount': {
|
|
402
|
-
'min': this.safeNumber(market, 'minVolume'),
|
|
403
|
-
'max': undefined,
|
|
404
|
-
},
|
|
405
|
-
'price': {
|
|
406
|
-
'min': undefined,
|
|
407
|
-
'max': undefined,
|
|
408
|
-
},
|
|
409
|
-
'cost': {
|
|
410
|
-
'min': this.safeNumber(market, 'minOppositeVolume'),
|
|
411
|
-
'max': undefined,
|
|
412
|
-
},
|
|
413
|
-
'leverage': {
|
|
414
|
-
'min': undefined,
|
|
415
|
-
'max': undefined,
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
'created': undefined,
|
|
419
|
-
'info': market,
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
return result;
|
|
423
|
-
}
|
|
424
|
-
parseTicker(ticker, market = undefined) {
|
|
425
|
-
//
|
|
426
|
-
// fetchTickers
|
|
427
|
-
//
|
|
428
|
-
// publicGetTickers
|
|
429
|
-
//
|
|
430
|
-
// {
|
|
431
|
-
// "assetPairId":"BTCUSD",
|
|
432
|
-
// "volumeBase":2.56905016,
|
|
433
|
-
// "volumeQuote":95653.8730,
|
|
434
|
-
// "priceChange":-0.0367945778541765034194707584,
|
|
435
|
-
// "lastPrice":36840.0,
|
|
436
|
-
// "high":38371.645,
|
|
437
|
-
// "low":35903.356,
|
|
438
|
-
// "timestamp":1643295740729
|
|
439
|
-
// }
|
|
440
|
-
//
|
|
441
|
-
// fetchTicker
|
|
442
|
-
//
|
|
443
|
-
// publicGetTickers
|
|
444
|
-
//
|
|
445
|
-
// {
|
|
446
|
-
// "assetPairId":"BTCUSD",
|
|
447
|
-
// "volumeBase":2.56905016,
|
|
448
|
-
// "volumeQuote":95653.8730,
|
|
449
|
-
// "priceChange":-0.0367945778541765034194707584,
|
|
450
|
-
// "lastPrice":36840.0,
|
|
451
|
-
// "high":38371.645,
|
|
452
|
-
// "low":35903.356,
|
|
453
|
-
// "timestamp":1643295740729
|
|
454
|
-
// }
|
|
455
|
-
//
|
|
456
|
-
// publicGetPrices
|
|
457
|
-
//
|
|
458
|
-
// {
|
|
459
|
-
// "assetPairId":"BTCUSD",
|
|
460
|
-
// "bid":36181.521,
|
|
461
|
-
// "ask":36244.492,
|
|
462
|
-
// "timestamp":1643305510990
|
|
463
|
-
// }
|
|
464
|
-
//
|
|
465
|
-
const timestamp = undefined; // temporary bug in lykke api, returns unrealistic numbers
|
|
466
|
-
const marketId = this.safeString(ticker, 'assetPairId');
|
|
467
|
-
market = this.safeMarket(marketId, market);
|
|
468
|
-
const close = this.safeString(ticker, 'lastPrice');
|
|
469
|
-
return this.safeTicker({
|
|
470
|
-
'symbol': this.safeString(market, 'symbol'),
|
|
471
|
-
'timestamp': timestamp,
|
|
472
|
-
'datetime': this.iso8601(timestamp),
|
|
473
|
-
'high': this.safeString(ticker, 'high'),
|
|
474
|
-
'low': this.safeString(ticker, 'low'),
|
|
475
|
-
'bid': this.safeString(ticker, 'bid'),
|
|
476
|
-
'bidVolume': undefined,
|
|
477
|
-
'ask': this.safeString(ticker, 'ask'),
|
|
478
|
-
'askVolume': undefined,
|
|
479
|
-
'vwap': undefined,
|
|
480
|
-
'open': undefined,
|
|
481
|
-
'close': close,
|
|
482
|
-
'last': close,
|
|
483
|
-
'previousClose': undefined,
|
|
484
|
-
'change': this.safeString(ticker, 'priceChange'),
|
|
485
|
-
'percentage': undefined,
|
|
486
|
-
'average': undefined,
|
|
487
|
-
'baseVolume': this.safeString(ticker, 'volumeBase'),
|
|
488
|
-
'quoteVolume': this.safeString(ticker, 'volumeQuote'),
|
|
489
|
-
'info': ticker,
|
|
490
|
-
}, market);
|
|
491
|
-
}
|
|
492
|
-
/**
|
|
493
|
-
* @method
|
|
494
|
-
* @name lykke#fetchTicker
|
|
495
|
-
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
|
496
|
-
* @see https://lykkecity.github.io/Trading-API/#get-current-prices
|
|
497
|
-
* @see https://lykkecity.github.io/Trading-API/#24hr-ticker-price-change-statistics
|
|
498
|
-
* @param {string} symbol unified symbol of the market to fetch the ticker for
|
|
499
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
500
|
-
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
501
|
-
*/
|
|
502
|
-
async fetchTicker(symbol, params = {}) {
|
|
503
|
-
await this.loadMarkets();
|
|
504
|
-
const market = this.market(symbol);
|
|
505
|
-
const request = {
|
|
506
|
-
'assetPairIds': market['id'],
|
|
507
|
-
};
|
|
508
|
-
// publicGetTickers or publicGetPrices
|
|
509
|
-
const method = this.safeString(this.options, 'fetchTickerMethod', 'publicGetTickers');
|
|
510
|
-
let response = undefined;
|
|
511
|
-
if (method === 'publicGetPrices') {
|
|
512
|
-
response = await this.publicGetPrices(this.extend(request, params));
|
|
513
|
-
}
|
|
514
|
-
else {
|
|
515
|
-
response = await this.publicGetTickers(this.extend(request, params));
|
|
516
|
-
}
|
|
517
|
-
const ticker = this.safeValue(response, 'payload', []);
|
|
518
|
-
//
|
|
519
|
-
// publicGetTickers
|
|
520
|
-
//
|
|
521
|
-
// {
|
|
522
|
-
// "payload":[
|
|
523
|
-
// {
|
|
524
|
-
// "assetPairId":"BTCUSD",
|
|
525
|
-
// "volumeBase":0.78056880,
|
|
526
|
-
// "volumeQuote":29782.5169,
|
|
527
|
-
// "priceChange":0.0436602362590968619931324699,
|
|
528
|
-
// "lastPrice":38626.885,
|
|
529
|
-
// "high":38742.896,
|
|
530
|
-
// "low":36872.498,
|
|
531
|
-
// "timestamp":1643687822840
|
|
532
|
-
// }
|
|
533
|
-
// ],
|
|
534
|
-
// "error":null
|
|
535
|
-
// }
|
|
536
|
-
//
|
|
537
|
-
// publicGetPrices
|
|
538
|
-
//
|
|
539
|
-
// {
|
|
540
|
-
// "payload":[
|
|
541
|
-
// {
|
|
542
|
-
// "assetPairId":"BTCUSD",
|
|
543
|
-
// "bid":38597.936,
|
|
544
|
-
// "ask":38640.311,
|
|
545
|
-
// "timestamp":1643688350847
|
|
546
|
-
// }
|
|
547
|
-
// ],
|
|
548
|
-
// "error":null
|
|
549
|
-
// }
|
|
550
|
-
//
|
|
551
|
-
return this.parseTicker(this.safeValue(ticker, 0, {}), market);
|
|
552
|
-
}
|
|
553
|
-
/**
|
|
554
|
-
* @method
|
|
555
|
-
* @name lykke#fetchTickers
|
|
556
|
-
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
|
557
|
-
* @see https://lykkecity.github.io/Trading-API/#24hr-ticker-price-change-statistics
|
|
558
|
-
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
|
559
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
560
|
-
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
561
|
-
*/
|
|
562
|
-
async fetchTickers(symbols = undefined, params = {}) {
|
|
563
|
-
await this.loadMarkets();
|
|
564
|
-
const response = await this.publicGetTickers(params);
|
|
565
|
-
const tickers = this.safeValue(response, 'payload', []);
|
|
566
|
-
//
|
|
567
|
-
// {
|
|
568
|
-
// "payload":[
|
|
569
|
-
// {
|
|
570
|
-
// "assetPairId":"BTCUSD",
|
|
571
|
-
// "volumeBase":0.78056880,
|
|
572
|
-
// "volumeQuote":29782.5169,
|
|
573
|
-
// "priceChange":0.0436602362590968619931324699,
|
|
574
|
-
// "lastPrice":38626.885,
|
|
575
|
-
// "high":38742.896,
|
|
576
|
-
// "low":36872.498,
|
|
577
|
-
// "timestamp":1643687822840
|
|
578
|
-
// }
|
|
579
|
-
// ],
|
|
580
|
-
// "error":null
|
|
581
|
-
// }
|
|
582
|
-
//
|
|
583
|
-
return this.parseTickers(tickers, symbols);
|
|
584
|
-
}
|
|
585
|
-
/**
|
|
586
|
-
* @method
|
|
587
|
-
* @name lykke#fetchOrderBook
|
|
588
|
-
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
|
|
589
|
-
* @see https://lykkecity.github.io/Trading-API/#asset-pair-order-book-ticker
|
|
590
|
-
* @param {string} symbol unified symbol of the market to fetch the order book for
|
|
591
|
-
* @param {int} [limit] the maximum amount of order book entries to return
|
|
592
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
593
|
-
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
|
|
594
|
-
*/
|
|
595
|
-
async fetchOrderBook(symbol, limit = undefined, params = {}) {
|
|
596
|
-
await this.loadMarkets();
|
|
597
|
-
const market = this.market(symbol);
|
|
598
|
-
const request = {
|
|
599
|
-
'assetPairId': market['id'],
|
|
600
|
-
};
|
|
601
|
-
if (limit !== undefined) {
|
|
602
|
-
request['depth'] = limit; // default 0
|
|
603
|
-
}
|
|
604
|
-
const response = await this.publicGetOrderbooks(this.extend(request, params));
|
|
605
|
-
const payload = this.safeValue(response, 'payload', []);
|
|
606
|
-
//
|
|
607
|
-
// {
|
|
608
|
-
// "payload":[
|
|
609
|
-
// {
|
|
610
|
-
// "assetPairId": "BTCUSD",
|
|
611
|
-
// "timestamp": "1643298038203",
|
|
612
|
-
// "bids": [
|
|
613
|
-
// {
|
|
614
|
-
// "v":0.59034382,
|
|
615
|
-
// "p":36665.329
|
|
616
|
-
// }
|
|
617
|
-
// ],
|
|
618
|
-
// "asks": [
|
|
619
|
-
// {
|
|
620
|
-
// "v":-0.003,
|
|
621
|
-
// "p":36729.686
|
|
622
|
-
// }
|
|
623
|
-
// ]
|
|
624
|
-
// }
|
|
625
|
-
// ],
|
|
626
|
-
// "error":null
|
|
627
|
-
// }
|
|
628
|
-
//
|
|
629
|
-
const orderbook = this.safeValue(payload, 0, {});
|
|
630
|
-
const timestamp = this.safeInteger(orderbook, 'timestamp');
|
|
631
|
-
return this.parseOrderBook(orderbook, market['symbol'], timestamp, 'bids', 'asks', 'p', 'v');
|
|
632
|
-
}
|
|
633
|
-
parseTrade(trade, market = undefined) {
|
|
634
|
-
//
|
|
635
|
-
// public fetchTrades
|
|
636
|
-
//
|
|
637
|
-
// {
|
|
638
|
-
// "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
|
|
639
|
-
// "assetPairId":"BTCUSD",
|
|
640
|
-
// "timestamp":1643345958414,
|
|
641
|
-
// "volume":0.00010996,
|
|
642
|
-
// "price":37205.723,
|
|
643
|
-
// "side":"buy"
|
|
644
|
-
// }
|
|
645
|
-
//
|
|
646
|
-
// private fetchMyTrades
|
|
647
|
-
// {
|
|
648
|
-
// "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
|
|
649
|
-
// "timestamp":1644155923357,
|
|
650
|
-
// "assetPairId":"BCHEUR",
|
|
651
|
-
// "orderId":"1b367978-7e4f-454b-b870-64040d484443",
|
|
652
|
-
// "role":"Taker",
|
|
653
|
-
// "side":"sell",
|
|
654
|
-
// "price":280.569,
|
|
655
|
-
// "baseVolume":0.01,
|
|
656
|
-
// "quoteVolume":2.8056,
|
|
657
|
-
// "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
658
|
-
// "quoteAssetId":"EUR",
|
|
659
|
-
// "fee":null
|
|
660
|
-
// }
|
|
661
|
-
//
|
|
662
|
-
const marketId = this.safeString(trade, 'assetPairId');
|
|
663
|
-
market = this.safeMarket(marketId, market);
|
|
664
|
-
const symbol = market['symbol'];
|
|
665
|
-
const id = this.safeString2(trade, 'id', 'id');
|
|
666
|
-
const orderId = this.safeString(trade, 'orderId');
|
|
667
|
-
const timestamp = this.safeInteger(trade, 'timestamp');
|
|
668
|
-
const price = this.safeString2(trade, 'price', 'price');
|
|
669
|
-
let amount = this.safeString2(trade, 'volume', 'amount');
|
|
670
|
-
if (amount === undefined) {
|
|
671
|
-
amount = this.safeString2(trade, 'baseVolume', 'amount');
|
|
672
|
-
}
|
|
673
|
-
const side = this.safeStringLower(trade, 'side');
|
|
674
|
-
return this.safeTrade({
|
|
675
|
-
'id': id,
|
|
676
|
-
'info': trade,
|
|
677
|
-
'timestamp': timestamp,
|
|
678
|
-
'datetime': this.iso8601(timestamp),
|
|
679
|
-
'symbol': symbol,
|
|
680
|
-
'type': undefined,
|
|
681
|
-
'order': orderId,
|
|
682
|
-
'side': side,
|
|
683
|
-
'takerOrMaker': undefined,
|
|
684
|
-
'price': price,
|
|
685
|
-
'amount': amount,
|
|
686
|
-
'cost': undefined,
|
|
687
|
-
'fee': undefined,
|
|
688
|
-
}, market);
|
|
689
|
-
}
|
|
690
|
-
/**
|
|
691
|
-
* @method
|
|
692
|
-
* @name lykke#fetchTrades
|
|
693
|
-
* @description get the list of most recent trades for a particular symbol
|
|
694
|
-
* @see https://lykkecity.github.io/Trading-API/#get-public-trades
|
|
695
|
-
* @param {string} symbol unified symbol of the market to fetch trades for
|
|
696
|
-
* @param {int} [since] timestamp in ms of the earliest trade to fetch
|
|
697
|
-
* @param {int} [limit] the maximum amount of trades to fetch
|
|
698
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
699
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
|
|
700
|
-
*/
|
|
701
|
-
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
|
702
|
-
await this.loadMarkets();
|
|
703
|
-
const market = this.market(symbol);
|
|
704
|
-
const request = {
|
|
705
|
-
'assetPairId': market['id'],
|
|
706
|
-
// 'offset': 0,
|
|
707
|
-
};
|
|
708
|
-
if (limit !== undefined) {
|
|
709
|
-
request['take'] = limit;
|
|
710
|
-
}
|
|
711
|
-
const response = await this.publicGetTradesPublicAssetPairId(this.extend(request, params));
|
|
712
|
-
const result = this.safeValue(response, 'payload', []);
|
|
713
|
-
//
|
|
714
|
-
// {
|
|
715
|
-
// "payload":[
|
|
716
|
-
// {
|
|
717
|
-
// "id":"71df1f0c-be4e-4d45-b809-c108fad5f2a8",
|
|
718
|
-
// "assetPairId":"BTCUSD",
|
|
719
|
-
// "timestamp":1643345958414,
|
|
720
|
-
// "volume":0.00010996,
|
|
721
|
-
// "price":37205.723,
|
|
722
|
-
// "side":"buy"
|
|
723
|
-
// }
|
|
724
|
-
// ],
|
|
725
|
-
// "error":null
|
|
726
|
-
// }
|
|
727
|
-
//
|
|
728
|
-
return this.parseTrades(result, market, since, limit);
|
|
729
|
-
}
|
|
730
|
-
parseBalance(response) {
|
|
731
|
-
//
|
|
732
|
-
// [
|
|
733
|
-
// {
|
|
734
|
-
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
735
|
-
// "available":0.1,
|
|
736
|
-
// "reserved":0.0,
|
|
737
|
-
// "timestamp":1644146723620
|
|
738
|
-
// }
|
|
739
|
-
// ]
|
|
740
|
-
//
|
|
741
|
-
const result = { 'info': response };
|
|
742
|
-
for (let i = 0; i < response.length; i++) {
|
|
743
|
-
const balance = response[i];
|
|
744
|
-
const currencyId = this.safeString(balance, 'assetId');
|
|
745
|
-
const code = this.safeCurrencyCode(currencyId);
|
|
746
|
-
const account = this.account();
|
|
747
|
-
const total = this.safeString(balance, 'available');
|
|
748
|
-
const used = this.safeString(balance, 'reserved');
|
|
749
|
-
account['total'] = total;
|
|
750
|
-
account['used'] = used;
|
|
751
|
-
result[code] = account;
|
|
752
|
-
}
|
|
753
|
-
return this.safeBalance(result);
|
|
754
|
-
}
|
|
755
|
-
/**
|
|
756
|
-
* @method
|
|
757
|
-
* @name lykke#fetchBalance
|
|
758
|
-
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
759
|
-
* @see https://lykkecity.github.io/Trading-API/#get-the-current-balance
|
|
760
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
761
|
-
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
762
|
-
*/
|
|
763
|
-
async fetchBalance(params = {}) {
|
|
764
|
-
await this.loadMarkets();
|
|
765
|
-
const response = await this.privateGetBalance(params);
|
|
766
|
-
const payload = this.safeValue(response, 'payload', []);
|
|
767
|
-
//
|
|
768
|
-
// {
|
|
769
|
-
// "payload":[
|
|
770
|
-
// {
|
|
771
|
-
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
772
|
-
// "available":0.1,
|
|
773
|
-
// "reserved":0.0,
|
|
774
|
-
// "timestamp":1644146723620
|
|
775
|
-
// }
|
|
776
|
-
// ],
|
|
777
|
-
// "error":null
|
|
778
|
-
// }
|
|
779
|
-
//
|
|
780
|
-
return this.parseBalance(payload);
|
|
781
|
-
}
|
|
782
|
-
parseOrderStatus(status) {
|
|
783
|
-
const statuses = {
|
|
784
|
-
'Open': 'open',
|
|
785
|
-
'Pending': 'open',
|
|
786
|
-
'InOrderBook': 'open',
|
|
787
|
-
'Processing': 'open',
|
|
788
|
-
'Matched': 'closed',
|
|
789
|
-
'Cancelled': 'canceled',
|
|
790
|
-
'Rejected': 'rejected',
|
|
791
|
-
'Replaced': 'canceled',
|
|
792
|
-
'Placed': 'open',
|
|
793
|
-
};
|
|
794
|
-
return this.safeString(statuses, status, status);
|
|
795
|
-
}
|
|
796
|
-
parseOrder(order, market = undefined) {
|
|
797
|
-
//
|
|
798
|
-
// {
|
|
799
|
-
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
|
800
|
-
// "timestamp":1644155923357,
|
|
801
|
-
// "lastTradeTimestamp":1644155923357,
|
|
802
|
-
// "status":"Matched",
|
|
803
|
-
// "assetPairId":"BCHEUR",
|
|
804
|
-
// "type":"Market",
|
|
805
|
-
// "side":"Sell",
|
|
806
|
-
// "price":280.569,
|
|
807
|
-
// "volume":0.01,
|
|
808
|
-
// "filledVolume":0.01,
|
|
809
|
-
// "remainingVolume":0.0,
|
|
810
|
-
// "cost":2.80569
|
|
811
|
-
// }
|
|
812
|
-
//
|
|
813
|
-
const id = this.safeString(order, 'id');
|
|
814
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
815
|
-
const marketId = this.safeString(order, 'assetPairId');
|
|
816
|
-
const symbol = this.safeSymbol(marketId, market);
|
|
817
|
-
const type = this.safeStringLower(order, 'type');
|
|
818
|
-
const lastTradeTimestamp = this.safeInteger(order, 'lastTradeTimestamp');
|
|
819
|
-
const timestamp = this.safeInteger(order, 'timestamp');
|
|
820
|
-
const price = this.safeString(order, 'price');
|
|
821
|
-
const side = this.safeStringLower(order, 'side');
|
|
822
|
-
const amount = this.safeString(order, 'volume');
|
|
823
|
-
const remaining = this.safeString(order, 'remainingVolume');
|
|
824
|
-
const filled = this.safeString(order, 'filledVolume');
|
|
825
|
-
const cost = this.safeString(order, 'cost');
|
|
826
|
-
return this.safeOrder({
|
|
827
|
-
'info': order,
|
|
828
|
-
'id': id,
|
|
829
|
-
'clientOrderId': undefined,
|
|
830
|
-
'timestamp': timestamp,
|
|
831
|
-
'datetime': this.iso8601(timestamp),
|
|
832
|
-
'lastTradeTimestamp': lastTradeTimestamp,
|
|
833
|
-
'symbol': symbol,
|
|
834
|
-
'type': type,
|
|
835
|
-
'timeInForce': undefined,
|
|
836
|
-
'postOnly': undefined,
|
|
837
|
-
'side': side,
|
|
838
|
-
'price': price,
|
|
839
|
-
'triggerPrice': undefined,
|
|
840
|
-
'amount': amount,
|
|
841
|
-
'cost': cost,
|
|
842
|
-
'average': undefined,
|
|
843
|
-
'filled': filled,
|
|
844
|
-
'remaining': remaining,
|
|
845
|
-
'status': status,
|
|
846
|
-
'fee': undefined,
|
|
847
|
-
'trades': undefined,
|
|
848
|
-
}, market);
|
|
849
|
-
}
|
|
850
|
-
/**
|
|
851
|
-
* @method
|
|
852
|
-
* @name lykke#createOrder
|
|
853
|
-
* @description create a trade order
|
|
854
|
-
* @see https://lykkecity.github.io/Trading-API/#place-a-limit-order
|
|
855
|
-
* @see https://lykkecity.github.io/Trading-API/#place-a-market-order
|
|
856
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
857
|
-
* @param {string} type 'market' or 'limit'
|
|
858
|
-
* @param {string} side 'buy' or 'sell'
|
|
859
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
860
|
-
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
|
861
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
862
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
863
|
-
*/
|
|
864
|
-
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
865
|
-
await this.loadMarkets();
|
|
866
|
-
const market = this.market(symbol);
|
|
867
|
-
const query = {
|
|
868
|
-
'assetPairId': market['id'],
|
|
869
|
-
'side': this.capitalize(side),
|
|
870
|
-
'volume': parseFloat(this.amountToPrecision(market['symbol'], amount)),
|
|
871
|
-
};
|
|
872
|
-
if (type === 'limit') {
|
|
873
|
-
query['price'] = parseFloat(this.priceToPrecision(market['symbol'], price));
|
|
874
|
-
}
|
|
875
|
-
let result = undefined;
|
|
876
|
-
if (this.capitalize(type) === 'Market') {
|
|
877
|
-
result = await this.privatePostOrdersMarket(this.extend(query, params));
|
|
878
|
-
}
|
|
879
|
-
else {
|
|
880
|
-
result = await this.privatePostOrdersLimit(this.extend(query, params));
|
|
881
|
-
}
|
|
882
|
-
//
|
|
883
|
-
// market
|
|
884
|
-
//
|
|
885
|
-
// {
|
|
886
|
-
// "payload":{
|
|
887
|
-
// "orderId":"2b98ec26-8410-49b6-9f37-1fb2150e2299",
|
|
888
|
-
// "price":280.699
|
|
889
|
-
// },
|
|
890
|
-
// "error":null
|
|
891
|
-
// }
|
|
892
|
-
//
|
|
893
|
-
// limit
|
|
894
|
-
//
|
|
895
|
-
// {
|
|
896
|
-
// "payload":{
|
|
897
|
-
// "orderId":"27be8802-30be-40ca-bf40-ec886b309c5b"
|
|
898
|
-
// },
|
|
899
|
-
// "error":null
|
|
900
|
-
// }
|
|
901
|
-
//
|
|
902
|
-
const payload = this.safeValue(result, 'payload');
|
|
903
|
-
const id = this.safeString(payload, 'orderId');
|
|
904
|
-
if (type === 'market') {
|
|
905
|
-
price = this.safeNumber(payload, 'price');
|
|
906
|
-
}
|
|
907
|
-
return this.safeOrder({
|
|
908
|
-
'id': id,
|
|
909
|
-
'info': result,
|
|
910
|
-
'clientOrderId': undefined,
|
|
911
|
-
'timestamp': undefined,
|
|
912
|
-
'datetime': undefined,
|
|
913
|
-
'lastTradeTimestamp': undefined,
|
|
914
|
-
'symbol': market['symbol'],
|
|
915
|
-
'type': type,
|
|
916
|
-
'side': side,
|
|
917
|
-
'price': price,
|
|
918
|
-
'amount': amount,
|
|
919
|
-
'cost': undefined,
|
|
920
|
-
'average': undefined,
|
|
921
|
-
'filled': undefined,
|
|
922
|
-
'remaining': undefined,
|
|
923
|
-
'status': undefined,
|
|
924
|
-
'fee': undefined,
|
|
925
|
-
'trades': undefined,
|
|
926
|
-
}, market);
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* @method
|
|
930
|
-
* @name lykke#cancelOrder
|
|
931
|
-
* @description cancels an open order
|
|
932
|
-
* @see https://lykkecity.github.io/Trading-API/#cancel-orders-by-id
|
|
933
|
-
* @param {string} id order id
|
|
934
|
-
* @param {string} symbol unified symbol of the market the order was made in
|
|
935
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
936
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
937
|
-
*/
|
|
938
|
-
async cancelOrder(id, symbol = undefined, params = {}) {
|
|
939
|
-
const request = {
|
|
940
|
-
'orderId': id,
|
|
941
|
-
};
|
|
942
|
-
//
|
|
943
|
-
// {
|
|
944
|
-
// "payload":null,
|
|
945
|
-
// "error":null
|
|
946
|
-
// }
|
|
947
|
-
//
|
|
948
|
-
const response = await this.privateDeleteOrdersOrderId(this.extend(request, params));
|
|
949
|
-
return this.safeOrder({
|
|
950
|
-
'info': response,
|
|
951
|
-
});
|
|
952
|
-
}
|
|
953
|
-
/**
|
|
954
|
-
* @method
|
|
955
|
-
* @name lykke#cancelAllOrders
|
|
956
|
-
* @description cancel all open orders
|
|
957
|
-
* @see https://lykkecity.github.io/Trading-API/#mass-cancel-orders
|
|
958
|
-
* @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
|
|
959
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
960
|
-
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
961
|
-
*/
|
|
962
|
-
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
963
|
-
await this.loadMarkets();
|
|
964
|
-
const request = {
|
|
965
|
-
// 'side': 'Buy',
|
|
966
|
-
};
|
|
967
|
-
let market = undefined;
|
|
968
|
-
if (symbol !== undefined) {
|
|
969
|
-
market = this.market(symbol);
|
|
970
|
-
request['assetPairId'] = market['id'];
|
|
971
|
-
}
|
|
972
|
-
//
|
|
973
|
-
// {
|
|
974
|
-
// "payload":null,
|
|
975
|
-
// "error":null
|
|
976
|
-
// }
|
|
977
|
-
//
|
|
978
|
-
const response = await this.privateDeleteOrders(this.extend(request, params));
|
|
979
|
-
return [
|
|
980
|
-
this.safeOrder({
|
|
981
|
-
'info': response,
|
|
982
|
-
}),
|
|
983
|
-
];
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* @method
|
|
987
|
-
* @name lykke#fetchOrder
|
|
988
|
-
* @description fetches information on an order made by the user
|
|
989
|
-
* @see https://lykkecity.github.io/Trading-API/#get-order-by-id
|
|
990
|
-
* @param {string} id order id
|
|
991
|
-
* @param {string} symbol not used by lykke fetchOrder
|
|
992
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
993
|
-
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
994
|
-
*/
|
|
995
|
-
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
996
|
-
await this.loadMarkets();
|
|
997
|
-
const request = {
|
|
998
|
-
'orderId': id,
|
|
999
|
-
};
|
|
1000
|
-
const response = await this.privateGetOrdersOrderId(this.extend(request, params));
|
|
1001
|
-
const payload = this.safeValue(response, 'payload');
|
|
1002
|
-
//
|
|
1003
|
-
// {
|
|
1004
|
-
// "payload":{
|
|
1005
|
-
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
|
1006
|
-
// "timestamp":1644155923357,
|
|
1007
|
-
// "lastTradeTimestamp":1644155923357,
|
|
1008
|
-
// "status":"Matched",
|
|
1009
|
-
// "assetPairId":"BCHEUR",
|
|
1010
|
-
// "type":"Market",
|
|
1011
|
-
// "side":"Sell",
|
|
1012
|
-
// "price":280.569,
|
|
1013
|
-
// "volume":0.01,
|
|
1014
|
-
// "filledVolume":0.01,
|
|
1015
|
-
// "remainingVolume":0.0,
|
|
1016
|
-
// "cost":2.80569
|
|
1017
|
-
// },
|
|
1018
|
-
// "error":null
|
|
1019
|
-
// }
|
|
1020
|
-
//
|
|
1021
|
-
return this.parseOrder(payload);
|
|
1022
|
-
}
|
|
1023
|
-
/**
|
|
1024
|
-
* @method
|
|
1025
|
-
* @name lykke#fetchOpenOrders
|
|
1026
|
-
* @description fetch all unfilled currently open orders
|
|
1027
|
-
* @see https://lykkecity.github.io/Trading-API/#get-active-or-closed-orders
|
|
1028
|
-
* @param {string} symbol unified market symbol
|
|
1029
|
-
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
1030
|
-
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
1031
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1032
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1033
|
-
*/
|
|
1034
|
-
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1035
|
-
await this.loadMarkets();
|
|
1036
|
-
let market = undefined;
|
|
1037
|
-
if (symbol !== undefined) {
|
|
1038
|
-
market = this.market(symbol);
|
|
1039
|
-
}
|
|
1040
|
-
const request = {
|
|
1041
|
-
// 'offset': 0,
|
|
1042
|
-
// 'take': 1,
|
|
1043
|
-
};
|
|
1044
|
-
if (limit !== undefined) {
|
|
1045
|
-
request['take'] = limit;
|
|
1046
|
-
}
|
|
1047
|
-
const response = await this.privateGetOrdersActive(this.extend(request, params));
|
|
1048
|
-
const payload = this.safeValue(response, 'payload');
|
|
1049
|
-
//
|
|
1050
|
-
// {
|
|
1051
|
-
// "payload":[
|
|
1052
|
-
// {
|
|
1053
|
-
// "id":"b26f58f5-8542-4b4c-9815-91562b523cc3",
|
|
1054
|
-
// "timestamp":1644157177155,
|
|
1055
|
-
// "lastTradeTimestamp":null,
|
|
1056
|
-
// "status":"Placed",
|
|
1057
|
-
// "assetPairId":"BCHEUR",
|
|
1058
|
-
// "type":"Limit",
|
|
1059
|
-
// "side":"Sell",
|
|
1060
|
-
// "price":666.666,
|
|
1061
|
-
// "volume":0.01,
|
|
1062
|
-
// "filledVolume":0.00,
|
|
1063
|
-
// "remainingVolume":0.01,
|
|
1064
|
-
// "cost":0.00000
|
|
1065
|
-
// }
|
|
1066
|
-
// ],
|
|
1067
|
-
// "error":null
|
|
1068
|
-
// }
|
|
1069
|
-
//
|
|
1070
|
-
return this.parseOrders(payload, market, since, limit);
|
|
1071
|
-
}
|
|
1072
|
-
/**
|
|
1073
|
-
* @method
|
|
1074
|
-
* @name lykke#fetchClosedOrders
|
|
1075
|
-
* @description fetches information on multiple closed orders made by the user
|
|
1076
|
-
* @see https://lykkecity.github.io/Trading-API/#get-active-or-closed-orders
|
|
1077
|
-
* @param {string} symbol unified market symbol of the market orders were made in
|
|
1078
|
-
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
1079
|
-
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
1080
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1081
|
-
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
1082
|
-
*/
|
|
1083
|
-
async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1084
|
-
await this.loadMarkets();
|
|
1085
|
-
let market = undefined;
|
|
1086
|
-
if (symbol !== undefined) {
|
|
1087
|
-
market = this.market(symbol);
|
|
1088
|
-
}
|
|
1089
|
-
const request = {
|
|
1090
|
-
// 'offset': 0,
|
|
1091
|
-
// 'take': 1,
|
|
1092
|
-
};
|
|
1093
|
-
if (limit !== undefined) {
|
|
1094
|
-
request['take'] = limit;
|
|
1095
|
-
}
|
|
1096
|
-
const response = await this.privateGetOrdersClosed(this.extend(request, params));
|
|
1097
|
-
const payload = this.safeValue(response, 'payload');
|
|
1098
|
-
//
|
|
1099
|
-
// {
|
|
1100
|
-
// "payload":[
|
|
1101
|
-
// {
|
|
1102
|
-
// "id":"1b367978-7e4f-454b-b870-64040d484443",
|
|
1103
|
-
// "timestamp":1644155923357,
|
|
1104
|
-
// "lastTradeTimestamp":1644155923357,
|
|
1105
|
-
// "status":"Matched",
|
|
1106
|
-
// "assetPairId":"BCHEUR",
|
|
1107
|
-
// "type":"Market",
|
|
1108
|
-
// "side":"Sell",
|
|
1109
|
-
// "price":280.569,
|
|
1110
|
-
// "volume":0.01,
|
|
1111
|
-
// "filledVolume":0.01,
|
|
1112
|
-
// "remainingVolume":0.0,
|
|
1113
|
-
// "cost":2.80569
|
|
1114
|
-
// }
|
|
1115
|
-
// ],
|
|
1116
|
-
// "error":null
|
|
1117
|
-
// }
|
|
1118
|
-
//
|
|
1119
|
-
return this.parseOrders(payload, market, since, limit);
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* @method
|
|
1123
|
-
* @name lykke#fetchMyTrades
|
|
1124
|
-
* @description fetch all trades made by the user
|
|
1125
|
-
* @see https://lykkecity.github.io/Trading-API/#get-trade-history
|
|
1126
|
-
* @param {string} symbol unified market symbol
|
|
1127
|
-
* @param {int} [since] the earliest time in ms to fetch trades for
|
|
1128
|
-
* @param {int} [limit] the maximum number of trades structures to retrieve
|
|
1129
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1130
|
-
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
|
|
1131
|
-
*/
|
|
1132
|
-
async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1133
|
-
await this.loadMarkets();
|
|
1134
|
-
const request = {
|
|
1135
|
-
// 'side': 'buy',
|
|
1136
|
-
// 'offset': 0,
|
|
1137
|
-
// 'take': 1,
|
|
1138
|
-
// 'to': 0,
|
|
1139
|
-
};
|
|
1140
|
-
let market = undefined;
|
|
1141
|
-
if (limit !== undefined) {
|
|
1142
|
-
request['take'] = limit; // How many maximum items have to be returned, max 1000 default 100.
|
|
1143
|
-
}
|
|
1144
|
-
if (symbol !== undefined) {
|
|
1145
|
-
market = this.market(symbol);
|
|
1146
|
-
request['assetPairId'] = market['id'];
|
|
1147
|
-
}
|
|
1148
|
-
if (since !== undefined) {
|
|
1149
|
-
request['from'] = since;
|
|
1150
|
-
}
|
|
1151
|
-
const response = await this.privateGetTrades(this.extend(request, params));
|
|
1152
|
-
const payload = this.safeValue(response, 'payload');
|
|
1153
|
-
//
|
|
1154
|
-
// {
|
|
1155
|
-
// "payload":[
|
|
1156
|
-
// {
|
|
1157
|
-
// "id":"813a3ffa-1c4b-45cb-b13f-1c077ea2748b",
|
|
1158
|
-
// "timestamp":1644155923357,
|
|
1159
|
-
// "assetPairId":"BCHEUR",
|
|
1160
|
-
// "orderId":"1b367978-7e4f-454b-b870-64040d484443",
|
|
1161
|
-
// "role":"Taker",
|
|
1162
|
-
// "side":"sell",
|
|
1163
|
-
// "price":280.569,
|
|
1164
|
-
// "baseVolume":0.01,
|
|
1165
|
-
// "quoteVolume":2.8056,
|
|
1166
|
-
// "baseAssetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
1167
|
-
// "quoteAssetId":"EUR",
|
|
1168
|
-
// "fee":null
|
|
1169
|
-
// }
|
|
1170
|
-
// ],
|
|
1171
|
-
// "error":null
|
|
1172
|
-
// }
|
|
1173
|
-
//
|
|
1174
|
-
return this.parseTrades(payload, market, since, limit);
|
|
1175
|
-
}
|
|
1176
|
-
parseBidAsk(bidask, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
|
|
1177
|
-
const price = this.safeString(bidask, priceKey);
|
|
1178
|
-
const amount = Precise["default"].stringAbs(this.safeString(bidask, amountKey));
|
|
1179
|
-
return [this.parseNumber(price), this.parseNumber(amount)];
|
|
1180
|
-
}
|
|
1181
|
-
/**
|
|
1182
|
-
* @method
|
|
1183
|
-
* @name lykke#fetchDepositAddress
|
|
1184
|
-
* @description fetch the deposit address for a currency associated with this account
|
|
1185
|
-
* @see https://lykkecity.github.io/Trading-API/#get-deposit-address-for-a-given-asset
|
|
1186
|
-
* @param {string} code unified currency code
|
|
1187
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1188
|
-
* @returns {object} an [address structure]{@link https://docs.ccxt.com/#/?id=address-structure}
|
|
1189
|
-
*/
|
|
1190
|
-
async fetchDepositAddress(code, params = {}) {
|
|
1191
|
-
await this.loadMarkets();
|
|
1192
|
-
const currency = this.currency(code);
|
|
1193
|
-
const request = {
|
|
1194
|
-
'assetId': this.safeString(currency, 'id'),
|
|
1195
|
-
};
|
|
1196
|
-
const response = await this.privateGetOperationsDepositsAddressesAssetId(this.extend(request, params));
|
|
1197
|
-
//
|
|
1198
|
-
// {
|
|
1199
|
-
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
1200
|
-
// "symbol":"BCH",
|
|
1201
|
-
// "address":null,
|
|
1202
|
-
// "baseAddress":null,
|
|
1203
|
-
// "addressExtension":null,
|
|
1204
|
-
// "state":"Active"
|
|
1205
|
-
// }
|
|
1206
|
-
//
|
|
1207
|
-
const address = this.safeString(response, 'baseAddress');
|
|
1208
|
-
const tag = this.safeString(response, 'addressExtension');
|
|
1209
|
-
this.checkAddress(address);
|
|
1210
|
-
return {
|
|
1211
|
-
'info': response,
|
|
1212
|
-
'currency': code,
|
|
1213
|
-
'network': undefined,
|
|
1214
|
-
'address': address,
|
|
1215
|
-
'tag': tag,
|
|
1216
|
-
};
|
|
1217
|
-
}
|
|
1218
|
-
parseTransaction(transaction, currency = undefined) {
|
|
1219
|
-
//
|
|
1220
|
-
// withdraw
|
|
1221
|
-
// "3035b1ad-2005-4587-a986-1f7966be78e0"
|
|
1222
|
-
//
|
|
1223
|
-
// fetchDepositsWithdrawals
|
|
1224
|
-
// {
|
|
1225
|
-
// "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
|
|
1226
|
-
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
1227
|
-
// "totalVolume":0.1,
|
|
1228
|
-
// "fee":0.0,
|
|
1229
|
-
// "type":"deposit",
|
|
1230
|
-
// "timestamp":1644146723620
|
|
1231
|
-
// }
|
|
1232
|
-
//
|
|
1233
|
-
let id = undefined;
|
|
1234
|
-
let assetId = undefined;
|
|
1235
|
-
let code = undefined;
|
|
1236
|
-
let amount = undefined;
|
|
1237
|
-
let fee = undefined;
|
|
1238
|
-
let type = undefined;
|
|
1239
|
-
let timestamp = undefined;
|
|
1240
|
-
if (typeof transaction === 'string') {
|
|
1241
|
-
id = transaction;
|
|
1242
|
-
}
|
|
1243
|
-
else {
|
|
1244
|
-
id = this.safeString(transaction, 'operationId');
|
|
1245
|
-
assetId = this.safeString(transaction, 'assetId');
|
|
1246
|
-
code = this.safeCurrencyCode(assetId, currency);
|
|
1247
|
-
amount = this.safeNumber(transaction, 'totalVolume');
|
|
1248
|
-
type = this.safeString(transaction, 'type');
|
|
1249
|
-
timestamp = this.safeInteger(transaction, 'timestamp');
|
|
1250
|
-
const feeCost = this.safeNumber(transaction, 'fee');
|
|
1251
|
-
fee = {
|
|
1252
|
-
'currency': code,
|
|
1253
|
-
'cost': feeCost,
|
|
1254
|
-
};
|
|
1255
|
-
}
|
|
1256
|
-
return {
|
|
1257
|
-
'info': transaction,
|
|
1258
|
-
'id': id,
|
|
1259
|
-
'txid': undefined,
|
|
1260
|
-
'timestamp': timestamp,
|
|
1261
|
-
'datetime': this.iso8601(timestamp),
|
|
1262
|
-
'network': undefined,
|
|
1263
|
-
'addressFrom': undefined,
|
|
1264
|
-
'address': undefined,
|
|
1265
|
-
'addressTo': undefined,
|
|
1266
|
-
'tagFrom': undefined,
|
|
1267
|
-
'tag': undefined,
|
|
1268
|
-
'tagTo': undefined,
|
|
1269
|
-
'type': type,
|
|
1270
|
-
'amount': amount,
|
|
1271
|
-
'currency': code,
|
|
1272
|
-
'status': undefined,
|
|
1273
|
-
'updated': undefined,
|
|
1274
|
-
'internal': undefined,
|
|
1275
|
-
'comment': undefined,
|
|
1276
|
-
'fee': fee,
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
/**
|
|
1280
|
-
* @method
|
|
1281
|
-
* @name lykke#fetchDepositsWithdrawals
|
|
1282
|
-
* @description fetch history of deposits and withdrawals
|
|
1283
|
-
* @see https://lykkecity.github.io/Trading-API/#get-the-history-of-withdrawals-and-deposits
|
|
1284
|
-
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
|
|
1285
|
-
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
|
|
1286
|
-
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
|
|
1287
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1288
|
-
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1289
|
-
*/
|
|
1290
|
-
async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
1291
|
-
await this.loadMarkets();
|
|
1292
|
-
const request = {
|
|
1293
|
-
// 'offset': 0,
|
|
1294
|
-
// 'take': 1,
|
|
1295
|
-
};
|
|
1296
|
-
if (limit !== undefined) {
|
|
1297
|
-
request['take'] = limit;
|
|
1298
|
-
}
|
|
1299
|
-
const response = await this.privateGetOperations(this.extend(request, params));
|
|
1300
|
-
const payload = this.safeValue(response, 'payload', []);
|
|
1301
|
-
//
|
|
1302
|
-
// {
|
|
1303
|
-
// "payload":[
|
|
1304
|
-
// {
|
|
1305
|
-
// "operationId":"787201c8-f1cc-45c0-aec1-fa06eeea426b",
|
|
1306
|
-
// "assetId":"2a34d6a6-5839-40e5-836f-c1178fa09b89",
|
|
1307
|
-
// "totalVolume":0.1,
|
|
1308
|
-
// "fee":0.0,
|
|
1309
|
-
// "type":"deposit",
|
|
1310
|
-
// "timestamp":1644146723620
|
|
1311
|
-
// }
|
|
1312
|
-
// ],
|
|
1313
|
-
// "error":null
|
|
1314
|
-
// }
|
|
1315
|
-
//
|
|
1316
|
-
let currency = undefined;
|
|
1317
|
-
if (code !== undefined) {
|
|
1318
|
-
currency = this.currency(code);
|
|
1319
|
-
}
|
|
1320
|
-
return this.parseTransactions(payload, currency, since, limit);
|
|
1321
|
-
}
|
|
1322
|
-
/**
|
|
1323
|
-
* @method
|
|
1324
|
-
* @name lykke#withdraw
|
|
1325
|
-
* @description make a withdrawal
|
|
1326
|
-
* @see https://lykkecity.github.io/Trading-API/#withdrawal
|
|
1327
|
-
* @param {string} code unified currency code
|
|
1328
|
-
* @param {float} amount the amount to withdraw
|
|
1329
|
-
* @param {string} address the address to withdraw to
|
|
1330
|
-
* @param {string} tag
|
|
1331
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1332
|
-
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/#/?id=transaction-structure}
|
|
1333
|
-
*/
|
|
1334
|
-
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
1335
|
-
await this.loadMarkets();
|
|
1336
|
-
this.checkAddress(address);
|
|
1337
|
-
const currency = this.currency(code);
|
|
1338
|
-
const request = {
|
|
1339
|
-
'assetId': currency['id'],
|
|
1340
|
-
'volume': parseFloat(this.currencyToPrecision(code, amount)),
|
|
1341
|
-
'destinationAddress': address,
|
|
1342
|
-
// 'destinationAddressExtension': tag,
|
|
1343
|
-
};
|
|
1344
|
-
if (tag !== undefined) {
|
|
1345
|
-
request['destinationAddressExtension'] = tag;
|
|
1346
|
-
}
|
|
1347
|
-
const response = await this.privatePostOperationsWithdrawals(this.extend(request, params));
|
|
1348
|
-
//
|
|
1349
|
-
// "3035b1ad-2005-4587-a986-1f7966be78e0"
|
|
1350
|
-
//
|
|
1351
|
-
return this.parseTransaction(response, currency);
|
|
1352
|
-
}
|
|
1353
|
-
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
1354
|
-
let url = this.urls['api'][api] + '/' + this.implodeParams(path, params);
|
|
1355
|
-
const query = this.omit(params, this.extractParams(path));
|
|
1356
|
-
headers = {
|
|
1357
|
-
'Accept': 'application/json',
|
|
1358
|
-
'Content-Type': 'application/json',
|
|
1359
|
-
};
|
|
1360
|
-
if (api === 'public') {
|
|
1361
|
-
if (Object.keys(query).length) {
|
|
1362
|
-
url += '?' + this.urlencode(query);
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
else if (api === 'private') {
|
|
1366
|
-
if ((method === 'GET') || (method === 'DELETE')) {
|
|
1367
|
-
if (Object.keys(query).length) {
|
|
1368
|
-
url += '?' + this.urlencode(query);
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
this.checkRequiredCredentials();
|
|
1372
|
-
headers['Authorization'] = 'Bearer ' + this.apiKey;
|
|
1373
|
-
if (method === 'POST') {
|
|
1374
|
-
if (Object.keys(params).length) {
|
|
1375
|
-
body = this.json(params);
|
|
1376
|
-
}
|
|
1377
|
-
}
|
|
1378
|
-
if (path === 'operations/withdrawals') {
|
|
1379
|
-
headers['X-Request-ID'] = this.uuid();
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|
|
1383
|
-
}
|
|
1384
|
-
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
1385
|
-
if (response === undefined) {
|
|
1386
|
-
return undefined;
|
|
1387
|
-
}
|
|
1388
|
-
const error = this.safeValue(response, 'error', {});
|
|
1389
|
-
const errorCode = this.safeString(error, 'code');
|
|
1390
|
-
if ((errorCode !== undefined) && (errorCode !== '0')) {
|
|
1391
|
-
const feedback = this.id + ' ' + body;
|
|
1392
|
-
const message = this.safeString(error, 'message');
|
|
1393
|
-
this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
|
|
1394
|
-
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
1395
|
-
throw new errors.ExchangeError(feedback);
|
|
1396
|
-
}
|
|
1397
|
-
return undefined;
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
|
|
1401
|
-
module.exports = lykke;
|