ccxt 4.2.85 → 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 (99) hide show
  1. package/README.md +5 -5
  2. package/dist/ccxt.browser.js +1132 -432
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/ascendex.js +11 -1
  6. package/dist/cjs/src/binance.js +14 -1
  7. package/dist/cjs/src/bingx.js +71 -20
  8. package/dist/cjs/src/bitbank.js +19 -23
  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 +576 -302
  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 +11 -12
  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/okcoin.js +3 -1
  33. package/dist/cjs/src/okx.js +24 -10
  34. package/dist/cjs/src/phemex.js +3 -1
  35. package/dist/cjs/src/pro/bitget.js +1 -0
  36. package/dist/cjs/src/pro/kucoin.js +11 -6
  37. package/dist/cjs/src/wazirx.js +1 -1
  38. package/dist/cjs/src/zonda.js +3 -0
  39. package/examples/js/benchmark.js +104 -0
  40. package/examples/ts/benchmark.ts +134 -0
  41. package/js/ccxt.d.ts +1 -1
  42. package/js/ccxt.js +1 -1
  43. package/js/src/abstract/coinex.d.ts +232 -123
  44. package/js/src/ascendex.d.ts +5 -12
  45. package/js/src/ascendex.js +11 -1
  46. package/js/src/base/Exchange.d.ts +13 -13
  47. package/js/src/base/types.d.ts +11 -0
  48. package/js/src/binance.d.ts +4 -11
  49. package/js/src/binance.js +14 -1
  50. package/js/src/bingx.d.ts +5 -2
  51. package/js/src/bingx.js +71 -20
  52. package/js/src/bitbank.js +19 -23
  53. package/js/src/bitfinex.js +3 -0
  54. package/js/src/bitfinex2.d.ts +3 -17
  55. package/js/src/bitfinex2.js +16 -1
  56. package/js/src/bitflyer.d.ts +1 -0
  57. package/js/src/bitflyer.js +20 -1
  58. package/js/src/bitget.d.ts +5 -12
  59. package/js/src/bitget.js +15 -1
  60. package/js/src/bitopro.js +3 -0
  61. package/js/src/bitrue.d.ts +3 -17
  62. package/js/src/bitrue.js +13 -7
  63. package/js/src/bitvavo.js +3 -0
  64. package/js/src/btcmarkets.js +1 -1
  65. package/js/src/btcturk.js +2 -1
  66. package/js/src/coinex.d.ts +5 -12
  67. package/js/src/coinex.js +576 -302
  68. package/js/src/currencycom.js +1 -1
  69. package/js/src/delta.d.ts +5 -37
  70. package/js/src/delta.js +3 -1
  71. package/js/src/digifinex.d.ts +5 -13
  72. package/js/src/digifinex.js +4 -2
  73. package/js/src/exmo.d.ts +5 -37
  74. package/js/src/exmo.js +11 -12
  75. package/js/src/gate.d.ts +5 -33
  76. package/js/src/gate.js +5 -2
  77. package/js/src/hitbtc.d.ts +5 -12
  78. package/js/src/hitbtc.js +26 -2
  79. package/js/src/htx.js +2 -2
  80. package/js/src/huobijp.js +1 -1
  81. package/js/src/hyperliquid.d.ts +7 -4
  82. package/js/src/hyperliquid.js +249 -12
  83. package/js/src/idex.js +11 -12
  84. package/js/src/krakenfutures.js +2 -6
  85. package/js/src/kucoinfutures.d.ts +2 -2
  86. package/js/src/lbank.js +3 -0
  87. package/js/src/mexc.d.ts +3 -3
  88. package/js/src/oceanex.js +1 -1
  89. package/js/src/okcoin.js +3 -1
  90. package/js/src/okx.d.ts +5 -33
  91. package/js/src/okx.js +24 -10
  92. package/js/src/phemex.d.ts +3 -11
  93. package/js/src/phemex.js +3 -1
  94. package/js/src/pro/bitget.js +1 -0
  95. package/js/src/pro/kucoin.js +11 -6
  96. package/js/src/wazirx.js +1 -1
  97. package/js/src/zonda.js +3 -0
  98. package/package.json +3 -2
  99. package/skip-tests.json +7 -3
