ccxt 4.1.9 → 4.1.11

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 (76) hide show
  1. package/.git-templates/hooks/pre-push +55 -0
  2. package/CONTRIBUTING.md +2 -0
  3. package/README.md +3 -3
  4. package/build.sh +3 -1
  5. package/dist/ccxt.browser.js +433 -191
  6. package/dist/ccxt.browser.min.js +3 -3
  7. package/dist/cjs/ccxt.js +1 -1
  8. package/dist/cjs/src/base/Exchange.js +31 -3
  9. package/dist/cjs/src/binance.js +21 -10
  10. package/dist/cjs/src/bingx.js +18 -11
  11. package/dist/cjs/src/bitbns.js +107 -83
  12. package/dist/cjs/src/bitget.js +11 -17
  13. package/dist/cjs/src/bitmart.js +2 -2
  14. package/dist/cjs/src/btcalpha.js +9 -1
  15. package/dist/cjs/src/btcmarkets.js +5 -5
  16. package/dist/cjs/src/bybit.js +2 -2
  17. package/dist/cjs/src/coinex.js +17 -5
  18. package/dist/cjs/src/coinspot.js +103 -8
  19. package/dist/cjs/src/delta.js +2 -2
  20. package/dist/cjs/src/deribit.js +7 -1
  21. package/dist/cjs/src/hitbtc.js +20 -2
  22. package/dist/cjs/src/huobi.js +5 -6
  23. package/dist/cjs/src/okx.js +3 -3
  24. package/dist/cjs/src/phemex.js +20 -1
  25. package/dist/cjs/src/pro/binance.js +3 -9
  26. package/dist/cjs/src/pro/phemex.js +2 -2
  27. package/dist/cjs/src/probit.js +3 -0
  28. package/dist/cjs/src/whitebit.js +14 -11
  29. package/dist/cjs/src/woo.js +21 -1
  30. package/js/ccxt.d.ts +1 -1
  31. package/js/ccxt.js +1 -1
  32. package/js/src/abstract/binance.d.ts +3 -0
  33. package/js/src/abstract/binancecoinm.d.ts +3 -0
  34. package/js/src/abstract/binanceus.d.ts +3 -0
  35. package/js/src/abstract/binanceusdm.d.ts +3 -0
  36. package/js/src/abstract/bingx.d.ts +1 -0
  37. package/js/src/base/Exchange.d.ts +7 -6
  38. package/js/src/base/Exchange.js +31 -3
  39. package/js/src/base/types.d.ts +10 -0
  40. package/js/src/binance.d.ts +5 -13
  41. package/js/src/binance.js +21 -10
  42. package/js/src/bingx.d.ts +2 -16
  43. package/js/src/bingx.js +18 -11
  44. package/js/src/bitbns.d.ts +1 -1
  45. package/js/src/bitbns.js +107 -83
  46. package/js/src/bitget.d.ts +2 -16
  47. package/js/src/bitget.js +11 -17
  48. package/js/src/bitmart.d.ts +2 -16
  49. package/js/src/bitmart.js +2 -2
  50. package/js/src/btcalpha.js +9 -1
  51. package/js/src/btcmarkets.js +5 -5
  52. package/js/src/bybit.d.ts +5 -19
  53. package/js/src/bybit.js +2 -2
  54. package/js/src/coinex.d.ts +1 -1
  55. package/js/src/coinex.js +17 -5
  56. package/js/src/coinspot.d.ts +1 -0
  57. package/js/src/coinspot.js +103 -8
  58. package/js/src/delta.d.ts +2 -20
  59. package/js/src/delta.js +2 -2
  60. package/js/src/deribit.js +7 -1
  61. package/js/src/gate.d.ts +2 -2
  62. package/js/src/hitbtc.d.ts +2 -2
  63. package/js/src/hitbtc.js +20 -2
  64. package/js/src/huobi.d.ts +3 -12
  65. package/js/src/huobi.js +5 -6
  66. package/js/src/okx.d.ts +3 -21
  67. package/js/src/okx.js +3 -3
  68. package/js/src/phemex.js +20 -1
  69. package/js/src/pro/binance.js +3 -9
  70. package/js/src/pro/phemex.js +2 -2
  71. package/js/src/probit.js +3 -0
  72. package/js/src/whitebit.js +14 -11
  73. package/js/src/woo.js +21 -1
  74. package/package.json +2 -2
  75. package/pyproject.toml +8 -0
  76. package/skip-tests.json +1 -1
@@ -8627,7 +8627,7 @@ class Exchange {
8627
8627
  // string = true
8628
8628
  //
8629
8629
  // [
8630
- // { 'currency': 'BTC', 'cost': '0.3' },
8630
+ // { 'currency': 'BTC', 'cost': '0.4' },
8631
8631
  // { 'currency': 'BTC', 'cost': '0.6', 'rate': '0.00123' },
8632
8632
  // { 'currency': 'BTC', 'cost': '0.5', 'rate': '0.00456' },
8633
8633
  // { 'currency': 'USDT', 'cost': '12.3456' },
@@ -8851,7 +8851,7 @@ class Exchange {
8851
8851
  }
8852
8852
  return result;
8853
8853
  }
8854
- marketSymbols(symbols, type = undefined, allowEmpty = true) {
8854
+ marketSymbols(symbols, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
8855
8855
  if (symbols === undefined) {
8856
8856
  if (!allowEmpty) {
8857
8857
  throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' empty list of symbols is not supported');
@@ -8866,10 +8866,26 @@ class Exchange {
8866
8866
  return symbols;
8867
8867
  }
8868
8868
  const result = [];
8869
+ let marketType = undefined;
8870
+ let isLinearSubType = undefined;
8869
8871
  for (let i = 0; i < symbols.length; i++) {
8870
8872
  const market = this.market(symbols[i]);
8873
+ if (sameTypeOnly && (marketType !== undefined)) {
8874
+ if (market['type'] !== marketType) {
8875
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' symbols must be of the same type, either ' + marketType + ' or ' + market['type'] + '.');
8876
+ }
8877
+ }
8878
+ if (sameSubTypeOnly && (isLinearSubType !== undefined)) {
8879
+ if (market['linear'] !== isLinearSubType) {
8880
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' symbols must be of the same subType, either linear or inverse.');
8881
+ }
8882
+ }
8871
8883
  if (type !== undefined && market['type'] !== type) {
8872
- throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' symbols must be of same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
8884
+ throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.BadRequest(this.id + ' symbols must be of the same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
8885
+ }
8886
+ marketType = market['type'];
8887
+ if (!market['spot']) {
8888
+ isLinearSubType = market['linear'];
8873
8889
  }
8874
8890
  const symbol = this.safeString(market, 'symbol', symbols[i]);
8875
8891
  result.push(symbol);
@@ -10898,6 +10914,18 @@ class Exchange {
10898
10914
  }
10899
10915
  return [request, params];
10900
10916
  }
10917
+ safeOpenInterest(interest, market = undefined) {
10918
+ return this.extend(interest, {
10919
+ 'symbol': this.safeString(market, 'symbol'),
10920
+ 'baseVolume': this.safeNumber(interest, 'baseVolume'),
10921
+ 'quoteVolume': this.safeNumber(interest, 'quoteVolume'),
10922
+ 'openInterestAmount': this.safeNumber(interest, 'openInterestAmount'),
10923
+ 'openInterestValue': this.safeNumber(interest, 'openInterestValue'),
10924
+ 'timestamp': this.safeInteger(interest, 'timestamp'),
10925
+ 'datetime': this.safeString(interest, 'datetime'),
10926
+ 'info': this.safeValue(interest, 'info'),
10927
+ });
10928
+ }
10901
10929
  }
10902
10930
 
10903
10931
 
@@ -15976,7 +16004,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
15976
16004
  'rateLimit': 50,
15977
16005
  'certified': true,
15978
16006
  'pro': true,
15979
- // new metainfo interface
16007
+ // new metainfo2 interface
15980
16008
  'has': {
15981
16009
  'CORS': undefined,
15982
16010
  'spot': true,
@@ -16203,6 +16231,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16203
16231
  'loan/vip/loanable/data': 40,
16204
16232
  'loan/vip/collateral/data': 40,
16205
16233
  'loan/vip/request/data': 2.6668,
16234
+ 'loan/vip/request/interestRate': 2.6668,
16206
16235
  'loan/income': 40.002,
16207
16236
  'loan/ongoing/orders': 40,
16208
16237
  'loan/ltv/adjustment/history': 40,
@@ -16717,10 +16746,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
16717
16746
  'adlQuantile': 5,
16718
16747
  'pmAccountInfo': 5,
16719
16748
  'orderAmendment': 1,
16720
- 'order/asyn': 5,
16721
- 'order/asyn/id': 5,
16722
- 'trade/asyn': 5,
16723
- 'trade/asyn/id': 5,
16749
+ 'income/asyn': 1000,
16750
+ 'income/asyn/id': 10,
16751
+ 'order/asyn': 1000,
16752
+ 'order/asyn/id': 10,
16753
+ 'trade/asyn': 1000,
16754
+ 'trade/asyn/id': 10,
16724
16755
  },
16725
16756
  'post': {
16726
16757
  'batchOrders': 5,
@@ -18339,6 +18370,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18339
18370
  },
18340
18371
  },
