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