ccxt 4.3.90 → 4.3.92

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.
package/js/src/kucoin.js CHANGED
@@ -244,6 +244,7 @@ export default class kucoin extends Exchange {
244
244
  'purchase/orders': 10,
245
245
  // broker
246
246
  'broker/api/rebase/download': 3,
247
+ 'migrate/user/account/status': 3,
247
248
  // affiliate
248
249
  'affiliate/inviter/statistics': 30,
249
250
  },
@@ -688,6 +689,7 @@ export default class kucoin extends Exchange {
688
689
  'project/marketInterestRate': 'v3',
689
690
  'redeem/orders': 'v3',
690
691
  'purchase/orders': 'v3',
692
+ 'migrate/user/account/status': 'v3',
691
693
  'margin/symbols': 'v3',
692
694
  'affiliate/inviter/statistics': 'v2',
693
695
  'asset/ndbroker/deposit/list': 'v1',
@@ -1211,6 +1213,30 @@ export default class kucoin extends Exchange {
1211
1213
  }
1212
1214
  return result;
1213
1215
  }
1216
+ async loadMigrationStatus(force = false) {
1217
+ if (!('hfMigrated' in this.options) || (this.options['hfMigrated'] === undefined) || force) {
1218
+ const result = await this.privateGetMigrateUserAccountStatus();
1219
+ const data = this.safeDict(result, 'data', {});
1220
+ const status = this.safeInteger(data, 'status');
1221
+ this.options['hfMigrated'] = (status === 2);
1222
+ }
1223
+ }
1224
+ async handleHfAndParams(params = {}) {
1225
+ await this.loadMigrationStatus();
1226
+ const migrated = this.safeBool(this.options, 'hfMigrated');
1227
+ let loadedHf = undefined;
1228
+ if (migrated !== undefined) {
1229
+ if (migrated) {
1230
+ loadedHf = true;
1231
+ }
1232
+ else {
1233
+ loadedHf = false;
1234
+ }
1235
+ }
1236
+ const hf = this.safeBool(params, 'hf', loadedHf);
1237
+ params = this.omit(params, 'hf');
1238
+ return [hf, params];
1239
+ }
1214
1240
  async fetchCurrencies(params = {}) {
1215
1241
  /**
1216
1242
  * @method
@@ -1754,7 +1780,8 @@ export default class kucoin extends Exchange {
1754
1780
  // }
1755
1781
  // }
1756
1782
  //
1757
- return this.parseTicker(response['data'], market);
1783
+ const data = this.safeDict(response, 'data', {});
1784
+ return this.parseTicker(data, market);
1758
1785
  }
1759
1786
  parseOHLCV(ohlcv, market = undefined) {
1760
1787
  //
@@ -2092,7 +2119,8 @@ export default class kucoin extends Exchange {
2092
2119
  const market = this.market(symbol);
2093
2120
  const testOrder = this.safeBool(params, 'test', false);
2094
2121
  params = this.omit(params, 'test');
2095
- const isHf = this.safeBool(params, 'hf', false);
2122
+ let hf = undefined;
2123
+ [hf, params] = await this.handleHfAndParams(params);
2096
2124
  const [triggerPrice, stopLossPrice, takeProfitPrice] = this.handleTriggerPrices(params);
2097
2125
  const tradeType = this.safeString(params, 'tradeType'); // keep it for backward compatibility
2098
2126
  const isTriggerOrder = (triggerPrice || stopLossPrice || takeProfitPrice);
@@ -2106,19 +2134,22 @@ export default class kucoin extends Exchange {
2106
2134
  if (isMarginOrder) {
2107
2135
  response = await this.privatePostMarginOrderTest(orderRequest);
2108
2136
  }
2137
+ else if (hf) {
2138
+ response = await this.privatePostHfOrdersTest(orderRequest);
2139
+ }
2109
2140
  else {
2110
2141
  response = await this.privatePostOrdersTest(orderRequest);
2111
2142
  }
2112
2143
  }
2113
- else if (isHf) {
2114
- response = await this.privatePostHfOrders(orderRequest);
2115
- }
2116
2144
  else if (isTriggerOrder) {
2117
2145
  response = await this.privatePostStopOrder(orderRequest);
2118
2146
  }
2119
2147
  else if (isMarginOrder) {
2120
2148
  response = await this.privatePostMarginOrder(orderRequest);
2121
2149
  }
2150
+ else if (hf) {
2151
+ response = await this.privatePostHfOrders(orderRequest);
2152
+ }
2122
2153
  else {
2123
2154
  response = await this.privatePostOrders(orderRequest);
2124
2155
  }
@@ -2219,8 +2250,8 @@ export default class kucoin extends Exchange {
2219
2250
  'symbol': market['id'],
2220
2251
  'orderList': ordersRequests,
2221
2252
  };
2222
- const hf = this.safeBool(params, 'hf', false);
2223
- params = this.omit(params, 'hf');
2253
+ let hf = undefined;
2254
+ [hf, params] = await this.handleHfAndParams(params);
2224
2255
  let response = undefined;
2225
2256
  if (hf) {
2226
2257
  response = await this.privatePostHfOrdersMulti(this.extend(request, params));
@@ -2409,7 +2440,8 @@ export default class kucoin extends Exchange {
2409
2440
  const request = {};
2410
2441
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2411
2442
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2412
- const hf = this.safeBool(params, 'hf', false);
2443
+ let hf = undefined;
2444
+ [hf, params] = await this.handleHfAndParams(params);
2413
2445
  if (hf) {
2414
2446
  if (symbol === undefined) {
2415
2447
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a symbol parameter for hf orders');
@@ -2418,7 +2450,7 @@ export default class kucoin extends Exchange {
2418
2450
  request['symbol'] = market['id'];
2419
2451
  }
2420
2452
  let response = undefined;
2421
- params = this.omit(params, ['clientOid', 'clientOrderId', 'stop', 'hf', 'trigger']);
2453
+ params = this.omit(params, ['clientOid', 'clientOrderId', 'stop', 'trigger']);
2422
2454
  if (clientOrderId !== undefined) {
2423
2455
  request['clientOid'] = clientOrderId;
2424
2456
  if (stop) {
@@ -2522,8 +2554,9 @@ export default class kucoin extends Exchange {
2522
2554
  await this.loadMarkets();
2523
2555
  const request = {};
2524
2556
  const stop = this.safeBool(params, 'stop', false);
2525
- const hf = this.safeBool(params, 'hf', false);
2526
- params = this.omit(params, ['stop', 'hf']);
2557
+ let hf = undefined;
2558
+ [hf, params] = await this.handleHfAndParams(params);
2559
+ params = this.omit(params, 'stop');
2527
2560
  const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
2528
2561
  if (symbol !== undefined) {
2529
2562
  request['symbol'] = this.marketId(symbol);
@@ -2580,8 +2613,12 @@ export default class kucoin extends Exchange {
2580
2613
  let lowercaseStatus = status.toLowerCase();
2581
2614
  const until = this.safeInteger(params, 'until');
2582
2615
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2583
- const hf = this.safeBool(params, 'hf', false);
2584
- params = this.omit(params, ['stop', 'hf', 'until', 'trigger']);
2616
+ let hf = undefined;
2617
+ [hf, params] = await this.handleHfAndParams(params);
2618
+ if (hf && (symbol === undefined)) {
2619
+ throw new ArgumentsRequired(this.id + ' fetchOrdersByStatus() requires a symbol parameter for hf orders');
2620
+ }
2621
+ params = this.omit(params, ['stop', 'trigger', 'till', 'until']);
2585
2622
  const [marginMode, query] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
2586
2623
  if (lowercaseStatus === 'open') {
2587
2624
  lowercaseStatus = 'active';
@@ -2759,7 +2796,8 @@ export default class kucoin extends Exchange {
2759
2796
  const request = {};
2760
2797
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
2761
2798
  const stop = this.safeBool2(params, 'stop', 'trigger', false);
2762
- const hf = this.safeBool(params, 'hf', false);
2799
+ let hf = undefined;
2800
+ [hf, params] = await this.handleHfAndParams(params);
2763
2801
  let market = undefined;
2764
2802
  if (symbol !== undefined) {
2765
2803
  market = this.market(symbol);
@@ -2770,7 +2808,7 @@ export default class kucoin extends Exchange {
2770
2808
  }
2771
2809
  request['symbol'] = market['id'];
2772
2810
  }
2773
- params = this.omit(params, ['stop', 'hf', 'clientOid', 'clientOrderId', 'trigger']);
2811
+ params = this.omit(params, ['stop', 'clientOid', 'clientOrderId', 'trigger']);
2774
2812
  let response = undefined;
2775
2813
  if (clientOrderId !== undefined) {
2776
2814
  request['clientOid'] = clientOrderId;
@@ -3036,7 +3074,8 @@ export default class kucoin extends Exchange {
3036
3074
  return await this.fetchPaginatedCallDynamic('fetchMyTrades', symbol, since, limit, params);
3037
3075
  }
3038
3076
  let request = {};
3039
- const hf = this.safeBool(params, 'hf', false);
3077
+ let hf = undefined;
3078
+ [hf, params] = await this.handleHfAndParams(params);
3040
3079
  if (hf && symbol === undefined) {
3041
3080
  throw new ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol parameter for hf orders');
3042
3081
  }
@@ -3640,8 +3679,9 @@ export default class kucoin extends Exchange {
3640
3679
  // }
3641
3680
  // }
3642
3681
  //
3643
- const responseData = response['data']['items'];
3644
- return this.parseTransactions(responseData, currency, since, limit, { 'type': 'deposit' });
3682
+ const data = this.safeDict(response, 'data', {});
3683
+ const items = this.safeList(data, 'items', []);
3684
+ return this.parseTransactions(items, currency, since, limit, { 'type': 'deposit' });
3645
3685
  }
3646
3686
  async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
3647
3687
  /**
@@ -3725,8 +3765,9 @@ export default class kucoin extends Exchange {
3725
3765
  // }
3726
3766
  // }
3727
3767
  //
3728
- const responseData = response['data']['items'];
3729
- return this.parseTransactions(responseData, currency, since, limit, { 'type': 'withdrawal' });
3768
+ const data = this.safeDict(response, 'data', {});
3769
+ const items = this.safeList(data, 'items', []);
3770
+ return this.parseTransactions(items, currency, since, limit, { 'type': 'withdrawal' });
3730
3771
  }
3731
3772
  parseBalanceHelper(entry) {
3732
3773
  const account = this.account();
@@ -3763,11 +3804,11 @@ export default class kucoin extends Exchange {
3763
3804
  const accountsByType = this.safeDict(this.options, 'accountsByType');
3764
3805
  let type = this.safeString(accountsByType, requestedType, requestedType);
3765
3806
  params = this.omit(params, 'type');
3766
- const isHf = this.safeBool(params, 'hf', false);
3767
- if (isHf) {
3807
+ let hf = undefined;
3808
+ [hf, params] = await this.handleHfAndParams(params);
3809
+ if (hf) {
3768
3810
  type = 'trade_hf';
3769
3811
  }
3770
- params = this.omit(params, 'hf');
3771
3812
  const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
3772
3813
  let response = undefined;
3773
3814
  const request = {};
@@ -4223,8 +4264,8 @@ export default class kucoin extends Exchange {
4223
4264
  await this.loadAccounts();
4224
4265
  let paginate = false;
4225
4266
  [paginate, params] = this.handleOptionAndParams(params, 'fetchLedger', 'paginate');
4226
- const isHf = this.safeBool(params, 'hf');
4227
- params = this.omit(params, 'hf');
4267
+ let hf = undefined;
4268
+ [hf, params] = await this.handleHfAndParams(params);
4228
4269
  if (paginate) {
4229
4270
  return await this.fetchPaginatedCallDynamic('fetchLedger', code, since, limit, params);
4230
4271
  }
@@ -4248,7 +4289,7 @@ export default class kucoin extends Exchange {
4248
4289
  let marginMode = undefined;
4249
4290
  [marginMode, params] = this.handleMarginModeAndParams('fetchLedger', params);
4250
4291
  let response = undefined;
4251
- if (isHf) {
4292
+ if (hf) {
4252
4293
  if (marginMode !== undefined) {
4253
4294
  response = await this.privateGetHfMarginAccountLedgers(this.extend(request, params));
4254
4295
  }
@@ -4588,7 +4629,7 @@ export default class kucoin extends Exchange {
4588
4629
  // }
4589
4630
  //
4590
4631
  const data = this.safeDict(response, 'data');
4591
- const rows = this.safeList(data, 'items');
4632
+ const rows = this.safeList(data, 'items', []);
4592
4633
  return this.parseBorrowRateHistories(rows, codes, since, limit);
4593
4634
  }
4594
4635
  async fetchBorrowRateHistory(code, since = undefined, limit = undefined, params = {}) {
@@ -4643,7 +4684,7 @@ export default class kucoin extends Exchange {
4643
4684
  // }
4644
4685
  //
4645
4686
  const data = this.safeDict(response, 'data');
4646
- const rows = this.safeList(data, 'items');
4687
+ const rows = this.safeList(data, 'items', []);
4647
4688
  return this.parseBorrowRateHistory(rows, code, since, limit);
4648
4689
  }
4649
4690
  parseBorrowRateHistories(response, codes, since, limit) {
@@ -28,6 +28,7 @@ export default class kucoinfutures extends kucoin {
28
28
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
29
29
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
30
30
  parseTicker(ticker: Dict, market?: Market): Ticker;
31
+ fetchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
31
32
  fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
32
33
  fetchPosition(symbol: string, params?: {}): Promise<import("./base/types.js").Position>;
33
34
  fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
@@ -51,6 +51,7 @@ export default class kucoinfutures extends kucoin {
51
51
  'createTriggerOrder': true,
52
52
  'fetchAccounts': true,
53
53
  'fetchBalance': true,
54
+ 'fetchBidsAsks': true,
54
55
  'fetchBorrowRateHistories': false,
55
56
  'fetchBorrowRateHistory': false,
56
57
  'fetchClosedOrders': true,
@@ -775,11 +776,20 @@ export default class kucoinfutures extends kucoin {
775
776
  * @see https://www.kucoin.com/docs/rest/futures-trading/market-data/get-symbols-list
776
777
  * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
777
778
  * @param {object} [params] extra parameters specific to the exchange API endpoint
779
+ * @param {string} [params.method] the method to use, futuresPublicGetAllTickers or futuresPublicGetContractsActive
778
780
  * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
779
781
  */
780
782
  await this.loadMarkets();
781
783
  symbols = this.marketSymbols(symbols);
782
- const response = await this.futuresPublicGetContractsActive(params);
784
+ let method = undefined;
785
+ [method, params] = this.handleOptionAndParams(params, 'fetchTickers', 'method', 'futuresPublicGetContractsActive');
786
+ let response = undefined;
787
+ if (method === 'futuresPublicGetAllTickers') {
788
+ response = await this.futuresPublicGetAllTickers(params);
789
+ }
790
+ else {
791
+ response = await this.futuresPublicGetContractsActive(params);
792
+ }
783
793
  //
784
794
  // {
785
795
  // "code": "200000",
@@ -842,7 +852,7 @@ export default class kucoinfutures extends kucoin {
842
852
  // }
843
853
  // }
844
854
  //
845
- const data = this.safeList(response, 'data', []);
855
+ const data = this.safeList(response, 'data');
846
856
  const tickers = this.parseTickers(data, symbols);
847
857
  return this.filterByArrayTickers(tickers, 'symbol', symbols);
848
858
  }
@@ -952,6 +962,20 @@ export default class kucoinfutures extends kucoin {
952
962
  'info': ticker,
953
963
  }, market);
954
964
  }
965
+ async fetchBidsAsks(symbols = undefined, params = {}) {
966
+ /**
967
+ * @method
968
+ * @name kucoinfutures#fetchBidsAsks
969
+ * @description fetches the bid and ask price and volume for multiple markets
970
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the bids and asks for, all markets are returned if not assigned
971
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
972
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
973
+ */
974
+ const request = {
975
+ 'method': 'futuresPublicGetAllTickers',
976
+ };
977
+ return await this.fetchTickers(symbols, this.extend(request, params));
978
+ }
955
979
  async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
956
980
  /**
957
981
  * @method
package/js/src/woo.js CHANGED
@@ -485,7 +485,7 @@ export default class woo extends Exchange {
485
485
  'swap': swap,
486
486
  'future': false,
487
487
  'option': false,
488
- 'active': undefined,
488
+ 'active': this.safeString(market, 'is_trading') === '1',
489
489
  'contract': contract,
490
490
  'linear': linear,
491
491
  'inverse': undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.3.90",
3
+ "version": "4.3.92",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.min.js",
6
6
  "type": "module",