18341
18372
  'info': market,
18373
+ 'created': this.safeInteger(market, 'onboardDate'), // present in inverse & linear apis
18342
18374
  };
18343
18375
  if ('PRICE_FILTER' in filtersByType) {
18344
18376
  const filter = this.safeValue(filtersByType, 'PRICE_FILTER', {});
@@ -18666,7 +18698,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
18666
18698
  // "unrealizedProfit":"0.00000000",
18667
18699
  // "positionInitialMargin":"0",
18668
18700
  // "openOrderInitialMargin":"0",
18669
- // "leverage":"20",
18701
+ // "leverage":"21",
18670
18702
  // "isolated":false,
18671
18703
  // "entryPrice":"0.00000",
18672
18704
  // "maxNotional":"5000000",
@@ -19168,6 +19200,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19168
19200
  await this.loadMarkets();
19169
19201
  let type = undefined;
19170
19202
  let market = undefined;
19203
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
19171
19204
  if (symbols !== undefined) {
19172
19205
  const first = this.safeString(symbols, 0);
19173
19206
  market = this.market(first);
@@ -24340,7 +24373,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24340
24373
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
24341
24374
  }
24342
24375
  }
24343
- else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2')) {
24376
+ else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
24344
24377
  this.checkRequiredCredentials();
24345
24378
  if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
24346
24379
  // inject in implicit API calls
@@ -25095,7 +25128,13 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25095
25128
  // ]
25096
25129
  //
25097
25130
  if (market['option']) {
25098
- return this.parseOpenInterests(response, market);
25131
+ const result = this.parseOpenInterests(response, market);
25132
+ for (let i = 0; i < result.length; i++) {
25133
+ const item = result[i];
25134
+ if (item['symbol'] === symbol) {
25135
+ return item;
25136
+ }
25137
+ }
25099
25138
  }
25100
25139
  else {
25101
25140
  return this.parseOpenInterest(response, market);
@@ -25108,7 +25147,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25108
25147
  const value = this.safeNumber2(interest, 'sumOpenInterestValue', 'sumOpenInterestUsd');
25109
25148
  // Inverse returns the number of contracts different from the base or quote volume in this case
25110
25149
  // compared with https://www.binance.com/en/futures/funding-history/quarterly/4
25111
- return {
25150
+ return this.safeOpenInterest({
25112
25151
  'symbol': this.safeSymbol(id, market, undefined, 'contract'),
25113
25152
  'baseVolume': market['inverse'] ? undefined : amount,
25114
25153
  'quoteVolume': value,
@@ -25117,7 +25156,7 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25117
25156
  'timestamp': timestamp,
25118
25157
  'datetime': this.iso8601(timestamp),
25119
25158
  'info': interest,
25120
- };
25159
+ }, market);
25121
25160
  }
25122
25161
  }
25123
25162
 
@@ -25483,6 +25522,13 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
25483
25522
  },
25484
25523
  },
25485
25524
  },
25525
+ 'v3': {
25526
+ 'public': {
25527
+ 'get': {
25528
+ 'quote/klines': 1,
25529
+ },
25530
+ },
25531
+ },
25486
25532
  },
