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