ccxt 4.4.90 → 4.4.91

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