ccxt 4.3.69 → 4.3.70

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 (45) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +5 -5
  3. package/dist/cjs/ccxt.js +3 -1
  4. package/dist/cjs/src/ascendex.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +1 -1
  7. package/dist/cjs/src/blofin.js +63 -6
  8. package/dist/cjs/src/bybit.js +1 -1
  9. package/dist/cjs/src/coinbaseinternational.js +168 -2
  10. package/dist/cjs/src/cryptocom.js +9 -1
  11. package/dist/cjs/src/hitbtc.js +1 -1
  12. package/dist/cjs/src/poloniex.js +1 -0
  13. package/dist/cjs/src/pro/blofin.js +665 -0
  14. package/dist/cjs/src/pro/coinbaseinternational.js +154 -9
  15. package/dist/cjs/src/pro/cryptocom.js +3 -1
  16. package/dist/cjs/src/pro/hitbtc.js +26 -8
  17. package/dist/cjs/src/pro/okx.js +7 -0
  18. package/dist/cjs/src/pro/poloniex.js +37 -12
  19. package/dist/cjs/src/pro/woo.js +5 -4
  20. package/js/ccxt.d.ts +4 -1
  21. package/js/ccxt.js +3 -1
  22. package/js/src/abstract/coinbaseinternational.d.ts +1 -1
  23. package/js/src/ascendex.js +1 -1
  24. package/js/src/base/Exchange.d.ts +1 -0
  25. package/js/src/base/Exchange.js +6 -0
  26. package/js/src/binance.js +1 -1
  27. package/js/src/blofin.d.ts +1 -1
  28. package/js/src/blofin.js +63 -6
  29. package/js/src/bybit.js +1 -1
  30. package/js/src/coinbaseinternational.d.ts +6 -1
  31. package/js/src/coinbaseinternational.js +168 -2
  32. package/js/src/cryptocom.js +10 -2
  33. package/js/src/hitbtc.js +1 -1
  34. package/js/src/poloniex.js +1 -0
  35. package/js/src/pro/blofin.d.ts +39 -0
  36. package/js/src/pro/blofin.js +668 -0
  37. package/js/src/pro/coinbaseinternational.d.ts +5 -1
  38. package/js/src/pro/coinbaseinternational.js +155 -10
  39. package/js/src/pro/cryptocom.js +4 -2
  40. package/js/src/pro/hitbtc.d.ts +1 -1
  41. package/js/src/pro/hitbtc.js +26 -8
  42. package/js/src/pro/okx.js +7 -0
  43. package/js/src/pro/poloniex.js +37 -12
  44. package/js/src/pro/woo.js +5 -4
  45. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -141,6 +141,7 @@ var bitrue$1 = require('./src/pro/bitrue.js');
141
141
  var bitstamp$1 = require('./src/pro/bitstamp.js');
142
142
  var bitvavo$1 = require('./src/pro/bitvavo.js');
143
143
  var blockchaincom$1 = require('./src/pro/blockchaincom.js');
144
+ var blofin$1 = require('./src/pro/blofin.js');
144
145
  var bybit$1 = require('./src/pro/bybit.js');
145
146
  var cex$1 = require('./src/pro/cex.js');
146
147
  var coinbase$1 = require('./src/pro/coinbase.js');
@@ -191,7 +192,7 @@ var xt$1 = require('./src/pro/xt.js');
191
192
 
192
193
  //-----------------------------------------------------------------------------
193
194
  // this is updated by vss.js when building
194
- const version = '4.3.69';
195
+ const version = '4.3.70';
195
196
  Exchange["default"].ccxtVersion = version;