25487
25533
  'contract': {
25488
25534
  'v1': {
@@ -25940,12 +25986,12 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
25940
25986
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
25941
25987
  * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
25942
25988
  * @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
25989
+ * @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
25943
25990
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
25944
25991
  * @param {string} timeframe the length of time each candle represents
25945
25992
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
25946
25993
  * @param {int} [limit] the maximum amount of candles to fetch
25947
25994
  * @param {object} [params] extra parameters specific to the bingx api endpoint
25948
- * @param {string} [params.price] "mark" or "index" for mark price and index price candles
25949
25995
  * @param {int} [params.until] timestamp in ms of the latest candle to fetch
25950
25996
  * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
25951
25997
  * @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
@@ -25967,20 +26013,17 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
25967
26013
  if (limit !== undefined) {
25968
26014
  request['limit'] = limit;
25969
26015
  }
25970
- else {
25971
- request['limit'] = 50;
25972
- }
25973
- const until = this.safeInteger2(params, 'until', 'startTime');
26016
+ const until = this.safeInteger2(params, 'until', 'endTime');
25974
26017
  if (until !== undefined) {
25975
26018
  params = this.omit(params, ['until']);
25976
- request['startTime'] = until;
26019
+ request['endTime'] = until;
25977
26020
  }
25978
26021
  let response = undefined;
25979
26022
  if (market['spot']) {
25980
26023
  response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
25981
26024
  }
25982
26025
  else {
25983
- response = await this.swapV2PublicGetQuoteKlines(this.extend(request, params));
26026
+ response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
25984
26027
  }
25985
26028
  //
25986
26029
  // {
@@ -26481,14 +26524,16 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26481
26524
  const id = this.safeString(interest, 'symbol');
26482
26525
  const symbol = this.safeSymbol(id, market, '-', 'swap');
26483
26526
  const openInterest = this.safeNumber(interest, 'openInterest');
26484
- return {
26527
+ return this.safeOpenInterest({
26485
26528
  'symbol': symbol,
26529
+ 'baseVolume': undefined,
26530
+ 'quoteVolume': undefined,
26486
26531
  'openInterestAmount': undefined,
26487
26532
  'openInterestValue': openInterest,
26488
26533
  'timestamp': timestamp,
26489
26534
  'datetime': this.iso8601(timestamp),
26490
26535
  'info': interest,
26491
- };
26536
+ }, market);
26492
26537
  }
26493
26538
  async fetchTicker(symbol, params = {}) {
26494
26539
  /**
@@ -26861,8 +26906,9 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26861
26906
  'liquidationPrice': undefined,
26862
26907
  'entryPrice': this.safeNumber2(position, 'avgPrice', 'entryPrice'),
26863
26908
  'unrealizedPnl': this.safeNumber(position, 'unrealizedProfit'),
26909
+ 'realizedPnl': this.safeNumber(position, 'realisedProfit'),
26864
26910
  'percentage': undefined,
26865
- 'contracts': undefined,
26911
+ 'contracts': this.safeNumber(position, 'positionAmt'),
26866
26912
  'contractSize': undefined,
26867
26913
  'markPrice': undefined,
26868
26914
  'lastPrice': undefined,
@@ -26873,7 +26919,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
26873
26919
  'lastUpdateTimestamp': undefined,
26874
26920
  'maintenanceMargin': undefined,
26875
26921
  'maintenanceMarginPercentage': undefined,
26876
- 'collateral': this.safeString(position, 'positionAmt'),
26922
+ 'collateral': this.safeNumber(position, 'positionAmt'),
26877
26923
  'initialMargin': this.safeNumber(position, 'initialMargin'),
26878
26924
  'initialMarginPercentage': undefined,
26879
26925
  'leverage': this.safeNumber(position, 'leverage'),
@@ -30880,9 +30926,12 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30880
30926
  // note that "Money" stands for INR - the only fiat in bitbns
30881
30927
  return this.parseBalance(response);
30882
30928
  }
30883
- parseOrderStatus(status) {
30929
+ parseStatus(status) {
30884
30930
  const statuses = {
30931
+ '-1': 'cancelled',
30885
30932
  '0': 'open',
30933
+ '1': 'open',
30934
+ '2': 'done',
30886
30935
  // 'PARTIALLY_FILLED': 'open',
30887
30936
  // 'FILLED': 'closed',
30888
30937
  // 'CANCELED': 'canceled',
@@ -30897,90 +30946,78 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30897
30946
  // createOrder
30898
30947
  //
30899
30948
  // {
30900
- // "data":"Successfully placed bid to purchase currency",
30901
- // "status":1,
30902
- // "error":null,
30903
- // "id":5424475,
30904
- // "code":200
30949
+ // "data": "Successfully placed bid to purchase currency",
30950
+ // "status": 1,
30951
+ // "error": null,
30952
+ // "id": 5424475,
30953
+ // "code": 200
30905
30954
  // }
30906
30955
  //
30907
- // fetchOrder
30956
+ // fetchOpenOrders, fetchOrder
30908
30957
  //
30909
- // {
30910
- // "entry_id":5424475,
30911
- // "btc":0.01,
30912
- // "rate":2000,
30913
- // "time":"2021-04-25T17:05:42.000Z",
30914
- // "type":0,
30915
- // "status":0,
30916
- // "total":0.01,
30917
- // "avg_cost":null,
30918
- // "side":"BUY",
30919
- // "amount":0.01,
30920
- // "remaining":0.01,
30921
- // "filled":0,
30922
- // "cost":null,
30923
- // "fee":0.05
30924
- // }
30958
+ // {
30959
+ // "entry_id": 5424475,
30960
+ // "btc": 0.01,
30961
+ // "rate": 2000,
30962
+ // "time": "2021-04-25T17:05:42.000Z",
30963
+ // "type": 0,
30964
+ // "status": 0
30965
+ // "t_rate": 0.45, // only stop orders
30966
+ // "trail": 0 // only stop orders
30967
+ // }
30925
30968
  //
30926
- // fetchOpenOrders
30969
+ // cancelOrder
30927
30970
  //
30928
- // {
30929
- // "entry_id":5424475,
30930
- // "btc":0.01,
30931
- // "rate":2000,
30932
- // "time":"2021-04-25T17:05:42.000Z",
30933
- // "type":0,
30934
- // "status":0
30935
- // }
30971
+ // {
30972
+ // "data": "Successfully cancelled the order",
30973
+ // "status": 1,
30974
+ // "error": null,
30975
+ // "code": 200
30976
+ // }
30936
30977
  //
30937
30978
  const id = this.safeString2(order, 'id', 'entry_id');
30938
- const marketId = this.safeString(order, 'symbol');
30939
- const symbol = this.safeSymbol(marketId, market);
30940
- const timestamp = this.parse8601(this.safeString(order, 'time'));
30941
- const price = this.safeString(order, 'rate');
30942
- const amount = this.safeString2(order, 'amount', 'btc');
30943
- const filled = this.safeString(order, 'filled');
30944
- const remaining = this.safeString(order, 'remaining');
30945
- const average = this.safeString(order, 'avg_cost');
30946
- const cost = this.safeString(order, 'cost');
30947
- let type = this.safeStringLower(order, 'type');
30948
- if (type === '0') {
30949
- type = 'limit';
30979
+ const datetime = this.safeString(order, 'time');
30980
+ const triggerPrice = this.safeString(order, 't_rate');
30981
+ let side = this.safeString(order, 'type');
30982
+ if (side === '0') {
30983
+ side = 'buy';
30950
30984
  }
30951
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
30952
- const side = this.safeStringLower(order, 'side');
30953
- const feeCost = this.safeNumber(order, 'fee');
30954
- let fee = undefined;
30955
- if (feeCost !== undefined) {
30956
- const feeCurrencyCode = undefined;
30957
- fee = {
30958
- 'cost': feeCost,
30959
- 'currency': feeCurrencyCode,
30960
- };
30985
+ else if (side === '1') {
30986
+ side = 'sell';
30987
+ }
30988
+ const data = this.safeString(order, 'data');
30989
+ let status = this.safeString(order, 'status');
30990
+ if (data === 'Successfully cancelled the order') {
30991
+ status = 'cancelled';
30992
+ }
30993
+ else {
30994
+ status = this.parseStatus(status);
30961
30995
  }
30962
30996
  return this.safeOrder({
30963
30997
  'info': order,
30964
30998
  'id': id,
30965
30999
  'clientOrderId': undefined,
30966
- 'timestamp': timestamp,
30967
- 'datetime': this.iso8601(timestamp),
31000
+ 'timestamp': this.parse8601(datetime),
31001
+ 'datetime': datetime,
30968
31002
  'lastTradeTimestamp': undefined,
30969
- 'symbol': symbol,
30970
- 'type': type,
31003
+ 'symbol': this.safeString(market, 'symbol'),
30971
31004
  'timeInForce': undefined,
30972
31005
  'postOnly': undefined,
30973
31006
  'side': side,
30974
- 'price': price,
30975
- 'stopPrice': undefined,
30976
- 'triggerPrice': undefined,
30977
- 'amount': amount,
30978
- 'cost': cost,
30979
- 'average': average,
30980
- 'filled': filled,
30981
- 'remaining': remaining,
31007
+ 'price': this.safeString(order, 'rate'),
31008
+ 'stopPrice': triggerPrice,
31009
+ 'triggerPrice': triggerPrice,
31010
+ 'amount': this.safeString(order, 'btc'),
31011
+ 'cost': undefined,
31012
+ 'average': undefined,
31013
+ 'filled': undefined,
31014
+ 'remaining': undefined,
30982
31015
  'status': status,
30983
- 'fee': fee,
31016
+ 'fee': {
31017
+ 'cost': undefined,
31018
+ 'currency': undefined,
31019
+ 'rate': undefined,
31020
+ },
30984
31021
  'trades': undefined,
30985
31022
  }, market);
30986
31023
  }
@@ -30989,19 +31026,27 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
30989
31026
  * @method
30990
31027
  * @name bitbns#createOrder
30991
31028
  * @description create a trade order
31029
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/place-orders
31030
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/market-orders-quantity // market orders
30992
31031
  * @param {string} symbol unified symbol of the market to create an order in
30993
31032
  * @param {string} type 'market' or 'limit'
30994
31033
  * @param {string} side 'buy' or 'sell'
30995
31034
  * @param {float} amount how much of currency you want to trade in units of base currency
30996
31035
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
30997
31036
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31037
+ * @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
31038
+ *
31039
+ * EXCHANGE SPECIFIC PARAMETERS
31040
+ * @param {float} [params.target_rate] *requires params.trail_rate when set, type must be 'limit'* a bracket order is placed when set
31041
+ * @param {float} [params.trail_rate] *requires params.target_rate when set, type must be 'limit'* a bracket order is placed when set
30998
31042
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
30999
31043
  */
31000
- if (type !== 'limit' && type !== 'market') {
31001
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' allows limit and market orders only');
31002
- }
31003
31044
  await this.loadMarkets();
31004
31045
  const market = this.market(symbol);
31046
+ const triggerPrice = this.safeStringN(params, ['triggerPrice', 'stopPrice', 't_rate']);
31047
+ const targetRate = this.safeString(params, 'target_rate');
31048
+ const trailRate = this.safeString(params, 'trail_rate');
31049
+ params = this.omit(params, ['triggerPrice', 'stopPrice', 'trail_rate', 'target_rate', 't_rate']);
31005
31050
  const request = {
31006
31051
  'side': side.toUpperCase(),
31007
31052
  'symbol': market['uppercaseId'],
@@ -31009,20 +31054,23 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31009
31054
  // 'target_rate': this.priceToPrecision (symbol, targetRate),
31010
31055
  // 't_rate': this.priceToPrecision (symbol, stopPrice),
31011
31056
  // 'trail_rate': this.priceToPrecision (symbol, trailRate),
31012
- // To Place Simple Buy or Sell Order use rate
31013
- // To Place Stoploss Buy or Sell Order use rate & t_rate
31014
- // To Place Bracket Buy or Sell Order use rate , t_rate, target_rate & trail_rate
31015
31057
  };
31016
31058
  let method = 'v2PostOrders';
31017
31059
  if (type === 'limit') {
31018
31060
  request['rate'] = this.priceToPrecision(symbol, price);
31019
31061
  }
31020
- else if (type === 'market') {
31062
+ else {
31021
31063
  method = 'v1PostPlaceMarketOrderQntySymbol';
31022
31064
  request['market'] = market['quoteId'];
31023
31065
  }
31024
- else {
31025
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' allows limit and market orders only');
31066
+ if (triggerPrice !== undefined) {
31067
+ request['t_rate'] = this.priceToPrecision(symbol, triggerPrice);
31068
+ }
31069
+ if (targetRate !== undefined) {
31070
+ request['target_rate'] = this.priceToPrecision(symbol, targetRate);
31071
+ }
31072
+ if (trailRate !== undefined) {
31073
+ request['trail_rate'] = this.priceToPrecision(symbol, trailRate);
31026
31074
  }
31027
31075
  const response = await this[method](this.extend(request, params));
31028
31076
  //
@@ -31041,9 +31089,12 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31041
31089
  * @method
31042
31090
  * @name bitbns#cancelOrder
31043
31091
  * @description cancels an open order
31092
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/cancel-orders
31093
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/cancel-stop-loss-orders
31044
31094
  * @param {string} id order id
31045
31095
  * @param {string} symbol unified symbol of the market the order was made in
31046
31096
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31097
+ * @param {boolean} [params.trigger] true if cancelling a trigger order
31047
31098
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
31048
31099
  */
31049
31100
  if (symbol === undefined) {
@@ -31051,13 +31102,18 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31051
31102
  }
31052
31103
  await this.loadMarkets();
31053
31104
  const market = this.market(symbol);
31054
- const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtcancelOrder' : 'cancelOrder';
31105
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
31106
+ params = this.omit(params, ['trigger', 'stop']);
31055
31107
  const request = {
31056
31108
  'entry_id': id,
31057
31109
  'symbol': market['uppercaseId'],
31058
- 'side': quoteSide,
31059
31110
  };
31060
- const response = await this.v2PostCancel(this.extend(request, params));
31111
+ let response = undefined;
31112
+ const tail = isTrigger ? 'StopLossOrder' : 'Order';
31113
+ let quoteSide = (market['quoteId'] === 'USDT') ? 'usdtcancel' : 'cancel';
31114
+ quoteSide += tail;
31115
+ request['side'] = quoteSide;
31116
+ response = await this.v2PostCancel(this.extend(request, params));
31061
31117
  return this.parseOrder(response, market);
31062
31118
  }
31063
31119
  async fetchOrder(id, symbol = undefined, params = {}) {
@@ -31065,6 +31121,8 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31065
31121
  * @method
31066
31122
  * @name bitbns#fetchOrder
31067
31123
  * @description fetches information on an order made by the user
31124
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-1/order-status
31125
+ * @param {string} id order id
31068
31126
  * @param {string} symbol unified symbol of the market the order was made in
31069
31127
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31070
31128
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
@@ -31078,6 +31136,10 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31078
31136
  'symbol': market['id'],
31079
31137
  'entry_id': id,
31080
31138
  };
31139
+ const trigger = this.safeValue2(params, 'trigger', 'stop');
31140
+ if (trigger) {
31141
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchOrder cannot fetch stop orders');
31142
+ }
31081
31143
  const response = await this.v1PostOrderStatusSymbol(this.extend(request, params));
31082
31144
  //
31083
31145
  // {
@@ -31113,10 +31175,13 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31113
31175
  * @method
31114
31176
  * @name bitbns#fetchOpenOrders
31115
31177
  * @description fetch all unfilled currently open orders
31178
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit
31179
+ * @see https://docs.bitbns.com/bitbns/rest-endpoints/order-apis/version-2/order-status-limit/order-status-stop-limit
31116
31180
  * @param {string} symbol unified market symbol
31117
31181
  * @param {int} [since] the earliest time in ms to fetch open orders for
31118
- * @param {int} [limit] the maximum number of open orders structures to retrieve
31182
+ * @param {int} [limit] the maximum number of open orders structures to retrieve
31119
31183
  * @param {object} [params] extra parameters specific to the bitbns api endpoint
31184
+ * @param {boolean} [params.trigger] true if fetching trigger orders
31120
31185
  * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
31121
31186
  */
31122
31187
  if (symbol === undefined) {
@@ -31124,11 +31189,13 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31124
31189
  }
31125
31190
  await this.loadMarkets();
31126
31191
  const market = this.market(symbol);
31127
- const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtListOpenOrders' : 'listOpenOrders';
31192
+ const isTrigger = this.safeValue2(params, 'trigger', 'stop');
31193
+ params = this.omit(params, ['trigger', 'stop']);
31194
+ const quoteSide = (market['quoteId'] === 'USDT') ? 'usdtListOpen' : 'listOpen';
31128
31195
  const request = {
31129
31196
  'symbol': market['uppercaseId'],
31130
- 'side': quoteSide,
31131
31197
  'page': 0,
31198
+ 'side': isTrigger ? (quoteSide + 'StopOrders') : (quoteSide + 'Orders'),
31132
31199
  };
31133
31200
  const response = await this.v2PostGetordersnew(this.extend(request, params));
31134
31201
  //
@@ -31141,6 +31208,9 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31141
31208
  // "time":"2021-04-25T17:05:42.000Z",
31142
31209
  // "type":0,
31143
31210
  // "status":0
31211
+ // "t_rate":0.45, // only stop orders
31212
+ // "type":1, // only stop orders
31213
+ // "trail":0 // only stop orders
31144
31214
  // }
31145
31215
  // ],
31146
31216
  // "status":1,
@@ -31563,7 +31633,7 @@ class bitbns extends _abstract_bitbns_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
31563
31633
  'body': body,
31564
31634
  };
