ccxt 4.2.76 → 4.2.78

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 (74) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +1181 -643
  3. package/dist/ccxt.browser.min.js +7 -7
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +6 -0
  6. package/dist/cjs/src/binance.js +502 -443
  7. package/dist/cjs/src/bingx.js +1 -1
  8. package/dist/cjs/src/blofin.js +14 -2
  9. package/dist/cjs/src/bybit.js +106 -60
  10. package/dist/cjs/src/coinbase.js +23 -10
  11. package/dist/cjs/src/delta.js +66 -49
  12. package/dist/cjs/src/gate.js +1 -0
  13. package/dist/cjs/src/htx.js +36 -27
  14. package/dist/cjs/src/hyperliquid.js +7 -5
  15. package/dist/cjs/src/kraken.js +8 -8
  16. package/dist/cjs/src/kucoin.js +204 -5
  17. package/dist/cjs/src/okcoin.js +27 -1
  18. package/dist/cjs/src/okx.js +18 -0
  19. package/dist/cjs/src/pro/ascendex.js +1 -1
  20. package/dist/cjs/src/pro/bitvavo.js +1 -1
  21. package/dist/cjs/src/pro/coinex.js +20 -14
  22. package/dist/cjs/src/pro/deribit.js +1 -1
  23. package/dist/cjs/src/pro/exmo.js +1 -1
  24. package/dist/cjs/src/pro/krakenfutures.js +1 -1
  25. package/dist/cjs/src/pro/phemex.js +1 -1
  26. package/dist/cjs/src/pro/poloniex.js +1 -1
  27. package/dist/cjs/src/pro/probit.js +1 -1
  28. package/dist/cjs/src/pro/woo.js +61 -6
  29. package/dist/cjs/src/woo.js +72 -3
  30. package/js/ccxt.d.ts +1 -1
  31. package/js/ccxt.js +1 -1
  32. package/js/src/abstract/kucoin.d.ts +1 -0
  33. package/js/src/abstract/kucoinfutures.d.ts +1 -0
  34. package/js/src/base/Exchange.d.ts +3 -3
  35. package/js/src/base/Exchange.js +6 -0
  36. package/js/src/base/types.d.ts +3 -3
  37. package/js/src/binance.d.ts +2 -2
  38. package/js/src/binance.js +502 -443
  39. package/js/src/bingx.js +1 -1
  40. package/js/src/bitflyer.d.ts +2 -2
  41. package/js/src/bithumb.d.ts +2 -2
  42. package/js/src/blofin.js +14 -2
  43. package/js/src/bybit.d.ts +1 -1
  44. package/js/src/bybit.js +106 -60
  45. package/js/src/coinbase.d.ts +2 -2
  46. package/js/src/coinbase.js +23 -10
  47. package/js/src/delta.d.ts +2 -1
  48. package/js/src/delta.js +66 -49
  49. package/js/src/deribit.d.ts +1 -1
  50. package/js/src/gate.d.ts +1 -1
  51. package/js/src/gate.js +1 -0
  52. package/js/src/htx.js +36 -27
  53. package/js/src/hyperliquid.js +7 -5
  54. package/js/src/kraken.js +8 -8
  55. package/js/src/kucoin.d.ts +4 -1
  56. package/js/src/kucoin.js +204 -5
  57. package/js/src/okcoin.js +27 -1
  58. package/js/src/okx.d.ts +1 -1
  59. package/js/src/okx.js +18 -0
  60. package/js/src/pro/ascendex.js +1 -1
  61. package/js/src/pro/bitvavo.js +1 -1
  62. package/js/src/pro/coinex.js +20 -14
  63. package/js/src/pro/deribit.js +1 -1
  64. package/js/src/pro/exmo.js +1 -1
  65. package/js/src/pro/krakenfutures.js +1 -1
  66. package/js/src/pro/phemex.js +1 -1
  67. package/js/src/pro/poloniex.js +1 -1
  68. package/js/src/pro/probit.js +1 -1
  69. package/js/src/pro/woo.d.ts +1 -0
  70. package/js/src/pro/woo.js +61 -6
  71. package/js/src/woo.d.ts +2 -0
  72. package/js/src/woo.js +72 -3
  73. package/package.json +1 -1
  74. package/skip-tests.json +6 -3
package/js/src/delta.js CHANGED
@@ -337,7 +337,7 @@ export default class delta extends Exchange {
337
337
  */
338
338
  const response = await this.publicGetSettings(params);
339
339
  // full response sample under `fetchStatus`
340
- const result = this.safeValue(response, 'result', {});
340
+ const result = this.safeDict(response, 'result', {});
341
341
  return this.safeIntegerProduct(result, 'server_time', 0.001);
342
342
  }