196
197
  const exchanges = {
197
198
  'ace': ace,
@@ -325,6 +326,7 @@ const pro = {
325
326
  'bitstamp': bitstamp$1,
326
327
  'bitvavo': bitvavo$1,
327
328
  'blockchaincom': blockchaincom$1,
329
+ 'blofin': blofin$1,
328
330
  'bybit': bybit$1,
329
331
  'cex': cex$1,
330
332
  'coinbase': coinbase$1,
@@ -3296,7 +3296,7 @@ class ascendex extends ascendex$1 {
3296
3296
  async fetchMarginModes(symbols = undefined, params = {}) {
3297
3297
  /**
3298
3298
  * @method
3299
- * @name ascendex#fetchMarginMode
3299
+ * @name ascendex#fetchMarginModes
3300
3300
  * @description fetches the set margin mode of the user
3301
3301
  * @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#position
3302
3302
  * @param {string[]} [symbols] a list of unified market symbols
@@ -1661,6 +1661,12 @@ class Exchange {
1661
1661
  handleDelta(bookside, delta) {
1662
1662
  throw new errors.NotSupported(this.id + ' handleDelta not supported yet');
1663
1663
  }
1664
+ handleDeltasWithKeys(bookSide, deltas, priceKey = 0, amountKey = 1, countOrIdKey = 2) {
1665
+ for (let i = 0; i < deltas.length; i++) {
1666
+ const bidAsk = this.parseBidAsk(deltas[i], priceKey, amountKey, countOrIdKey);
1667
+ bookSide.storeArray(bidAsk);
1668
+ }
1669
+ }
1664
1670
  getCacheIndex(orderbook, deltas) {
1665
1671
  // return the first index of the cache that can be applied to the orderbook or -1 if not possible
1666
1672
  return -1;
@@ -12636,7 +12636,7 @@ class binance extends binance$1 {
12636
12636
  async fetchMarginModes(symbols = undefined, params = {}) {
12637
12637
  /**
12638
12638
  * @method
12639
- * @name binance#fetchMarginMode
12639
+ * @name binance#fetchMarginModes
12640
12640
  * @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
12641
12641
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
12642
12642
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
@@ -20,6 +20,7 @@ class blofin extends blofin$1 {
20
20
  'countries': ['US'],
21
21
  'version': 'v1',
22
22
  'rateLimit': 100,
23
+ 'pro': true,
23
24
  'has': {
24
25
  'CORS': undefined,
25
26
  'spot': false,
@@ -94,7 +95,7 @@ class blofin extends blofin$1 {
94
95
  'fetchOpenInterestHistory': false,
95
96
  'fetchOpenOrder': undefined,
96
97
  'fetchOpenOrders': true,
97
- 'fetchOrder': true,
98
+ 'fetchOrder': undefined,
98
99
  'fetchOrderBook': true,
99
100
  'fetchOrderBooks': false,
100
101
  'fetchOrders': false,
@@ -144,11 +145,12 @@ class blofin extends blofin$1 {
144
145
  '2h': '2H',
145
146
  '4h': '4H',
146
147
  '6h': '6H',
148
+ '8h': '8H',
147
149
  '12h': '12H',
148
150
  '1d': '1D',
151
+ '3d': '3D',
149
152
  '1w': '1W',
150
153
  '1M': '1M',
151
- '3M': '3M',
152
154
  },
153
155
  'hostname': 'www.blofin.com',
154
156
  'urls': {
@@ -489,6 +491,25 @@ class blofin extends blofin$1 {
489
491
  return this.parseOrderBook(first, symbol, timestamp);
490
492
  }
491
493
  parseTicker(ticker, market = undefined) {
494
+ //
495
+ // response similar for REST & WS
496
+ //
497
+ // {
498
+ // instId: "ADA-USDT",
499
+ // ts: "1707736811486",
500
+ // last: "0.5315",
501
+ // lastSize: "4",
502
+ // askPrice: "0.5318",
503
+ // askSize: "248",
504
+ // bidPrice: "0.5315",
505
+ // bidSize: "63",
506
+ // open24h: "0.5555",
507
+ // high24h: "0.5563",
508
+ // low24h: "0.5315",
509
+ // volCurrency24h: "198560100",
510
+ // vol24h: "1985601",
511
+ // }
512
+ //
492
513
  const timestamp = this.safeInteger(ticker, 'ts');
493
514
  const marketId = this.safeString(ticker, 'instId');
494
515
  market = this.safeMarket(marketId, market, '-');
@@ -561,7 +582,8 @@ class blofin extends blofin$1 {
561
582
  }
562
583
  parseTrade(trade, market = undefined) {
563
584
  //
564
- // fetch trades
585
+ // fetch trades (response similar for REST & WS)
586
+ //
565
587
  // {
566
588
  // "tradeId": "3263934920",
567
589
  // "instId": "LTC-USDT",
@@ -570,6 +592,7 @@ class blofin extends blofin$1 {
570
592
  // "side": "buy",
571
593
  // "ts": "1707232020854"
572
594
  // }
595
+ //
573
596
  // my trades
574
597
  // {
575
598
  // "instId": "LTC-USDT",
@@ -848,10 +871,12 @@ class blofin extends blofin$1 {
848
871
  return this.parseFundingBalance(response);
849
872
  }
850
873
  else {
851
- return this.parseTradingBalance(response);
874
+ return this.parseBalance(response);
852
875
  }
853
876
  }
854
- parseTradingBalance(response) {
877
+ parseBalance(response) {
878
+ //
879
+ // "data" similar for REST & WS
855
880
  //
856
881
  // {
857
882
  // "code": "0",
@@ -873,7 +898,8 @@ class blofin extends blofin$1 {
873
898
  // "orderFrozen": "14920.994472632597427761",
874
899
  // "equityUsd": "10011254.077985990315787910",
875
900
  // "isolatedUnrealizedPnl": "-22.151999999999999999952",
876
- // "bonus": "0"
901
+ // "bonus": "0" // present only in REST
902
+ // "unrealizedPnl": "0" // present only in WS
877
903
  // }
878
904
  // ]
879
905
  // }
@@ -1035,6 +1061,8 @@ class blofin extends blofin$1 {
1035
1061
  return this.safeString(statuses, status, status);
1036
1062
  }
1037
1063
  parseOrder(order, market = undefined) {
1064
+ //
1065
+ // response similar for REST & WS
1038
1066
  //
1039
1067
  // {
1040
1068
  // "orderId": "2075628533",
@@ -1063,6 +1091,9 @@ class blofin extends blofin$1 {
1063
1091
  // "cancelSource": "not_canceled",
1064
1092
  // "cancelSourceReason": null,
1065
1093
  // "brokerId": "ec6dd3a7dd982d0b"
1094
+ // "filled_amount": "1.000000000000000000", // filledAmount in "ws" watchOrders
1095
+ // "cancelSource": "", // only in WS
1096
+ // "instType": "SWAP", // only in WS
1066
1097
  // }
1067
1098
  //
1068
1099
  const id = this.safeString2(order, 'tpslId', 'orderId');
@@ -1812,6 +1843,32 @@ class blofin extends blofin$1 {
1812
1843
  return this.filterByArrayPositions(result, 'symbol', symbols, false);
1813
1844
  }
1814
1845
  parsePosition(position, market = undefined) {
1846
+ //
1847
+ // response similar for REST & WS
1848
+ //
1849
+ // {
1850
+ // instType: 'SWAP',
1851
+ // instId: 'LTC-USDT',
1852
+ // marginMode: 'cross',
1853
+ // positionId: '644159',
1854
+ // positionSide: 'net',
1855
+ // positions: '1',
1856
+ // availablePositions: '1',
1857
+ // averagePrice: '68.16',
1858
+ // unrealizedPnl: '0.80631223',
1859
+ // unrealizedPnlRatio: '0.03548909463028169',
1860
+ // leverage: '3',
1861
+ // liquidationPrice: '10.116655172370356435',
1862
+ // markPrice: '68.96',
1863
+ // initialMargin: '22.988770743333333333',
1864
+ // margin: '', // this field might not exist in rest response
1865
+ // marginRatio: '152.523509620342499273',
1866
+ // maintenanceMargin: '0.34483156115',
1867
+ // adl: '4',
1868
+ // createTime: '1707235776528',
1869
+ // updateTime: '1707235776528'
1870
+ // }
1871
+ //
1815
1872
  const marketId = this.safeString(position, 'instId');
1816
1873
  market = this.safeMarket(marketId, market);
1817
1874
  const symbol = market['symbol'];
@@ -8198,7 +8198,7 @@ class bybit extends bybit$1 {
8198
8198
  const quoteValueString = Precise["default"].stringMul(baseValueString, priceString);
8199
8199
  return this.safeLiquidation({
8200
8200
  'info': liquidation,
8201
- 'symbol': this.safeSymbol(marketId, market),
8201
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
8202
8202
  'contracts': this.parseNumber(contractsString),
8203
8203
  'contractSize': this.parseNumber(contractSizeString),
8204
8204
  'price': this.parseNumber(priceString),
@@ -83,7 +83,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
83
83
  'fetchMyBuys': true,
84
84
  'fetchMySells': true,
85
85
  'fetchMyTrades': true,
86
- 'fetchOHLCV': false,
86
+ 'fetchOHLCV': true,
87
87
  'fetchOpenInterestHistory': false,
88
88
  'fetchOpenOrders': true,
89
89
  'fetchOrder': true,
@@ -102,6 +102,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
102
102
  'fetchTrades': false,
103
103
  'fetchTradingFee': false,
104
104
  'fetchTradingFees': false,
105
+ 'fetchTransfers': true,
105
106
  'fetchWithdrawals': true,
106
107
  'reduceMargin': false,
107
108
  'sandbox': true,
@@ -144,7 +145,7 @@ class coinbaseinternational extends coinbaseinternational$1 {
144
145
  'instruments/{instrument}',
145
146
  'instruments/{instrument}/quote',
146
147
  'instruments/{instrument}/funding',
147
- '',
148
+ 'instruments/{instrument}/candles',
148
149
  ],
149
150
  },
150
151
  'private': {
@@ -352,6 +353,81 @@ class coinbaseinternational extends coinbaseinternational$1 {
352
353
  'info': account,
353
354
  };
354
355
  }
356
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = 100, params = {}) {
357
+ /**
358
+ * @method
359
+ * @name coinbaseinternational#fetchOHLCV
360
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
361
+ * @see https://docs.cdp.coinbase.com/intx/reference/getinstrumentcandles
362
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
363
+ * @param {string} timeframe the length of time each candle represents
364
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
365
+ * @param {int} [limit] the maximum amount of candles to fetch, default 100 max 10000
366
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
367
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
368
+ * @param {int} [params.until] timestamp in ms of the latest candle to fetch
369
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
370
+ */
371
+ await this.loadMarkets();
372
+ let paginate = false;
373
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
374
+ if (paginate) {
375
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 10000);
376
+ }
377
+ const market = this.market(symbol);
378
+ const request = {
379
+ 'instrument': market['id'],
380
+ 'granularity': this.safeString(this.timeframes, timeframe, timeframe),
381
+ };
382
+ if (since !== undefined) {
383
+ request['start'] = this.iso8601(since);
384
+ }
385
+ else {
386
+ throw new errors.ArgumentsRequired(this.id + ' fetchOHLCV() requires a since argument');
387
+ }
388
+ const unitl = this.safeInteger(params, 'until');
389
+ if (unitl !== undefined) {
390
+ params = this.omit(params, 'until');
391
+ request['end'] = this.iso8601(unitl);
392
+ }
393
+ const response = await this.v1PublicGetInstrumentsInstrumentCandles(this.extend(request, params));
394
+ //
395
+ // {
396
+ // "aggregations": [
397
+ // {
398
+ // "start": "2024-04-23T00:00:00Z",
399
+ // "open": "62884.4",
400
+ // "high": "64710.6",
401
+ // "low": "62884.4",
402
+ // "close": "63508.4",
403
+ // "volume": "3253.9983"
404
+ // }
405
+ // ]
406
+ // }
407
+ //
408
+ const candles = this.safeList(response, 'aggregations', []);
409
+ return this.parseOHLCVs(candles, market, timeframe, since, limit);
410
+ }
411
+ parseOHLCV(ohlcv, market = undefined) {
412
+ //
413
+ // {
414
+ // "start": "2024-04-23T00:00:00Z",
415
+ // "open": "62884.4",
416
+ // "high": "64710.6",
417
+ // "low": "62884.4",
418
+ // "close": "63508.4",
419
+ // "volume": "3253.9983"
420
+ // }
421
+ //
422
+ return [
423
+ this.parse8601(this.safeString2(ohlcv, 'start', 'time')),
424
+ this.safeNumber(ohlcv, 'open'),
425
+ this.safeNumber(ohlcv, 'high'),
426
+ this.safeNumber(ohlcv, 'low'),
427
+ this.safeNumber(ohlcv, 'close'),
428
+ this.safeNumber(ohlcv, 'volume'),
429
+ ];
430
+ }
355
431
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
356
432
  /**
357
433
  * @method
@@ -517,6 +593,96 @@ class coinbaseinternational extends coinbaseinternational$1 {
517
593
  'rate': undefined,
518
594
  };
519
595
  }
596
+ async fetchTransfers(code = undefined, since = undefined, limit = undefined, params = {}) {
597
+ /**
598
+ * @method
599
+ * @name coinbaseinternational#fetchTransfers
600
+ * @description fetch a history of internal transfers made on an account
601
+ * @see https://docs.cdp.coinbase.com/intx/reference/gettransfers
602
+ * @param {string} code unified currency code of the currency transferred
603
+ * @param {int} [since] the earliest time in ms to fetch transfers for
604
+ * @param {int} [limit] the maximum number of transfers structures to retrieve
605
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
606
+ * @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/#/?id=transfer-structure}
607
+ */
608
+ await this.loadMarkets();
609
+ const request = {
610
+ 'type': 'INTERNAL',
611
+ };
612
+ let currency = undefined;
613
+ if (code !== undefined) {
614
+ currency = this.currency(code);
615
+ }
616
+ let portfolios = undefined;
617
+ [portfolios, params] = this.handleOptionAndParams(params, 'fetchTransfers', 'portfolios');
618
+ if (portfolios !== undefined) {
619
+ request['portfolios'] = portfolios;
620
+ }
621
+ if (since !== undefined) {
622
+ request['time_from'] = this.iso8601(since);
623
+ }
624
+ if (limit !== undefined) {
625
+ request['result_limit'] = limit;
626
+ }
627
+ else {
628
+ request['result_limit'] = 100;
629
+ }
630
+ const response = await this.v1PrivateGetTransfers(this.extend(request, params));
631
+ const transfers = this.safeList(response, 'results', []);
632
+ return this.parseTransfers(transfers, currency, since, limit);
633
+ }
634
+ parseTransfer(transfer, currency = undefined) {
635
+ //
636
+ // {
637
+ // "amount":"0.0008",
638
+ // "asset":"USDC",
639
+ // "created_at":"2024-02-22T16:00:00Z",
640
+ // "from_portfolio":{
641
+ // "id":"13yuk1fs-1-0",
642
+ // "name":"Eng Test Portfolio - 2",
643
+ // "uuid":"018712f2-5ff9-7de3-9010-xxxxxxxxx"
644
+ // },
645
+ // "instrument_id":"149264164756389888",
646
+ // "instrument_symbol":"ETH-PERP",
647
+ // "position_id":"1xy4v51m-1-2",
648
+ // "status":"PROCESSED",
649
+ // "to_portfolio":{
650
+ // "name":"CB_FUND"
651
+ // },
652
+ // "transfer_type":"FUNDING",
653
+ // "transfer_uuid":"a6b708df-2c44-32c5-bb98-xxxxxxxxxx",
654
+ // "updated_at":"2024-02-22T16:00:00Z"
655
+ // }
656
+ //
657
+ const datetime = this.safeInteger(transfer, 'created_at');
658
+ const timestamp = this.parse8601(datetime);
659
+ const currencyId = this.safeString(transfer, 'asset');
660
+ const code = this.safeCurrencyCode(currencyId);
661
+ const fromPorfolio = this.safeDict(transfer, 'from_portfolio', {});
662
+ const fromId = this.safeString(fromPorfolio, 'id');
663
+ const toPorfolio = this.safeDict(transfer, 'to_portfolio', {});
664
+ const toId = this.safeString(toPorfolio, 'id');
665
+ return {
666
+ 'info': transfer,
667
+ 'id': this.safeString(transfer, 'transfer_uuid'),
668
+ 'timestamp': timestamp,
669
+ 'datetime': this.iso8601(timestamp),
670
+ 'currency': code,
671
+ 'amount': this.safeNumber(transfer, 'amount'),
672
+ 'fromAccount': fromId,
673
+ 'toAccount': toId,
674
+ 'status': this.parseTransferStatus(this.safeString(transfer, 'status')),
675
+ };
676
+ }
677
+ parseTransferStatus(status) {
678
+ const statuses = {
679
+ 'FAILED': 'failed',
680
+ 'PROCESSED': 'ok',
681
+ 'NEW': 'pending',
682
+ 'STARTED': 'pending',
683
+ };
684
+ return this.safeString(statuses, status, status);
685
+ }
520
686
  async createDepositAddress(code, params = {}) {
521
687
  /**
522
688
  * @method
@@ -386,7 +386,15 @@ class cryptocom extends cryptocom$1 {
386
386
  '40006': errors.BadRequest,
387
387
  '40007': errors.BadRequest,
388
388
  '40101': errors.AuthenticationError,
389
- '50001': errors.BadRequest,
389
+ '40102': errors.InvalidNonce,
390
+ '40103': errors.AuthenticationError,
391
+ '40104': errors.AuthenticationError,
392
+ '40107': errors.BadRequest,
393
+ '40401': errors.OrderNotFound,
394
+ '40801': errors.RequestTimeout,
395
+ '42901': errors.RateLimitExceeded,
396
+ '43005': errors.InvalidOrder,
397
+ '50001': errors.ExchangeError,
390
398
  '9010001': errors.OnMaintenance, // {"code":9010001,"message":"SYSTEM_MAINTENANCE","details":"Crypto.com Exchange is currently under maintenance. Please refer to https://status.crypto.com for more details."}
391
399
  },
392
400
  'broad': {},
@@ -2523,7 +2523,7 @@ class hitbtc extends hitbtc$1 {
2523
2523
  async fetchMarginModes(symbols = undefined, params = {}) {
2524
2524
  /**
2525
2525
  * @method
2526
- * @name hitbtc#fetchMarginMode
2526
+ * @name hitbtc#fetchMarginModes
2527
2527
  * @description fetches margin mode of the user
2528
2528
  * @see https://api.hitbtc.com/#get-margin-position-parameters
2529
2529
  * @see https://api.hitbtc.com/#get-futures-position-parameters
@@ -344,6 +344,7 @@ class poloniex extends poloniex$1 {
344
344
  '21350': errors.InvalidOrder,
345
345
  '21355': errors.ExchangeError,
346
346
  '21356': errors.BadRequest,
347
+ '21721': errors.InsufficientFunds,
347
348
  '24101': errors.BadSymbol,
348
349
  '24102': errors.InvalidOrder,
349
350
  '24103': errors.InvalidOrder,