31565
31635
  const payload = this.stringToBase64(this.json(auth));
31566
- const signature = this.hmac(payload, this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha512 */ .o);
31636
+ const signature = this.hmac(this.encode(payload), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha512 */ .o);
31567
31637
  headers['X-BITBNS-PAYLOAD'] = payload;
31568
31638
  headers['X-BITBNS-SIGNATURE'] = signature;
31569
31639
  headers['Content-Type'] = 'application/x-www-form-urlencoded';
@@ -41510,7 +41580,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41510
41580
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-trigger-order-tpsl
41511
41581
  * @param {string} symbol unified market symbol
41512
41582
  * @param {object} [params] extra parameters specific to the bitget api endpoint
41513
- * @param {string} [params.code] marginCoin unified currency code
41514
41583
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
41515
41584
  */
41516
41585
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
@@ -41525,33 +41594,28 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
41525
41594
  if (sandboxMode) {
41526
41595
  productType = 'S' + productType;
41527
41596
  }
41528
- const [marketType, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
41597
+ let marketType = undefined;
41598
+ [marketType, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
41529
41599
  if (marketType === 'spot') {
41530
41600
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.NotSupported(this.id + ' cancelAllOrders () does not support spot markets');
41531
41601
  }
41532
41602
  const request = {
41533
41603
  'productType': productType,
41604
+ 'marginCoin': market['settleId'],
41534
41605
  };
41535
- let method = undefined;
41536
- const stop = this.safeValue(query, 'stop');
41537
- const planType = this.safeString(query, 'planType');
41606
+ const stop = this.safeValue2(params, 'stop', 'trigger');
41607
+ const planType = this.safeString(params, 'planType');
41608
+ params = this.omit(params, ['stop', 'trigger']);
41609
+ let response = undefined;
41538
41610
  if (stop !== undefined || planType !== undefined) {
41539
41611
  if (planType === undefined) {
41540
41612
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelOrder() requires a planType parameter for stop orders, either normal_plan, profit_plan, loss_plan, pos_profit, pos_loss, moving_plan or track_plan');
41541
41613
  }
41542
- method = 'privateMixPostPlanCancelAllPlan';
41614
+ response = await this.privateMixPostPlanCancelAllPlan(this.extend(request, params));
41543
41615
  }
41544
41616
  else {
41545
- const code = this.safeString2(params, 'code', 'marginCoin');
41546
- if (code === undefined) {
41547
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' cancelAllOrders () requires a code argument [marginCoin] in the params');
41548
- }
41549
- const currency = this.currency(code);
41550
- request['marginCoin'] = this.safeCurrencyCode(code, currency);
41551
- method = 'privateMixPostOrderCancelAllOrders';
41617
+ response = await this.privateMixPostOrderCancelAllOrders(this.extend(request, params));
41552
41618
  }
41553
- const ommitted = this.omit(query, ['stop', 'code', 'marginCoin']);
41554
- const response = await this[method](this.extend(request, ommitted));
41555
41619
  //
41556
41620
  // {
41557
41621
  // "code": "00000",
@@ -43368,14 +43432,14 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
43368
43432
  const id = this.safeString(interest, 'symbol');
43369
43433
  const symbol = this.safeSymbol(id, market);
43370
43434
  const amount = this.safeNumber(interest, 'amount');
43371
- return {
43435
+ return this.safeOpenInterest({
43372
43436
  'symbol': symbol,
43373
43437
  'openInterestAmount': amount,
43374
43438
  'openInterestValue': undefined,
43375
43439
  'timestamp': timestamp,
43376
43440
  'datetime': this.iso8601(timestamp),
43377
43441
  'info': interest,
43378
- };
43442
+ }, market);
43379
43443
  }
43380
43444
  handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
43381
43445
  if (!response) {
@@ -48252,14 +48316,14 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
48252
48316
  //
48253
48317
  const timestamp = this.safeInteger(interest, 'timestamp');
48254
48318
  const id = this.safeString(interest, 'symbol');
48255
- return {
48319
+ return this.safeOpenInterest({
48256
48320
  'symbol': this.safeSymbol(id, market),
48257
48321
  'openInterestAmount': this.safeNumber(interest, 'open_interest'),
48258
48322
  'openInterestValue': this.safeNumber(interest, 'open_interest_value'),
48259
48323
  'timestamp': timestamp,
48260
48324
  'datetime': this.iso8601(timestamp),
48261
48325
  'info': interest,
48262
- };
48326
+ }, market);
48263
48327
  }
48264
48328
  async setLeverage(leverage, symbol = undefined, params = {}) {
48265
48329
  /**
@@ -67668,6 +67732,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
67668
67732
  /**
67669
67733
  * @method
67670
67734
  * @name btcalpha#fetchOrderBook
67735
+ * @see https://btc-alpha.github.io/api-docs/#get-orderbook
67671
67736
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
67672
67737
  * @param {string} symbol unified symbol of the market to fetch the order book for
67673
67738
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -68048,15 +68113,19 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68048
68113
  /**
68049
68114
  * @method
68050
68115
  * @name btcalpha#createOrder
68116
+ * @see https://btc-alpha.github.io/api-docs/#create-order
68051
68117
  * @description create a trade order
68052
68118
  * @param {string} symbol unified symbol of the market to create an order in
68053
- * @param {string} type 'market' or 'limit'
68119
+ * @param {string} type 'limit'
68054
68120
  * @param {string} side 'buy' or 'sell'
68055
68121
  * @param {float} amount how much of currency you want to trade in units of base currency
68056
68122
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
68057
68123
  * @param {object} [params] extra parameters specific to the btcalpha api endpoint
68058
68124
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
68059
68125
  */
68126
+ if (type === 'market') {
68127
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' only limits orders are supported');
68128
+ }
68060
68129
  await this.loadMarkets();
