ccxt 4.2.86 → 4.2.87

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 (93) hide show
  1. package/README.md +3 -3
  2. package/build.sh +1 -1
  3. package/dist/ccxt.browser.js +671 -130
  4. package/dist/ccxt.browser.min.js +3 -3
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/ascendex.js +11 -1
  7. package/dist/cjs/src/binance.js +14 -1
  8. package/dist/cjs/src/bingx.js +37 -1
  9. package/dist/cjs/src/bitfinex.js +3 -0
  10. package/dist/cjs/src/bitfinex2.js +16 -1
  11. package/dist/cjs/src/bitflyer.js +19 -0
  12. package/dist/cjs/src/bitget.js +15 -1
  13. package/dist/cjs/src/bitopro.js +3 -0
  14. package/dist/cjs/src/bitrue.js +13 -7
  15. package/dist/cjs/src/bitvavo.js +3 -0
  16. package/dist/cjs/src/btcmarkets.js +1 -1
  17. package/dist/cjs/src/btcturk.js +2 -1
  18. package/dist/cjs/src/coinex.js +182 -54
  19. package/dist/cjs/src/currencycom.js +1 -1
  20. package/dist/cjs/src/delta.js +3 -1
  21. package/dist/cjs/src/digifinex.js +4 -2
  22. package/dist/cjs/src/exmo.js +11 -12
  23. package/dist/cjs/src/gate.js +5 -2
  24. package/dist/cjs/src/hitbtc.js +26 -2
  25. package/dist/cjs/src/htx.js +2 -2
  26. package/dist/cjs/src/huobijp.js +1 -1
  27. package/dist/cjs/src/hyperliquid.js +249 -12
  28. package/dist/cjs/src/idex.js +1 -1
  29. package/dist/cjs/src/krakenfutures.js +2 -6
  30. package/dist/cjs/src/lbank.js +3 -0
  31. package/dist/cjs/src/oceanex.js +1 -1
  32. package/dist/cjs/src/okx.js +24 -10
  33. package/dist/cjs/src/phemex.js +3 -1
  34. package/dist/cjs/src/pro/kucoin.js +11 -6
  35. package/dist/cjs/src/wazirx.js +1 -1
  36. package/dist/cjs/src/zonda.js +3 -0
  37. package/examples/js/benchmark.js +104 -0
  38. package/examples/ts/benchmark.ts +134 -0
  39. package/js/ccxt.d.ts +1 -1
  40. package/js/ccxt.js +1 -1
  41. package/js/src/ascendex.d.ts +5 -12
  42. package/js/src/ascendex.js +11 -1
  43. package/js/src/base/Exchange.d.ts +4 -4
  44. package/js/src/base/types.d.ts +11 -0
  45. package/js/src/binance.d.ts +4 -11
  46. package/js/src/binance.js +14 -1
  47. package/js/src/bingx.d.ts +5 -2
  48. package/js/src/bingx.js +37 -1
  49. package/js/src/bitfinex.js +3 -0
  50. package/js/src/bitfinex2.d.ts +3 -17
  51. package/js/src/bitfinex2.js +16 -1
  52. package/js/src/bitflyer.d.ts +1 -0
  53. package/js/src/bitflyer.js +20 -1
  54. package/js/src/bitget.d.ts +5 -12
  55. package/js/src/bitget.js +15 -1
  56. package/js/src/bitopro.js +3 -0
  57. package/js/src/bitrue.d.ts +3 -17
  58. package/js/src/bitrue.js +13 -7
  59. package/js/src/bitvavo.js +3 -0
  60. package/js/src/btcmarkets.js +1 -1
  61. package/js/src/btcturk.js +2 -1
  62. package/js/src/coinex.d.ts +4 -11
  63. package/js/src/coinex.js +182 -54
  64. package/js/src/currencycom.js +1 -1
  65. package/js/src/delta.d.ts +5 -37
  66. package/js/src/delta.js +3 -1
  67. package/js/src/digifinex.d.ts +5 -13
  68. package/js/src/digifinex.js +4 -2
  69. package/js/src/exmo.d.ts +5 -37
  70. package/js/src/exmo.js +11 -12
  71. package/js/src/gate.d.ts +5 -33
  72. package/js/src/gate.js +5 -2
  73. package/js/src/hitbtc.d.ts +5 -12
  74. package/js/src/hitbtc.js +26 -2
  75. package/js/src/htx.js +2 -2
  76. package/js/src/huobijp.js +1 -1
  77. package/js/src/hyperliquid.d.ts +7 -4
  78. package/js/src/hyperliquid.js +249 -12
  79. package/js/src/idex.js +1 -1
  80. package/js/src/krakenfutures.js +2 -6
  81. package/js/src/kucoinfutures.d.ts +2 -2
  82. package/js/src/lbank.js +3 -0
  83. package/js/src/mexc.d.ts +3 -3
  84. package/js/src/oceanex.js +1 -1
  85. package/js/src/okx.d.ts +5 -33
  86. package/js/src/okx.js +24 -10
  87. package/js/src/phemex.d.ts +3 -11
  88. package/js/src/phemex.js +3 -1
  89. package/js/src/pro/kucoin.js +11 -6
  90. package/js/src/wazirx.js +1 -1
  91. package/js/src/zonda.js +3 -0
  92. package/package.json +3 -2
  93. package/skip-tests.json +3 -3
