ccxt 4.4.90__py2.py3-none-any.whl → 4.4.91__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 +6 -3
- ccxt/async_support/base/ws/client.py +173 -64
- ccxt/async_support/base/ws/future.py +23 -50
- ccxt/async_support/binance.py +1 -1
- ccxt/async_support/bitmex.py +2 -1
- ccxt/async_support/cex.py +61 -0
- ccxt/async_support/cryptocom.py +17 -2
- ccxt/async_support/cryptomus.py +1 -1
- ccxt/async_support/exmo.py +14 -7
- ccxt/async_support/gate.py +2 -2
- ccxt/async_support/hyperliquid.py +104 -53
- ccxt/async_support/kraken.py +26 -1
- ccxt/async_support/mexc.py +1 -0
- ccxt/async_support/modetrade.py +2 -2
- ccxt/async_support/paradex.py +1 -1
- ccxt/base/exchange.py +8 -5
- ccxt/binance.py +1 -1
- ccxt/bitmex.py +2 -1
- ccxt/cex.py +61 -0
- ccxt/cryptocom.py +17 -2
- ccxt/cryptomus.py +1 -1
- ccxt/exmo.py +13 -7
- ccxt/gate.py +2 -2
- ccxt/hyperliquid.py +104 -53
- ccxt/kraken.py +26 -1
- ccxt/mexc.py +1 -0
- ccxt/modetrade.py +2 -2
- ccxt/paradex.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitstamp.py +1 -1
- ccxt/pro/bybit.py +6 -136
- ccxt/pro/kraken.py +246 -258
- ccxt/pro/mexc.py +0 -1
- {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/METADATA +6 -7
- {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/RECORD +40 -57
- ccxt/abstract/coinlist.py +0 -57
- ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- ccxt/async_support/bitcoincom.py +0 -18
- ccxt/async_support/bitfinex1.py +0 -1711
- ccxt/async_support/bitpanda.py +0 -17
- ccxt/async_support/coinlist.py +0 -2542
- ccxt/async_support/poloniexfutures.py +0 -1875
- ccxt/bitcoincom.py +0 -18
- ccxt/bitfinex1.py +0 -1710
- ccxt/bitpanda.py +0 -17
- ccxt/coinlist.py +0 -2542
- ccxt/poloniexfutures.py +0 -1875
- ccxt/pro/bitcoincom.py +0 -35
- ccxt/pro/bitfinex1.py +0 -635
- ccxt/pro/bitpanda.py +0 -16
- ccxt/pro/poloniexfutures.py +0 -1004
- ccxt/pro/wazirx.py +0 -766
- {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/WHEEL +0 -0
- {ccxt-4.4.90.dist-info → ccxt-4.4.91.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinlist.py
DELETED
@@ -1,2542 +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.coinlist import ImplicitAPI
|
8
|
-
import hashlib
|
9
|
-
import math
|
10
|
-
from ccxt.base.types import Account, Any, Balances, Currencies, Currency, Int, LedgerEntry, Market, Num, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, FundingRate, Trade, TradingFees, Transaction, TransferEntry
|
11
|
-
from typing import List
|
12
|
-
from ccxt.base.errors import ExchangeError
|
13
|
-
from ccxt.base.errors import AuthenticationError
|
14
|
-
from ccxt.base.errors import PermissionDenied
|
15
|
-
from ccxt.base.errors import ArgumentsRequired
|
16
|
-
from ccxt.base.errors import BadRequest
|
17
|
-
from ccxt.base.errors import BadSymbol
|
18
|
-
from ccxt.base.errors import InsufficientFunds
|
19
|
-
from ccxt.base.errors import InvalidAddress
|
20
|
-
from ccxt.base.errors import InvalidOrder
|
21
|
-
from ccxt.base.errors import OrderNotFound
|
22
|
-
from ccxt.base.errors import NotSupported
|
23
|
-
from ccxt.base.errors import OnMaintenance
|
24
|
-
from ccxt.base.decimal_to_precision import TICK_SIZE
|
25
|
-
from ccxt.base.precise import Precise
|
26
|
-
|
27
|
-
|
28
|
-
class coinlist(Exchange, ImplicitAPI):
|
29
|
-
|
30
|
-
def describe(self) -> Any:
|
31
|
-
return self.deep_extend(super(coinlist, self).describe(), {
|
32
|
-
'id': 'coinlist',
|
33
|
-
'name': 'Coinlist',
|
34
|
-
'countries': ['US'], # United States
|
35
|
-
'version': 'v1',
|
36
|
-
'rateLimit': 300, # 1000 per 5 minutes
|
37
|
-
'certified': False,
|
38
|
-
'pro': False,
|
39
|
-
'has': {
|
40
|
-
'CORS': None,
|
41
|
-
'spot': True,
|
42
|
-
'margin': False,
|
43
|
-
'swap': False,
|
44
|
-
'future': False,
|
45
|
-
'option': False,
|
46
|
-
'addMargin': False,
|
47
|
-
'cancelAllOrders': True,
|
48
|
-
'cancelOrder': True,
|
49
|
-
'cancelOrders': True,
|
50
|
-
'closeAllPositions': False,
|
51
|
-
'closePosition': False,
|
52
|
-
'createDepositAddress': False,
|
53
|
-
'createOrder': True,
|
54
|
-
'createPostOnlyOrder': True,
|
55
|
-
'createReduceOnlyOrder': False,
|
56
|
-
'createStopLimitOrder': True,
|
57
|
-
'createStopMarketOrder': True,
|
58
|
-
'createStopOrder': True,
|
59
|
-
'deposit': False,
|
60
|
-
'editOrder': True,
|
61
|
-
'fetchAccounts': True,
|
62
|
-
'fetchBalance': True,
|
63
|
-
'fetchBidsAsks': False,
|
64
|
-
'fetchBorrowInterest': False,
|
65
|
-
'fetchBorrowRateHistories': False,
|
66
|
-
'fetchBorrowRateHistory': False,
|
67
|
-
'fetchCanceledOrders': True,
|
68
|
-
'fetchClosedOrder': False,
|
69
|
-
'fetchClosedOrders': True,
|
70
|
-
'fetchCrossBorrowRate': False,
|
71
|
-
'fetchCrossBorrowRates': False,
|
72
|
-
'fetchCurrencies': True,
|
73
|
-
'fetchDeposit': False,
|
74
|
-
'fetchDepositAddress': False,
|
75
|
-
'fetchDepositAddresses': False,
|
76
|
-
'fetchDepositAddressesByNetwork': False,
|
77
|
-
'fetchDeposits': False,
|
78
|
-
'fetchDepositsWithdrawals': True,
|
79
|
-
'fetchDepositWithdrawFee': False,
|
80
|
-
'fetchDepositWithdrawFees': False,
|
81
|
-
'fetchFundingHistory': False,
|
82
|
-
'fetchFundingRate': True,
|
83
|
-
'fetchFundingRateHistory': False,
|
84
|
-
'fetchFundingRates': False,
|
85
|
-
'fetchIndexOHLCV': False,
|
86
|
-
'fetchIsolatedBorrowRate': False,
|
87
|
-
'fetchIsolatedBorrowRates': False,
|
88
|
-
'fetchL3OrderBook': False,
|
89
|
-
'fetchLedger': True,
|
90
|
-
'fetchLeverage': False,
|
91
|
-
'fetchLeverageTiers': False,
|
92
|
-
'fetchMarketLeverageTiers': False,
|
93
|
-
'fetchMarkets': True,
|
94
|
-
'fetchMarkOHLCV': False,
|
95
|
-
'fetchMyTrades': True,
|
96
|
-
'fetchOHLCV': True,
|
97
|
-
'fetchOpenInterestHistory': False,
|
98
|
-
'fetchOpenOrder': False,
|
99
|
-
'fetchOpenOrders': True,
|
100
|
-
'fetchOrder': True,
|
101
|
-
'fetchOrderBook': True,
|
102
|
-
'fetchOrderBooks': False,
|
103
|
-
'fetchOrders': True,
|
104
|
-
'fetchOrderTrades': True,
|
105
|
-
'fetchPosition': False,
|
106
|
-
'fetchPositionHistory': False,
|
107
|
-
'fetchPositionMode': False,
|
108
|
-
'fetchPositions': False,
|
109
|
-
'fetchPositionsForSymbol': False,
|
110
|
-
'fetchPositionsHistory': False,
|
111
|
-
'fetchPositionsRisk': False,
|
112
|
-
'fetchPremiumIndexOHLCV': False,
|
113
|
-
'fetchStatus': False,
|
114
|
-
'fetchTicker': True,
|
115
|
-
'fetchTickers': True,
|
116
|
-
'fetchTime': True,
|
117
|
-
'fetchTrades': True,
|
118
|
-
'fetchTradingFee': False,
|
119
|
-
'fetchTradingFees': True,
|
120
|
-
'fetchTradingLimits': False,
|
121
|
-
'fetchTransactionFee': False,
|
122
|
-
'fetchTransactionFees': False,
|
123
|
-
'fetchTransactions': True,
|
124
|
-
'fetchTransfers': True,
|
125
|
-
'fetchWithdrawal': False,
|
126
|
-
'fetchWithdrawals': False,
|
127
|
-
'fetchWithdrawalWhitelist': False,
|
128
|
-
'reduceMargin': False,
|
129
|
-
'repayCrossMargin': False,
|
130
|
-
'repayIsolatedMargin': False,
|
131
|
-
'setLeverage': False,
|
132
|
-
'setMargin': False,
|
133
|
-
'setMarginMode': False,
|
134
|
-
'setPositionMode': False,
|
135
|
-
'signIn': False,
|
136
|
-
'transfer': True,
|
137
|
-
'withdraw': True,
|
138
|
-
'ws': False,
|
139
|
-
},
|
140
|
-
'timeframes': {
|
141
|
-
'1m': '1m',
|
142
|
-
'5m': '5m',
|
143
|
-
'30m': '30m',
|
144
|
-
},
|
145
|
-
'urls': {
|
146
|
-
'logo': 'https://github-production-user-asset-6210df.s3.amazonaws.com/1294454/281108917-eff2ae1d-ce8a-4b2a-950d-8678b12da965.jpg',
|
147
|
-
'api': {
|
148
|
-
'public': 'https://trade-api.coinlist.co',
|
149
|
-
'private': 'https://trade-api.coinlist.co',
|
150
|
-
},
|
151
|
-
'www': 'https://coinlist.co',
|
152
|
-
'doc': [
|
153
|
-
'https://trade-docs.coinlist.co',
|
154
|
-
],
|
155
|
-
'fees': 'https://coinlist.co/fees',
|
156
|
-
},
|
157
|
-
'api': {
|
158
|
-
'public': {
|
159
|
-
'get': {
|
160
|
-
'v1/symbols': 1,
|
161
|
-
'v1/symbols/summary': 1,
|
162
|
-
'v1/symbols/{symbol}': 1, # not unified
|
163
|
-
'v1/symbols/{symbol}/summary': 1,
|
164
|
-
'v1/symbols/{symbol}/book': 1,
|
165
|
-
'v1/symbols/{symbol}/quote': 1, # not unified
|
166
|
-
'v1/symbols/{symbol}/candles': 1,
|
167
|
-
'v1/symbols/{symbol}/auctions': 1,
|
168
|
-
'v1/symbols/{symbol}/auctions/{auction_code}': 1, # not unified
|
169
|
-
'v1/time': 1,
|
170
|
-
'v1/assets': 1,
|
171
|
-
'v1/leaderboard': 1,
|
172
|
-
'v1/affiliate/{competition_code}': 1,
|
173
|
-
'v1/competition/{competition_id}': 1,
|
174
|
-
'v1/symbols/{symbol}/funding': 1,
|
175
|
-
},
|
176
|
-
},
|
177
|
-
'private': {
|
178
|
-
'get': {
|
179
|
-
'v1/fees': 1,
|
180
|
-
'v1/accounts': 1,
|
181
|
-
'v1/accounts/{trader_id}': 1, # not unified
|
182
|
-
'v1/accounts/{trader_id}/alias': 1,
|
183
|
-
'v1/accounts/{trader_id}/ledger': 1,
|
184
|
-
'v1/accounts/{trader_id}/wallets': 1, # not unified
|
185
|
-
'v1/accounts/{trader_id}/wallet-ledger': 1,
|
186
|
-
'v1/accounts/{trader_id}/ledger-summary': 1, # not unified
|
187
|
-
'v1/keys': 1, # not unified
|
188
|
-
'v1/fills': 1,
|
189
|
-
'v1/orders': 1,
|
190
|
-
'v1/orders/{order_id}': 1,
|
191
|
-
'v1/reports': 1, # not unified
|
192
|
-
'v1/balances': 1,
|
193
|
-
'v1/transfers': 1,
|
194
|
-
'v1/user': 1, # not unified
|
195
|
-
'v1/credits': 1, # not unified
|
196
|
-
'v1/positions': 1,
|
197
|
-
'v1/accounts/{trader_id}/competitions': 1,
|
198
|
-
'v1/closedPositions': 1,
|
199
|
-
},
|
200
|
-
'post': {
|
201
|
-
'v1/keys': 1, # not unified
|
202
|
-
'v1/orders': 1,
|
203
|
-
'v1/orders/cancel-all-after': 1, # not unified
|
204
|
-
'v1/reports': 1, # not unified
|
205
|
-
'v1/transfers/to-wallet': 1,
|
206
|
-
'v1/transfers/from-wallet': 1,
|
207
|
-
'v1/transfers/internal-transfer': 1,
|
208
|
-
'v1/transfers/withdrawal-request': 1,
|
209
|
-
'v1/orders/bulk': 1, # not unified
|
210
|
-
'v1/accounts/{trader_id}/competitions': 1,
|
211
|
-
'v1/accounts/{trader_id}/create-competition': 1,
|
212
|
-
},
|
213
|
-
'patch': {
|
214
|
-
'v1/orders/{order_id}': 1,
|
215
|
-
'v1/orders/bulk': 1, # not unified
|
216
|
-
},
|
217
|
-
'put': {
|
218
|
-
'v1/accounts/{trader_id}/alias': 1,
|
219
|
-
},
|
220
|
-
'delete': {
|
221
|
-
'v1/keys/{key}': 1, # not unified
|
222
|
-
'v1/orders': 1,
|
223
|
-
'v1/orders/{order_id}': 1,
|
224
|
-
'v1/orders/bulk': 1,
|
225
|
-
},
|
226
|
-
},
|
227
|
-
},
|
228
|
-
'features': {
|
229
|
-
'default': {
|
230
|
-
'sandbox': False,
|
231
|
-
'createOrder': {
|
232
|
-
'marginMode': False,
|
233
|
-
'triggerPrice': True,
|
234
|
-
'triggerPriceType': {
|
235
|
-
'last': True,
|
236
|
-
'mark': True,
|
237
|
-
'index': True,
|
238
|
-
},
|
239
|
-
'triggerDirection': False,
|
240
|
-
'stopLossPrice': False, # todo
|
241
|
-
'takeProfitPrice': False, # todo
|
242
|
-
'attachedStopLossTakeProfit': None,
|
243
|
-
'timeInForce': {
|
244
|
-
'IOC': False,
|
245
|
-
'FOK': False,
|
246
|
-
'PO': True,
|
247
|
-
'GTD': False,
|
248
|
-
},
|
249
|
-
'hedged': False,
|
250
|
-
'trailing': True, # todo implement
|
251
|
-
'leverage': False,
|
252
|
-
'marketBuyByCost': False,
|
253
|
-
'marketBuyRequiresPrice': False,
|
254
|
-
'selfTradePrevention': True, # todo implement
|
255
|
-
'iceberg': False,
|
256
|
-
},
|
257
|
-
'createOrders': None,
|
258
|
-
'fetchMyTrades': {
|
259
|
-
'marginMode': False,
|
260
|
-
'limit': 500,
|
261
|
-
'daysBack': 100000,
|
262
|
-
'untilDays': 100000,
|
263
|
-
'symbolRequired': False,
|
264
|
-
},
|
265
|
-
'fetchOrder': {
|
266
|
-
'marginMode': False,
|
267
|
-
'trigger': False,
|
268
|
-
'trailing': False,
|
269
|
-
'symbolRequired': False,
|
270
|
-
},
|
271
|
-
'fetchOpenOrders': {
|
272
|
-
'marginMode': False,
|
273
|
-
'limit': 500,
|
274
|
-
'trigger': False,
|
275
|
-
'trailing': False,
|
276
|
-
'symbolRequired': False,
|
277
|
-
},
|
278
|
-
'fetchOrders': {
|
279
|
-
'marginMode': False,
|
280
|
-
'limit': 500,
|
281
|
-
'daysBack': 100000,
|
282
|
-
'untilDays': 100000,
|
283
|
-
'trigger': False,
|
284
|
-
'trailing': False,
|
285
|
-
'symbolRequired': False,
|
286
|
-
},
|
287
|
-
'fetchClosedOrders': {
|
288
|
-
'marginMode': False,
|
289
|
-
'limit': 500,
|
290
|
-
'daysBack': 100000,
|
291
|
-
'daysBackCanceled': None,
|
292
|
-
'untilDays': 100000,
|
293
|
-
'trigger': False,
|
294
|
-
'trailing': False,
|
295
|
-
'symbolRequired': False,
|
296
|
-
},
|
297
|
-
'fetchOHLCV': {
|
298
|
-
'limit': 300,
|
299
|
-
},
|
300
|
-
},
|
301
|
-
'swap': {
|
302
|
-
'linear': None,
|
303
|
-
'inverse': None,
|
304
|
-
},
|
305
|
-
'future': {
|
306
|
-
'linear': None,
|
307
|
-
'inverse': None,
|
308
|
-
},
|
309
|
-
},
|
310
|
-
'fees': {
|
311
|
-
'trading': {
|
312
|
-
'feeSide': 'get',
|
313
|
-
'tierBased': True,
|
314
|
-
'percentage': True,
|
315
|
-
'taker': self.parse_number('0.0045'),
|
316
|
-
'maker': self.parse_number('0.0025'),
|
317
|
-
'tiers': {
|
318
|
-
'taker': [
|
319
|
-
[self.parse_number('0'), self.parse_number('0.0045')],
|
320
|
-
[self.parse_number('20000'), self.parse_number('0.003')],
|
321
|
-
[self.parse_number('50000'), self.parse_number('0.0025')],
|
322
|
-
[self.parse_number('100000'), self.parse_number('0.002')],
|
323
|
-
[self.parse_number('500000'), self.parse_number('0.0018')],
|
324
|
-
[self.parse_number('750000'), self.parse_number('0.0018')],
|
325
|
-
[self.parse_number('1000000'), self.parse_number('0.0016')],
|
326
|
-
[self.parse_number('2500000'), self.parse_number('0.0013')],
|
327
|
-
[self.parse_number('5000000'), self.parse_number('0.0012')],
|
328
|
-
[self.parse_number('10000000'), self.parse_number('0.001')],
|
329
|
-
[self.parse_number('50000000'), self.parse_number('0.0005')],
|
330
|
-
[self.parse_number('100000000'), self.parse_number('0.0005')],
|
331
|
-
],
|
332
|
-
'maker': [
|
333
|
-
[self.parse_number('0'), self.parse_number('0.0025')],
|
334
|
-
[self.parse_number('20000'), self.parse_number('0.0025')],
|
335
|
-
[self.parse_number('50000'), self.parse_number('0.0025')],
|
336
|
-
[self.parse_number('100000'), self.parse_number('0.002')],
|
337
|
-
[self.parse_number('500000'), self.parse_number('0.0015')],
|
338
|
-
[self.parse_number('750000'), self.parse_number('0.0012')],
|
339
|
-
[self.parse_number('1000000'), self.parse_number('0.001')],
|
340
|
-
[self.parse_number('2500000'), self.parse_number('0.0008')],
|
341
|
-
[self.parse_number('5000000'), self.parse_number('0.0007')],
|
342
|
-
[self.parse_number('10000000'), self.parse_number('0.0006')],
|
343
|
-
[self.parse_number('50000000'), self.parse_number('0.0000')],
|
344
|
-
[self.parse_number('100000000'), self.parse_number('0.00')],
|
345
|
-
],
|
346
|
-
},
|
347
|
-
},
|
348
|
-
},
|
349
|
-
'precisionMode': TICK_SIZE,
|
350
|
-
# exchange-specific options
|
351
|
-
'options': {
|
352
|
-
'accountsByType': {
|
353
|
-
'CoinList Pro': 'trading',
|
354
|
-
'CoinList Pro trading account': 'trading',
|
355
|
-
'Pro': 'trading',
|
356
|
-
'pro': 'trading',
|
357
|
-
'trade': 'trading',
|
358
|
-
'trading': 'trading',
|
359
|
-
'CoinList': 'funding',
|
360
|
-
'CoinList wallet': 'funding',
|
361
|
-
'Wallet': 'funding',
|
362
|
-
'wallet': 'funding',
|
363
|
-
'fund': 'funding',
|
364
|
-
'funding': 'funding',
|
365
|
-
},
|
366
|
-
},
|
367
|
-
'exceptions': {
|
368
|
-
# https://trade-docs.coinlist.co/?javascript--nodejs#message-codes
|
369
|
-
'exact': {
|
370
|
-
'AUTH_SIG_INVALID': AuthenticationError, # {"status":400,"message":"invalid signature","message_code":"AUTH_SIG_INVALID"}
|
371
|
-
'DENIED_MAINTENANCE': OnMaintenance, # The system is under active maintenance.
|
372
|
-
'ORDER_REJECT_BAD_STATUS': InvalidOrder, # The order has a status that makes it not cancelable or modifyable.
|
373
|
-
'ORDER_REJECT_INVALID_POST_ONLY': InvalidOrder,
|
374
|
-
'ORDER_REJECT_INVALID_CLOSE_ONLY': InvalidOrder,
|
375
|
-
'ORDER_REJECT_POST_ONLY_REQUIRED': InvalidOrder, # The market currently allows only post-only orders.
|
376
|
-
'ORDER_REJECT_FROZEN_ORDER': InvalidOrder, # This operation is currently not allowed on self order at self time.
|
377
|
-
'ORDER_REJECT_LIMIT_PRICE_PROTECTION_VIOLATION': InvalidOrder, # The limit price violates the price protection range for self symbol.
|
378
|
-
'ORDER_REJECT_CLOSED': NotSupported, # The market is closed for order operations.
|
379
|
-
'ORDER_REJECT_MAX_ORDERS': BadRequest, # You have violated the 25 orders per symbol limit.
|
380
|
-
'ORDER_REJECT_NOT_FOUND': OrderNotFound, # The order to modify or cancel was not found.
|
381
|
-
'ORDER_REJECT_PARSE_ERROR': BadRequest, # The request failed to parse. Check data types.(strings vs. numbers)
|
382
|
-
'ORDER_REJECT_PRICE_INVALID': InvalidOrder, # Prices must be positive and aligned with the tick size defined for the symbol.
|
383
|
-
'ORDER_REJECT_QUANTITY_ZERO': InvalidOrder, # Quantity may not be zero.
|
384
|
-
'ORDER_REJECT_TOKEN_LIMIT': InsufficientFunds, # Your current token balance is not enough to back self order.
|
385
|
-
'ORDER_REJECT_TOKEN_LIMIT_OTHER': InvalidOrder,
|
386
|
-
'ORDER_REJECT_SELF_TRADE': InvalidOrder, # This order would have been involved in a self-trade.
|
387
|
-
'ORDER_VALIDATE_BAD_SIZE_ALIGNMENT': InvalidOrder, # {"message":"size is not aligned to 0.0001 minimum increment","message_code":"ORDER_VALIDATE_BAD_SIZE_ALIGNMENT","message_details":{"minimum_size_increment":"0.0001"}}
|
388
|
-
'ORDER_VALIDATE_BAD_TICK_ALIGNMENT': InvalidOrder, # {"message":"price is not aligned to 0.01 tick size","message_code":"ORDER_VALIDATE_BAD_TICK_ALIGNMENT","message_details":{"minimum_price_increment":{"s":1,"e":-2,"c":[1000000000000]}}}
|
389
|
-
'ORDER_VALIDATE_SYMBOL_NOT_FOUND': BadSymbol, # {"message":"symbol asdfsdfs not found","message_code":"ORDER_VALIDATE_SYMBOL_NOT_FOUND"}
|
390
|
-
'TRANSFERS_WITHDRAWAL_REQUEST_TOO_LARGE': InsufficientFunds, # {"message":"Withdrawal request too large. 0.000000000000000000 ETH available for withdrawal.","message_code":"TRANSFERS_WITHDRAWAL_REQUEST_TOO_LARGE","message_details":{"token_code":"ETH","amount":"0.010000000000000000","withdrawable_balance":"0.000000000000000000"}}
|
391
|
-
'WITHDRAWAL_REQUEST_NOT_ALLOWED': PermissionDenied, # {"message":"Withdrawal from CoinList not allowed for trader.","message_code":"WITHDRAWAL_REQUEST_NOT_ALLOWED","message_details":{"asset":"USDT","amount":"5","trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b","destination_address":"0x9050dfA063D1bE7cA711c750b18D51fDD13e90Ee"}}
|
392
|
-
},
|
393
|
-
'broad': {
|
394
|
-
'A destinationAddress is required for non-USD withdrawals': InvalidAddress, # {"status":400,"message":"400 - {\"message\":\"A destinationAddress is required for non-USD withdrawals.\"}"}
|
395
|
-
'fails to match the JsonSchema date-time format pattern': BadRequest, # {"status":401,"message":"\"end_time\" with value \"1698862680000\" fails to match the JsonSchema date-time format pattern"}
|
396
|
-
'is required': ArgumentsRequired, # {"status":400,"message":"\"type\" is required"}
|
397
|
-
'must be a string': BadRequest, # {"status":400,"message":"\"destination_address\" must be a string"}
|
398
|
-
'must be a valid GUID': BadRequest, # {"status":400,"message":"\"order_id\" must be a valid GUID"}
|
399
|
-
'must be greater than or equal to': BadRequest, # {"status":401,"message":"\"count\" must be greater than or equal to 1"}
|
400
|
-
'must be less than or equal to': BadRequest, # {"status":401,"message":"\"count\" must be less than or equal to 500"}
|
401
|
-
'must be one of': BadRequest, # {"status":401,"message":"\"granularity\" must be one of [1m, 5m, 30m]"}
|
402
|
-
'Symbol not found': BadSymbol, # {"message":"Symbol not found: {symbol}"}
|
403
|
-
},
|
404
|
-
},
|
405
|
-
})
|
406
|
-
|
407
|
-
def calculate_rate_limiter_cost(self, api, method, path, params, config={}):
|
408
|
-
if isinstance(params, list):
|
409
|
-
length = len(params)
|
410
|
-
return int(math.ceil(length / 2))
|
411
|
-
return 1
|
412
|
-
|
413
|
-
async def fetch_time(self, params={}) -> Int:
|
414
|
-
"""
|
415
|
-
fetches the current integer timestamp in milliseconds from the exchange server
|
416
|
-
|
417
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-system-time
|
418
|
-
|
419
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
420
|
-
:returns int: the current integer timestamp in milliseconds from the exchange server
|
421
|
-
"""
|
422
|
-
response = await self.publicGetV1Time(params)
|
423
|
-
#
|
424
|
-
# {
|
425
|
-
# "epoch": 1698087996.039,
|
426
|
-
# "iso": "2023-10-23T19:06:36.039Z"
|
427
|
-
# }
|
428
|
-
#
|
429
|
-
string = self.safe_string(response, 'iso')
|
430
|
-
return self.parse8601(string)
|
431
|
-
|
432
|
-
async def fetch_currencies(self, params={}) -> Currencies:
|
433
|
-
"""
|
434
|
-
fetches all available currencies on an exchange
|
435
|
-
|
436
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-supported-assets
|
437
|
-
|
438
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
439
|
-
:returns dict: an associative dictionary of currencies
|
440
|
-
"""
|
441
|
-
response = await self.publicGetV1Assets(params)
|
442
|
-
#
|
443
|
-
# {
|
444
|
-
# "assets": [
|
445
|
-
# {
|
446
|
-
# "asset": "AAVE",
|
447
|
-
# "index_code": ".AAVEUSD",
|
448
|
-
# "decimal_places": 18,
|
449
|
-
# "min_withdrawal": "1.0000",
|
450
|
-
# "is_transferable": True,
|
451
|
-
# "is_visible": True
|
452
|
-
# },
|
453
|
-
# {
|
454
|
-
# "asset": "ALGO",
|
455
|
-
# "index_code": ".ALGOUSD",
|
456
|
-
# "decimal_places": 6,
|
457
|
-
# "min_withdrawal": "1.0000",
|
458
|
-
# "is_transferable": True,
|
459
|
-
# "is_visible": True
|
460
|
-
# }
|
461
|
-
# ]
|
462
|
-
# }
|
463
|
-
#
|
464
|
-
currencies = self.safe_value(response, 'assets', [])
|
465
|
-
result: dict = {}
|
466
|
-
for i in range(0, len(currencies)):
|
467
|
-
currency = currencies[i]
|
468
|
-
id = self.safe_string(currency, 'asset')
|
469
|
-
code = self.safe_currency_code(id)
|
470
|
-
isFiat = code == 'USD'
|
471
|
-
isTransferable = self.safe_bool(currency, 'is_transferable', False)
|
472
|
-
result[code] = self.safe_currency_structure({
|
473
|
-
'id': id,
|
474
|
-
'code': code,
|
475
|
-
'name': code,
|
476
|
-
'info': currency,
|
477
|
-
'active': None,
|
478
|
-
'deposit': isTransferable,
|
479
|
-
'withdraw': isTransferable,
|
480
|
-
'fee': None,
|
481
|
-
'precision': self.parse_number(self.parse_precision(self.safe_string(currency, 'decimal_places'))),
|
482
|
-
'limits': {
|
483
|
-
'amount': {
|
484
|
-
'min': None,
|
485
|
-
'max': None,
|
486
|
-
},
|
487
|
-
'withdraw': {
|
488
|
-
'min': self.safe_number(currency, 'min_withdrawal'),
|
489
|
-
'max': None,
|
490
|
-
},
|
491
|
-
},
|
492
|
-
'networks': {}, # todo
|
493
|
-
'type': 'fiat' if isFiat else 'crypto',
|
494
|
-
})
|
495
|
-
return result
|
496
|
-
|
497
|
-
async def fetch_markets(self, params={}) -> List[Market]:
|
498
|
-
"""
|
499
|
-
retrieves data on all markets for coinlist
|
500
|
-
|
501
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-symbols
|
502
|
-
|
503
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
504
|
-
:returns dict[]: an array of objects representing market data
|
505
|
-
"""
|
506
|
-
response = await self.publicGetV1Symbols(params)
|
507
|
-
#
|
508
|
-
# {
|
509
|
-
# "symbols": [
|
510
|
-
# {
|
511
|
-
# "symbol": "CQT-USDT", # spot
|
512
|
-
# "base_currency": "CQT",
|
513
|
-
# "is_trader_geofenced": False,
|
514
|
-
# "list_time": "2021-06-15T00:00:00.000Z",
|
515
|
-
# "type": "spot",
|
516
|
-
# "series_code": "CQT-USDT-SPOT",
|
517
|
-
# "long_name": "Covalent",
|
518
|
-
# "asset_class": "CRYPTO",
|
519
|
-
# "minimum_price_increment": "0.0001",
|
520
|
-
# "minimum_size_increment": "0.0001",
|
521
|
-
# "quote_currency": "USDT",
|
522
|
-
# "index_code": null,
|
523
|
-
# "price_band_threshold_market": "0.05",
|
524
|
-
# "price_band_threshold_limit": "0.25",
|
525
|
-
# "last_price": "0.12160000",
|
526
|
-
# "fair_price": "0.12300000",
|
527
|
-
# "index_price": null
|
528
|
-
# },
|
529
|
-
# ]
|
530
|
-
# }
|
531
|
-
#
|
532
|
-
markets = self.safe_value(response, 'symbols', [])
|
533
|
-
return self.parse_markets(markets)
|
534
|
-
|
535
|
-
def parse_market(self, market: dict) -> Market:
|
536
|
-
# perp
|
537
|
-
# {
|
538
|
-
# "symbol":"BTC-PERP",
|
539
|
-
# "base_currency":"BTC",
|
540
|
-
# "is_trader_geofenced":false,
|
541
|
-
# "expiry_name":null,
|
542
|
-
# "expiry_time":null,
|
543
|
-
# "list_time":"2024-09-16T00:00:00.000Z",
|
544
|
-
# "type":"perp-swap",
|
545
|
-
# "series_code":"BTC",
|
546
|
-
# "long_name":"Bitcoin",
|
547
|
-
# "asset_class":"CRYPTO",
|
548
|
-
# "minimum_price_increment":"0.01",
|
549
|
-
# "minimum_size_increment":"0.0001",
|
550
|
-
# "quote_currency":"USDT",
|
551
|
-
# "multiplier":"1",
|
552
|
-
# "contract_frequency":"FGHJKMNQUVXZ",
|
553
|
-
# "index_code":".BTC-USDT",
|
554
|
-
# "price_band_threshold_market":"0.05",
|
555
|
-
# "price_band_threshold_limit":"0.25",
|
556
|
-
# "maintenance_initial_ratio":"0.500000000000000000",
|
557
|
-
# "liquidation_initial_ratio":"0.500000000000000000",
|
558
|
-
# "last_price":"75881.36000000",
|
559
|
-
# "fair_price":"76256.00000000",
|
560
|
-
# "index_price":"77609.90000000",
|
561
|
-
# "mark_price":"76237.75000000",
|
562
|
-
# "mark_price_dollarizer":"0.99950000",
|
563
|
-
# "funding_interval":{
|
564
|
-
# "hours":"8"
|
565
|
-
# },
|
566
|
-
# "funding_rate_index_code":".BTC-USDT-FR8H",
|
567
|
-
# "initial_margin_base":"0.200000000000000000",
|
568
|
-
# "initial_margin_per_contract":"0.160000000000000000",
|
569
|
-
# "position_limit":"5.0000"
|
570
|
-
# }
|
571
|
-
# spot
|
572
|
-
# {
|
573
|
-
# "symbol": "CQT-USDT", # spot
|
574
|
-
# "base_currency": "CQT",
|
575
|
-
# "is_trader_geofenced": False,
|
576
|
-
# "list_time": "2021-06-15T00:00:00.000Z",
|
577
|
-
# "type": "spot",
|
578
|
-
# "series_code": "CQT-USDT-SPOT",
|
579
|
-
# "long_name": "Covalent",
|
580
|
-
# "asset_class": "CRYPTO",
|
581
|
-
# "minimum_price_increment": "0.0001",
|
582
|
-
# "minimum_size_increment": "0.0001",
|
583
|
-
# "quote_currency": "USDT",
|
584
|
-
# "index_code": null,
|
585
|
-
# "price_band_threshold_market": "0.05",
|
586
|
-
# "price_band_threshold_limit": "0.25",
|
587
|
-
# "last_price": "0.12160000",
|
588
|
-
# "fair_price": "0.12300000",
|
589
|
-
# "index_price": null
|
590
|
-
# }
|
591
|
-
isSwap = self.safe_string(market, 'type') == 'perp-swap'
|
592
|
-
id = self.safe_string(market, 'symbol')
|
593
|
-
baseId = self.safe_string(market, 'base_currency')
|
594
|
-
quoteId = self.safe_string(market, 'quote_currency')
|
595
|
-
base = self.safe_currency_code(baseId)
|
596
|
-
quote = self.safe_currency_code(quoteId)
|
597
|
-
amountPrecision = self.safe_string(market, 'minimum_size_increment')
|
598
|
-
pricePrecision = self.safe_string(market, 'minimum_price_increment')
|
599
|
-
created = self.safe_string(market, 'list_time')
|
600
|
-
settledId = None
|
601
|
-
settled = None
|
602
|
-
linear = None
|
603
|
-
inverse = None
|
604
|
-
contractSize = None
|
605
|
-
symbol = base + '/' + quote
|
606
|
-
if isSwap:
|
607
|
-
contractSize = self.parse_number('1')
|
608
|
-
linear = True
|
609
|
-
inverse = False
|
610
|
-
settledId = quoteId
|
611
|
-
settled = quote
|
612
|
-
symbol = symbol + ':' + quote
|
613
|
-
type = 'swap' if isSwap else 'spot'
|
614
|
-
return {
|
615
|
-
'id': id,
|
616
|
-
'symbol': symbol,
|
617
|
-
'base': base,
|
618
|
-
'quote': quote,
|
619
|
-
'settle': settled,
|
620
|
-
'baseId': baseId,
|
621
|
-
'quoteId': quoteId,
|
622
|
-
'settleId': settledId,
|
623
|
-
'type': type,
|
624
|
-
'spot': not isSwap,
|
625
|
-
'margin': False,
|
626
|
-
'swap': isSwap,
|
627
|
-
'future': False,
|
628
|
-
'option': False,
|
629
|
-
'active': True,
|
630
|
-
'contract': isSwap,
|
631
|
-
'linear': linear,
|
632
|
-
'inverse': inverse,
|
633
|
-
'contractSize': contractSize,
|
634
|
-
'expiry': None,
|
635
|
-
'expiryDatetime': None,
|
636
|
-
'strike': None,
|
637
|
-
'optionType': None,
|
638
|
-
'precision': {
|
639
|
-
'amount': self.parse_number(amountPrecision),
|
640
|
-
'price': self.parse_number(pricePrecision),
|
641
|
-
},
|
642
|
-
'limits': {
|
643
|
-
'leverage': {
|
644
|
-
'min': None,
|
645
|
-
'max': None,
|
646
|
-
},
|
647
|
-
'amount': {
|
648
|
-
'min': None,
|
649
|
-
'max': None,
|
650
|
-
},
|
651
|
-
'price': {
|
652
|
-
'min': None,
|
653
|
-
'max': None,
|
654
|
-
},
|
655
|
-
'cost': {
|
656
|
-
'min': None,
|
657
|
-
'max': None,
|
658
|
-
},
|
659
|
-
},
|
660
|
-
'created': self.parse8601(created),
|
661
|
-
'info': market,
|
662
|
-
}
|
663
|
-
|
664
|
-
async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
|
665
|
-
"""
|
666
|
-
fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
|
667
|
-
|
668
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-symbol-summaries
|
669
|
-
|
670
|
-
:param str[] [symbols]: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
|
671
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
672
|
-
:returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
|
673
|
-
"""
|
674
|
-
await self.load_markets()
|
675
|
-
request: dict = {}
|
676
|
-
tickers = await self.publicGetV1SymbolsSummary(self.extend(request, params))
|
677
|
-
#
|
678
|
-
# {
|
679
|
-
# "MATIC-USD": {
|
680
|
-
# "type":"spot",
|
681
|
-
# "last_price":"0.60990000",
|
682
|
-
# "lowest_ask":"0.61190000",
|
683
|
-
# "highest_bid":"0.60790000",
|
684
|
-
# "last_trade": {
|
685
|
-
# "price":"0.60000000",
|
686
|
-
# "volume":"2.0000",
|
687
|
-
# "imbalance":"198.0000",
|
688
|
-
# "logicalTime":"2023-10-22T23:02:25.000Z",
|
689
|
-
# "auctionCode":"MATIC-USD-2023-10-22T23:02:25.000Z"
|
690
|
-
# },
|
691
|
-
# "volume_base_24h":"34.0555",
|
692
|
-
# "volume_quote_24h":"19.9282",
|
693
|
-
# "price_change_percent_24h":"7.50925436",
|
694
|
-
# "highest_price_24h":"0.68560000",
|
695
|
-
# "lowest_price_24h":"0.55500000"
|
696
|
-
# },
|
697
|
-
# }
|
698
|
-
#
|
699
|
-
return self.parse_tickers(tickers, symbols, params)
|
700
|
-
|
701
|
-
async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
|
702
|
-
"""
|
703
|
-
fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
|
704
|
-
|
705
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-market-summary
|
706
|
-
|
707
|
-
:param str symbol: unified symbol of the market to fetch the ticker for
|
708
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
709
|
-
:returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
|
710
|
-
"""
|
711
|
-
await self.load_markets()
|
712
|
-
market = self.market(symbol)
|
713
|
-
request: dict = {
|
714
|
-
'symbol': market['id'],
|
715
|
-
}
|
716
|
-
ticker = await self.publicGetV1SymbolsSymbolSummary(self.extend(request, params))
|
717
|
-
#
|
718
|
-
# {
|
719
|
-
# "type":"spot",
|
720
|
-
# "last_price":"31125.00000000",
|
721
|
-
# "lowest_ask":"31349.99000000",
|
722
|
-
# "highest_bid":"30900.00000000",
|
723
|
-
# "last_trade": {
|
724
|
-
# "price":"31000.00000000",
|
725
|
-
# "volume":"0.0003",
|
726
|
-
# "imbalance":"0.0000",
|
727
|
-
# "logicalTime":"2023-10-23T16:57:15.000Z",
|
728
|
-
# "auctionCode":"BTC-USDT-2023-10-23T16:57:15.000Z"
|
729
|
-
# },
|
730
|
-
# "volume_base_24h":"0.3752",
|
731
|
-
# "volume_quote_24h":"11382.7181",
|
732
|
-
# "price_change_percent_24h":"3.66264694",
|
733
|
-
# "highest_price_24h":"31225.12000000",
|
734
|
-
# "lowest_price_24h":"29792.81000000"
|
735
|
-
# }
|
736
|
-
#
|
737
|
-
return self.parse_ticker(ticker, market)
|
738
|
-
|
739
|
-
def parse_ticker(self, ticker: dict, market: Market = None) -> Ticker:
|
740
|
-
#
|
741
|
-
# {
|
742
|
-
# "type":"spot",
|
743
|
-
# "last_price":"0.60990000",
|
744
|
-
# "lowest_ask":"0.61190000",
|
745
|
-
# "highest_bid":"0.60790000",
|
746
|
-
# "last_trade": {
|
747
|
-
# "price":"0.60000000",
|
748
|
-
# "volume":"2.0000",
|
749
|
-
# "imbalance":"198.0000",
|
750
|
-
# "logicalTime":"2023-10-22T23:02:25.000Z",
|
751
|
-
# "auctionCode":"MATIC-USD-2023-10-22T23:02:25.000Z"
|
752
|
-
# },
|
753
|
-
# "volume_base_24h":"34.0555",
|
754
|
-
# "volume_quote_24h":"19.9282",
|
755
|
-
# "price_change_percent_24h":"7.50925436",
|
756
|
-
# "highest_price_24h":"0.68560000",
|
757
|
-
# "lowest_price_24h":"0.55500000"
|
758
|
-
# }
|
759
|
-
#
|
760
|
-
lastTrade = self.safe_value(ticker, 'last_trade', {})
|
761
|
-
timestamp = self.parse8601(self.safe_string(lastTrade, 'logicalTime'))
|
762
|
-
bid = self.safe_string(ticker, 'highest_bid')
|
763
|
-
ask = self.safe_string(ticker, 'lowest_ask')
|
764
|
-
baseVolume = self.safe_string(ticker, 'volume_base_24h')
|
765
|
-
quoteVolume = self.safe_string(ticker, 'volume_quote_24h')
|
766
|
-
high = self.safe_string(ticker, 'highest_price_24h')
|
767
|
-
low = self.safe_string(ticker, 'lowest_price_24h')
|
768
|
-
close = self.safe_string(ticker, 'last_price')
|
769
|
-
changePcnt = self.safe_string(ticker, 'price_change_percent_24h')
|
770
|
-
return self.safe_ticker({
|
771
|
-
'symbol': market['symbol'],
|
772
|
-
'timestamp': timestamp,
|
773
|
-
'datetime': self.iso8601(timestamp),
|
774
|
-
'open': None,
|
775
|
-
'high': high,
|
776
|
-
'low': low,
|
777
|
-
'close': close,
|
778
|
-
'bid': bid,
|
779
|
-
'bidVolume': None,
|
780
|
-
'ask': ask,
|
781
|
-
'askVolume': None,
|
782
|
-
'vwap': None,
|
783
|
-
'previousClose': None,
|
784
|
-
'change': None,
|
785
|
-
'percentage': changePcnt,
|
786
|
-
'average': None,
|
787
|
-
'baseVolume': baseVolume,
|
788
|
-
'quoteVolume': quoteVolume,
|
789
|
-
'info': ticker,
|
790
|
-
}, market)
|
791
|
-
|
792
|
-
async def fetch_order_book(self, symbol: str, limit: Int = None, params={}) -> OrderBook:
|
793
|
-
"""
|
794
|
-
fetches information on open orders with bid(buy) and ask(sell) prices, volumes and other data
|
795
|
-
|
796
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-order-book-level-2
|
797
|
-
|
798
|
-
:param str symbol: unified symbol of the market to fetch the order book for
|
799
|
-
:param int [limit]: the maximum amount of order book entries to return(default 100, max 200)
|
800
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
801
|
-
:returns dict: A dictionary of `order book structures <https://docs.ccxt.com/#/?id=order-book-structure>` indexed by market symbols
|
802
|
-
"""
|
803
|
-
await self.load_markets()
|
804
|
-
market = self.market(symbol)
|
805
|
-
request: dict = {
|
806
|
-
'symbol': market['id'],
|
807
|
-
}
|
808
|
-
response = await self.publicGetV1SymbolsSymbolBook(self.extend(request, params))
|
809
|
-
#
|
810
|
-
# {
|
811
|
-
# "bids": [
|
812
|
-
# ["30900.00000000", "0.0001"],
|
813
|
-
# ["30664.21000000", "0.0172"],
|
814
|
-
# ["30664.20000000", "0.0906"],
|
815
|
-
# ],
|
816
|
-
# "asks": [
|
817
|
-
# ["31349.99000000", "0.0003"],
|
818
|
-
# ["31350.00000000", "0.0023"],
|
819
|
-
# ["31359.33000000", "0.0583"],
|
820
|
-
# ],
|
821
|
-
# "after_auction_code": "BTC-USDT-2023-10-23T18:40:51.000Z",
|
822
|
-
# "call_time": "2023-10-23T18:40:51.068Z",
|
823
|
-
# "logical_time": "2023-10-23T18:40:51.000Z"
|
824
|
-
# }
|
825
|
-
#
|
826
|
-
logical_time = self.parse8601(self.safe_string(response, 'logical_time'))
|
827
|
-
orderbook = self.parse_order_book(response, symbol, logical_time)
|
828
|
-
orderbook['nonce'] = None
|
829
|
-
return orderbook
|
830
|
-
|
831
|
-
async def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
832
|
-
"""
|
833
|
-
fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
834
|
-
|
835
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-candles
|
836
|
-
|
837
|
-
:param str symbol: unified symbol of the market to fetch OHLCV data for
|
838
|
-
:param str timeframe: the length of time each candle represents
|
839
|
-
:param int [since]: timestamp in ms of the earliest candle to fetch
|
840
|
-
:param int [limit]: the maximum amount of candles to fetch
|
841
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
842
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
843
|
-
:returns int[][]: A list of candles ordered, open, high, low, close, volume
|
844
|
-
"""
|
845
|
-
await self.load_markets()
|
846
|
-
market = self.market(symbol)
|
847
|
-
granularity = self.safe_string(self.timeframes, timeframe)
|
848
|
-
request: dict = {
|
849
|
-
'symbol': market['id'],
|
850
|
-
'granularity': granularity,
|
851
|
-
}
|
852
|
-
if since is not None:
|
853
|
-
request['start_time'] = self.iso8601(since)
|
854
|
-
if limit is not None:
|
855
|
-
duration = self.parse_timeframe(timeframe) * 1000
|
856
|
-
request['end_time'] = self.iso8601(self.sum(since, duration * (limit)))
|
857
|
-
else:
|
858
|
-
request['end_time'] = self.iso8601(self.milliseconds())
|
859
|
-
until = self.safe_integer(params, 'until')
|
860
|
-
if until is not None:
|
861
|
-
params = self.omit(params, ['until'])
|
862
|
-
request['end_time'] = self.iso8601(until)
|
863
|
-
response = await self.publicGetV1SymbolsSymbolCandles(self.extend(request, params))
|
864
|
-
#
|
865
|
-
# {
|
866
|
-
# "candles": [
|
867
|
-
# [
|
868
|
-
# "2023-10-17T15:00:00.000Z",
|
869
|
-
# "28522.96000000",
|
870
|
-
# "28522.96000000",
|
871
|
-
# "28522.96000000",
|
872
|
-
# "28522.96000000",
|
873
|
-
# "0.1881",
|
874
|
-
# null
|
875
|
-
# ],
|
876
|
-
# [
|
877
|
-
# "2023-10-17T15:30:00.000Z",
|
878
|
-
# "28582.64000000",
|
879
|
-
# "28582.64000000",
|
880
|
-
# "28582.64000000",
|
881
|
-
# "28582.64000000",
|
882
|
-
# "0.0050",
|
883
|
-
# null
|
884
|
-
# ]
|
885
|
-
# ]
|
886
|
-
# }
|
887
|
-
#
|
888
|
-
candles = self.safe_list(response, 'candles', [])
|
889
|
-
return self.parse_ohlcvs(candles, market, timeframe, since, limit)
|
890
|
-
|
891
|
-
def parse_ohlcv(self, ohlcv, market: Market = None) -> list:
|
892
|
-
#
|
893
|
-
# [
|
894
|
-
# "2023-10-17T15:30:00.000Z",
|
895
|
-
# "28582.64000000",
|
896
|
-
# "28582.64000000",
|
897
|
-
# "28582.64000000",
|
898
|
-
# "28582.64000000",
|
899
|
-
# "0.0050",
|
900
|
-
# null
|
901
|
-
# ]
|
902
|
-
#
|
903
|
-
return [
|
904
|
-
self.parse8601(self.safe_string(ohlcv, 0)),
|
905
|
-
self.safe_number(ohlcv, 1),
|
906
|
-
self.safe_number(ohlcv, 2),
|
907
|
-
self.safe_number(ohlcv, 3),
|
908
|
-
self.safe_number(ohlcv, 4),
|
909
|
-
self.safe_number(ohlcv, 5),
|
910
|
-
]
|
911
|
-
|
912
|
-
async def fetch_trades(self, symbol: str, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
913
|
-
"""
|
914
|
-
get the list of most recent trades for a particular symbol
|
915
|
-
|
916
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-auctions
|
917
|
-
|
918
|
-
:param str symbol: unified symbol of the market to fetch trades for
|
919
|
-
:param int [since]: timestamp in ms of the earliest trade to fetch
|
920
|
-
:param int [limit]: the maximum amount of trades to fetch(default 200, max 500)
|
921
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
922
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
923
|
-
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=public-trades>`
|
924
|
-
"""
|
925
|
-
await self.load_markets()
|
926
|
-
market = self.market(symbol)
|
927
|
-
request: dict = {
|
928
|
-
'symbol': market['id'],
|
929
|
-
}
|
930
|
-
if since is not None:
|
931
|
-
request['start_time'] = self.iso8601(since)
|
932
|
-
if limit is not None:
|
933
|
-
request['count'] = min(limit, 500)
|
934
|
-
until = self.safe_integer(params, 'until')
|
935
|
-
if until is not None:
|
936
|
-
params = self.omit(params, ['until'])
|
937
|
-
request['end_time'] = self.iso8601(until)
|
938
|
-
response = await self.publicGetV1SymbolsSymbolAuctions(self.extend(request, params))
|
939
|
-
#
|
940
|
-
# {
|
941
|
-
# "auctions": [
|
942
|
-
# {
|
943
|
-
# "symbol":"BTC-USDT",
|
944
|
-
# "auction_code":"BTC-USDT-2023-10-01T08:05:56.000Z",
|
945
|
-
# "price":"27241.53000000",
|
946
|
-
# "volume":"0.0052",
|
947
|
-
# "imbalance":"-1.0983",
|
948
|
-
# "logical_time":"2023-10-01T08:05:56.000Z",
|
949
|
-
# "call_time":"2023-10-01T08:05:56.068Z"
|
950
|
-
# },
|
951
|
-
# {
|
952
|
-
# "symbol":"BTC-USDT",
|
953
|
-
# "auction_code":"BTC-USDT-2023-10-01T08:09:09.000Z",
|
954
|
-
# "price":"27236.83000000",
|
955
|
-
# "volume":"0.0283",
|
956
|
-
# "imbalance":"-1.0754",
|
957
|
-
# "logical_time":"2023-10-01T08:09:09.000Z",
|
958
|
-
# "call_time":"2023-10-01T08:09:09.078Z"
|
959
|
-
# }
|
960
|
-
# ]
|
961
|
-
# }
|
962
|
-
#
|
963
|
-
auctions = self.safe_list(response, 'auctions', [])
|
964
|
-
return self.parse_trades(auctions, market, since, limit)
|
965
|
-
|
966
|
-
def parse_trade(self, trade: dict, market: Market = None) -> Trade:
|
967
|
-
#
|
968
|
-
# fetchTrades
|
969
|
-
# {
|
970
|
-
# "symbol": "BTC-USDT",
|
971
|
-
# "auction_code": "BTC-USDT-2023-10-01T08:05:56.000Z",
|
972
|
-
# "price": "27241.53000000",
|
973
|
-
# "volume": "0.0052",
|
974
|
-
# "imbalance": "-1.0983",
|
975
|
-
# "logical_time": "2023-10-01T08:05:56.000Z",
|
976
|
-
# "call_time": "2023-10-01T08:05:56.068Z"
|
977
|
-
# }
|
978
|
-
#
|
979
|
-
# fetchMyTrades
|
980
|
-
# {
|
981
|
-
# "symbol": "ETH-USDT",
|
982
|
-
# "auction_code": "ETH-USDT-2023-10-20T13:22:14.000Z",
|
983
|
-
# "order_id": "83ed365f-497d-433b-96c1-9d08c1a12842",
|
984
|
-
# "quantity": "0.0008",
|
985
|
-
# "price": "1615.24000000",
|
986
|
-
# "fee": "0.005815",
|
987
|
-
# "fee_type": "taker",
|
988
|
-
# "fee_currency": "USDT",
|
989
|
-
# "logical_time": "2023-10-20T13:22:14.000Z"
|
990
|
-
# }
|
991
|
-
#
|
992
|
-
marketId = self.safe_string(trade, 'symbol')
|
993
|
-
market = self.safe_market(marketId, market)
|
994
|
-
symbol = market['symbol']
|
995
|
-
id = self.safe_string(trade, 'auction_code')
|
996
|
-
timestamp = self.parse8601(self.safe_string(trade, 'logical_time'))
|
997
|
-
priceString = self.safe_string(trade, 'price')
|
998
|
-
amountString = self.safe_string_2(trade, 'volume', 'quantity')
|
999
|
-
order = self.safe_string(trade, 'order_id')
|
1000
|
-
fee = None
|
1001
|
-
side = None
|
1002
|
-
feeCost = self.safe_string(trade, 'fee')
|
1003
|
-
if feeCost is not None:
|
1004
|
-
# only in fetchMyTrades
|
1005
|
-
amountIsNegative = Precise.string_lt(amountString, '0')
|
1006
|
-
if amountIsNegative:
|
1007
|
-
side = 'sell'
|
1008
|
-
amountString = Precise.string_neg(amountString)
|
1009
|
-
else:
|
1010
|
-
side = 'buy'
|
1011
|
-
fee = {
|
1012
|
-
'cost': feeCost,
|
1013
|
-
'currency': self.safe_string(trade, 'fee_currency'),
|
1014
|
-
}
|
1015
|
-
else:
|
1016
|
-
imbalance = self.safe_string(trade, 'imbalance')
|
1017
|
-
if Precise.string_lt(imbalance, '0'):
|
1018
|
-
side = 'buy'
|
1019
|
-
else:
|
1020
|
-
side = 'sell'
|
1021
|
-
takerOrMaker = self.safe_string(trade, 'fee_type')
|
1022
|
-
return self.safe_trade({
|
1023
|
-
'id': id,
|
1024
|
-
'order': order,
|
1025
|
-
'timestamp': timestamp,
|
1026
|
-
'datetime': self.iso8601(timestamp),
|
1027
|
-
'symbol': symbol,
|
1028
|
-
'type': None,
|
1029
|
-
'side': side,
|
1030
|
-
'takerOrMaker': takerOrMaker,
|
1031
|
-
'price': priceString,
|
1032
|
-
'amount': amountString,
|
1033
|
-
'cost': None,
|
1034
|
-
'fee': fee,
|
1035
|
-
'info': trade,
|
1036
|
-
}, market)
|
1037
|
-
|
1038
|
-
async def fetch_trading_fees(self, params={}) -> TradingFees:
|
1039
|
-
"""
|
1040
|
-
fetch the trading fees for multiple markets
|
1041
|
-
|
1042
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-fees
|
1043
|
-
|
1044
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1045
|
-
:returns dict: a dictionary of `fee structures <https://docs.ccxt.com/#/?id=fee-structure>` indexed by market symbols
|
1046
|
-
"""
|
1047
|
-
await self.load_markets()
|
1048
|
-
response = await self.privateGetV1Fees(params)
|
1049
|
-
#
|
1050
|
-
# {
|
1051
|
-
# fees_by_symbols: {
|
1052
|
-
# 'BTC-USD,BTC-USDT,ETH-USD,ETH-USDT,ETH-BTC,AAVE-USD,AAVE-USDT,ALGO-USD,ALGO-USDT,AVAX-USD,AVAX-USDT,BICO-USD,BICO-USDT,BLD-USD,BLD-USDT,BTRST-USDT,BZZ-USDT,CELO-USD,CELO-BTC,CFG-USD,CFG-USDT,CLV-USDT,COMP-USD,COMP-USDT,CYBER-USDT,CQT-USDT,CSPR-USD,CSPR-USDT,CUSD-USD,CUSD-USDC,DOGE-USD,DOGE-USDT,DOT-USD,DOT-USDT,EFI-USDT,FIL-USD,FIL-USDT,FLOW-USD,FLOW-USDT,GAL-USD,GAL-USDT,GODS-USDT,GOG-USDT,HMT-USD,HMT-USDT,ICP-USD,ICP-USDT,IMX-USD,IMX-USDT,LINK-USD,LINK-USDT,MATIC-USD,MATIC-USDT,MINA-USD,MINA-USDT,MKR-USD,MKR-USDT,NEON-USDT,NYM-USD,NYM-USDT,OCEAN-USD,OXT-USD,ROSE-USD,ROSE-USDT,SKL-USD,SKL-USDT,SOL-USD,SOL-USDT,STX-USDT,SUI-USDT,T-USDT,UNI-USD,UNI-USDT,USDT-USD,VEGA-USDT,WAXL-USD,WAXL-USDT,WBTC-BTC,WCFG-USD,WCFG-USDT,XTZ-USD': {
|
1053
|
-
# base: {
|
1054
|
-
# fees: {maker: '0', taker: '0.0045', liquidation: '0'},
|
1055
|
-
# floors: {maker: null, taker: null}
|
1056
|
-
# },
|
1057
|
-
# volume_tier_1: {
|
1058
|
-
# fees: {maker: '0', taker: '0.003', liquidation: '0'},
|
1059
|
-
# floors: {maker: null, taker: null}
|
1060
|
-
# },
|
1061
|
-
# volume_tier_2: {
|
1062
|
-
# fees: {maker: '0', taker: '0.0025', liquidation: '0'},
|
1063
|
-
# floors: {maker: null, taker: null}
|
1064
|
-
# },
|
1065
|
-
# volume_tier_3: {
|
1066
|
-
# fees: {maker: '0', taker: '0.002', liquidation: '0'},
|
1067
|
-
# floors: {maker: null, taker: null}
|
1068
|
-
# },
|
1069
|
-
# volume_tier_4: {
|
1070
|
-
# fees: {maker: '0', taker: '0.0018', liquidation: '0'},
|
1071
|
-
# floors: {maker: null, taker: null}
|
1072
|
-
# },
|
1073
|
-
# volume_tier_5: {
|
1074
|
-
# fees: {maker: '0', taker: '0.0018', liquidation: '0'},
|
1075
|
-
# floors: {maker: null, taker: null}
|
1076
|
-
# },
|
1077
|
-
# volume_tier_6: {
|
1078
|
-
# fees: {maker: '0', taker: '0.0016', liquidation: '0'},
|
1079
|
-
# floors: {maker: null, taker: null}
|
1080
|
-
# },
|
1081
|
-
# volume_tier_7: {
|
1082
|
-
# fees: {maker: '0', taker: '0.0013', liquidation: '0'},
|
1083
|
-
# floors: {maker: null, taker: null}
|
1084
|
-
# },
|
1085
|
-
# volume_tier_8: {
|
1086
|
-
# fees: {maker: '0', taker: '0.0012', liquidation: '0'},
|
1087
|
-
# floors: {maker: null, taker: null}
|
1088
|
-
# },
|
1089
|
-
# volume_tier_9: {
|
1090
|
-
# fees: {maker: '0', taker: '0.001', liquidation: '0'},
|
1091
|
-
# floors: {maker: null, taker: null}
|
1092
|
-
# }
|
1093
|
-
# volume_tier_10: {
|
1094
|
-
# fees: {maker: '0', taker: '0.0005', liquidation: '0'},
|
1095
|
-
# floors: {maker: null, taker: null}
|
1096
|
-
# },
|
1097
|
-
# volume_tier_11: {
|
1098
|
-
# fees: {maker: '0', taker: '0.0005', liquidation: '0'},
|
1099
|
-
# floors: {maker: null, taker: null}
|
1100
|
-
# },
|
1101
|
-
# }
|
1102
|
-
# }
|
1103
|
-
# }
|
1104
|
-
#
|
1105
|
-
fees = self.safe_value(response, 'fees_by_symbols', {})
|
1106
|
-
result: dict = {}
|
1107
|
-
groupsOfSymbols = list(fees.keys())
|
1108
|
-
for i in range(0, len(groupsOfSymbols)):
|
1109
|
-
group = groupsOfSymbols[i]
|
1110
|
-
feeTiers = self.safe_value(fees, group, {})
|
1111
|
-
tiers = self.parse_fee_tiers(feeTiers)
|
1112
|
-
firstTier = self.safe_value(feeTiers, 'base', {})
|
1113
|
-
firstTierFees = self.safe_value(firstTier, 'fees', {})
|
1114
|
-
ids = group.split(',')
|
1115
|
-
for j in range(0, len(ids)):
|
1116
|
-
id = ids[j]
|
1117
|
-
market = self.safe_market(id)
|
1118
|
-
symbol = market['symbol']
|
1119
|
-
info: dict = {}
|
1120
|
-
info[group] = feeTiers
|
1121
|
-
result[symbol] = {
|
1122
|
-
'info': info,
|
1123
|
-
'symbol': symbol,
|
1124
|
-
'maker': self.safe_number(firstTierFees, 'maker'),
|
1125
|
-
'taker': self.safe_number(firstTierFees, 'taker'),
|
1126
|
-
'percentage': True,
|
1127
|
-
'tierBased': True,
|
1128
|
-
'tiers': tiers,
|
1129
|
-
}
|
1130
|
-
return result
|
1131
|
-
|
1132
|
-
def parse_fee_tiers(self, feeTiers, market: Market = None):
|
1133
|
-
#
|
1134
|
-
# base: {
|
1135
|
-
# fees: {maker: '0', taker: '0.0045', liquidation: '0'},
|
1136
|
-
# floors: {maker: null, taker: null}
|
1137
|
-
# },
|
1138
|
-
# volume_tier_1: {
|
1139
|
-
# fees: {maker: '0', taker: '0.003', liquidation: '0'},
|
1140
|
-
# floors: {maker: null, taker: null}
|
1141
|
-
# },
|
1142
|
-
# volume_tier_2: {
|
1143
|
-
# fees: {maker: '0', taker: '0.0025', liquidation: '0'},
|
1144
|
-
# floors: {maker: null, taker: null}
|
1145
|
-
# },
|
1146
|
-
# volume_tier_3: {
|
1147
|
-
# fees: {maker: '0', taker: '0.002', liquidation: '0'},
|
1148
|
-
# floors: {maker: null, taker: null}
|
1149
|
-
# },
|
1150
|
-
# volume_tier_4: {
|
1151
|
-
# fees: {maker: '0', taker: '0.0018', liquidation: '0'},
|
1152
|
-
# floors: {maker: null, taker: null}
|
1153
|
-
# },
|
1154
|
-
# volume_tier_5: {
|
1155
|
-
# fees: {maker: '0', taker: '0.0018', liquidation: '0'},
|
1156
|
-
# floors: {maker: null, taker: null}
|
1157
|
-
# },
|
1158
|
-
# volume_tier_6: {
|
1159
|
-
# fees: {maker: '0', taker: '0.0016', liquidation: '0'},
|
1160
|
-
# floors: {maker: null, taker: null}
|
1161
|
-
# },
|
1162
|
-
# volume_tier_7: {
|
1163
|
-
# fees: {maker: '0', taker: '0.0013', liquidation: '0'},
|
1164
|
-
# floors: {maker: null, taker: null}
|
1165
|
-
# },
|
1166
|
-
# volume_tier_8: {
|
1167
|
-
# fees: {maker: '0', taker: '0.0012', liquidation: '0'},
|
1168
|
-
# floors: {maker: null, taker: null}
|
1169
|
-
# },
|
1170
|
-
# volume_tier_9: {
|
1171
|
-
# fees: {maker: '0', taker: '0.001', liquidation: '0'},
|
1172
|
-
# floors: {maker: null, taker: null}
|
1173
|
-
# }
|
1174
|
-
# volume_tier_10: {
|
1175
|
-
# fees: {maker: '0', taker: '0.0005', liquidation: '0'},
|
1176
|
-
# floors: {maker: null, taker: null}
|
1177
|
-
# },
|
1178
|
-
# volume_tier_11: {
|
1179
|
-
# fees: {maker: '0', taker: '0.0005', liquidation: '0'},
|
1180
|
-
# floors: {maker: null, taker: null}
|
1181
|
-
# },
|
1182
|
-
#
|
1183
|
-
takerFees = []
|
1184
|
-
makerFees = []
|
1185
|
-
keys = list(feeTiers.keys())
|
1186
|
-
keysLength = len(keys)
|
1187
|
-
if keysLength > 0:
|
1188
|
-
for i in range(0, keysLength):
|
1189
|
-
key = keys[i]
|
1190
|
-
tier = self.safe_value(feeTiers, key, {})
|
1191
|
-
tierFees = self.safe_value(tier, 'fees', {})
|
1192
|
-
taker = self.safe_string(tierFees, 'taker')
|
1193
|
-
maker = self.safe_string(tierFees, 'maker')
|
1194
|
-
makerFees.append([None, self.parse_number(maker)])
|
1195
|
-
takerFees.append([None, self.parse_number(taker)])
|
1196
|
-
takerFees = self.sort_by(takerFees, 1, True)
|
1197
|
-
makerFees = self.sort_by(makerFees, 1, True)
|
1198
|
-
firstTier = self.safe_dict(takerFees, 0, [])
|
1199
|
-
exchangeFees = self.safe_dict(self, 'fees', {})
|
1200
|
-
exchangeFeesTrading = self.safe_dict(exchangeFees, 'trading', {})
|
1201
|
-
exchangeFeesTradingTiers = self.safe_dict(exchangeFeesTrading, 'tiers', {})
|
1202
|
-
exchangeFeesTradingTiersTaker = self.safe_list(exchangeFeesTradingTiers, 'taker', [])
|
1203
|
-
exchangeFeesTradingTiersMaker = self.safe_list(exchangeFeesTradingTiers, 'maker', [])
|
1204
|
-
exchangeFeesTradingTiersTakerLength = len(exchangeFeesTradingTiersTaker)
|
1205
|
-
firstTierLength = len(firstTier)
|
1206
|
-
if (keysLength == exchangeFeesTradingTiersTakerLength) and (firstTierLength > 0):
|
1207
|
-
for i in range(0, keysLength):
|
1208
|
-
takerFees[i][0] = exchangeFeesTradingTiersTaker[i][0]
|
1209
|
-
makerFees[i][0] = exchangeFeesTradingTiersMaker[i][0]
|
1210
|
-
return {
|
1211
|
-
'maker': makerFees,
|
1212
|
-
'taker': takerFees,
|
1213
|
-
}
|
1214
|
-
|
1215
|
-
async def fetch_accounts(self, params={}) -> List[Account]:
|
1216
|
-
"""
|
1217
|
-
fetch all the accounts associated with a profile
|
1218
|
-
|
1219
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-accounts
|
1220
|
-
|
1221
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1222
|
-
:returns dict: a dictionary of `account structures <https://docs.ccxt.com/#/?id=account-structure>` indexed by the account type
|
1223
|
-
"""
|
1224
|
-
await self.load_markets()
|
1225
|
-
response = await self.privateGetV1Accounts(params)
|
1226
|
-
#
|
1227
|
-
# {
|
1228
|
-
# "accounts": [
|
1229
|
-
# {
|
1230
|
-
# "trader_id": "b18507ce-7d55-4bf1-b12a-0ccca5b90936",
|
1231
|
-
# "name": "string"
|
1232
|
-
# }
|
1233
|
-
# ]
|
1234
|
-
# }
|
1235
|
-
#
|
1236
|
-
accounts = self.safe_value(response, 'accounts', [])
|
1237
|
-
return self.parse_accounts(accounts, params)
|
1238
|
-
|
1239
|
-
def parse_account(self, account):
|
1240
|
-
#
|
1241
|
-
# {
|
1242
|
-
# "trader_id": "b18507ce-7d55-4bf1-b12a-0ccca5b90936",
|
1243
|
-
# "name": "string"
|
1244
|
-
# }
|
1245
|
-
#
|
1246
|
-
return {
|
1247
|
-
'id': self.safe_string(account, 'trader_id'),
|
1248
|
-
'type': 'trading',
|
1249
|
-
'code': None,
|
1250
|
-
'info': account,
|
1251
|
-
}
|
1252
|
-
|
1253
|
-
async def fetch_balance(self, params={}) -> Balances:
|
1254
|
-
"""
|
1255
|
-
query for balance and get the amount of funds available for trading or funds locked in orders
|
1256
|
-
|
1257
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-balances
|
1258
|
-
|
1259
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1260
|
-
:returns dict: a `balance structure <https://docs.ccxt.com/#/?id=balance-structure>`
|
1261
|
-
"""
|
1262
|
-
await self.load_markets()
|
1263
|
-
response = await self.privateGetV1Balances(params)
|
1264
|
-
return self.parse_balance(response)
|
1265
|
-
|
1266
|
-
def parse_balance(self, response) -> Balances:
|
1267
|
-
#
|
1268
|
-
# {
|
1269
|
-
# "asset_balances": {
|
1270
|
-
# "BTC": "0.00308696",
|
1271
|
-
# "ETH": "20.000000000000000000"
|
1272
|
-
# },
|
1273
|
-
# "asset_holds": {
|
1274
|
-
# "BTC": "0.00000000",
|
1275
|
-
# "ETH": "1.000000000000000000"
|
1276
|
-
# },
|
1277
|
-
# "net_liquidation_value_usd": "string"
|
1278
|
-
# }
|
1279
|
-
#
|
1280
|
-
result: dict = {
|
1281
|
-
'info': response,
|
1282
|
-
'timestamp': None,
|
1283
|
-
'datetime': None,
|
1284
|
-
}
|
1285
|
-
totalBalances = self.safe_value(response, 'asset_balances', {})
|
1286
|
-
usedBalances = self.safe_value(response, 'asset_holds', {})
|
1287
|
-
currencyIds = list(totalBalances.keys())
|
1288
|
-
for i in range(0, len(currencyIds)):
|
1289
|
-
currencyId = currencyIds[i]
|
1290
|
-
code = self.safe_currency_code(currencyId)
|
1291
|
-
account = self.account()
|
1292
|
-
account['total'] = self.safe_string(totalBalances, currencyId)
|
1293
|
-
account['used'] = self.safe_string(usedBalances, currencyId, '0')
|
1294
|
-
result[code] = account
|
1295
|
-
return self.safe_balance(result)
|
1296
|
-
|
1297
|
-
async def fetch_my_trades(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1298
|
-
"""
|
1299
|
-
fetch all trades made by the user
|
1300
|
-
|
1301
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-fills
|
1302
|
-
|
1303
|
-
:param str symbol: unified market symbol
|
1304
|
-
:param int [since]: the earliest time in ms to fetch trades for
|
1305
|
-
:param int [limit]: the maximum number of trades structures to retrieve(default 200, max 500)
|
1306
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1307
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1308
|
-
:returns Trade[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1309
|
-
"""
|
1310
|
-
await self.load_markets()
|
1311
|
-
request: dict = {}
|
1312
|
-
market = None
|
1313
|
-
if symbol is not None:
|
1314
|
-
market = self.market(symbol)
|
1315
|
-
request['symbol'] = market['id']
|
1316
|
-
if since is not None:
|
1317
|
-
request['start_time'] = self.iso8601(since)
|
1318
|
-
if limit is not None:
|
1319
|
-
request['count'] = limit
|
1320
|
-
until = self.safe_integer(params, 'until')
|
1321
|
-
if until is not None:
|
1322
|
-
params = self.omit(params, ['until'])
|
1323
|
-
request['end_time'] = self.iso8601(until)
|
1324
|
-
response = await self.privateGetV1Fills(self.extend(request, params))
|
1325
|
-
#
|
1326
|
-
# {
|
1327
|
-
# "fills": [
|
1328
|
-
# {
|
1329
|
-
# "symbol": "ETH-USDT",
|
1330
|
-
# "auction_code": "ETH-USDT-2023-10-20T13:16:30.000Z",
|
1331
|
-
# "order_id": "39911d5f-c789-4a7d-ad34-820a804d1da6",
|
1332
|
-
# "quantity": "-0.0009",
|
1333
|
-
# "price": "1608.83000000",
|
1334
|
-
# "fee": "0.006516",
|
1335
|
-
# "fee_type": "taker",
|
1336
|
-
# "fee_currency": "USDT",
|
1337
|
-
# "logical_time": "2023-10-20T13:16:30.000Z"
|
1338
|
-
# },
|
1339
|
-
# {
|
1340
|
-
# "symbol": "ETH-USDT",
|
1341
|
-
# "auction_code": "ETH-USDT-2023-10-20T13:22:14.000Z",
|
1342
|
-
# "order_id": "83ed365f-497d-433b-96c1-9d08c1a12842",
|
1343
|
-
# "quantity": "0.0008",
|
1344
|
-
# "price": "1615.24000000",
|
1345
|
-
# "fee": "0.005815",
|
1346
|
-
# "fee_type": "taker",
|
1347
|
-
# "fee_currency": "USDT",
|
1348
|
-
# "logical_time": "2023-10-20T13:22:14.000Z"
|
1349
|
-
# },
|
1350
|
-
# ]
|
1351
|
-
# }
|
1352
|
-
#
|
1353
|
-
fills = self.safe_list(response, 'fills', [])
|
1354
|
-
return self.parse_trades(fills, market, since, limit)
|
1355
|
-
|
1356
|
-
async def fetch_order_trades(self, id: str, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Trade]:
|
1357
|
-
"""
|
1358
|
-
fetch all the trades made from a single order
|
1359
|
-
|
1360
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-fills
|
1361
|
-
|
1362
|
-
:param str id: order id
|
1363
|
-
:param str symbol: unified market symbol
|
1364
|
-
:param int [since]: the earliest time in ms to fetch trades for
|
1365
|
-
:param int [limit]: the maximum number of trades to retrieve
|
1366
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1367
|
-
:returns dict[]: a list of `trade structures <https://docs.ccxt.com/#/?id=trade-structure>`
|
1368
|
-
"""
|
1369
|
-
request: dict = {
|
1370
|
-
'order_id': id,
|
1371
|
-
}
|
1372
|
-
return await self.fetch_my_trades(symbol, since, limit, self.extend(request, params))
|
1373
|
-
|
1374
|
-
async def fetch_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1375
|
-
"""
|
1376
|
-
fetches information on multiple orders made by the user
|
1377
|
-
|
1378
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
|
1379
|
-
|
1380
|
-
:param str symbol: unified market symbol of the market orders were made in
|
1381
|
-
:param int [since]: the earliest time in ms to fetch orders for
|
1382
|
-
:param int [limit]: the maximum number of order structures to retrieve(default 200, max 500)
|
1383
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1384
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1385
|
-
:param string|str[] [params.status]: the status of the order - 'accepted', 'done', 'canceled', 'rejected', 'pending'(default ['accepted', 'done', 'canceled', 'rejected', 'pending'])
|
1386
|
-
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1387
|
-
"""
|
1388
|
-
await self.load_markets()
|
1389
|
-
status = self.safe_string(params, 'status')
|
1390
|
-
if status is None:
|
1391
|
-
status = ['accepted', 'done', 'canceled', 'rejected', 'pending']
|
1392
|
-
request: dict = {
|
1393
|
-
'status': status,
|
1394
|
-
}
|
1395
|
-
market = None
|
1396
|
-
if symbol is not None:
|
1397
|
-
market = self.market(symbol)
|
1398
|
-
request['symbol'] = market['id']
|
1399
|
-
if since is not None:
|
1400
|
-
request['start_time'] = self.iso8601(since)
|
1401
|
-
if limit is not None:
|
1402
|
-
request['count'] = limit
|
1403
|
-
until = self.safe_integer(params, 'until')
|
1404
|
-
if until is not None:
|
1405
|
-
params = self.omit(params, ['until'])
|
1406
|
-
request['end_time'] = self.iso8601(until)
|
1407
|
-
response = await self.privateGetV1Orders(self.extend(request, params))
|
1408
|
-
#
|
1409
|
-
# {
|
1410
|
-
# "orders":[
|
1411
|
-
# {
|
1412
|
-
# "order_id":"913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
|
1413
|
-
# "price":"35800.00000000",
|
1414
|
-
# "stop_price":null,
|
1415
|
-
# "cost":"0.00000000",
|
1416
|
-
# "fill_fees":"0.00000000",
|
1417
|
-
# "trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b",
|
1418
|
-
# "status":"accepted",
|
1419
|
-
# "epoch_timestamp":"2023-10-26T08:20:56.307Z",
|
1420
|
-
# "origin":"web",
|
1421
|
-
# "self_trade_prevention":null,
|
1422
|
-
# "client_id":null,
|
1423
|
-
# "created_at":"2023-10-26T08:20:56.307Z",
|
1424
|
-
# "symbol":"BTC-USDT",
|
1425
|
-
# "size":"0.0003",
|
1426
|
-
# "side":"sell",
|
1427
|
-
# "type":"limit",
|
1428
|
-
# "post_only":false,
|
1429
|
-
# "size_filled":"0.0000"
|
1430
|
-
# }
|
1431
|
-
# ]
|
1432
|
-
# }
|
1433
|
-
#
|
1434
|
-
orders = self.safe_list(response, 'orders', [])
|
1435
|
-
return self.parse_orders(orders, market, since, limit)
|
1436
|
-
|
1437
|
-
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
1438
|
-
"""
|
1439
|
-
fetches information on an order made by the user
|
1440
|
-
|
1441
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-specific-order-by-id
|
1442
|
-
|
1443
|
-
:param int|str id: order id
|
1444
|
-
:param str symbol: not used by coinlist fetchOrder()
|
1445
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1446
|
-
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1447
|
-
"""
|
1448
|
-
await self.load_markets()
|
1449
|
-
request: dict = {
|
1450
|
-
'order_id': id,
|
1451
|
-
}
|
1452
|
-
response = await self.privateGetV1OrdersOrderId(self.extend(request, params))
|
1453
|
-
#
|
1454
|
-
# {
|
1455
|
-
# "order_id": "93101167-9065-4b9c-b98b-5d789a3ed9fe",
|
1456
|
-
# "client_id": "string",
|
1457
|
-
# "symbol": "string",
|
1458
|
-
# "type": "market",
|
1459
|
-
# "side": "buy",
|
1460
|
-
# "size": "string",
|
1461
|
-
# "price": "string",
|
1462
|
-
# "stop_price": "string",
|
1463
|
-
# "stop_trigger": "last",
|
1464
|
-
# "self_trade_prevention": "keep-newest",
|
1465
|
-
# "average_fill_price": "string",
|
1466
|
-
# "fill_fees": "string",
|
1467
|
-
# "size_filled": "string",
|
1468
|
-
# "created_at": "2019-08-24T14:15:22Z",
|
1469
|
-
# "epoch_timestamp": "2019-08-24T14:15:22Z",
|
1470
|
-
# "post_only": True,
|
1471
|
-
# "peg_price_type": "trailing-stop",
|
1472
|
-
# "peg_offset_value": "string",
|
1473
|
-
# "origin": "web",
|
1474
|
-
# "status": "pending"
|
1475
|
-
# }
|
1476
|
-
#
|
1477
|
-
return self.parse_order(response)
|
1478
|
-
|
1479
|
-
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1480
|
-
"""
|
1481
|
-
fetch all unfilled currently open orders
|
1482
|
-
|
1483
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
|
1484
|
-
|
1485
|
-
:param str symbol: unified market symbol
|
1486
|
-
:param int [since]: the earliest time in ms to fetch open orders for
|
1487
|
-
:param int [limit]: the maximum number of open order structures to retrieve(default 200, max 500)
|
1488
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1489
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1490
|
-
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1491
|
-
"""
|
1492
|
-
await self.load_markets()
|
1493
|
-
request: dict = {
|
1494
|
-
'status': 'accepted',
|
1495
|
-
}
|
1496
|
-
return self.fetch_orders(symbol, since, limit, self.extend(request, params))
|
1497
|
-
|
1498
|
-
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
1499
|
-
"""
|
1500
|
-
fetches information on multiple closed orders made by the user
|
1501
|
-
|
1502
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
|
1503
|
-
|
1504
|
-
:param str symbol: unified market symbol of the market orders were made in
|
1505
|
-
:param int [since]: the earliest time in ms to fetch orders for
|
1506
|
-
:param int [limit]: the maximum number of closed order structures to retrieve(default 200, max 500)
|
1507
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1508
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1509
|
-
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1510
|
-
"""
|
1511
|
-
await self.load_markets()
|
1512
|
-
request: dict = {
|
1513
|
-
'status': 'done',
|
1514
|
-
}
|
1515
|
-
return self.fetch_orders(symbol, since, limit, self.extend(request, params))
|
1516
|
-
|
1517
|
-
async def fetch_canceled_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
1518
|
-
"""
|
1519
|
-
fetches information on multiple canceled orders made by the user
|
1520
|
-
|
1521
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-orders
|
1522
|
-
|
1523
|
-
:param str symbol: unified market symbol of the market orders were made in
|
1524
|
-
:param int [since]: the earliest time in ms to fetch orders for
|
1525
|
-
:param int [limit]: the maximum number of canceled order structures to retrieve(default 200, max 500)
|
1526
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1527
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1528
|
-
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1529
|
-
"""
|
1530
|
-
await self.load_markets()
|
1531
|
-
request: dict = {
|
1532
|
-
'status': 'canceled',
|
1533
|
-
}
|
1534
|
-
return self.fetch_orders(symbol, since, limit, self.extend(request, params))
|
1535
|
-
|
1536
|
-
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
1537
|
-
"""
|
1538
|
-
cancel open orders of market
|
1539
|
-
|
1540
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#cancel-all-orders
|
1541
|
-
|
1542
|
-
:param str symbol: unified market symbol
|
1543
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1544
|
-
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1545
|
-
"""
|
1546
|
-
await self.load_markets()
|
1547
|
-
market = None
|
1548
|
-
request: dict = {}
|
1549
|
-
if symbol is not None:
|
1550
|
-
market = self.market(symbol)
|
1551
|
-
request['symbol'] = market['id']
|
1552
|
-
response = await self.privateDeleteV1Orders(self.extend(request, params))
|
1553
|
-
#
|
1554
|
-
# {
|
1555
|
-
# "message": "Order cancellation request received.",
|
1556
|
-
# "timestamp": "2023-10-26T10:29:28.652Z"
|
1557
|
-
# }
|
1558
|
-
#
|
1559
|
-
orders = [response]
|
1560
|
-
return self.parse_orders(orders, market)
|
1561
|
-
|
1562
|
-
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
1563
|
-
"""
|
1564
|
-
cancels an open order
|
1565
|
-
|
1566
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-order-by-id
|
1567
|
-
|
1568
|
-
:param str id: order id
|
1569
|
-
:param str symbol: not used by coinlist cancelOrder()
|
1570
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1571
|
-
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1572
|
-
"""
|
1573
|
-
await self.load_markets()
|
1574
|
-
request: dict = {
|
1575
|
-
'order_id': id,
|
1576
|
-
}
|
1577
|
-
response = await self.privateDeleteV1OrdersOrderId(self.extend(request, params))
|
1578
|
-
#
|
1579
|
-
# {
|
1580
|
-
# "message": "Cancel order request received.",
|
1581
|
-
# "order_id": "d36e7588-6525-485c-b768-8ad8b3f745f9",
|
1582
|
-
# "timestamp": "2023-10-26T14:36:37.559Z"
|
1583
|
-
# }
|
1584
|
-
#
|
1585
|
-
return self.parse_order(response)
|
1586
|
-
|
1587
|
-
async def cancel_orders(self, ids, symbol: Str = None, params={}):
|
1588
|
-
"""
|
1589
|
-
cancel multiple orders
|
1590
|
-
|
1591
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#cancel-specific-orders
|
1592
|
-
|
1593
|
-
:param str[] ids: order ids
|
1594
|
-
:param str symbol: not used by coinlist cancelOrders()
|
1595
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1596
|
-
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
1597
|
-
"""
|
1598
|
-
await self.load_markets()
|
1599
|
-
params = ids
|
1600
|
-
response = await self.privateDeleteV1OrdersBulk(params)
|
1601
|
-
#
|
1602
|
-
# {
|
1603
|
-
# "message": "Cancel order requests received.",
|
1604
|
-
# "order_ids": [
|
1605
|
-
# "ff132955-43bc-4fe5-9d9c-5ba226cc89a0"
|
1606
|
-
# ],
|
1607
|
-
# "timestamp": "2024-06-01T02:32:30.305Z"
|
1608
|
-
# }
|
1609
|
-
#
|
1610
|
-
orderIds = self.safe_list(response, 'order_ids', [])
|
1611
|
-
orders = []
|
1612
|
-
datetime = self.safe_string(response, 'timestamp')
|
1613
|
-
for i in range(0, len(orderIds)):
|
1614
|
-
orders.append(self.safe_order({
|
1615
|
-
'info': orderIds[i],
|
1616
|
-
'id': orderIds[i],
|
1617
|
-
'lastUpdateTimestamp': self.parse8601(datetime),
|
1618
|
-
}))
|
1619
|
-
return orders
|
1620
|
-
|
1621
|
-
async def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
|
1622
|
-
"""
|
1623
|
-
create a trade order
|
1624
|
-
|
1625
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#create-new-order
|
1626
|
-
|
1627
|
-
:param str symbol: unified symbol of the market to create an order in
|
1628
|
-
:param str type: 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_limit'
|
1629
|
-
:param str side: 'buy' or 'sell'
|
1630
|
-
:param float amount: how much of currency you want to trade in units of base currency
|
1631
|
-
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1632
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1633
|
-
:param bool [params.postOnly]: if True, the order will only be posted to the order book and not executed immediately(default False)
|
1634
|
-
:param float [params.triggerPrice]: only for the 'stop_market', 'stop_limit', 'take_market' or 'take_limit' orders(the price at which an order is triggered)
|
1635
|
-
:param str [params.clientOrderId]: client order id(default None)
|
1636
|
-
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1637
|
-
"""
|
1638
|
-
await self.load_markets()
|
1639
|
-
market = self.market(symbol)
|
1640
|
-
request: dict = {
|
1641
|
-
'symbol': market['id'],
|
1642
|
-
'type': type,
|
1643
|
-
'side': side,
|
1644
|
-
'size': self.amount_to_precision(symbol, amount),
|
1645
|
-
}
|
1646
|
-
isMarket = False
|
1647
|
-
if (type == 'limit') or (type == 'stop_limit') or (type == 'take_limit'):
|
1648
|
-
if price is None:
|
1649
|
-
raise ArgumentsRequired(self.id + ' createOrder() requires a price argument for a ' + type + ' order')
|
1650
|
-
request['price'] = self.price_to_precision(symbol, price)
|
1651
|
-
else:
|
1652
|
-
isMarket = True
|
1653
|
-
postOnly = None
|
1654
|
-
postOnly, params = self.handle_post_only(isMarket, False, params)
|
1655
|
-
if postOnly:
|
1656
|
-
request['post_only'] = True
|
1657
|
-
triggerPrice = self.safe_number_n(params, ['triggerPrice', 'trigger_price', 'stopPrice', 'stop_price'])
|
1658
|
-
if triggerPrice is not None:
|
1659
|
-
params = self.omit(params, ['triggerPrice', 'trigger_price', 'stopPrice'])
|
1660
|
-
request['stop_price'] = self.price_to_precision(symbol, triggerPrice)
|
1661
|
-
if type == 'market':
|
1662
|
-
request['type'] = 'stop_market'
|
1663
|
-
elif type == 'limit':
|
1664
|
-
request['type'] = 'stop_limit'
|
1665
|
-
elif (type == 'stop_market') or (type == 'stop_limit') or (type == 'take_market') or (type == 'take_limit'):
|
1666
|
-
raise ArgumentsRequired(self.id + ' createOrder() requires a triggerPrice parameter for stop-loss and take-profit orders')
|
1667
|
-
clientOrderId = self.safe_string_2(params, 'clientOrderId', 'client_id')
|
1668
|
-
if clientOrderId is not None:
|
1669
|
-
request['client_id'] = clientOrderId
|
1670
|
-
params = self.omit(params, ['clientOrderId', 'client_id'])
|
1671
|
-
response = await self.privatePostV1Orders(self.extend(request, params))
|
1672
|
-
#
|
1673
|
-
# {
|
1674
|
-
# "message": "New order request received.",
|
1675
|
-
# "order": {
|
1676
|
-
# "symbol": "BTC-USDT",
|
1677
|
-
# "type": "market",
|
1678
|
-
# "side": "sell",
|
1679
|
-
# "size": "0.0003",
|
1680
|
-
# "order_id": "cad67c0f-9aec-4ac8-ac03-aaf5db299ff7",
|
1681
|
-
# "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b"
|
1682
|
-
# },
|
1683
|
-
# "timestamp": "2023-10-26T11:30:55.376Z"
|
1684
|
-
# }
|
1685
|
-
#
|
1686
|
-
order = self.safe_dict(response, 'order', {})
|
1687
|
-
return self.parse_order(order, market)
|
1688
|
-
|
1689
|
-
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
1690
|
-
"""
|
1691
|
-
create a trade order
|
1692
|
-
|
1693
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#modify-existing-order
|
1694
|
-
|
1695
|
-
:param str id: order id
|
1696
|
-
:param str symbol: unified symbol of the market to create an order in
|
1697
|
-
:param str type: 'market' or 'limit' or 'stop_market' or 'stop_limit' or 'take_market' or 'take_limit'
|
1698
|
-
:param str side: 'buy' or 'sell'
|
1699
|
-
:param float amount: how much of currency you want to trade in units of base currency
|
1700
|
-
:param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
|
1701
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1702
|
-
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1703
|
-
"""
|
1704
|
-
await self.load_markets()
|
1705
|
-
if amount is None:
|
1706
|
-
raise ArgumentsRequired(self.id + ' editOrder() requires an amount argument')
|
1707
|
-
market = self.market(symbol)
|
1708
|
-
request: dict = {
|
1709
|
-
'order_id': id,
|
1710
|
-
'type': type,
|
1711
|
-
'side': side,
|
1712
|
-
'size': self.amount_to_precision(symbol, amount),
|
1713
|
-
}
|
1714
|
-
if price is not None:
|
1715
|
-
request['price'] = self.price_to_precision(symbol, price)
|
1716
|
-
response = await self.privatePatchV1OrdersOrderId(self.extend(request, params))
|
1717
|
-
return self.parse_order(response, market)
|
1718
|
-
|
1719
|
-
def parse_order(self, order: dict, market: Market = None) -> Order:
|
1720
|
-
#
|
1721
|
-
# fetchOrder
|
1722
|
-
# {
|
1723
|
-
# "order_id": "913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
|
1724
|
-
# "price": "35800.00000000",
|
1725
|
-
# "stop_price":null,
|
1726
|
-
# "cost": "0.00000000",
|
1727
|
-
# "fill_fees": "0.00000000",
|
1728
|
-
# "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b",
|
1729
|
-
# "status": "canceled",
|
1730
|
-
# "epoch_timestamp": "2023-10-26T08:20:56.307Z",
|
1731
|
-
# "origin": "web",
|
1732
|
-
# "self_trade_prevention":null,
|
1733
|
-
# "client_id":null,
|
1734
|
-
# "symbol": "BTC-USDT",
|
1735
|
-
# "size": "0.0003",
|
1736
|
-
# "side": "sell",
|
1737
|
-
# "type": "limit",
|
1738
|
-
# "post_only":false,
|
1739
|
-
# "size_filled": "0.0000"
|
1740
|
-
# }
|
1741
|
-
#
|
1742
|
-
# fetchOrders
|
1743
|
-
# {
|
1744
|
-
# "order_id":"913ea6e7-9fc9-43fb-9db1-f195d3baa93f",
|
1745
|
-
# "price":"35800.00000000",
|
1746
|
-
# "stop_price":null,
|
1747
|
-
# "cost":"0.00000000",
|
1748
|
-
# "fill_fees":"0.00000000",
|
1749
|
-
# "trader_id":"9c6f737e-a829-4843-87b1-b1ce86f2853b",
|
1750
|
-
# "status":"accepted",
|
1751
|
-
# "epoch_timestamp":"2023-10-26T08:20:56.307Z",
|
1752
|
-
# "origin":"web",
|
1753
|
-
# "self_trade_prevention":null,
|
1754
|
-
# "client_id":null,
|
1755
|
-
# "created_at":"2023-10-26T08:20:56.307Z",
|
1756
|
-
# "symbol":"BTC-USDT",
|
1757
|
-
# "size":"0.0003",
|
1758
|
-
# "side":"sell",
|
1759
|
-
# "type":"limit",
|
1760
|
-
# "post_only":false,
|
1761
|
-
# "size_filled":"0.0000"
|
1762
|
-
# }
|
1763
|
-
#
|
1764
|
-
# createOrder
|
1765
|
-
# {
|
1766
|
-
# "symbol": "BTC-USDT",
|
1767
|
-
# "type": "market",
|
1768
|
-
# "side": "sell",
|
1769
|
-
# "size": "0.0003",
|
1770
|
-
# "order_id": "cad67c0f-9aec-4ac8-ac03-aaf5db299ff7",
|
1771
|
-
# "trader_id": "9c6f737e-a829-4843-87b1-b1ce86f2853b"
|
1772
|
-
# },
|
1773
|
-
#
|
1774
|
-
# cancelOrder
|
1775
|
-
# {
|
1776
|
-
# "message": "Cancel order request received.",
|
1777
|
-
# "order_id": "d36e7588-6525-485c-b768-8ad8b3f745f9",
|
1778
|
-
# "timestamp": "2023-10-26T14:36:37.559Z"
|
1779
|
-
# }
|
1780
|
-
#
|
1781
|
-
# cancelOrders
|
1782
|
-
# {
|
1783
|
-
# "message": "Order cancellation request received.",
|
1784
|
-
# "timestamp": "2023-10-26T10:29:28.652Z"
|
1785
|
-
# }
|
1786
|
-
#
|
1787
|
-
# cancelAllOrders
|
1788
|
-
# {
|
1789
|
-
# "message": "Order cancellation request received.",
|
1790
|
-
# "timestamp": "2023-10-26T10:29:28.652Z"
|
1791
|
-
# }
|
1792
|
-
#
|
1793
|
-
id = self.safe_string(order, 'order_id')
|
1794
|
-
marketId = self.safe_string(order, 'symbol')
|
1795
|
-
market = self.safe_market(marketId, market)
|
1796
|
-
clientOrderId = self.safe_string(order, 'client_id')
|
1797
|
-
timestampString = self.safe_string_2(order, 'created_at', 'epoch_timestamp')
|
1798
|
-
if timestampString is None:
|
1799
|
-
timestampString = self.safe_string(order, 'timestamp')
|
1800
|
-
timestamp = self.parse8601(timestampString)
|
1801
|
-
status = self.parse_order_status(self.safe_string(order, 'status'))
|
1802
|
-
type = self.parse_order_type(self.safe_string(order, 'type'))
|
1803
|
-
side = self.safe_string(order, 'side')
|
1804
|
-
price = self.safe_string(order, 'price')
|
1805
|
-
triggerPrice = self.safe_string(order, 'stop_price')
|
1806
|
-
average = self.safe_string(order, 'average_fill_price') # from documentation
|
1807
|
-
amount = self.safe_string(order, 'size')
|
1808
|
-
filled = self.safe_string(order, 'size_filled')
|
1809
|
-
feeCost = self.safe_string(order, 'fill_fees')
|
1810
|
-
postOnly = self.safe_value(order, 'post_only')
|
1811
|
-
fee = None
|
1812
|
-
if feeCost is not None:
|
1813
|
-
fee = {
|
1814
|
-
'currency': market['quote'],
|
1815
|
-
'cost': feeCost,
|
1816
|
-
'rate': None,
|
1817
|
-
}
|
1818
|
-
return self.safe_order({
|
1819
|
-
'id': id,
|
1820
|
-
'clientOrderId': clientOrderId,
|
1821
|
-
'timestamp': timestamp,
|
1822
|
-
'datetime': self.iso8601(timestamp),
|
1823
|
-
'lastTradeTimestamp': None,
|
1824
|
-
'status': status,
|
1825
|
-
'symbol': market['symbol'],
|
1826
|
-
'type': type,
|
1827
|
-
'timeInForce': 'GTC',
|
1828
|
-
'side': side,
|
1829
|
-
'price': price,
|
1830
|
-
'triggerPrice': triggerPrice,
|
1831
|
-
'average': average,
|
1832
|
-
'amount': amount,
|
1833
|
-
'cost': None,
|
1834
|
-
'filled': filled,
|
1835
|
-
'remaining': None,
|
1836
|
-
'fee': fee,
|
1837
|
-
'trades': None,
|
1838
|
-
'info': order,
|
1839
|
-
'postOnly': postOnly,
|
1840
|
-
}, market)
|
1841
|
-
|
1842
|
-
def parse_order_status(self, status: Str):
|
1843
|
-
statuses: dict = {
|
1844
|
-
'pending': 'open',
|
1845
|
-
'accepted': 'open',
|
1846
|
-
'rejected': 'rejected',
|
1847
|
-
'done': 'closed',
|
1848
|
-
'canceled': 'canceled',
|
1849
|
-
}
|
1850
|
-
return self.safe_string(statuses, status, status)
|
1851
|
-
|
1852
|
-
def parse_order_type(self, status):
|
1853
|
-
statuses: dict = {
|
1854
|
-
'market': 'market',
|
1855
|
-
'limit': 'limit',
|
1856
|
-
'stop_market': 'market',
|
1857
|
-
'stop_limit': 'limit',
|
1858
|
-
'take_market': 'market',
|
1859
|
-
'take_limit': 'limit',
|
1860
|
-
}
|
1861
|
-
return self.safe_string(statuses, status, status)
|
1862
|
-
|
1863
|
-
async def transfer(self, code: str, amount: float, fromAccount: str, toAccount: str, params={}) -> TransferEntry:
|
1864
|
-
"""
|
1865
|
-
transfer currency internally between wallets on the same account
|
1866
|
-
|
1867
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-between-entities
|
1868
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-wallet-to-pro
|
1869
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#transfer-funds-from-pro-to-wallet
|
1870
|
-
|
1871
|
-
:param str code: unified currency code
|
1872
|
-
:param float amount: amount to transfer
|
1873
|
-
:param str fromAccount: account to transfer from
|
1874
|
-
:param str toAccount: account to transfer to
|
1875
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1876
|
-
:returns dict: a `transfer structure <https://docs.ccxt.com/#/?id=transfer-structure>`
|
1877
|
-
"""
|
1878
|
-
await self.load_markets()
|
1879
|
-
currency = self.currency(code)
|
1880
|
-
request: dict = {
|
1881
|
-
'asset': currency['id'],
|
1882
|
-
'amount': self.currency_to_precision(code, amount),
|
1883
|
-
}
|
1884
|
-
accountsByType = self.safe_value(self.options, 'accountsByType', {})
|
1885
|
-
fromAcc = self.safe_string(accountsByType, fromAccount, fromAccount)
|
1886
|
-
toAcc = self.safe_string(accountsByType, toAccount, toAccount)
|
1887
|
-
response = None
|
1888
|
-
if (fromAcc == 'funding') and (toAcc == 'trading'):
|
1889
|
-
response = await self.privatePostV1TransfersFromWallet(self.extend(request, params))
|
1890
|
-
elif (fromAcc == 'trading') and (toAcc == 'funding'):
|
1891
|
-
response = await self.privatePostV1TransfersToWallet(self.extend(request, params))
|
1892
|
-
else:
|
1893
|
-
request['from_trader_id'] = fromAcc
|
1894
|
-
request['to_trader_id'] = toAcc
|
1895
|
-
response = await self.privatePostV1TransfersInternalTransfer(self.extend(request, params))
|
1896
|
-
#
|
1897
|
-
# privatePostV1TransfersInternalTransfer
|
1898
|
-
# {
|
1899
|
-
# "from_trader_id": "1f494ace-b3ed-4324-b202-55526ed06381",
|
1900
|
-
# "to_trader_id": "d32c7a40-cc24-44b0-8597-f9edb3da989f",
|
1901
|
-
# "asset": "string",
|
1902
|
-
# "amount": "string"
|
1903
|
-
# }
|
1904
|
-
#
|
1905
|
-
# privatePostV1TransfersFromWallet, privatePostV1TransfersToWallet
|
1906
|
-
# {
|
1907
|
-
# "transfer_id": "bb34f528-d9b0-47c6-b11f-4d4840b86ee3"
|
1908
|
-
# }
|
1909
|
-
#
|
1910
|
-
transfer = self.parse_transfer(response, currency)
|
1911
|
-
return transfer
|
1912
|
-
|
1913
|
-
async def fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[TransferEntry]:
|
1914
|
-
"""
|
1915
|
-
fetch a history of internal transfers between CoinList.co and CoinList Pro. It does not return external deposits or withdrawals
|
1916
|
-
|
1917
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#list-transfers
|
1918
|
-
|
1919
|
-
:param str code: unified currency code
|
1920
|
-
:param int [since]: the earliest time in ms to fetch transfers for
|
1921
|
-
:param int [limit]: the maximum number of transfer structures to retrieve(default 200, max 500)
|
1922
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1923
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
1924
|
-
:returns dict[]: a list of `transfer structures <https://docs.ccxt.com/#/?id=transfer-structure>`
|
1925
|
-
"""
|
1926
|
-
await self.load_markets()
|
1927
|
-
currency = None
|
1928
|
-
if code is not None:
|
1929
|
-
currency = self.currency(code)
|
1930
|
-
request: dict = {}
|
1931
|
-
if since is not None:
|
1932
|
-
request['start_time'] = self.iso8601(since)
|
1933
|
-
if limit is not None:
|
1934
|
-
request['count'] = limit
|
1935
|
-
until = self.safe_integer(params, 'until')
|
1936
|
-
if until is not None:
|
1937
|
-
params = self.omit(params, ['until'])
|
1938
|
-
request['end_time'] = self.iso8601(until)
|
1939
|
-
response = await self.privateGetV1Transfers(self.extend(request, params))
|
1940
|
-
#
|
1941
|
-
# {
|
1942
|
-
# "transfers": [
|
1943
|
-
# {
|
1944
|
-
# "transfer_id": "2c02db25-e8f2-4271-8222-e110bfd0aa2a",
|
1945
|
-
# "created_at": "2023-10-20T13:15:37.000Z",
|
1946
|
-
# "confirmed_at": "2023-10-20T13:15:37.000Z",
|
1947
|
-
# "asset": "ETH",
|
1948
|
-
# "amount": "0.010000000000000000",
|
1949
|
-
# "status": "confirmed"
|
1950
|
-
# },
|
1951
|
-
# {
|
1952
|
-
# "transfer_id": "890694db-156c-4e93-a3ef-4db61685aca7",
|
1953
|
-
# "created_at": "2023-10-26T14:32:22.000Z",
|
1954
|
-
# "confirmed_at": "2023-10-26T14:32:22.000Z",
|
1955
|
-
# "asset": "USD",
|
1956
|
-
# "amount": "-3.00",
|
1957
|
-
# "status": "confirmed"
|
1958
|
-
# }
|
1959
|
-
# ]
|
1960
|
-
# }
|
1961
|
-
#
|
1962
|
-
transfers = self.safe_list(response, 'transfers', [])
|
1963
|
-
return self.parse_transfers(transfers, currency, since, limit)
|
1964
|
-
|
1965
|
-
def parse_transfer(self, transfer: dict, currency: Currency = None) -> TransferEntry:
|
1966
|
-
#
|
1967
|
-
# fetchTransfers
|
1968
|
-
# {
|
1969
|
-
# "transfer_id": "890694db-156c-4e93-a3ef-4db61685aca7",
|
1970
|
-
# "created_at": "2023-10-26T14:32:22.000Z",
|
1971
|
-
# "confirmed_at": "2023-10-26T14:32:22.000Z",
|
1972
|
-
# "asset": "USD",
|
1973
|
-
# "amount": "-3.00",
|
1974
|
-
# "status": "confirmed"
|
1975
|
-
# }
|
1976
|
-
#
|
1977
|
-
# transfer - privatePostV1TransfersInternalTransfer
|
1978
|
-
# {
|
1979
|
-
# "from_trader_id": "1f494ace-b3ed-4324-b202-55526ed06381",
|
1980
|
-
# "to_trader_id": "d32c7a40-cc24-44b0-8597-f9edb3da989f",
|
1981
|
-
# "asset": "string",
|
1982
|
-
# "amount": "string"
|
1983
|
-
# }
|
1984
|
-
#
|
1985
|
-
# transfer - privatePostV1TransfersFromWallet, privatePostV1TransfersToWallet
|
1986
|
-
# {
|
1987
|
-
# "transfer_id": "bb34f528-d9b0-47c6-b11f-4d4840b86ee3"
|
1988
|
-
# }
|
1989
|
-
#
|
1990
|
-
currencyId = self.safe_string(transfer, 'asset')
|
1991
|
-
confirmedAt = self.safe_string(transfer, 'confirmed_at')
|
1992
|
-
timetstamp = self.parse8601(confirmedAt)
|
1993
|
-
status = self.safe_string(transfer, 'status')
|
1994
|
-
amountString = self.safe_string(transfer, 'amount')
|
1995
|
-
fromAccount = None
|
1996
|
-
toAccount = None
|
1997
|
-
amount = None
|
1998
|
-
if amountString is not None:
|
1999
|
-
amountIsNegative = Precise.string_lt(amountString, '0')
|
2000
|
-
if amountIsNegative:
|
2001
|
-
fromAccount = 'trading'
|
2002
|
-
toAccount = 'funding'
|
2003
|
-
amountString = Precise.string_neg(amountString)
|
2004
|
-
else:
|
2005
|
-
fromAccount = 'funding'
|
2006
|
-
toAccount = 'trading'
|
2007
|
-
amount = self.parse_number(amountString)
|
2008
|
-
return {
|
2009
|
-
'info': transfer,
|
2010
|
-
'id': self.safe_string(transfer, 'transfer_id'),
|
2011
|
-
'timestamp': timetstamp,
|
2012
|
-
'datetime': self.iso8601(timetstamp),
|
2013
|
-
'currency': self.safe_currency_code(currencyId, currency),
|
2014
|
-
'amount': amount,
|
2015
|
-
'fromAccount': fromAccount,
|
2016
|
-
'toAccount': toAccount,
|
2017
|
-
'status': self.parse_transfer_status(status),
|
2018
|
-
}
|
2019
|
-
|
2020
|
-
def parse_transfer_status(self, status: Str) -> Str:
|
2021
|
-
statuses: dict = {
|
2022
|
-
'confirmed': 'ok',
|
2023
|
-
}
|
2024
|
-
return self.safe_string(statuses, status, status)
|
2025
|
-
|
2026
|
-
async def fetch_deposits_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Transaction]:
|
2027
|
-
"""
|
2028
|
-
fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet
|
2029
|
-
|
2030
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-coinlist-wallet-ledger
|
2031
|
-
|
2032
|
-
:param str [code]: unified currency code for the currency of the deposit/withdrawals
|
2033
|
-
:param int [since]: timestamp in ms of the earliest deposit/withdrawal
|
2034
|
-
:param int [limit]: max number of deposit/withdrawals to return(default 200, max 500)
|
2035
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2036
|
-
:returns dict: a list of `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2037
|
-
"""
|
2038
|
-
if code is None:
|
2039
|
-
raise ArgumentsRequired(self.id + ' fetchDepositsWithdrawals() requires a code argument')
|
2040
|
-
traderId = self.safe_string_2(params, 'trader_id', 'traderId')
|
2041
|
-
if traderId is None:
|
2042
|
-
raise ArgumentsRequired(self.id + ' fetchDepositsWithdrawals() requires a traderId argument in the params')
|
2043
|
-
await self.load_markets()
|
2044
|
-
currency = self.currency(code)
|
2045
|
-
request: dict = {
|
2046
|
-
'asset': currency['id'],
|
2047
|
-
'trader_id': traderId,
|
2048
|
-
}
|
2049
|
-
if limit is not None:
|
2050
|
-
request['count'] = limit
|
2051
|
-
params = self.omit(params, ['trader_id', 'traderId'])
|
2052
|
-
response = await self.privateGetV1AccountsTraderIdWalletLedger(self.extend(request, params))
|
2053
|
-
#
|
2054
|
-
# [
|
2055
|
-
# {
|
2056
|
-
# "id": "2c02db25-e8f2-4271-8222-e110bfd0aa2a",
|
2057
|
-
# "asset": "ETH",
|
2058
|
-
# "amount": "0.01",
|
2059
|
-
# "created_at": "2023-10-20T13:15:37.000Z",
|
2060
|
-
# "description": "Transfer to CoinList Pro",
|
2061
|
-
# "type": "PRO_TRANSFER",
|
2062
|
-
# "delta": "-0.010000000000000000"
|
2063
|
-
# },
|
2064
|
-
# {
|
2065
|
-
# "id": "7139384d-6cec-479e-a19c-d498647ccb47",
|
2066
|
-
# "asset": "ETH",
|
2067
|
-
# "amount": "0.01",
|
2068
|
-
# "created_at": "2023-10-20T13:10:55.000Z",
|
2069
|
-
# "description": "CRYPTO_DEPOSIT",
|
2070
|
-
# "type": "CRYPTO_DEPOSIT",
|
2071
|
-
# "delta": "0.010000000000000000"
|
2072
|
-
# },
|
2073
|
-
#
|
2074
|
-
# ...
|
2075
|
-
#
|
2076
|
-
# {
|
2077
|
-
# "id": "91bbbb22-5ede-4e9a-81ef-3f9318aa83d2",
|
2078
|
-
# "asset": "USDT",
|
2079
|
-
# "amount": "4.169654",
|
2080
|
-
# "withdrawal_fee_amount": "8.830346000000000000",
|
2081
|
-
# "created_at": "2023-10-27T16:14:11.000Z",
|
2082
|
-
# "description": "CRYPTO_WITHDRAWAL",
|
2083
|
-
# "type": "CRYPTO_WITHDRAWAL",
|
2084
|
-
# "delta": "-4.169654000000000000"
|
2085
|
-
# },
|
2086
|
-
# {
|
2087
|
-
# "id": "830261bd-cda9-401f-b6df-105f4da3b37c",
|
2088
|
-
# "asset": "USDT",
|
2089
|
-
# "amount": "13",
|
2090
|
-
# "created_at": "2023-10-27T14:52:05.000Z",
|
2091
|
-
# "description": "Transfer from CoinList Pro",
|
2092
|
-
# "type": "PRO_TRANSFER",
|
2093
|
-
# "delta": "13.000000000000000000"
|
2094
|
-
# }
|
2095
|
-
# ]
|
2096
|
-
#
|
2097
|
-
# coinlist returns both internal transfers and blockchain transactions
|
2098
|
-
return self.parse_transactions(response, currency, since, limit)
|
2099
|
-
|
2100
|
-
async def withdraw(self, code: str, amount: float, address: str, tag=None, params={}) -> Transaction:
|
2101
|
-
"""
|
2102
|
-
request a withdrawal from CoinList wallet.(Disabled by default. Contact CoinList to apply for an exception.)
|
2103
|
-
|
2104
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#request-withdrawal-from-wallet
|
2105
|
-
|
2106
|
-
:param str code: unified currency code
|
2107
|
-
:param float amount: the amount to withdraw
|
2108
|
-
:param str address: the address to withdraw to
|
2109
|
-
:param str tag:
|
2110
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2111
|
-
:returns dict: a `transaction structure <https://docs.ccxt.com/#/?id=transaction-structure>`
|
2112
|
-
"""
|
2113
|
-
await self.load_markets()
|
2114
|
-
currency = self.currency(code)
|
2115
|
-
request: dict = {
|
2116
|
-
'asset': currency['id'],
|
2117
|
-
'amount': self.currency_to_precision(code, amount),
|
2118
|
-
'destination_address': address,
|
2119
|
-
}
|
2120
|
-
response = await self.privatePostV1TransfersWithdrawalRequest(self.extend(request, params))
|
2121
|
-
#
|
2122
|
-
# {
|
2123
|
-
# "transfer_id": "d4a2d8dd-7def-4545-a062-761683b9aa05"
|
2124
|
-
# }
|
2125
|
-
#
|
2126
|
-
data = self.safe_dict(response, 'data', {})
|
2127
|
-
return self.parse_transaction(data, currency)
|
2128
|
-
|
2129
|
-
def parse_transaction(self, transaction: dict, currency: Currency = None) -> Transaction:
|
2130
|
-
# withdraw
|
2131
|
-
#
|
2132
|
-
# {
|
2133
|
-
# "transfer_id": "d4a2d8dd-7def-4545-a062-761683b9aa05"
|
2134
|
-
# }
|
2135
|
-
#
|
2136
|
-
# fetchDepositsWithdrawals
|
2137
|
-
# {
|
2138
|
-
# "id": "91bbbb22-5ede-4e9a-81ef-3f9318aa83d2",
|
2139
|
-
# "asset": "USDT",
|
2140
|
-
# "amount": "4.169654",
|
2141
|
-
# "withdrawal_fee_amount": "8.830346000000000000",
|
2142
|
-
# "created_at": "2023-10-27T16:14:11.000Z",
|
2143
|
-
# "description": "CRYPTO_WITHDRAWAL",
|
2144
|
-
# "type": "CRYPTO_WITHDRAWAL",
|
2145
|
-
# "delta": "-4.169654000000000000"
|
2146
|
-
# },
|
2147
|
-
#
|
2148
|
-
currencyId = self.safe_string(transaction, 'asset')
|
2149
|
-
code = self.safe_currency_code(currencyId, currency)
|
2150
|
-
id = self.safe_string_2(transaction, 'id', 'transfer_id')
|
2151
|
-
amount = self.safe_number(transaction, 'amount')
|
2152
|
-
timestamp = self.parse8601(self.safe_string(transaction, 'created_at'))
|
2153
|
-
type = self.safe_string(transaction, 'type', None)
|
2154
|
-
if type is None:
|
2155
|
-
type = 'withdrawal' # None only in withdraw() method
|
2156
|
-
else:
|
2157
|
-
type = self.parse_transaction_type(type)
|
2158
|
-
fee = None
|
2159
|
-
feeCost = self.safe_string(transaction, 'withdrawal_fee_amount')
|
2160
|
-
if feeCost is not None:
|
2161
|
-
fee = {
|
2162
|
-
'cost': feeCost,
|
2163
|
-
'currency': code,
|
2164
|
-
}
|
2165
|
-
return {
|
2166
|
-
'info': transaction,
|
2167
|
-
'id': id,
|
2168
|
-
'txid': None,
|
2169
|
-
'timestamp': timestamp,
|
2170
|
-
'datetime': self.iso8601(timestamp),
|
2171
|
-
'network': None,
|
2172
|
-
'addressFrom': None,
|
2173
|
-
'address': None,
|
2174
|
-
'addressTo': None,
|
2175
|
-
'tagFrom': None,
|
2176
|
-
'tag': None,
|
2177
|
-
'tagTo': None,
|
2178
|
-
'type': type,
|
2179
|
-
'amount': amount,
|
2180
|
-
'currency': code,
|
2181
|
-
'status': None,
|
2182
|
-
'updated': None,
|
2183
|
-
'fee': fee,
|
2184
|
-
'comment': self.safe_string(transaction, 'description'),
|
2185
|
-
'internal': None,
|
2186
|
-
}
|
2187
|
-
|
2188
|
-
def parse_transaction_type(self, type):
|
2189
|
-
types: dict = {
|
2190
|
-
'CRYPTO_DEPOSIT': 'deposit',
|
2191
|
-
'CRYPTO_WITHDRAWAL': 'withdrawal',
|
2192
|
-
'PRO_TRANSFER': 'transfer',
|
2193
|
-
}
|
2194
|
-
return self.safe_string(types, type, type)
|
2195
|
-
|
2196
|
-
async def fetch_ledger(self, code: Str = None, since: Int = None, limit: Int = None, params={}) -> List[LedgerEntry]:
|
2197
|
-
"""
|
2198
|
-
fetch the history of changes, actions done by the user or operations that altered the balance of the user
|
2199
|
-
|
2200
|
-
https://trade-docs.coinlist.co/?javascript--nodejs#get-account-history
|
2201
|
-
|
2202
|
-
:param str [code]: unified currency code, default is None
|
2203
|
-
:param int [since]: timestamp in ms of the earliest ledger entry, default is None
|
2204
|
-
:param int [limit]: max number of ledger entries to return(default 200, max 500)
|
2205
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2206
|
-
:param int [params.until]: the latest time in ms to fetch entries for
|
2207
|
-
:returns dict: a `ledger structure <https://docs.ccxt.com/#/?id=ledger>`
|
2208
|
-
"""
|
2209
|
-
traderId = self.safe_string_2(params, 'trader_id', 'traderId')
|
2210
|
-
if traderId is None:
|
2211
|
-
raise ArgumentsRequired(self.id + ' fetchLedger() requires a traderId argument in the params')
|
2212
|
-
await self.load_markets()
|
2213
|
-
request: dict = {
|
2214
|
-
'trader_id': traderId,
|
2215
|
-
}
|
2216
|
-
currency = None
|
2217
|
-
if code is not None:
|
2218
|
-
currency = self.currency(code)
|
2219
|
-
if since is not None:
|
2220
|
-
request['start_time'] = self.iso8601(since)
|
2221
|
-
if limit is not None:
|
2222
|
-
request['count'] = limit
|
2223
|
-
until = self.safe_integer(params, 'until')
|
2224
|
-
if until is not None:
|
2225
|
-
params = self.omit(params, ['until'])
|
2226
|
-
request['end_time'] = self.iso8601(until)
|
2227
|
-
params = self.omit(params, ['trader_id', 'traderId'])
|
2228
|
-
response = await self.privateGetV1AccountsTraderIdLedger(self.extend(request, params))
|
2229
|
-
#
|
2230
|
-
# {
|
2231
|
-
# "transactions": [
|
2232
|
-
# {
|
2233
|
-
# "transaction_id": "0288634e-49bd-494d-b04a-18fd1832d394",
|
2234
|
-
# "transaction_type": "XFER",
|
2235
|
-
# "type": "deposit",
|
2236
|
-
# "asset": "ETH",
|
2237
|
-
# "symbol": null,
|
2238
|
-
# "amount": "0.010000000000000000",
|
2239
|
-
# "details": null,
|
2240
|
-
# "created_at": "2023-10-20T13:15:39.443Z"
|
2241
|
-
# },
|
2242
|
-
# {
|
2243
|
-
# "transaction_id": "47a45928-abcd-4c12-8bd6-587c3028025f",
|
2244
|
-
# "transaction_type": "SWAP",
|
2245
|
-
# "type": "atomic token swap",
|
2246
|
-
# "asset": "USDT",
|
2247
|
-
# "symbol": "ETH-USDT",
|
2248
|
-
# "amount": "1.447947",
|
2249
|
-
# "details": null,
|
2250
|
-
# "created_at": "2023-10-20T13:16:30.373Z"
|
2251
|
-
# },
|
2252
|
-
# {
|
2253
|
-
# "transaction_id": "1ffe3a54-916e-41f0-b957-3a01309eb009",
|
2254
|
-
# "transaction_type": "FEE",
|
2255
|
-
# "type": "fee",
|
2256
|
-
# "asset": "USDT",
|
2257
|
-
# "symbol": "ETH-USDT",
|
2258
|
-
# "amount": "-0.006516",
|
2259
|
-
# "details": {
|
2260
|
-
# "fee_details": [
|
2261
|
-
# {
|
2262
|
-
# "insurance_fee": "0",
|
2263
|
-
# "order_id": "39911d5f-c789-4a7d-ad34-820a804d1da6",
|
2264
|
-
# "fee_type": "taker",
|
2265
|
-
# "fee_currency": "USDT"
|
2266
|
-
# }
|
2267
|
-
# ]
|
2268
|
-
# },
|
2269
|
-
# "created_at": "2023-10-20T13:16:30.373Z"
|
2270
|
-
# },
|
2271
|
-
# {
|
2272
|
-
# "transaction_id": "3930e8a3-2218-481f-8c3c-2219287e205e",
|
2273
|
-
# "transaction_type": "SWAP",
|
2274
|
-
# "type": "atomic token swap",
|
2275
|
-
# "asset": "ETH",
|
2276
|
-
# "symbol": "ETH-USDT",
|
2277
|
-
# "amount": "-0.000900000000000000",
|
2278
|
-
# "details": null,
|
2279
|
-
# "created_at": "2023-10-20T13:16:30.373Z"
|
2280
|
-
# },
|
2281
|
-
# {
|
2282
|
-
# "transaction_id": "a6c65cb3-95d0-44e2-8202-f70581d6e55c",
|
2283
|
-
# "transaction_type": "XFER",
|
2284
|
-
# "type": "withdrawal",
|
2285
|
-
# "asset": "USD",
|
2286
|
-
# "symbol": null,
|
2287
|
-
# "amount": "-3.00",
|
2288
|
-
# "details": null,
|
2289
|
-
# "created_at": "2023-10-26T14:32:24.887Z"
|
2290
|
-
# }
|
2291
|
-
# ]
|
2292
|
-
# }
|
2293
|
-
#
|
2294
|
-
ledger = self.safe_value(response, 'transactions', [])
|
2295
|
-
return self.parse_ledger(ledger, currency, since, limit)
|
2296
|
-
|
2297
|
-
def parse_ledger_entry(self, item: dict, currency: Currency = None) -> LedgerEntry:
|
2298
|
-
#
|
2299
|
-
# deposit transaction from wallet(funding) to pro(trading)
|
2300
|
-
# {
|
2301
|
-
# "transaction_id": "0288634e-49bd-494d-b04a-18fd1832d394",
|
2302
|
-
# "transaction_type": "XFER",
|
2303
|
-
# "type": "deposit",
|
2304
|
-
# "asset": "ETH",
|
2305
|
-
# "symbol": null,
|
2306
|
-
# "amount": "0.010000000000000000",
|
2307
|
-
# "details": null,
|
2308
|
-
# "created_at": "2023-10-20T13:15:39.443Z"
|
2309
|
-
# }
|
2310
|
-
#
|
2311
|
-
# withdrawal transaction from pro(trading) to wallet(funding)
|
2312
|
-
# {
|
2313
|
-
# "transaction_id": "a6c65cb3-95d0-44e2-8202-f70581d6e55c",
|
2314
|
-
# "transaction_type": "XFER",
|
2315
|
-
# "type": "withdrawal",
|
2316
|
-
# "asset": "USD",
|
2317
|
-
# "symbol": null,
|
2318
|
-
# "amount": "-3.00",
|
2319
|
-
# "details": null,
|
2320
|
-
# "created_at": "2023-10-26T14:32:24.887Z"
|
2321
|
-
# }
|
2322
|
-
#
|
2323
|
-
# sell trade
|
2324
|
-
# {
|
2325
|
-
# "transaction_id": "47a45928-abcd-4c12-8bd6-587c3028025f",
|
2326
|
-
# "transaction_type": "SWAP",
|
2327
|
-
# "type": "atomic token swap",
|
2328
|
-
# "asset": "USDT",
|
2329
|
-
# "symbol": "ETH-USDT",
|
2330
|
-
# "amount": "1.447947",
|
2331
|
-
# "details": null,
|
2332
|
-
# "created_at": "2023-10-20T13:16:30.373Z"
|
2333
|
-
# }
|
2334
|
-
#
|
2335
|
-
# buy trade
|
2336
|
-
# {
|
2337
|
-
# "transaction_id": "46d20a93-45c4-4441-a238-f89602eb8c8c",
|
2338
|
-
# "transaction_type": "SWAP",
|
2339
|
-
# "type": "atomic token swap",
|
2340
|
-
# "asset": "ETH",
|
2341
|
-
# "symbol": "ETH-USDT",
|
2342
|
-
# "amount": "0.000800000000000000",
|
2343
|
-
# "details": null,
|
2344
|
-
# "created_at": "2023-10-20T13:22:14.256Z"
|
2345
|
-
# },
|
2346
|
-
#
|
2347
|
-
# fee
|
2348
|
-
# {
|
2349
|
-
# "transaction_id": "57fd526c-36b1-4721-83ce-42aadcb1e953",
|
2350
|
-
# "transaction_type": "FEE",
|
2351
|
-
# "type": "fee",
|
2352
|
-
# "asset": "USDT",
|
2353
|
-
# "symbol": "BTC-USDT",
|
2354
|
-
# "amount": "-0.047176",
|
2355
|
-
# "details": {
|
2356
|
-
# "fee_details": [
|
2357
|
-
# {
|
2358
|
-
# "insurance_fee": "0",
|
2359
|
-
# "order_id": "c0bc33cd-eeb9-40a0-ab5f-2d99f323ef58",
|
2360
|
-
# "fee_type": "taker",
|
2361
|
-
# "fee_currency": "USDT"
|
2362
|
-
# }
|
2363
|
-
# ]
|
2364
|
-
# },
|
2365
|
-
# "created_at": "2023-10-25T16:46:24.294Z"
|
2366
|
-
# }
|
2367
|
-
#
|
2368
|
-
id = self.safe_string(item, 'transaction_id')
|
2369
|
-
createdAt = self.safe_string(item, 'created_at')
|
2370
|
-
timestamp = self.parse8601(createdAt)
|
2371
|
-
amount = self.safe_string(item, 'amount')
|
2372
|
-
amountIsNegative = Precise.string_lt(amount, '0')
|
2373
|
-
direction = None
|
2374
|
-
if amountIsNegative:
|
2375
|
-
direction = 'out'
|
2376
|
-
amount = Precise.string_neg(amount)
|
2377
|
-
else:
|
2378
|
-
direction = 'in'
|
2379
|
-
currencyId = self.safe_string(item, 'asset')
|
2380
|
-
code = self.safe_currency_code(currencyId, currency)
|
2381
|
-
currency = self.safe_currency(currencyId, currency)
|
2382
|
-
type = self.parse_ledger_entry_type(self.safe_string(item, 'type'))
|
2383
|
-
return self.safe_ledger_entry({
|
2384
|
-
'info': item,
|
2385
|
-
'id': id,
|
2386
|
-
'timestamp': timestamp,
|
2387
|
-
'datetime': self.iso8601(timestamp),
|
2388
|
-
'direction': direction,
|
2389
|
-
'account': 'trading',
|
2390
|
-
'referenceId': None,
|
2391
|
-
'referenceAccount': None,
|
2392
|
-
'type': type,
|
2393
|
-
'currency': code,
|
2394
|
-
'amount': self.parse_number(amount),
|
2395
|
-
'before': None,
|
2396
|
-
'after': None,
|
2397
|
-
'status': 'ok',
|
2398
|
-
'fee': None,
|
2399
|
-
}, currency)
|
2400
|
-
|
2401
|
-
def parse_ledger_entry_type(self, type):
|
2402
|
-
types: dict = {
|
2403
|
-
'atomic token swap': 'trade',
|
2404
|
-
'fee': 'fee',
|
2405
|
-
'deposit': 'transfer',
|
2406
|
-
'withdrawal': 'transfer',
|
2407
|
-
}
|
2408
|
-
return self.safe_string(types, type, type)
|
2409
|
-
|
2410
|
-
async def fetch_funding_rate(self, symbol: str, params={}) -> FundingRate:
|
2411
|
-
"""
|
2412
|
-
fetch the current funding rate
|
2413
|
-
|
2414
|
-
https://trade-docs.coinlist.co/#coinlist-pro-api-Funding-Rates
|
2415
|
-
|
2416
|
-
:param str symbol: unified market symbol
|
2417
|
-
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2418
|
-
:returns dict: a `funding rate structure <https://docs.ccxt.com/#/?id=funding-rate-structure>`
|
2419
|
-
"""
|
2420
|
-
await self.load_markets()
|
2421
|
-
market = self.market(symbol)
|
2422
|
-
if not market['swap']:
|
2423
|
-
raise BadSymbol(self.id + ' fetchFundingRate() supports swap contracts only')
|
2424
|
-
request: dict = {
|
2425
|
-
'symbol': market['id'],
|
2426
|
-
}
|
2427
|
-
response = await self.publicGetV1SymbolsSymbolFunding(self.extend(request, params))
|
2428
|
-
#
|
2429
|
-
# {
|
2430
|
-
# "last": {
|
2431
|
-
# "funding_rate": "-0.00043841",
|
2432
|
-
# "funding_time": "2025-04-15T04:00:00.000Z"
|
2433
|
-
# },
|
2434
|
-
# "next": {
|
2435
|
-
# "funding_rate": "-0.00046952",
|
2436
|
-
# "funding_time": "2025-04-15T12:00:00.000Z"
|
2437
|
-
# },
|
2438
|
-
# "indicative": {
|
2439
|
-
# "funding_rate": "-0.00042517",
|
2440
|
-
# "funding_time": "2025-04-15T20:00:00.000Z"
|
2441
|
-
# },
|
2442
|
-
# "timestamp": "2025-04-15T07:01:15.219Z"
|
2443
|
-
# }
|
2444
|
-
#
|
2445
|
-
return self.parse_funding_rate(response, market)
|
2446
|
-
|
2447
|
-
def parse_funding_rate(self, contract, market: Market = None) -> FundingRate:
|
2448
|
-
#
|
2449
|
-
# {
|
2450
|
-
# "last": {
|
2451
|
-
# "funding_rate": "-0.00043841",
|
2452
|
-
# "funding_time": "2025-04-15T04:00:00.000Z"
|
2453
|
-
# },
|
2454
|
-
# "next": {
|
2455
|
-
# "funding_rate": "-0.00046952",
|
2456
|
-
# "funding_time": "2025-04-15T12:00:00.000Z"
|
2457
|
-
# },
|
2458
|
-
# "indicative": {
|
2459
|
-
# "funding_rate": "-0.00042517",
|
2460
|
-
# "funding_time": "2025-04-15T20:00:00.000Z"
|
2461
|
-
# },
|
2462
|
-
# "timestamp": "2025-04-15T07:01:15.219Z"
|
2463
|
-
# }
|
2464
|
-
#
|
2465
|
-
previous = self.safe_dict(contract, 'last', {})
|
2466
|
-
current = self.safe_dict(contract, 'next', {})
|
2467
|
-
next = self.safe_dict(contract, 'indicative', {})
|
2468
|
-
previousDatetime = self.safe_string(previous, 'funding_time')
|
2469
|
-
currentDatetime = self.safe_string(current, 'funding_time')
|
2470
|
-
nextDatetime = self.safe_string(next, 'funding_time')
|
2471
|
-
datetime = self.safe_string(contract, 'timestamp')
|
2472
|
-
return {
|
2473
|
-
'info': contract,
|
2474
|
-
'symbol': self.safe_symbol(None, market),
|
2475
|
-
'markPrice': None,
|
2476
|
-
'indexPrice': None,
|
2477
|
-
'interestRate': None,
|
2478
|
-
'estimatedSettlePrice': None,
|
2479
|
-
'timestamp': self.parse8601(datetime),
|
2480
|
-
'datetime': datetime,
|
2481
|
-
'fundingRate': self.safe_number(current, 'funding_rate'),
|
2482
|
-
'fundingTimestamp': self.parse8601(currentDatetime),
|
2483
|
-
'fundingDatetime': currentDatetime,
|
2484
|
-
'nextFundingRate': self.safe_number(next, 'funding_rate'),
|
2485
|
-
'nextFundingTimestamp': self.parse8601(nextDatetime),
|
2486
|
-
'nextFundingDatetime': nextDatetime,
|
2487
|
-
'previousFundingRate': self.safe_number(previous, 'funding_rate'),
|
2488
|
-
'previousFundingTimestamp': self.parse8601(previousDatetime),
|
2489
|
-
'previousFundingDatetime': previousDatetime,
|
2490
|
-
'interval': '8h',
|
2491
|
-
}
|
2492
|
-
|
2493
|
-
def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
|
2494
|
-
request = self.omit(params, self.extract_params(path))
|
2495
|
-
endpoint = '/' + self.implode_params(path, params)
|
2496
|
-
url = self.urls['api'][api] + endpoint
|
2497
|
-
isBulk = isinstance(params, list)
|
2498
|
-
query: Str = None
|
2499
|
-
if not isBulk:
|
2500
|
-
query = self.urlencode(request)
|
2501
|
-
if api == 'private':
|
2502
|
-
self.check_required_credentials()
|
2503
|
-
timestamp = str(self.seconds())
|
2504
|
-
auth = timestamp + method + endpoint
|
2505
|
-
if (method == 'POST') or (method == 'PATCH') or isBulk:
|
2506
|
-
body = self.json(request)
|
2507
|
-
auth += body
|
2508
|
-
elif query is not None and len(query) != 0:
|
2509
|
-
auth += '?' + query
|
2510
|
-
url += '?' + query
|
2511
|
-
signature = self.hmac(self.encode(auth), self.base64_to_binary(self.secret), hashlib.sha256, 'base64')
|
2512
|
-
headers = {
|
2513
|
-
'CL-ACCESS-KEY': self.apiKey,
|
2514
|
-
'CL-ACCESS-SIG': signature,
|
2515
|
-
'CL-ACCESS-TIMESTAMP': timestamp,
|
2516
|
-
'Content-Type': 'application/json',
|
2517
|
-
}
|
2518
|
-
elif query is not None and len(query) != 0:
|
2519
|
-
url += '?' + query
|
2520
|
-
return {'url': url, 'method': method, 'body': body, 'headers': headers}
|
2521
|
-
|
2522
|
-
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
2523
|
-
if response is None:
|
2524
|
-
# In some cases the exchange returns 202 Accepted for bad orders.
|
2525
|
-
# The body of that response contains order_id of the order.
|
2526
|
-
# Some bad orders will get status 'rejected' and could be fetched later(by using fetchOrders() or fetchOrder(order_id)).
|
2527
|
-
# While others don't get any status, they simply disappear, but the response is still 202 Accepted and contains their order_id.
|
2528
|
-
# When using fechOrder(order_id) for such disappeared orders, the exchange returns an empty response with code 404.
|
2529
|
-
if (code == 404) and (url.find('/orders/') >= 0) and (method == 'GET'):
|
2530
|
-
parts = url.split('/orders/')
|
2531
|
-
orderId = self.safe_string(parts, 1)
|
2532
|
-
raise OrderNotFound(self.id + ' order ' + orderId + ' not found(or rejected on the exchange side)')
|
2533
|
-
return None
|
2534
|
-
responseCode = self.safe_string(response, 'status')
|
2535
|
-
messageCode = self.safe_string(response, 'message_code')
|
2536
|
-
if (messageCode is not None) or ((responseCode is not None) and (code != 200) and (code != 202) and (responseCode != '200') and (responseCode != '202')):
|
2537
|
-
feedback = self.id + ' ' + body
|
2538
|
-
message = self.safe_string(response, 'message')
|
2539
|
-
self.throw_broadly_matched_exception(self.exceptions['broad'], message, feedback)
|
2540
|
-
self.throw_exactly_matched_exception(self.exceptions['exact'], messageCode, feedback)
|
2541
|
-
raise ExchangeError(feedback)
|
2542
|
-
return None
|