68061
68130
  const market = this.market(symbol);
68062
68131
  const request = {
@@ -68080,6 +68149,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68080
68149
  /**
68081
68150
  * @method
68082
68151
  * @name btcalpha#cancelOrder
68152
+ * @see https://btc-alpha.github.io/api-docs/#cancel-order
68083
68153
  * @description cancels an open order
68084
68154
  * @param {string} id order id
68085
68155
  * @param {string} symbol unified symbol of the market the order was made in
@@ -68096,6 +68166,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68096
68166
  /**
68097
68167
  * @method
68098
68168
  * @name btcalpha#fetchOrder
68169
+ * @see https://btc-alpha.github.io/api-docs/#retrieve-single-order
68099
68170
  * @description fetches information on an order made by the user
68100
68171
  * @param {string} symbol not used by btcalpha fetchOrder
68101
68172
  * @param {object} [params] extra parameters specific to the btcalpha api endpoint
@@ -68112,6 +68183,7 @@ class btcalpha extends _abstract_btcalpha_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
68112
68183
  /**
68113
68184
  * @method
68114
68185
  * @name btcalpha#fetchOrders
68186
+ * @see https://btc-alpha.github.io/api-docs/#list-own-orders
68115
68187
  * @description fetches information on multiple orders made by the user
68116
68188
  * @param {string} symbol unified market symbol of the market orders were made in
68117
68189
  * @param {int} [since] the earliest time in ms to fetch orders for
@@ -69142,13 +69214,13 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
69142
69214
  const tagTo = tag;
69143
69215
  const addressFrom = undefined;
69144
69216
  const tagFrom = undefined;
69145
- const fee = this.safeNumber(transaction, 'fee');
69217
+ const fee = this.safeString(transaction, 'fee');
69146
69218
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
69147
69219
  const currencyId = this.safeString(transaction, 'assetName');
69148
69220
  const code = this.safeCurrencyCode(currencyId);
69149
- let amount = this.safeNumber(transaction, 'amount');
69221
+ let amount = this.safeString(transaction, 'amount');
69150
69222
  if (fee) {
69151
- amount -= fee;
69223
+ amount = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringSub */ .O.stringSub(amount, fee);
69152
69224
  }
69153
69225
  return {
69154
69226
  'id': this.safeString(transaction, 'id'),
@@ -69163,14 +69235,14 @@ class btcmarkets extends _abstract_btcmarkets_js__WEBPACK_IMPORTED_MODULE_0__/*
69163
69235
  'tagTo': tagTo,
69164
69236
  'tagFrom': tagFrom,
69165
69237
  'type': type,
69166
- 'amount': amount,
69238
+ 'amount': this.parseNumber(amount),
69167
69239
  'currency': code,
69168
69240
  'status': status,
69169
69241
  'updated': lastUpdate,
69170
69242
  'comment': undefined,
69171
69243
  'fee': {
69172
69244
  'currency': code,
69173
- 'cost': fee,
69245
+ 'cost': this.parseNumber(fee),
69174
69246
  'rate': undefined,
69175
69247
  },
69176
69248
  'info': transaction,
@@ -78045,14 +78117,14 @@ class bybit extends _abstract_bybit_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
78045
78117
  //
78046
78118
  const timestamp = this.safeInteger(interest, 'timestamp');
78047
78119
  const value = this.safeNumber2(interest, 'open_interest', 'openInterest');
78048
- return {
78120
+ return this.safeOpenInterest({
78049
78121
  'symbol': market['symbol'],
78050
78122
  'openInterestAmount': undefined,
78051
78123
  'openInterestValue': value,
78052
78124
  'timestamp': timestamp,
78053
78125
  'datetime': this.iso8601(timestamp),
78054
78126
  'info': interest,
78055
- };
78127
+ }, market);
78056
78128
  }
78057
78129
  async fetchBorrowRate(code, params = {}) {
78058
78130
  /**
@@ -89773,7 +89845,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89773
89845
  const liquidationPrice = this.safeString(position, 'liq_price');
89774
89846
  const entryPrice = this.safeString(position, 'open_price');
89775
89847
  const unrealizedPnl = this.safeString(position, 'profit_unreal');
89776
- const contractSize = this.safeString(position, 'amount');
89848
+ const contracts = this.safeNumber(position, 'amount');
89777
89849
  const sideInteger = this.safeInteger(position, 'side');
89778
89850
  const side = (sideInteger === 1) ? 'short' : 'long';
89779
89851
  const timestamp = this.safeTimestamp(position, 'update_time');
@@ -89791,8 +89863,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
89791
89863
  'entryPrice': entryPrice,
89792
89864
  'unrealizedPnl': unrealizedPnl,
89793
89865
  'percentage': undefined,
89794
- 'contracts': undefined,
89795
- 'contractSize': contractSize,
89866
+ 'contracts': contracts,
89867
+ 'contractSize': this.safeNumber(market, 'contractSize'),
89796
89868
  'markPrice': undefined,
89797
89869
  'lastPrice': undefined,
89798
89870
  'side': side,
@@ -90405,23 +90477,34 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90405
90477
  };
90406
90478
  return this.safeString(statuses, status, status);
90407
90479
  }
90408
- async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = 100, params = {}) {
90480
+ async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
90409
90481
  /**
90410
90482
  * @method
90411
90483
  * @name coinex#fetchFundingRateHistory
90484
+ * @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
90412
90485
  * @description fetches historical funding rate prices
90413
90486
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
90414
90487
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
90415
90488
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
90416
90489
  * @param {object} [params] extra parameters specific to the coinex api endpoint
90490
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
90491
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
90417
90492
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
90418
90493
  */
90419
90494
  if (symbol === undefined) {
90420
90495
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' fetchFundingRateHistory() requires a symbol argument');
90421
90496
  }
90422
90497
  await this.loadMarkets();
90498
+ let paginate = false;
90499
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
90500
+ if (paginate) {
90501
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
90502
+ }
90503
+ if (limit === undefined) {
90504
+ limit = 100;
90505
+ }
90423
90506
  const market = this.market(symbol);
90424
- const request = {
90507
+ let request = {
90425
90508
  'market': market['id'],
90426
90509
  'limit': limit,
90427
90510
  'offset': 0,
@@ -90430,6 +90513,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
90430
90513
  if (since !== undefined) {
90431
90514
  request['start_time'] = since;
90432
90515
  }
90516
+ [request, params] = this.handleUntilOption('end_time', request, params);
90433
90517
  const response = await this.perpetualPublicGetMarketFundingHistory(this.extend(request, params));
90434
90518
  //
90435
90519
  // {
@@ -96310,14 +96394,16 @@ class coinsph extends _abstract_coinsph_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
96310
96394
  /* harmony export */ "Z": () => (/* binding */ coinspot)
96311
96395
  /* harmony export */ });
96312
96396
  /* harmony import */ var _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4663);
96313
- /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6689);
96397
+ /* harmony import */ var _base_errors_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6689);
96314
96398
  /* harmony import */ var _base_functions_number_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9292);
96315
- /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7110);
96399
+ /* harmony import */ var _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7110);
96400
+ /* harmony import */ var _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2194);
96316
96401
  // ---------------------------------------------------------------------------
96317
96402
 
96318
96403
 
96319
96404
 
96320
96405
 
96406
+
96321
96407
  // ---------------------------------------------------------------------------