@@ -1326,6 +1326,9 @@ export default class bitfinex extends Exchange {
1326
1326
  if (limit === undefined) {
1327
1327
  limit = 100;
1328
1328
  }
1329
+ else {
1330
+ limit = Math.min(limit, 10000);
1331
+ }
1329
1332
  const market = this.market(symbol);
1330
1333
  const v2id = 't' + market['id'];
1331
1334
  const request = {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex2.js';
2
- import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num } from './base/types.js';
2
+ import type { TransferEntry, Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation, OrderRequest, Num, MarginModification } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex2
5
5
  * @augments Exchange
@@ -154,22 +154,8 @@ export default class bitfinex2 extends Exchange {
154
154
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
155
155
  fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
156
156
  parseLiquidation(liquidation: any, market?: Market): Liquidation;
157
- setMargin(symbol: string, amount: number, params?: {}): Promise<{
158
- info: any;
159
- type: any;
160
- amount: any;
161
- code: any;
162
- symbol: any;
163
- status: string;
164
- }>;
165
- parseMarginModification(data: any, market?: any): {
166
- info: any;
167
- type: any;
168
- amount: any;
169
- code: any;
170
- symbol: any;
171
- status: string;
172
- };
157
+ setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
158
+ parseMarginModification(data: any, market?: any): MarginModification;
173
159
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
174
160
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
175
161
  }
@@ -1383,6 +1383,9 @@ export default class bitfinex2 extends Exchange {
1383
1383
  if (limit === undefined) {
1384
1384
  limit = 10000;
1385
1385
  }
1386
+ else {
1387
+ limit = Math.min(limit, 10000);
1388
+ }
1386
1389
  let request = {
1387
1390
  'symbol': market['id'],
1388
1391
  'timeframe': this.safeString(this.timeframes, timeframe, timeframe),
@@ -3504,15 +3507,27 @@ export default class bitfinex2 extends Exchange {
3504
3507
  return this.parseMarginModification(data, market);
3505
3508
  }
3506
3509
  parseMarginModification(data, market = undefined) {
3510
+ //
3511
+ // setMargin
3512
+ //
3513
+ // [
3514
+ // [
3515
+ // 1
3516
+ // ]
3517
+ // ]
3518
+ //
3507
3519
  const marginStatusRaw = data[0];
3508
3520
  const marginStatus = (marginStatusRaw === 1) ? 'ok' : 'failed';
3509
3521
  return {
3510
3522
  'info': data,
3523
+ 'symbol': market['symbol'],
3511
3524
  'type': undefined,
3512
3525
  'amount': undefined,
3526
+ 'total': undefined,
3513
3527
  'code': undefined,
3514
- 'symbol': market['symbol'],
3515
3528
  'status': marginStatus,
3529
+ 'timestamp': undefined,
3530
+ 'datetime': undefined,
3516
3531
  };
3517
3532
  }
3518
3533
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -44,4 +44,5 @@ export default class bitflyer extends Exchange {
44
44
  body: any;
45
45
  headers: any;
46
46
  };
47
+ handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
47
48
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bitflyer.js';
9
- import { ExchangeError, ArgumentsRequired, OrderNotFound } from './base/errors.js';
9
+ import { ExchangeError, ArgumentsRequired, OrderNotFound, OnMaintenance } from './base/errors.js';
10
10
  import { TICK_SIZE } from './base/functions/number.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { Precise } from './base/Precise.js';
@@ -117,6 +117,11 @@ export default class bitflyer extends Exchange {
117
117
  },
118
118
  },
119
119
  'precisionMode': TICK_SIZE,
120
+ 'exceptions': {
121
+ 'exact': {
122
+ '-2': OnMaintenance, // {"status":-2,"error_message":"Under maintenance","data":null}
123
+ },
124
+ },
120
125
  });