343
343
  async fetchStatus(params = {}) {
@@ -402,7 +402,7 @@ export default class delta extends Exchange {
402
402
  // "success": true
403
403
  // }
404
404
  //
405
- const result = this.safeValue(response, 'result', {});
405
+ const result = this.safeDict(response, 'result', {});
406
406
  const underMaintenance = this.safeString(result, 'under_maintenance');
407
407
  const status = (underMaintenance === 'true') ? 'maintenance' : 'ok';
408
408
  const updated = this.safeIntegerProduct(result, 'server_time', 0.001, this.milliseconds());
@@ -454,7 +454,7 @@ export default class delta extends Exchange {
454
454
  // "success":true
455
455
  // }
456
456
  //
457
- const currencies = this.safeValue(response, 'result', []);
457
+ const currencies = this.safeList(response, 'result', []);
458
458
  const result = {};
459
459
  for (let i = 0; i < currencies.length; i++) {
460
460
  const currency = currencies[i];
@@ -491,16 +491,33 @@ export default class delta extends Exchange {
491
491
  }
492
492
  async loadMarkets(reload = false, params = {}) {
493
493
  const markets = await super.loadMarkets(reload, params);
494
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId');
494
+ const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId');
495
495
  if ((currenciesByNumericId === undefined) || reload) {
496
- this.options['currenciesByNumericId'] = this.indexBy(this.currencies, 'numericId');
496
+ this.options['currenciesByNumericId'] = this.indexByStringifiedNumericId(this.currencies);
497
497
  }
498
- const marketsByNumericId = this.safeValue(this.options, 'marketsByNumericId');
498
+ const marketsByNumericId = this.safeDict(this.options, 'marketsByNumericId');
499
499
  if ((marketsByNumericId === undefined) || reload) {
500
- this.options['marketsByNumericId'] = this.indexBy(this.markets, 'numericId');
500
+ this.options['marketsByNumericId'] = this.indexByStringifiedNumericId(this.markets);
501
501
  }
502
502
  return markets;
503
503
  }
504
+ indexByStringifiedNumericId(input) {
505
+ const result = {};
506
+ if (input === undefined) {
507
+ return undefined;
508
+ }
509
+ const keys = Object.keys(input);
510
+ for (let i = 0; i < keys.length; i++) {
511
+ const key = keys[i];
512
+ const item = input[key];
513
+ const numericIdString = this.safeString(item, 'numericId');
514
+ if (numericIdString === undefined) {
515
+ continue;
516
+ }
517
+ result[numericIdString] = item;
518
+ }
519
+ return result;
520
+ }
504
521
  async fetchMarkets(params = {}) {
505
522
  /**
506
523
  * @method
@@ -689,7 +706,7 @@ export default class delta extends Exchange {
689
706
  // "success":true
690
707
  // }
691
708
  //
692
- const markets = this.safeValue(response, 'result', []);
709
+ const markets = this.safeList(response, 'result', []);
693
710
  const result = [];
694
711
  for (let i = 0; i < markets.length; i++) {
695
712
  const market = markets[i];
@@ -698,10 +715,10 @@ export default class delta extends Exchange {
698
715
  continue;
699
716
  }
700
717
  // const settlingAsset = this.safeValue (market, 'settling_asset', {});
701
- const quotingAsset = this.safeValue(market, 'quoting_asset', {});
702
- const underlyingAsset = this.safeValue(market, 'underlying_asset', {});
703
- const settlingAsset = this.safeValue(market, 'settling_asset');
704
- const productSpecs = this.safeValue(market, 'product_specs', {});
718
+ const quotingAsset = this.safeDict(market, 'quoting_asset', {});
719
+ const underlyingAsset = this.safeDict(market, 'underlying_asset', {});
720
+ const settlingAsset = this.safeDict(market, 'settling_asset');
721
+ const productSpecs = this.safeDict(market, 'product_specs', {});
705
722
  const baseId = this.safeString(underlyingAsset, 'symbol');
706
723
  const quoteId = this.safeString(quotingAsset, 'symbol');
707
724
  const settleId = this.safeString(settlingAsset, 'symbol');
@@ -934,7 +951,7 @@ export default class delta extends Exchange {
934
951
  const marketId = this.safeString(ticker, 'symbol');
935
952
  const symbol = this.safeSymbol(marketId, market);
936
953
  const last = this.safeString(ticker, 'close');
937
- const quotes = this.safeValue(ticker, 'quotes', {});
954
+ const quotes = this.safeDict(ticker, 'quotes', {});
938
955
  return this.safeTicker({
939
956
  'symbol': symbol,
940
957
  'timestamp': timestamp,
@@ -1098,7 +1115,7 @@ export default class delta extends Exchange {
1098
1115
  // "success": true
1099
1116
  // }
1100
1117
  //
1101
- const result = this.safeValue(response, 'result', {});
1118
+ const result = this.safeDict(response, 'result', {});
1102
1119
  return this.parseTicker(result, market);
1103
1120
  }
1104
1121
  async fetchTickers(symbols = undefined, params = {}) {
@@ -1244,7 +1261,7 @@ export default class delta extends Exchange {
1244
1261
  // "success":true
1245
1262
  // }
1246
1263
  //
1247
- const tickers = this.safeValue(response, 'result', []);
1264
+ const tickers = this.safeList(response, 'result', []);
1248
1265
  const result = {};
1249
1266
  for (let i = 0; i < tickers.length; i++) {
1250
1267
  const ticker = this.parseTicker(tickers[i]);
@@ -1291,7 +1308,7 @@ export default class delta extends Exchange {
1291
1308
  // "success":true
1292
1309
  // }
1293
1310
  //
1294
- const result = this.safeValue(response, 'result', {});
1311
+ const result = this.safeDict(response, 'result', {});
1295
1312
  return this.parseOrderBook(result, market['symbol'], undefined, 'buy', 'sell', 'price', 'size');
1296
1313
  }
1297
1314
  parseTrade(trade, market = undefined) {
@@ -1348,7 +1365,7 @@ export default class delta extends Exchange {
1348
1365
  timestamp = this.safeIntegerProduct(trade, 'timestamp', 0.001, timestamp);
1349
1366
  const priceString = this.safeString(trade, 'price');
1350
1367
  const amountString = this.safeString(trade, 'size');
1351
- const product = this.safeValue(trade, 'product', {});
1368
+ const product = this.safeDict(trade, 'product', {});
1352
1369
  const marketId = this.safeString(product, 'symbol');
1353
1370
  const symbol = this.safeSymbol(marketId, market);
1354
1371
  const sellerRole = this.safeString(trade, 'seller_role');
@@ -1362,7 +1379,7 @@ export default class delta extends Exchange {
1362
1379
  }
1363
1380
  }
1364
1381
  const takerOrMaker = this.safeString(trade, 'role');
1365
- const metaData = this.safeValue(trade, 'meta_data', {});
1382
+ const metaData = this.safeDict(trade, 'meta_data', {});
1366
1383
  let type = this.safeString(metaData, 'order_type');
1367
1384
  if (type !== undefined) {
1368
1385
  type = type.replace('_order', '');
@@ -1370,7 +1387,7 @@ export default class delta extends Exchange {
1370
1387
  const feeCostString = this.safeString(trade, 'commission');
1371
1388
  let fee = undefined;
1372
1389
  if (feeCostString !== undefined) {
1373
- const settlingAsset = this.safeValue(product, 'settling_asset', {});
1390
+ const settlingAsset = this.safeDict(product, 'settling_asset', {});
1374
1391
  const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
1375
1392
  const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1376
1393
  fee = {
@@ -1427,7 +1444,7 @@ export default class delta extends Exchange {
1427
1444
  // "success":true
1428
1445
  // }
1429
1446
  //
1430
- const result = this.safeValue(response, 'result', []);
1447
+ const result = this.safeList(response, 'result', []);
1431
1448
  return this.parseTrades(result, market, since, limit);
1432
1449
  }
1433
1450
  parseOHLCV(ohlcv, market = undefined) {
@@ -1502,17 +1519,17 @@ export default class delta extends Exchange {
1502
1519
  // ]
1503
1520
  // }
1504
1521
  //
1505
- const result = this.safeValue(response, 'result', []);
1522
+ const result = this.safeList(response, 'result', []);
1506
1523
  return this.parseOHLCVs(result, market, timeframe, since, limit);
1507
1524
  }
1508
1525
  parseBalance(response) {
1509
- const balances = this.safeValue(response, 'result', []);
1526
+ const balances = this.safeList(response, 'result', []);
1510
1527
  const result = { 'info': response };
1511
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId', {});
1528
+ const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId', {});
1512
1529
  for (let i = 0; i < balances.length; i++) {
1513
1530
  const balance = balances[i];
1514
1531
  const currencyId = this.safeString(balance, 'asset_id');
1515
- const currency = this.safeValue(currenciesByNumericId, currencyId);
1532
+ const currency = this.safeDict(currenciesByNumericId, currencyId);
1516
1533
  const code = (currency === undefined) ? currencyId : currency['code'];
1517
1534
  const account = this.account();
1518
1535
  account['total'] = this.safeString(balance, 'balance');
@@ -1581,7 +1598,7 @@ export default class delta extends Exchange {
1581
1598
  // "success":true
1582
1599
  // }
1583
1600
  //
1584
- const result = this.safeValue(response, 'result', {});
1601
+ const result = this.safeDict(response, 'result', {});
1585
1602
  return this.parsePosition(result, market);
1586
1603
  }
1587
1604
  async fetchPositions(symbols = undefined, params = {}) {
@@ -1617,7 +1634,7 @@ export default class delta extends Exchange {
1617
1634
  // ]
1618
1635
  // }
1619
1636
  //
1620
- const result = this.safeValue(response, 'result', []);
1637
+ const result = this.safeList(response, 'result', []);
1621
1638
  return this.parsePositions(result, symbols);
1622
1639
  }
1623
1640
  parsePosition(position, market = undefined) {
@@ -1739,7 +1756,7 @@ export default class delta extends Exchange {
1739
1756
  const clientOrderId = this.safeString(order, 'client_order_id');
1740
1757
  const timestamp = this.parse8601(this.safeString(order, 'created_at'));
1741
1758
  const marketId = this.safeString(order, 'product_id');
1742
- const marketsByNumericId = this.safeValue(this.options, 'marketsByNumericId', {});
1759
+ const marketsByNumericId = this.safeDict(this.options, 'marketsByNumericId', {});
1743
1760
  market = this.safeValue(marketsByNumericId, marketId, market);
1744
1761
  const symbol = (market === undefined) ? marketId : market['symbol'];
1745
1762
  const status = this.parseOrderStatus(this.safeString(order, 'state'));
@@ -1755,7 +1772,7 @@ export default class delta extends Exchange {
1755
1772
  if (feeCostString !== undefined) {
1756
1773
  let feeCurrencyCode = undefined;
1757
1774
  if (market !== undefined) {
1758
- const settlingAsset = this.safeValue(market['info'], 'settling_asset', {});
1775
+ const settlingAsset = this.safeDict(market['info'], 'settling_asset', {});
1759
1776
  const feeCurrencyId = this.safeString(settlingAsset, 'symbol');
1760
1777
  feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
1761
1778
  }
@@ -1822,7 +1839,7 @@ export default class delta extends Exchange {
1822
1839
  if (clientOrderId !== undefined) {
1823
1840
  request['client_order_id'] = clientOrderId;
1824
1841
  }
1825
- const reduceOnly = this.safeValue(params, 'reduceOnly');
1842
+ const reduceOnly = this.safeBool(params, 'reduceOnly');
1826
1843
  if (reduceOnly) {
1827
1844
  request['reduce_only'] = reduceOnly;
1828
1845
  params = this.omit(params, 'reduceOnly');
@@ -1864,7 +1881,7 @@ export default class delta extends Exchange {
1864
1881
  // "success":true
1865
1882
  // }
1866
1883
  //
1867
- const result = this.safeValue(response, 'result', {});
1884
+ const result = this.safeDict(response, 'result', {});
1868
1885
  return this.parseOrder(result, market);
1869
1886
  }
1870
1887
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -1914,7 +1931,7 @@ export default class delta extends Exchange {
1914
1931
  // }
1915
1932
  // }
1916
1933
  //
1917
- const result = this.safeValue(response, 'result');
1934
+ const result = this.safeDict(response, 'result');
1918
1935
  return this.parseOrder(result, market);
1919
1936
  }
1920
1937
  async cancelOrder(id, symbol = undefined, params = {}) {
@@ -1974,7 +1991,7 @@ export default class delta extends Exchange {
1974
1991
  // "success":true
1975
1992
  // }
1976
1993
  //
1977
- const result = this.safeValue(response, 'result');
1994
+ const result = this.safeDict(response, 'result');
1978
1995
  return this.parseOrder(result, market);
1979
1996
  }
1980
1997
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -2087,7 +2104,7 @@ export default class delta extends Exchange {
2087
2104
  // }
2088
2105
  // }
2089
2106
  //
2090
- const result = this.safeValue(response, 'result', []);
2107
+ const result = this.safeList(response, 'result', []);
2091
2108
  return this.parseOrders(result, market, since, limit);
2092
2109
  }
2093
2110
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2169,7 +2186,7 @@ export default class delta extends Exchange {
2169
2186
  // "success":true
2170
2187
  // }
2171
2188
  //
2172
- const result = this.safeValue(response, 'result', []);
2189
+ const result = this.safeList(response, 'result', []);
2173
2190
  return this.parseTrades(result, market, since, limit);
2174
2191
  }
2175
2192
  async fetchLedger(code = undefined, since = undefined, limit = undefined, params = {}) {
@@ -2222,7 +2239,7 @@ export default class delta extends Exchange {
2222
2239
  // "success":true
2223
2240
  // }
2224
2241
  //
2225
- const result = this.safeValue(response, 'result', []);
2242
+ const result = this.safeList(response, 'result', []);
2226
2243
  return this.parseLedger(result, currency, since, limit);
2227
2244
  }
2228
2245
  parseLedgerEntryType(type) {
@@ -2259,7 +2276,7 @@ export default class delta extends Exchange {
2259
2276
  const id = this.safeString(item, 'uuid');
2260
2277
  let direction = undefined;
2261
2278
  const account = undefined;
2262
- const metaData = this.safeValue(item, 'meta_data', {});
2279
+ const metaData = this.safeDict(item, 'meta_data', {});
2263
2280
  const referenceId = this.safeString(metaData, 'transaction_id');
2264
2281
  const referenceAccount = undefined;
2265
2282
  let type = this.safeString(item, 'transaction_type');
@@ -2270,8 +2287,8 @@ export default class delta extends Exchange {
2270
2287
  direction = 'out';
2271
2288
  }
2272
2289
  type = this.parseLedgerEntryType(type);
2273
- const currencyId = this.safeInteger(item, 'asset_id');
2274
- const currenciesByNumericId = this.safeValue(this.options, 'currenciesByNumericId');
2290
+ const currencyId = this.safeString(item, 'asset_id');
2291
+ const currenciesByNumericId = this.safeDict(this.options, 'currenciesByNumericId');
2275
2292
  currency = this.safeValue(currenciesByNumericId, currencyId, currency);
2276
2293
  const code = (currency === undefined) ? undefined : currency['code'];
2277
2294
  const amount = this.safeString(item, 'amount');
@@ -2335,7 +2352,7 @@ export default class delta extends Exchange {
2335
2352
  // }
2336
2353
  // }
2337
2354
  //
2338
- const result = this.safeValue(response, 'result', {});
2355
+ const result = this.safeDict(response, 'result', {});
2339
2356
  return this.parseDepositAddress(result, currency);
2340
2357
  }
2341
2358
  parseDepositAddress(depositAddress, currency = undefined) {
@@ -2429,7 +2446,7 @@ export default class delta extends Exchange {
2429
2446
  // "success": true
2430
2447
  // }
2431
2448
  //
2432
- const result = this.safeValue(response, 'result', {});
2449
+ const result = this.safeDict(response, 'result', {});
2433
2450
  return this.parseFundingRate(result, market);
2434
2451
  }
2435
2452
  async fetchFundingRates(symbols = undefined, params = {}) {
@@ -2495,7 +2512,7 @@ export default class delta extends Exchange {
2495
2512
  // "success":true
2496
2513
  // }
2497
2514
  //
2498
- const rates = this.safeValue(response, 'result', []);
2515
+ const rates = this.safeList(response, 'result', []);
2499
2516
  const result = this.parseFundingRates(rates);
2500
2517
  return this.filterByArray(result, 'symbol', symbols);
2501
2518
  }
@@ -2627,7 +2644,7 @@ export default class delta extends Exchange {
2627
2644
  // "success": true
2628
2645
  // }
2629
2646
  //
2630
- const result = this.safeValue(response, 'result', {});
2647
+ const result = this.safeDict(response, 'result', {});
2631
2648
  return this.parseMarginModification(result, market);
2632
2649
  }
2633
2650
  parseMarginModification(data, market = undefined) {
@@ -2734,7 +2751,7 @@ export default class delta extends Exchange {
2734
2751
  // "success": true
2735
2752
  // }
2736
2753
  //
2737
- const result = this.safeValue(response, 'result', {});
2754
+ const result = this.safeDict(response, 'result', {});
2738
2755
  return this.parseOpenInterest(result, market);
2739
2756
  }
2740
2757
  parseOpenInterest(interest, market = undefined) {
@@ -2958,7 +2975,7 @@ export default class delta extends Exchange {
2958
2975
  // "success": true
2959
2976
  // }
2960
2977
  //
2961
- const result = this.safeValue(response, 'result', []);
2978
+ const result = this.safeList(response, 'result', []);
2962
2979
  const settlements = this.parseSettlements(result, market);
2963
2980
  const sorted = this.sortBy(settlements, 'timestamp');
2964
2981
  return this.filterBySymbolSinceLimit(sorted, market['symbol'], since, limit);
@@ -3102,7 +3119,7 @@ export default class delta extends Exchange {
3102
3119
  // "success": true
3103
3120
  // }
3104
3121
  //
3105
- const result = this.safeValue(response, 'result', {});
3122
+ const result = this.safeDict(response, 'result', {});
3106
3123
  return this.parseGreeks(result, market);
3107
3124
  }
3108
3125
  parseGreeks(greeks, market = undefined) {
@@ -3158,8 +3175,8 @@ export default class delta extends Exchange {
3158
3175
  const timestamp = this.safeIntegerProduct(greeks, 'timestamp', 0.001);
3159
3176
  const marketId = this.safeString(greeks, 'symbol');
3160
3177
  const symbol = this.safeSymbol(marketId, market);
3161
- const stats = this.safeValue(greeks, 'greeks', {});
3162
- const quotes = this.safeValue(greeks, 'quotes', {});
3178
+ const stats = this.safeDict(greeks, 'greeks', {});
3179
+ const quotes = this.safeDict(greeks, 'quotes', {});
3163
3180
  return {
3164
3181
  'symbol': symbol,
3165
3182
  'timestamp': timestamp,
@@ -3202,7 +3219,7 @@ export default class delta extends Exchange {
3202
3219
  //
3203
3220
  // {"result":{},"success":true}
3204
3221
  //
3205
- const position = this.parsePosition(this.safeValue(response, 'result', {}));
3222
+ const position = this.parsePosition(this.safeDict(response, 'result', {}));
3206
3223
  return [position];
3207
3224
  }
3208
3225
  async fetchMarginMode(symbol, params = {}) {
@@ -3339,7 +3356,7 @@ export default class delta extends Exchange {
3339
3356
  //
3340
3357
  // {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
3341
3358
  //
3342
- const error = this.safeValue(response, 'error', {});
3359
+ const error = this.safeDict(response, 'error', {});
3343
3360
  const errorCode = this.safeString(error, 'code');
3344
3361
  if (errorCode !== undefined) {
3345
3362
  const feedback = this.id + ' ' + body;
@@ -10,7 +10,7 @@ export default class deribit extends Exchange {
10
10
  convertMarketIdExpireDate(date: any): string;
11
11
  convertExpireDateToMarketIdDate(date: any): any;
12
12
  createExpiredOptionMarket(symbol: string): MarketInterface;
13
- safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
13
+ safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
14
14
  fetchTime(params?: {}): Promise<number>;
15
15
  fetchCurrencies(params?: {}): Promise<{}>;
16
16
  codeFromOptions(methodName: any, params?: {}): any;
package/js/src/gate.d.ts CHANGED
@@ -9,7 +9,7 @@ export default class gate extends Exchange {
9
9
  setSandboxMode(enable: boolean): void;
10
10
  convertExpireDate(date: any): string;
11
11
  createExpiredOptionMarket(symbol: string): MarketInterface;
12
- safeMarket(marketId?: any, market?: any, delimiter?: any, marketType?: any): MarketInterface;
12
+ safeMarket(marketId?: Str, market?: Market, delimiter?: Str, marketType?: Str): MarketInterface;
13
13
  fetchMarkets(params?: {}): Promise<any>;
14
14
  fetchSpotMarkets(params?: {}): Promise<any[]>;
15
15
  fetchContractMarkets(params?: {}): Promise<any[]>;
package/js/src/gate.js CHANGED
@@ -52,6 +52,7 @@ export default class gate extends Exchange {
52
52
  'rebate': 'https://api.gateio.ws/api/v4',
53
53
  'earn': 'https://api.gateio.ws/api/v4',
54
54
  'account': 'https://api.gateio.ws/api/v4',
55
+ 'loan': 'https://api.gateio.ws/api/v4',
55
56
  },
56
57
  },
57
58
  'test': {
package/js/src/htx.js CHANGED
@@ -2980,42 +2980,47 @@ export default class htx extends Exchange {
2980
2980
  // 'from': parseInt ((since / 1000).toString ()), spot only
2981
2981
  // 'to': this.seconds (), spot only
2982
2982
  };
2983
- const price = this.safeString(params, 'price');
2984
- params = this.omit(params, 'price');
2983
+ const priceType = this.safeStringN(params, ['priceType', 'price']);
2984
+ params = this.omit(params, ['priceType', 'price']);
2985
+ let until = undefined;
2986
+ [until, params] = this.handleParamInteger(params, 'until');
2987
+ const untilSeconds = (until !== undefined) ? this.parseToInt(until / 1000) : undefined;
2985
2988
  if (market['contract']) {
2986
2989
  if (limit !== undefined) {
2987
- request['size'] = limit; // when using limit from and to are ignored
2990
+ request['size'] = limit; // when using limit: from & to are ignored
2988
2991
  // https://huobiapi.github.io/docs/usdt_swap/v1/en/#general-get-kline-data
2989
2992
  }
2990
2993
  else {
2991
2994
  limit = 2000; // only used for from/to calculation
2992
2995
  }
2993
- if (price === undefined) {
2996
+ if (priceType === undefined) {
2994
2997
  const duration = this.parseTimeframe(timeframe);
2998
+ let calcualtedEnd = undefined;
2995
2999
  if (since === undefined) {
2996
3000
  const now = this.seconds();
2997
3001
  request['from'] = now - duration * (limit - 1);
2998
- request['to'] = now;
3002
+ calcualtedEnd = now;
2999
3003
  }
3000
3004
  else {
3001
3005
  const start = this.parseToInt(since / 1000);
3002
3006
  request['from'] = start;
3003
- request['to'] = this.sum(start, duration * (limit - 1));
3007
+ calcualtedEnd = this.sum(start, duration * (limit - 1));
3004
3008
  }
3009
+ request['to'] = (untilSeconds !== undefined) ? untilSeconds : calcualtedEnd;
3005
3010
  }
3006
3011
  }
3007
3012
  let response = undefined;
3008
3013
  if (market['future']) {
3009
3014
  if (market['inverse']) {
3010
3015
  request['symbol'] = market['id'];
3011
- if (price === 'mark') {
3016
+ if (priceType === 'mark') {
3012
3017
  response = await this.contractPublicGetIndexMarketHistoryMarkPriceKline(this.extend(request, params));
3013
3018
  }
3014
- else if (price === 'index') {
3019
+ else if (priceType === 'index') {
3015
3020
  response = await this.contractPublicGetIndexMarketHistoryIndex(this.extend(request, params));
3016
3021
  }
3017
- else if (price === 'premiumIndex') {
3018
- throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
3022
+ else if (priceType === 'premiumIndex') {
3023
+ throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
3019
3024
  }
3020
3025
  else {
3021
3026
  response = await this.contractPublicGetMarketHistoryKline(this.extend(request, params));
@@ -3023,13 +3028,13 @@ export default class htx extends Exchange {
3023
3028
  }
3024
3029
  else if (market['linear']) {
3025
3030
  request['contract_code'] = market['id'];
3026
- if (price === 'mark') {
3031
+ if (priceType === 'mark') {
3027
3032
  response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
3028
3033
  }
3029
- else if (price === 'index') {
3030
- throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
3034
+ else if (priceType === 'index') {
3035
+ throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
3031
3036
  }
3032
- else if (price === 'premiumIndex') {
3037
+ else if (priceType === 'premiumIndex') {
3033
3038
  response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
3034
3039
  }
3035
3040
  else {
@@ -3040,13 +3045,13 @@ export default class htx extends Exchange {
3040
3045
  else if (market['swap']) {
3041
3046
  request['contract_code'] = market['id'];
3042
3047
  if (market['inverse']) {
3043
- if (price === 'mark') {
3048
+ if (priceType === 'mark') {
3044
3049
  response = await this.contractPublicGetIndexMarketHistorySwapMarkPriceKline(this.extend(request, params));
3045
3050
  }
3046
- else if (price === 'index') {
3047
- throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
3051
+ else if (priceType === 'index') {
3052
+ throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
3048
3053
  }
3049
- else if (price === 'premiumIndex') {
3054
+ else if (priceType === 'premiumIndex') {
3050
3055
  response = await this.contractPublicGetIndexMarketHistorySwapPremiumIndexKline(this.extend(request, params));
3051
3056
  }
3052
3057
  else {
@@ -3054,13 +3059,13 @@ export default class htx extends Exchange {
3054
3059
  }
3055
3060
  }
3056
3061
  else if (market['linear']) {
3057
- if (price === 'mark') {
3062
+ if (priceType === 'mark') {
3058
3063
  response = await this.contractPublicGetIndexMarketHistoryLinearSwapMarkPriceKline(this.extend(request, params));
3059
3064
  }
3060
- else if (price === 'index') {
3061
- throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + price + ' kline data');
3065
+ else if (priceType === 'index') {
3066
+ throw new BadRequest(this.id + ' ' + market['type'] + ' has no api endpoint for ' + priceType + ' kline data');
3062
3067
  }
3063
- else if (price === 'premiumIndex') {
3068
+ else if (priceType === 'premiumIndex') {
3064
3069
  response = await this.contractPublicGetIndexMarketHistoryLinearSwapPremiumIndexKline(this.extend(request, params));
3065
3070
  }
3066
3071
  else {
@@ -3073,18 +3078,22 @@ export default class htx extends Exchange {
3073
3078
  let useHistorical = undefined;
3074
3079
  [useHistorical, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'useHistoricalEndpointForSpot', true);
3075
3080
  if (!useHistorical) {
3076
- // `limit` only available for the this endpoint
3077
3081
  if (limit !== undefined) {
3078
- request['size'] = limit; // max 2000
3082
+ request['size'] = Math.min(2000, limit); // max 2000
3079
3083
  }
3080
3084
  response = await this.spotPublicGetMarketHistoryKline(this.extend(request, params));
3081
3085
  }
3082
3086
  else {
3083
- // `since` only available for the this endpoint
3087
+ // "from & to" only available for the this endpoint
3084
3088
  if (since !== undefined) {
3085
- // default 150 bars
3086
3089
  request['from'] = this.parseToInt(since / 1000);
3087
3090
  }
3091
+ if (untilSeconds !== undefined) {
3092
+ request['to'] = untilSeconds;
3093
+ }
3094
+ if (limit !== undefined) {
3095
+ request['size'] = Math.min(1000, limit); // max 1000, otherwise default returns 150
3096
+ }
3088
3097
  response = await this.spotPublicGetMarketHistoryCandles(this.extend(request, params));
3089
3098
  }
3090
3099
  }
@@ -3100,7 +3109,7 @@ export default class htx extends Exchange {
3100
3109
  // ]
3101
3110
  // }
3102
3111
  //
3103
- const data = this.safeValue(response, 'data', []);
3112
+ const data = this.safeList(response, 'data', []);
3104
3113
  return this.parseOHLCVs(data, market, timeframe, since, limit);
3105
3114
  }
3106
3115
  async fetchAccounts(params = {}) {
@@ -558,7 +558,7 @@ export default class hyperliquid extends Exchange {
558
558
  // }
559
559
  //
560
560
  return [
561
- this.safeInteger(ohlcv, 'T'),
561
+ this.safeInteger(ohlcv, 't'),
562
562
  this.safeNumber(ohlcv, 'o'),
563
563
  this.safeNumber(ohlcv, 'h'),
564
564
  this.safeNumber(ohlcv, 'l'),
@@ -764,8 +764,9 @@ export default class hyperliquid extends Exchange {
764
764
  * @param {bool} [params.postOnly] true or false whether the order is post-only
765
765
  * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
766
766
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
767
- * @param {string} [params.clientOrderId] client order id, optional 128 bit hex string
767
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
768
768
  * @param {string} [params.slippage] the slippage for market order
769
+ * @param {string} [params.vaultAddress] the vault address for order
769
770
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
770
771
  */
771
772
  await this.loadMarkets();
@@ -815,7 +816,7 @@ export default class hyperliquid extends Exchange {
815
816
  }
816
817
  }
817
818
  }
818
- params = this.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice']);
819
+ params = this.omit(params, ['slippage', 'clientOrderId', 'client_id', 'slippage', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'timeInForce']);
819
820
  const nonce = this.milliseconds();
820
821
  const orderReq = [];
821
822
  for (let i = 0; i < orders.length; i++) {
@@ -942,7 +943,7 @@ export default class hyperliquid extends Exchange {
942
943
  * @param {string} id order id
943
944
  * @param {string} symbol unified symbol of the market the order was made in
944
945
  * @param {object} [params] extra parameters specific to the exchange API endpoint
945
- * @param {string} [params.clientOrderId] client order id (default undefined)
946
+ * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
946
947
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
947
948
  */
948
949
  return await this.cancelOrders([id], symbol, params);
@@ -957,7 +958,7 @@ export default class hyperliquid extends Exchange {
957
958
  * @param {string[]} ids order ids
958
959
  * @param {string} [symbol] unified market symbol
959
960
  * @param {object} [params] extra parameters specific to the exchange API endpoint
960
- * @param {string|string[]} [params.clientOrderId] client order ids (default undefined)
961
+ * @param {string|string[]} [params.clientOrderId] client order ids, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
961
962
  * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
962
963
  */
963
964
  this.checkRequiredCredentials();
@@ -1040,6 +1041,7 @@ export default class hyperliquid extends Exchange {
1040
1041
  * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
1041
1042
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
1042
1043
  * @param {string} [params.clientOrderId] client order id, (optional 128 bit hex string e.g. 0x1234567890abcdef1234567890abcdef)
1044
+ * @param {string} [params.vaultAddress] the vault address for order
1043
1045
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
1044
1046
  */
1045
1047
  this.checkRequiredCredentials();