96322
96408
  /**
96323
96409
  * @class coinspot
@@ -96361,6 +96447,7 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96361
96447
  'fetchLeverageTiers': false,
96362
96448
  'fetchMarginMode': false,
96363
96449
  'fetchMarkOHLCV': false,
96450
+ 'fetchMyTrades': true,
96364
96451
  'fetchOpenInterestHistory': false,
96365
96452
  'fetchOrderBook': true,
96366
96453
  'fetchPosition': false,
@@ -96660,6 +96747,64 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96660
96747
  const trades = this.safeValue(response, 'orders', []);
96661
96748
  return this.parseTrades(trades, market, since, limit);
96662
96749
  }
96750
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
96751
+ /**
96752
+ * @method
96753
+ * @name coinspot#fetchMyTrades
96754
+ * @description fetch all trades made by the user
96755
+ * @param {string} symbol unified market symbol
96756
+ * @param {int} [since] the earliest time in ms to fetch trades for
96757
+ * @param {int} [limit] the maximum number of trades structures to retrieve
96758
+ * @param {object} [params] extra parameters specific to the bitbank api endpoint
96759
+ * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
96760
+ */
96761
+ await this.loadMarkets();
96762
+ const request = {};
96763
+ let market = undefined;
96764
+ if (symbol !== undefined) {
96765
+ market = this.market(symbol);
96766
+ }
96767
+ if (since !== undefined) {
96768
+ request['startdate'] = this.yyyymmdd(since);
96769
+ }
96770
+ const response = await this.privatePostRoMyTransactions(this.extend(request, params));
96771
+ // {
96772
+ // status: 'ok',
96773
+ // buyorders: [
96774
+ // {
96775
+ // otc: false,
96776
+ // market: 'ALGO/AUD',
96777
+ // amount: 386.95197925,
96778
+ // created: '2022-10-20T09:56:44.502Z',
96779
+ // audfeeExGst: 1.80018002,
96780
+ // audGst: 0.180018,
96781
+ // audtotal: 200
96782
+ // },
96783
+ // ],
96784
+ // sellorders: [
96785
+ // {
96786
+ // otc: false,
96787
+ // market: 'SOLO/ALGO',
96788
+ // amount: 154.52345614,
96789
+ // total: 115.78858204658796,
96790
+ // created: '2022-04-16T09:36:43.698Z',
96791
+ // audfeeExGst: 1.08995731,
96792
+ // audGst: 0.10899573,
96793
+ // audtotal: 118.7
96794
+ // },
96795
+ // ]
96796
+ // }
96797
+ const buyTrades = this.safeValue(response, 'buyorders', []);
96798
+ for (let i = 0; i < buyTrades.length; i++) {
96799
+ buyTrades[i]['side'] = 'buy';
96800
+ }
96801
+ const sellTrades = this.safeValue(response, 'sellorders', []);
96802
+ for (let i = 0; i < sellTrades.length; i++) {
96803
+ sellTrades[i]['side'] = 'sell';
96804
+ }
96805
+ const trades = this.arrayConcat(buyTrades, sellTrades);
96806
+ return this.parseTrades(trades, market, since, limit);
96807
+ }
96663
96808
  parseTrade(trade, market = undefined) {
96664
96809
  //
96665
96810
  // public fetchTrades
@@ -96673,12 +96818,47 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96673
96818
  // "market":"BTC/AUD"
96674
96819
  // }
96675
96820
  //
96676
- const priceString = this.safeString(trade, 'rate');
96821
+ // private fetchMyTrades
96822
+ // {
96823
+ // otc: false,
96824
+ // market: 'ALGO/AUD',
96825
+ // amount: 386.95197925,
96826
+ // created: '2022-10-20T09:56:44.502Z',
96827
+ // audfeeExGst: 1.80018002,
96828
+ // audGst: 0.180018,
96829
+ // audtotal: 200,
96830
+ // total: 200,
96831
+ // side: 'buy',
96832
+ // price: 0.5168600000125209
96833
+ // }
96834
+ let timestamp = undefined;
96835
+ let priceString = undefined;
96836
+ let fee = undefined;
96837
+ const audTotal = this.safeString(trade, 'audtotal');
96838
+ const costString = this.safeString(trade, 'total', audTotal);
96839
+ const side = this.safeString(trade, 'side');
96677
96840
  const amountString = this.safeString(trade, 'amount');
96678
- const costString = this.safeNumber(trade, 'total');
96679
- const timestamp = this.safeInteger(trade, 'solddate');
96680
96841
  const marketId = this.safeString(trade, 'market');
96681
96842
  const symbol = this.safeSymbol(marketId, market, '/');
96843
+ const solddate = this.safeInteger(trade, 'solddate');
96844
+ if (solddate !== undefined) {
96845
+ priceString = this.safeString(trade, 'rate');
96846
+ timestamp = solddate;
96847
+ }
96848
+ else {
96849
+ priceString = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringDiv */ .O.stringDiv(costString, amountString);
96850
+ const createdString = this.safeString(trade, 'created');
96851
+ timestamp = this.parse8601(createdString);
96852
+ const audfeeExGst = this.safeString(trade, 'audfeeExGst');
96853
+ const audGst = this.safeString(trade, 'audGst');
96854
+ // The transaction fee which consumers pay is inclusive of GST by default
96855
+ const feeCost = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise.stringAdd */ .O.stringAdd(audfeeExGst, audGst);
96856
+ const feeCurrencyId = 'AUD';
96857
+ fee = {
96858
+ 'cost': this.parseNumber(feeCost),
96859
+ 'currency': this.safeCurrencyCode(feeCurrencyId),
96860
+ };
96861
+ }
96682
96862
  return this.safeTrade({
96683
96863
  'info': trade,
96684
96864
  'id': undefined,
@@ -96687,12 +96867,12 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96687
96867
  'datetime': this.iso8601(timestamp),
96688
96868
  'order': undefined,
96689
96869
  'type': undefined,
96690
- 'side': undefined,
96870
+ 'side': side,
96691
96871
  'takerOrMaker': undefined,
96692
- 'price': priceString,
96693
- 'amount': amountString,
96694
- 'cost': costString,
96695
- 'fee': undefined,
96872
+ 'price': this.parseNumber(priceString),
96873
+ 'amount': this.parseNumber(amountString),
96874
+ 'cost': this.parseNumber(costString),
96875
+ 'fee': fee,
96696
96876
  }, market);
96697
96877
  }
96698
96878
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -96712,7 +96892,7 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96712
96892
  await this.loadMarkets();
96713
96893
  const method = 'privatePostMy' + this.capitalize(side);
96714
96894
  if (type === 'market') {
96715
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError(this.id + ' createOrder() allows limit orders only');
96895
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ExchangeError(this.id + ' createOrder() allows limit orders only');
96716
96896
  }
96717
96897
  const market = this.market(symbol);
96718
96898
  const request = {
@@ -96734,7 +96914,7 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96734
96914
  */
96735
96915
  const side = this.safeString(params, 'side');
96736
96916
  if (side !== 'buy' && side !== 'sell') {
96737
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"');
96917
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_3__.ArgumentsRequired(this.id + ' cancelOrder() requires a side parameter, "buy" or "sell"');
96738
96918
  }
96739
96919
  params = this.omit(params, 'side');
96740
96920
  const method = 'privatePostMy' + this.capitalize(side) + 'Cancel';
@@ -96752,7 +96932,7 @@ class coinspot extends _abstract_coinspot_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
96752
96932
  headers = {
96753
96933
  'Content-Type': 'application/json',
96754
96934
  'key': this.apiKey,
96755
- 'sign': this.hmac(this.encode(body), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_3__/* .sha512 */ .o),
96935
+ 'sign': this.hmac(this.encode(body), this.encode(this.secret), _static_dependencies_noble_hashes_sha512_js__WEBPACK_IMPORTED_MODULE_4__/* .sha512 */ .o),
96756
96936
  };
96757
96937
  }
96758
96938
  return { 'url': url, 'method': method, 'body': body, 'headers': headers };
@@ -104645,7 +104825,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
104645
104825
  //
104646
104826
  const timestamp = this.safeIntegerProduct(interest, 'timestamp', 0.001);
104647
104827
  const marketId = this.safeString(interest, 'symbol');
104648
- return {
104828
+ return this.safeOpenInterest({
104649
104829
  'symbol': this.safeSymbol(marketId, market),
104650
104830
  'baseVolume': this.safeNumber(interest, 'oi_value'),
104651
104831
  'quoteVolume': this.safeNumber(interest, 'oi_value_usd'),
@@ -104654,7 +104834,7 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
104654
104834
  'timestamp': timestamp,
104655
104835
  'datetime': this.iso8601(timestamp),
104656
104836
  'info': interest,
104657
- };
104837
+ }, market);
104658
104838
  }
104659
104839
  async fetchLeverage(symbol, params = {}) {
104660
104840
  /**
@@ -105432,7 +105612,7 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
105432
105612
  const defaultCode = this.safeValue(this.options, 'code', 'BTC');
105433
105613
  const options = this.safeValue(this.options, methodName, {});
105434
105614
  const code = this.safeValue(options, 'code', defaultCode);
105435
- return this.safeValue2(params, 'code', code);
105615
+ return this.safeValue(params, 'code', code);
105436
105616
  }
105437
105617
  async fetchStatus(params = {}) {
105438
105618
  /**
@@ -107769,10 +107949,16 @@ class deribit extends _abstract_deribit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
107769
107949
  * @param {string} symbol unified market symbol
107770
107950
  * @param {object} [params] extra parameters specific to the deribit api endpoint
107771
107951
  * @param {int} [params.end_timestamp] fetch funding rate ending at this timestamp
107952
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
107772
107953
  * @returns {object} a [funding rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-structure}
107773
107954
  */
107774
107955
  await this.loadMarkets();
107775
107956
  const market = this.market(symbol);
107957
+ let paginate = false;
107958
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
107959
+ if (paginate) {
107960
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 720);
107961
+ }
107776
107962
  const time = this.milliseconds();