121
126
  }
122
127
  parseExpiryDate(expiry) {
@@ -1044,4 +1049,18 @@ export default class bitflyer extends Exchange {
1044
1049
  }
1045
1050
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1046
1051
  }
1052
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1053
+ if (response === undefined) {
1054
+ return undefined; // fallback to the default error handler
1055
+ }
1056
+ const feedback = this.id + ' ' + body;
1057
+ // i.e. {"status":-2,"error_message":"Under maintenance","data":null}
1058
+ const errorMessage = this.safeString(response, 'error_message');
1059
+ const statusCode = this.safeNumber(response, 'status');
1060
+ if (errorMessage !== undefined) {
1061
+ this.throwExactlyMatchedException(this.exceptions['exact'], statusCode, feedback);
1062
+ this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
1063
+ }
1064
+ return undefined;
1065
+ }
1047
1066
  }
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitget.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderRequest, FundingHistory, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Market, Strings, Currency, Position, Liquidation, TransferEntry, Leverage, MarginMode, Num, MarginModification } from './base/types.js';
3
3
  /**
4
4
  * @class bitget
5
5
  * @augments Exchange
@@ -146,17 +146,10 @@ export default class bitget extends Exchange {
146
146
  id: string;
147
147
  };
148
148
  parseFundingHistories(contracts: any, market?: any, since?: Int, limit?: Int): FundingHistory[];
149
- modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<any>;
150
- parseMarginModification(data: any, market?: Market): {
151
- info: any;
152
- type: any;
153
- amount: any;
154
- code: string;
155
- symbol: string;
156
- status: string;
157
- };
158
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
159
- addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
149
+ modifyMarginHelper(symbol: string, amount: any, type: any, params?: {}): Promise<MarginModification>;
150
+ parseMarginModification(data: any, market?: Market): MarginModification;
151
+ reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
152
+ addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
160
153
  fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
161
154
  parseLeverage(leverage: any, market?: any): Leverage;
162
155
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
package/js/src/bitget.js CHANGED
@@ -1222,6 +1222,7 @@ export default class bitget extends Exchange {
1222
1222
  '40768': OrderNotFound,
1223
1223
  '41114': OnMaintenance,
1224
1224
  '43011': InvalidOrder,
1225
+ '43012': InsufficientFunds,
1225
1226
  '43025': InvalidOrder,
1226
1227
  '43115': OnMaintenance,
1227
1228
  '45110': InvalidOrder,
@@ -6963,15 +6964,28 @@ export default class bitget extends Exchange {
6963
6964
  });
6964
6965
  }
6965
6966
  parseMarginModification(data, market = undefined) {
6967
+ //
6968
+ // addMargin/reduceMargin
6969
+ //
6970
+ // {
6971
+ // "code": "00000",
6972
+ // "msg": "success",
6973
+ // "requestTime": 1700813444618,
6974
+ // "data": ""
6975
+ // }
6976
+ //
6966
6977
  const errorCode = this.safeString(data, 'code');
6967
6978
  const status = (errorCode === '00000') ? 'ok' : 'failed';
6968
6979
  return {
6969
6980
  'info': data,
6981
+ 'symbol': market['symbol'],
6970
6982
  'type': undefined,
6971
6983
  'amount': undefined,
6984
+ 'total': undefined,
6972
6985
  'code': market['settle'],
6973
- 'symbol': market['symbol'],
6974
6986
  'status': status,
6987
+ 'timestamp': undefined,
6988
+ 'datetime': undefined,
6975
6989
  };
6976
6990
  }
6977
6991
  async reduceMargin(symbol, amount, params = {}) {
package/js/src/bitopro.js CHANGED
@@ -759,6 +759,9 @@ export default class bitopro extends Exchange {
759
759
  if (limit === undefined) {
760
760
  limit = 500;
761
761
  }
762
+ else {
763
+ limit = Math.min(limit, 75000); // supports slightly more than 75k candles atm, but limit here to avoid errors
764
+ }
762
765
  const timeframeInSeconds = this.parseTimeframe(timeframe);
763
766
  let alignedSince = undefined;
764
767
  if (since === undefined) {
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitrue.js';
2
- import type { Balances, Currency, Int, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry } from './base/types.js';
2
+ import type { Balances, Currency, Int, MarginModification, Market, Num, OHLCV, Order, OrderBook, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry } from './base/types.js';
3
3
  /**
4
4
  * @class bitrue
5
5
  * @augments Exchange
@@ -73,22 +73,8 @@ export default class bitrue extends Exchange {
73
73
  fetchTransfers(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
74
74
  transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
75
75
  setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
76
- parseMarginModification(data: any, market?: any): {
77
- info: any;
78
- type: any;
79
- amount: any;
80
- code: any;
81
- symbol: any;
82
- status: any;
83
- };
84
- setMargin(symbol: string, amount: number, params?: {}): Promise<{
85
- info: any;
86
- type: any;
87
- amount: any;
88
- code: any;
89
- symbol: any;
90
- status: any;
91
- }>;
76
+ parseMarginModification(data: any, market?: any): MarginModification;
77
+ setMargin(symbol: string, amount: number, params?: {}): Promise<MarginModification>;
92
78
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
93
79
  url: any;
94
80
  method: string;
package/js/src/bitrue.js CHANGED
@@ -1351,9 +1351,6 @@ export default class bitrue extends Exchange {
1351
1351
  'interval': this.safeString(timeframesFuture, timeframe, '1min'),
1352
1352
  };
1353
1353
  if (limit !== undefined) {
1354
- if (limit > 300) {
1355
- limit = 300;
1356
- }
1357
1354
  request['limit'] = limit;
1358
1355
  }
1359
1356
  if (market['linear']) {
@@ -1372,9 +1369,6 @@ export default class bitrue extends Exchange {
1372
1369
  'scale': this.safeString(timeframesSpot, timeframe, '1m'),
1373
1370
  };
1374
1371
  if (limit !== undefined) {
1375
- if (limit > 1440) {
1376
- limit = 1440;
1377
- }
1378
1372
  request['limit'] = limit;
1379
1373
  }
1380
1374
  if (since !== undefined) {
@@ -3046,13 +3040,25 @@ export default class bitrue extends Exchange {
3046
3040
  return response;
3047
3041
  }
3048
3042
  parseMarginModification(data, market = undefined) {
3043
+ //
3044
+ // setMargin
3045
+ //
3046
+ // {
3047
+ // "code": 0,
3048
+ // "msg": "success"
3049
+ // "data": null
3050
+ // }
3051
+ //
3049
3052
  return {
3050
3053
  'info': data,
3054
+ 'symbol': market['symbol'],
3051
3055
  'type': undefined,
3052
3056
  'amount': undefined,
3057
+ 'total': undefined,
3053
3058
  'code': undefined,
3054
- 'symbol': market['symbol'],
3055
3059
  'status': undefined,
3060
+ 'timestamp': undefined,
3061
+ 'datetime': undefined,
3056
3062
  };
3057
3063
  }
3058
3064
  async setMargin(symbol, amount, params = {}) {
package/js/src/bitvavo.js CHANGED
@@ -935,6 +935,9 @@ export default class bitvavo extends Exchange {
935
935
  if (limit === undefined) {
936
936
  limit = 1440;
937
937
  }
938
+ else {
939
+ limit = Math.min(limit, 1440);
940
+ }
938
941
  request['end'] = this.sum(since, limit * duration * 1000);
939
942
  }
940
943
  [request, params] = this.handleUntilOption('end', request, params);
@@ -541,7 +541,7 @@ export default class btcmarkets extends Exchange {
541
541
  request['from'] = this.iso8601(since);
542
542
  }
543
543
  if (limit !== undefined) {
544
- request['limit'] = limit; // default is 10, max 200
544
+ request['limit'] = Math.min(limit, 200); // default is 10, max 200
545
545
  }
546
546
  const response = await this.publicGetMarketsMarketIdCandles(this.extend(request, params));
547
547
  //
package/js/src/btcturk.js CHANGED
@@ -588,6 +588,7 @@ export default class btcturk extends Exchange {
588
588
  limit = 100; // default value
589
589
  }
590
590
  if (limit !== undefined) {
591
+ limit = Math.min(limit, 11000); // max 11000 candles diapason can be covered
591
592
  if (timeframe === '1y') { // difficult with leap years
592
593
  throw new BadRequest(this.id + ' fetchOHLCV () does not accept a limit parameter when timeframe == "1y"');
593
594
  }
@@ -598,7 +599,7 @@ export default class btcturk extends Exchange {
598
599
  request['to'] = Math.min(request['to'], to);
599
600
  }
600
601
  else {
601
- request['from'] = this.parseToInt(until / 1000) - limitSeconds;
602
+ request['from'] = this.parseToInt(0 / 1000) - limitSeconds;
602
603
  }
603
604
  }
604
605
  const response = await this.graphGetKlinesHistory(this.extend(request, params));
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/coinex.js';
2
- import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num } from './base/types.js';
2
+ import type { Balances, Currency, FundingHistory, FundingRateHistory, Int, Market, OHLCV, Order, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, OrderRequest, TransferEntry, Leverage, Leverages, Num, MarginModification } from './base/types.js';
3
3
  /**
4
4
  * @class coinex
5
5
  * @augments Exchange
@@ -88,16 +88,9 @@ export default class coinex extends Exchange {
88
88
  parseLeverageTiers(response: any, symbols?: Strings, marketIdKey?: any): {};
89
89
  parseMarketLeverageTiers(item: any, market?: Market): any[];
90
90
  modifyMarginHelper(symbol: string, amount: any, addOrReduce: any, params?: {}): Promise<any>;
91
- parseMarginModification(data: any, market?: Market): {
92
- info: any;
93
- type: any;
94
- amount: any;
95
- code: string;
96
- symbol: string;
97
- status: any;
98
- };
99
- addMargin(symbol: string, amount: any, params?: {}): Promise<any>;
100
- reduceMargin(symbol: string, amount: any, params?: {}): Promise<any>;
91
+ parseMarginModification(data: any, market?: Market): MarginModification;
92
+ addMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
93
+ reduceMargin(symbol: string, amount: any, params?: {}): Promise<MarginModification>;
101
94
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
102
95
  fetchFundingRate(symbol: string, params?: {}): Promise<{
103
96
  info: any;