package/js/src/bingx.js CHANGED
@@ -33,6 +33,7 @@ export default class bingx extends Exchange {
33
33
  'swap': true,
34
34
  'future': false,
35
35
  'option': false,
36
+ 'addMargin': true,
36
37
  'cancelAllOrders': true,
37
38
  'cancelOrder': true,
38
39
  'cancelOrders': true,
@@ -79,6 +80,7 @@ export default class bingx extends Exchange {
79
80
  'fetchTrades': true,
80
81
  'fetchTransfers': true,
81
82
  'fetchWithdrawals': true,
83
+ 'reduceMargin': true,
82
84
  'setLeverage': true,
83
85
  'setMargin': true,
84
86
  'setMarginMode': true,
@@ -632,7 +634,7 @@ export default class bingx extends Exchange {
632
634
  symbol += ':' + settle;
633
635
  }
634
636
  const fees = this.safeDict(this.fees, type, {});
635
- const contractSize = this.safeNumber(market, 'size');
637
+ const contractSize = (swap) ? this.parseNumber('1') : undefined;
636
638
  const isActive = this.safeString(market, 'status') === '1';
637
639
  const isInverse = (spot) ? undefined : false;
638
640
  const isLinear = (spot) ? undefined : swap;
@@ -673,7 +675,7 @@ export default class bingx extends Exchange {
673
675
  'max': this.safeInteger(market, 'maxLongLeverage'),
674
676
  },
675
677
  'amount': {
676
- 'min': this.safeNumber(market, 'minQty'),
678
+ 'min': this.safeNumber2(market, 'minQty', 'tradeMinQuantity'),
677
679
  'max': this.safeNumber(market, 'maxQty'),
678
680
  },
679
681
  'price': {
@@ -681,7 +683,7 @@ export default class bingx extends Exchange {
681
683
  'max': undefined,
682
684
  },
683
685
  'cost': {
684
- 'min': this.safeNumber(market, 'minNotional'),
686
+ 'min': this.safeNumber2(market, 'minNotional', 'tradeMinUSDT'),
685
687
  'max': this.safeNumber(market, 'maxNotional'),
686
688
  },
687
689
  },
@@ -1038,6 +1040,13 @@ export default class bingx extends Exchange {
1038
1040
  if (isMaker !== undefined) {
1039
1041
  takeOrMaker = isMaker ? 'maker' : 'taker';
1040
1042
  }
1043
+ let amount = this.safeStringN(trade, ['qty', 'amount', 'q']);
1044
+ if ((market !== undefined) && market['swap'] && ('volume' in trade)) {
1045
+ // private trade returns num of contracts instead of base currency (as the order-related methods do)
1046
+ const contractSize = this.safeString(market['info'], 'tradeMinQuantity');
1047
+ const volume = this.safeString(trade, 'volume');
1048
+ amount = Precise.stringMul(volume, contractSize);
1049
+ }
1041
1050
  return this.safeTrade({
1042
1051
  'id': this.safeStringN(trade, ['id', 't']),
1043
1052
  'info': trade,
@@ -1049,7 +1058,7 @@ export default class bingx extends Exchange {
1049
1058
  'side': this.parseOrderSide(side),
1050
1059
  'takerOrMaker': takeOrMaker,
1051
1060
  'price': this.safeString2(trade, 'price', 'p'),
1052
- 'amount': this.safeStringN(trade, ['qty', 'volume', 'amount', 'q']),
1061
+ 'amount': amount,
1053
1062
  'cost': cost,
1054
1063
  'fee': {
1055
1064
  'cost': this.parseNumber(Precise.stringAbs(this.safeString2(trade, 'commission', 'n'))),
@@ -1681,19 +1690,27 @@ export default class bingx extends Exchange {
1681
1690
  }
1682
1691
  parsePosition(position, market = undefined) {
1683
1692
  //
1684
- // {
1685
- // "symbol": "BTC-USDT",
1686
- // "positionId": "12345678",
1687
- // "positionSide": "LONG",
1688
- // "isolated": true,
1689
- // "positionAmt": "123.33",
1690
- // "availableAmt": "128.99",
1691
- // "unrealizedProfit": "1.22",
1692
- // "realisedProfit": "8.1",
1693
- // "initialMargin": "123.33",
1694
- // "avgPrice": "2.2",
1695
- // "leverage": 10,
1696
- // }
1693
+ // {
1694
+ // "positionId":"1773122376147623936",
1695
+ // "symbol":"XRP-USDT",
1696
+ // "currency":"USDT",
1697
+ // "positionAmt":"3",
1698
+ // "availableAmt":"3",
1699
+ // "positionSide":"LONG",
1700
+ // "isolated":false,
1701
+ // "avgPrice":"0.6139",
1702
+ // "initialMargin":"0.0897",
1703
+ // "leverage":20,
1704
+ // "unrealizedProfit":"-0.0023",
1705
+ // "realisedProfit":"-0.0009",
1706
+ // "liquidationPrice":0,
1707
+ // "pnlRatio":"-0.0260",
1708
+ // "maxMarginReduction":"",
1709
+ // "riskRate":"",
1710
+ // "markPrice":"",
1711
+ // "positionValue":"",
1712
+ // "onlyOnePosition":false
1713
+ // }
1697
1714
  //
1698
1715
  // standard position
1699
1716
  //
@@ -1720,7 +1737,7 @@ export default class bingx extends Exchange {
1720
1737
  'info': position,
1721
1738
  'id': this.safeString(position, 'positionId'),
1722
1739
  'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
1723
- 'notional': this.safeNumber(position, 'positionAmt'),
1740
+ 'notional': this.safeNumber(position, 'positionValue'),
1724
1741
  'marginMode': marginMode,
1725
1742
  'liquidationPrice': undefined,
1726
1743
  'entryPrice': this.safeNumber2(position, 'avgPrice', 'entryPrice'),
@@ -1738,7 +1755,7 @@ export default class bingx extends Exchange {
1738
1755
  'lastUpdateTimestamp': undefined,
1739
1756
  'maintenanceMargin': undefined,
1740
1757
  'maintenanceMarginPercentage': undefined,
1741
- 'collateral': this.safeNumber(position, 'positionAmt'),
1758
+ 'collateral': undefined,
1742
1759
  'initialMargin': this.safeNumber(position, 'initialMargin'),
1743
1760
  'initialMarginPercentage': undefined,
1744
1761
  'leverage': this.safeNumber(position, 'leverage'),
@@ -3452,6 +3469,18 @@ export default class bingx extends Exchange {
3452
3469
  };
3453
3470
  return await this.swapV2PrivatePostTradeMarginType(this.extend(request, params));
3454
3471
  }
3472
+ async addMargin(symbol, amount, params = {}) {
3473
+ const request = {
3474
+ 'type': 1,
3475
+ };
3476
+ return await this.setMargin(symbol, amount, this.extend(request, params));
3477
+ }
3478
+ async reduceMargin(symbol, amount, params = {}) {
3479
+ const request = {
3480
+ 'type': 2,
3481
+ };
3482
+ return await this.setMargin(symbol, amount, this.extend(request, params));
3483
+ }
3455
3484
  async setMargin(symbol, amount, params = {}) {
3456
3485
  /**
3457
3486
  * @method
@@ -3486,7 +3515,29 @@ export default class bingx extends Exchange {
3486
3515
  // "type": 1
3487
3516
  // }
3488
3517
  //
3489
- return response;
3518
+ return this.parseMarginModification(response, market);
3519
+ }
3520
+ parseMarginModification(data, market = undefined) {
3521
+ //
3522
+ // {
3523
+ // "code": 0,
3524
+ // "msg": "",
3525
+ // "amount": 1,
3526
+ // "type": 1
3527
+ // }
3528
+ //
3529
+ const type = this.safeString(data, 'type');
3530
+ return {
3531
+ 'info': data,
3532
+ 'symbol': this.safeString(market, 'symbol'),
3533
+ 'type': (type === '1') ? 'add' : 'reduce',
3534
+ 'amount': this.safeNumber(data, 'amount'),
3535
+ 'total': this.safeNumber(data, 'margin'),
3536
+ 'code': this.safeString(market, 'settle'),
3537
+ 'status': undefined,
3538
+ 'timestamp': undefined,
3539
+ 'datetime': undefined,
3540
+ };
3490
3541
  }
3491
3542
  async fetchLeverage(symbol, params = {}) {
3492
3543
  /**
package/js/src/bitbank.js CHANGED
@@ -141,21 +141,23 @@ export default class bitbank extends Exchange {
141
141
  },
142
142
  'precisionMode': TICK_SIZE,
143
143
  'exceptions': {
144
- '20001': AuthenticationError,
145
- '20002': AuthenticationError,
146
- '20003': AuthenticationError,
147
- '20005': AuthenticationError,
148
- '20004': InvalidNonce,
149
- '40020': InvalidOrder,
150
- '40021': InvalidOrder,
151
- '40025': ExchangeError,
152
- '40013': OrderNotFound,
153
- '40014': OrderNotFound,
154
- '50008': PermissionDenied,
155
- '50009': OrderNotFound,
156
- '50010': OrderNotFound,
157
- '60001': InsufficientFunds,
158
- '60005': InvalidOrder,
144
+ 'exact': {
145
+ '20001': AuthenticationError,
146
+ '20002': AuthenticationError,
147
+ '20003': AuthenticationError,
148
+ '20005': AuthenticationError,
149
+ '20004': InvalidNonce,
150
+ '40020': InvalidOrder,
151
+ '40021': InvalidOrder,
152
+ '40025': ExchangeError,
153
+ '40013': OrderNotFound,
154
+ '40014': OrderNotFound,
155
+ '50008': PermissionDenied,
156
+ '50009': OrderNotFound,
157
+ '50010': OrderNotFound,
158
+ '60001': InsufficientFunds,
159
+ '60005': InvalidOrder,
160
+ },
159
161
  },
160
162
  });
161
163
  }
@@ -986,16 +988,10 @@ export default class bitbank extends Exchange {
986
988
  '70009': 'We are currently temporarily restricting orders to be carried out. Please use the limit order.',
987
989
  '70010': 'We are temporarily raising the minimum order quantity as the system load is now rising.',
988
990
  };
989
- const errorClasses = this.exceptions;
990
991
  const code = this.safeString(data, 'code');
991
992
  const message = this.safeString(errorMessages, code, 'Error');
992
- const ErrorClass = this.safeValue(errorClasses, code);
993
- if (ErrorClass !== undefined) {
994
- throw new errorClasses[code](message);
995
- }
996
- else {
997
- throw new ExchangeError(this.id + ' ' + this.json(response));
998
- }
993
+ this.throwExactlyMatchedException(this.exceptions['exact'], code, message);
994
+ throw new ExchangeError(this.id + ' ' + this.json(response));
999
995
  }
1000
996
  return undefined;
1001
997
  }
@@ -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;
@@ -211,7 +204,7 @@ export default class coinex extends Exchange {
211
204
  parseLeverage(leverage: any, market?: any): Leverage;
212
205
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
213
206
  nonce(): number;
214
- sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
207
+ sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
215
208
  url: string;
216
209
  method: string;
217
210
  body: any;