107777
107963
  const month = 30 * 24 * 60 * 60 * 1000;
107778
107964
  if (since === undefined) {
@@ -124257,19 +124443,28 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
124257
124443
  * @method
124258
124444
  * @name hitbtc#fetchOHLCV
124259
124445
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
124446
+ * @see https://api.hitbtc.com/#candles
124260
124447
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
124261
124448
  * @param {string} timeframe the length of time each candle represents
124262
124449
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
124263
124450
  * @param {int} [limit] the maximum amount of candles to fetch
124264
124451
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
124452
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
124453
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
124265
124454
  * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
124266
124455
  */
124267
124456
  await this.loadMarkets();
124457
+ let paginate = false;
124458
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOHLCV', 'paginate');
124459
+ if (paginate) {
124460
+ return await this.fetchPaginatedCallDeterministic('fetchOHLCV', symbol, since, limit, timeframe, params, 1000);
124461
+ }
124268
124462
  const market = this.market(symbol);
124269
- const request = {
124463
+ let request = {
124270
124464
  'symbols': market['id'],
124271
124465
  'period': this.safeString(this.timeframes, timeframe, timeframe),
124272
124466
  };
124467
+ [request, params] = this.handleUntilOption('till', request, params);
124273
124468
  if (since !== undefined) {
124274
124469
  request['from'] = this.iso8601(since);
124275
124470
  }
@@ -125064,16 +125259,24 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
125064
125259
  /**
125065
125260
  * @method
125066
125261
  * @name hitbtc#fetchFundingRateHistory
125262
+ * @see https://api.hitbtc.com/#funding-history
125067
125263
  * @description fetches historical funding rate prices
125068
125264
  * @param {string} symbol unified symbol of the market to fetch the funding rate history for
125069
125265
  * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
125070
125266
  * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
125071
125267
  * @param {object} [params] extra parameters specific to the hitbtc api endpoint
125268
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
125269
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
125072
125270
  * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
125073
125271
  */
125074
125272
  await this.loadMarkets();
125273
+ let paginate = false;
125274
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
125275
+ if (paginate) {
125276
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
125277
+ }
125075
125278
  let market = undefined;
125076
- const request = {
125279
+ let request = {
125077
125280
  // all arguments are optional
125078
125281
  // 'symbols': Comma separated list of symbol codes,
125079
125282
  // 'sort': 'DESC' or 'ASC'
@@ -125082,6 +125285,7 @@ class hitbtc extends _abstract_hitbtc_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
125082
125285
  // 'limit': 100,
125083
125286
  // 'offset': 0,
125084
125287
  };
125288
+ [request, params] = this.handleUntilOption('till', request, params);
125085
125289
  if (symbol !== undefined) {
125086
125290
  market = this.market(symbol);
125087
125291
  symbol = market['symbol'];
@@ -135421,10 +135625,9 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
135421
135625
  const data = this.safeValue(response, 'data', []);
135422
135626
  const openInterest = this.parseOpenInterest(data[0], market);
135423
135627
  const timestamp = this.safeInteger(response, 'ts');
135424
- return this.extend(openInterest, {
135425
- 'timestamp': timestamp,
135426
- 'datetime': this.iso8601(timestamp),
135427
- });
135628
+ openInterest['timestamp'] = timestamp;
135629
+ openInterest['datetime'] = this.iso8601(timestamp);
135630
+ return openInterest;
135428
135631
  }
135429
135632
  parseOpenInterest(interest, market = undefined) {
135430
135633
  //
@@ -135482,7 +135685,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
135482
135685
  const timestamp = this.safeInteger(interest, 'ts');
135483
135686
  const amount = this.safeNumber(interest, 'volume');
135484
135687
  const value = this.safeNumber(interest, 'value');
135485
- return {
135688
+ return this.safeOpenInterest({
135486
135689
  'symbol': this.safeString(market, 'symbol'),
135487
135690
  'baseVolume': amount,
135488
135691
  'quoteVolume': value,
@@ -135491,7 +135694,7 @@ class huobi extends _abstract_huobi_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
135491
135694
  'timestamp': timestamp,
135492
135695
  'datetime': this.iso8601(timestamp),
135493
135696
  'info': interest,
135494
- };
135697
+ }, market);
135495
135698
  }
135496
135699
  async borrowMargin(code, amount, symbol = undefined, params = {}) {
135497
135700
  /**
@@ -178203,7 +178406,6 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178203
178406
  for (let i = 0; i < types.length; i++) {
178204
178407
  promises.push(this.fetchMarketsByType(types[i], params));
178205
178408
  }
178206
- // why not both ¯\_(ツ)_/¯
178207
178409
  promises = await Promise.all(promises);
178208
178410
  for (let i = 0; i < promises.length; i++) {
178209
178411
  result = this.arrayConcat(result, promises[i]);
@@ -178337,6 +178539,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
178337
178539
  'expiryDatetime': this.iso8601(expiry),
178338
178540
  'strike': strikePrice,
178339
178541
  'optionType': optionType,
178542
+ 'created': this.safeInteger(market, 'listTime'),
178340
178543
  'precision': {
178341
178544
  'amount': this.safeNumber(market, 'lotSz'),
178342
178545
  'price': this.parseNumber(tickSize),
@@ -183523,7 +183726,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
183523
183726
  openInterestAmount = this.safeNumber(interest, 'oi');
183524
183727
  openInterestValue = this.safeNumber(interest, 'oiCcy');
183525
183728
  }
183526
- return {
183729
+ return this.safeOpenInterest({
183527
183730
  'symbol': this.safeSymbol(id),
183528
183731
  'baseVolume': baseVolume,
183529
183732
  'quoteVolume': quoteVolume,
@@ -183532,7 +183735,7 @@ class okx extends _abstract_okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
183532
183735
  'timestamp': timestamp,
183533
183736
  'datetime': this.iso8601(timestamp),
183534
183737
  'info': interest,
183535
- };
183738
+ }, market);
183536
183739
  }
183537
183740
  setSandboxMode(enable) {
183538
183741
  super.setSandboxMode(enable);
@@ -188790,6 +188993,19 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188790
188993
  return this.safeString(statuses, status, status);
188791
188994
  }
188792
188995
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
188996
+ /**
188997
+ * @method
188998
+ * @name phemex#fetchFundingRateHistory
188999
+ * @description fetches historical funding rate prices
189000
+ * @see https://phemex-docs.github.io/#query-funding-rate-history-2
189001
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
189002
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
189003
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
189004
+ * @param {object} [params] extra parameters specific to the phemex api endpoint
189005
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
189006
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
189007
+ * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
189008
+ */
188793
189009
  this.checkRequiredSymbol('fetchFundingRateHistory', symbol);
188794
189010
  await this.loadMarkets();
188795
189011
  const market = this.market(symbol);
@@ -188797,6 +189013,11 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188797
189013
  if (!market['swap']) {
188798
189014
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' fetchFundingRateHistory() supports swap contracts only');
188799
189015
  }
189016
+ let paginate = false;
189017
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
189018
+ if (paginate) {
189019
+ return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 100);
189020
+ }
188800
189021
  let customSymbol = undefined;
188801
189022
  if (isUsdtSettled) {
188802
189023
  customSymbol = '.' + market['id'] + 'FR8H'; // phemex requires a custom symbol for funding rate history
@@ -188804,7 +189025,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188804
189025
  else {
188805
189026
  customSymbol = '.' + market['baseId'] + 'FR8H';
188806
189027
  }
188807
- const request = {
189028
+ let request = {
188808
189029
  'symbol': customSymbol,
188809
189030
  };
188810
189031
  if (since !== undefined) {
@@ -188813,6 +189034,7 @@ class phemex extends _abstract_phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
188813
189034
  if (limit !== undefined) {
188814
189035
  request['limit'] = limit;
188815
189036
  }
189037
+ [request, params] = this.handleUntilOption('end', request, params);
188816
189038
  let response = undefined;
188817
189039
  if (isUsdtSettled) {
188818
189040
  response = await this.v2GetApiDataPublicDataFundingRateHistory(this.extend(request, params));
@@ -194955,14 +195177,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
194955
195177
  * @param {object} [params] extra parameters specific to the binance api endpoint
194956
195178
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
194957
195179
  */
194958
- if (limit !== undefined) {
194959
- if ((limit !== 5) && (limit !== 10) && (limit !== 20) && (limit !== 50) && (limit !== 100) && (limit !== 500) && (limit !== 1000)) {
194960
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ExchangeError(this.id + ' watchOrderBook limit argument must be undefined, 5, 10, 20, 50, 100, 500 or 1000');
194961
- }
194962
- }
194963
- //
194964
195180
  await this.loadMarkets();
194965
- symbols = this.marketSymbols(symbols);
195181
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
194966
195182
  const firstMarket = this.market(symbols[0]);
194967
195183
  let type = firstMarket['type'];
194968
195184
  if (firstMarket['contract']) {
@@ -195225,7 +195441,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
195225
195441
  * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/en/latest/manual.html?#public-trades}
195226
195442
  */
195227
195443
  await this.loadMarkets();
195228
- symbols = this.marketSymbols(symbols);
195444
+ symbols = this.marketSymbols(symbols, undefined, false, true, true);
195229
195445
  const options = this.safeValue(this.options, 'watchTradesForSymbols', {});
195230
195446
  const name = this.safeString(options, 'name', 'trade');
195231
195447
  const firstMarket = this.market(symbols[0]);
@@ -195700,7 +195916,7 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
195700
195916
  * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
195701
195917
  */
195702
195918
  await this.loadMarkets();
195703
- symbols = this.marketSymbols(symbols);
195919
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
195704
195920
  const marketIds = this.marketIds(symbols);
195705
195921
  let market = undefined;
195706
195922
  let type = undefined;
@@ -233682,10 +233898,10 @@ class phemex extends _phemex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
233682
233898
  },
233683
233899
  'urls': {
233684
233900
  'test': {
233685
- 'ws': 'wss://testnet.phemex.com/ws',
233901
+ 'ws': 'wss://testnet-api.phemex.com/ws',
233686
233902
  },
233687
233903
  'api': {
233688
- 'ws': 'wss://phemex.com/ws',
233904
+ 'ws': 'wss://ws.phemex.com',
233689
233905
  },
233690
233906
  },
233691
233907
  'options': {
@@ -242077,6 +242293,9 @@ class probit extends _abstract_probit_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
242077
242293
  if (limit !== undefined) {
242078
242294
  request['limit'] = limit;
242079
242295
  }
242296
+ else {
242297
+ request['limit'] = 100;
242298
+ }
242080
242299
  const response = await this.privateGetTransferPayment(this.extend(request, params));
242081
242300
  //
242082
242301
  // {
@@ -262187,13 +262406,14 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262187
262406
  // "stockPrec": "3", // Stock currency precision
262188
262407
  // "moneyPrec": "2", // Precision of money currency
262189
262408
  // "feePrec": "4", // Fee precision
262190
- // "makerFee": "0.001", // Default maker fee ratio
262191
- // "takerFee": "0.001", // Default taker fee ratio
262409
+ // "makerFee": "0.1", // Default maker fee ratio
262410
+ // "takerFee": "0.1", // Default taker fee ratio
262192
262411
  // "minAmount": "0.001", // Minimal amount of stock to trade
262193
262412
  // "minTotal": "0.001", // Minimal amount of money to trade
262194
262413
  // "tradesEnabled": true, // Is trading enabled
262195
262414
  // "isCollateral": true, // Is margin trading enabled
262196
- // "type": "spot" // Market type. Possible values: "spot", "futures"
262415
+ // "type": "spot", // Market type. Possible values: "spot", "futures"
262416
+ // "maxTotal": "1000000000" // Maximum total(amount * price) of money to trade
262197
262417
  // },
262198
262418
  // {
262199
262419
  // ...
@@ -262235,6 +262455,10 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262235
262455
  else {
262236
262456
  type = 'spot';
262237
262457
  }
262458
+ const takerFeeRate = this.safeString(market, 'takerFee');
262459
+ const taker = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(takerFeeRate, '100');
262460
+ const makerFeeRate = this.safeString(market, 'makerFee');
262461
+ const maker = _base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringDiv */ .O.stringDiv(makerFeeRate, '100');
262238
262462
  const entry = {
262239
262463
  'id': id,
262240
262464
  'symbol': symbol,
@@ -262254,8 +262478,8 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262254
262478
  'contract': contract,
262255
262479
  'linear': linear,
262256
262480
  'inverse': inverse,
262257
- 'taker': this.safeNumber(market, 'makerFee'),
262258
- 'maker': this.safeNumber(market, 'takerFee'),
262481
+ 'taker': this.parseNumber(taker),
262482
+ 'maker': this.parseNumber(maker),
262259
262483
  'contractSize': contractSize,
262260
262484
  'expiry': undefined,
262261
262485
  'expiryDatetime': undefined,
@@ -262280,7 +262504,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262280
262504
  },
262281
262505
  'cost': {
262282
262506
  'min': this.safeNumber(market, 'minTotal'),
262283
- 'max': undefined,
262507
+ 'max': this.safeNumber(market, 'maxTotal'),
262284
262508
  },
262285
262509
  },
262286
262510
  'info': market,
@@ -262724,6 +262948,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262724
262948
  /**
262725
262949
  * @method
262726
262950
  * @name whitebit#fetchOrderBook
262951
+ * @see https://whitebit-exchange.github.io/api-docs/public/http-v4/#orderbook
262727
262952
  * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
262728
262953
  * @param {string} symbol unified symbol of the market to fetch the order book for
262729
262954
  * @param {int} [limit] the maximum amount of order book entries to return
@@ -262736,7 +262961,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262736
262961
  'market': market['id'],
262737
262962
  };
262738
262963
  if (limit !== undefined) {
262739
- request['depth'] = limit; // default = 50, maximum = 100
262964
+ request['limit'] = limit; // default = 100, maximum = 100
262740
262965
  }
262741
262966
  const response = await this.v4PublicGetOrderbookMarket(this.extend(request, params));
262742
262967
  //
@@ -262758,7 +262983,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262758
262983
  // ]
262759
262984
  // }
262760
262985
  //
262761
- const timestamp = this.parseToInt(_base_Precise_js__WEBPACK_IMPORTED_MODULE_3__/* .Precise.stringMul */ .O.stringMul(this.safeString(response, 'timestamp'), '1000'));
262986
+ const timestamp = this.safeIntegerProduct(response, 'timestamp', 1000);
262762
262987
  return this.parseOrderBook(response, symbol, timestamp);
262763
262988
  }
262764
262989
  async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
@@ -262970,10 +263195,7 @@ class whitebit extends _abstract_whitebit_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
262970
263195
  }
262971
263196
  limit = Math.min(limit, maxLimit);
262972
263197
  const start = this.parseToInt(since / 1000);
262973
- const duration = this.parseTimeframe(timeframe);
262974
- const end = this.sum(start, duration * limit);
262975
263198
  request['start'] = start;
262976
- request['end'] = end;
262977
263199
  }
262978
263200
  if (limit !== undefined) {
262979
263201
  request['limit'] = Math.min(limit, 1440);
@@ -265581,6 +265803,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
265581
265803
  /**
265582
265804
  * @method
265583
265805
  * @name woo#fetchOHLCV
265806
+ * @see https://docs.woo.org/#kline-public
265584
265807
  * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
265585
265808
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
265586
265809
  * @param {string} timeframe the length of time each candle represents
@@ -266547,8 +266770,26 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
266547
266770
  return this.filterByArray(result, 'symbol', symbols);
266548
266771
  }
266549
266772
  async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
266773
+ /**
266774
+ * @method
266775
+ * @name woo#fetchFundingRateHistory
266776
+ * @description fetches historical funding rate prices
266777
+ * @see https://docs.woo.org/#get-funding-rate-history-for-one-market-public
266778
+ * @param {string} symbol unified symbol of the market to fetch the funding rate history for
266779
+ * @param {int} [since] timestamp in ms of the earliest funding rate to fetch
266780
+ * @param {int} [limit] the maximum amount of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure} to fetch
266781
+ * @param {object} [params] extra parameters specific to the woo api endpoint
266782
+ * @param {int} [params.until] timestamp in ms of the latest funding rate
266783
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
266784
+ * @returns {object[]} a list of [funding rate structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-rate-history-structure}
266785
+ */
266550
266786
  await this.loadMarkets();
266551
- const request = {};
266787
+ let paginate = false;
266788
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchFundingRateHistory', 'paginate');
266789
+ if (paginate) {
266790
+ return await this.fetchPaginatedCallIncremental('fetchFundingRateHistory', symbol, since, limit, params, 'page', 25);
266791
+ }
266792
+ let request = {};
266552
266793
  if (symbol !== undefined) {
266553
266794
  const market = this.market(symbol);
266554
266795
  symbol = market['symbol'];
@@ -266557,6 +266798,7 @@ class woo extends _abstract_woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
266557
266798
  if (since !== undefined) {
266558
266799
  request['start_t'] = this.parseToInt(since / 1000);
266559
266800
  }
266801
+ [request, params] = this.handleUntilOption('end_t', request, params, 0.001);
266560
266802
  const response = await this.v1PublicGetFundingRateHistory(this.extend(request, params));
266561
266803
  //
266562
266804
  // {
@@ -276313,7 +276555,7 @@ SOFTWARE.
276313
276555
 
276314
276556
  //-----------------------------------------------------------------------------
276315
276557
  // this is updated by vss.js when building
276316
- const version = '4.1.9';
276558
+ const version = '4.1.11';
276317
276559
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange.ccxtVersion */ .e.ccxtVersion = version;
276318
276560
  //-----------------------------------------------------------------------------
276319
276561