ccxt 4.1.94 → 4.1.96

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 (56) hide show
  1. package/README.md +3 -3
  2. package/build.sh +16 -16
  3. package/dist/ccxt.browser.js +417 -275
  4. package/dist/ccxt.browser.min.js +2 -2
  5. package/dist/cjs/ccxt.js +1 -1
  6. package/dist/cjs/src/binance.js +145 -135
  7. package/dist/cjs/src/bingx.js +8 -7
  8. package/dist/cjs/src/bit2c.js +2 -3
  9. package/dist/cjs/src/bitfinex2.js +2 -3
  10. package/dist/cjs/src/bitget.js +32 -24
  11. package/dist/cjs/src/bitmart.js +1 -1
  12. package/dist/cjs/src/btcbox.js +2 -3
  13. package/dist/cjs/src/coinbase.js +11 -5
  14. package/dist/cjs/src/cryptocom.js +2 -1
  15. package/dist/cjs/src/delta.js +25 -0
  16. package/dist/cjs/src/gate.js +2 -2
  17. package/dist/cjs/src/kraken.js +46 -45
  18. package/dist/cjs/src/krakenfutures.js +53 -26
  19. package/dist/cjs/src/kucoin.js +73 -3
  20. package/dist/cjs/src/kucoinfutures.js +1 -1
  21. package/dist/cjs/src/pro/binance.js +2 -3
  22. package/dist/cjs/src/pro/bitfinex.js +2 -3
  23. package/dist/cjs/src/pro/cex.js +1 -1
  24. package/dist/cjs/src/pro/gate.js +2 -2
  25. package/dist/cjs/src/pro/kraken.js +2 -3
  26. package/dist/cjs/src/pro/okx.js +1 -1
  27. package/dist/cjs/src/pro/woo.js +2 -3
  28. package/js/ccxt.d.ts +1 -1
  29. package/js/ccxt.js +1 -1
  30. package/js/src/abstract/kucoin.d.ts +12 -0
  31. package/js/src/abstract/kucoinfutures.d.ts +12 -1
  32. package/js/src/binance.js +145 -135
  33. package/js/src/bingx.js +8 -7
  34. package/js/src/bit2c.js +2 -3
  35. package/js/src/bitfinex2.js +2 -3
  36. package/js/src/bitget.js +32 -24
  37. package/js/src/bitmart.js +1 -1
  38. package/js/src/btcbox.js +2 -3
  39. package/js/src/coinbase.js +11 -5
  40. package/js/src/cryptocom.js +2 -1
  41. package/js/src/delta.d.ts +5 -4
  42. package/js/src/delta.js +25 -0
  43. package/js/src/gate.js +2 -2
  44. package/js/src/kraken.js +46 -45
  45. package/js/src/krakenfutures.js +53 -26
  46. package/js/src/kucoin.d.ts +3 -0
  47. package/js/src/kucoin.js +73 -3
  48. package/js/src/kucoinfutures.js +1 -1
  49. package/js/src/pro/binance.js +2 -3
  50. package/js/src/pro/bitfinex.js +2 -3
  51. package/js/src/pro/cex.js +1 -1
  52. package/js/src/pro/gate.js +2 -2
  53. package/js/src/pro/kraken.js +2 -3
  54. package/js/src/pro/okx.js +1 -1
  55. package/js/src/pro/woo.js +2 -3
  56. package/package.json +2 -2
@@ -19647,24 +19647,23 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19647
19647
  let type = this.safeString(params, 'type', defaultType);
19648
19648
  let subType = undefined;
19649
19649
  [subType, params] = this.handleSubTypeAndParams('fetchBalance', undefined, params);
19650
- const [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
19651
- let method = 'privateGetAccount';
19650
+ let marginMode = undefined;
19651
+ let query = undefined;
19652
+ [marginMode, query] = this.handleMarginModeAndParams('fetchBalance', params);
19653
+ query = this.omit(query, 'type');
19654
+ let response = undefined;
19652
19655
  const request = {};
19653
19656
  if (this.isLinear(type, subType)) {
19654
- const options = this.safeValue(this.options, type, {});
19655
- const fetchBalanceOptions = this.safeValue(options, 'fetchBalance', {});
19656
- method = this.safeString(fetchBalanceOptions, 'method', 'fapiPrivateV2GetAccount');
19657
19657
  type = 'linear';
19658
+ response = await this.fapiPrivateV2GetAccount(this.extend(request, query));
19658
19659
  }
19659
19660
  else if (this.isInverse(type, subType)) {
19660
- const options = this.safeValue(this.options, type, {});
19661
- const fetchBalanceOptions = this.safeValue(options, 'fetchBalance', {});
19662
- method = this.safeString(fetchBalanceOptions, 'method', 'dapiPrivateGetAccount');
19663
19661
  type = 'inverse';
19662
+ response = await this.dapiPrivateGetAccount(this.extend(request, query));
19664
19663
  }
19665
19664
  else if (marginMode === 'isolated') {
19666
- method = 'sapiGetMarginIsolatedAccount';
19667
19665
  const paramSymbols = this.safeValue(params, 'symbols');
19666
+ query = this.omit(query, 'symbols');
19668
19667
  if (paramSymbols !== undefined) {
19669
19668
  let symbols = '';
19670
19669
  if (Array.isArray(paramSymbols)) {
@@ -19680,18 +19679,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
19680
19679
  }
19681
19680
  request['symbols'] = symbols;
19682
19681
  }
19682
+ response = await this.sapiGetMarginIsolatedAccount(this.extend(request, query));
19683
19683
  }
19684
19684
  else if ((type === 'margin') || (marginMode === 'cross')) {
19685
- method = 'sapiGetMarginAccount';
19685
+ response = await this.sapiGetMarginAccount(this.extend(request, query));
19686
19686
  }
19687
19687
  else if (type === 'savings') {
19688
- method = 'sapiGetLendingUnionAccount';
19688
+ response = await this.sapiGetLendingUnionAccount(this.extend(request, query));
19689
19689
  }
19690
19690
  else if (type === 'funding') {
19691
- method = 'sapiPostAssetGetFundingAsset';
19691
+ response = await this.sapiPostAssetGetFundingAsset(this.extend(request, query));
19692
+ }
19693
+ else {
19694
+ response = await this.privateGetAccount(this.extend(request, query));
19692
19695
  }
19693
- const requestParams = this.omit(query, ['type', 'symbols']);
19694
- const response = await this[method](this.extend(request, requestParams));
19695
19696
  //
19696
19697
  // spot
19697
19698
  //
@@ -20383,33 +20384,35 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
20383
20384
  if (until !== undefined) {
20384
20385
  request['endTime'] = until;
20385
20386
  }
20386
- let method = 'publicGetKlines';
20387
+ let response = undefined;
20387
20388
  if (market['option']) {
20388
- method = 'eapiPublicGetKlines';
20389
+ response = await this.eapiPublicGetKlines(this.extend(request, params));
20389
20390
  }
20390
20391
  else if (price === 'mark') {
20391
20392
  if (market['inverse']) {
20392
- method = 'dapiPublicGetMarkPriceKlines';
20393
+ response = await this.dapiPublicGetMarkPriceKlines(this.extend(request, params));
20393
20394
  }
20394
20395
  else {
20395
- method = 'fapiPublicGetMarkPriceKlines';
20396
+ response = await this.fapiPublicGetMarkPriceKlines(this.extend(request, params));
20396
20397
  }
20397
20398
  }
20398
20399
  else if (price === 'index') {
20399
20400
  if (market['inverse']) {
20400
- method = 'dapiPublicGetIndexPriceKlines';
20401
+ response = await this.dapiPublicGetIndexPriceKlines(this.extend(request, params));
20401
20402
  }
20402
20403
  else {
20403
- method = 'fapiPublicGetIndexPriceKlines';
20404
+ response = await this.fapiPublicGetIndexPriceKlines(this.extend(request, params));
20404
20405
  }
20405
20406
  }
20406
20407
  else if (market['linear']) {
20407
- method = 'fapiPublicGetKlines';
20408
+ response = await this.fapiPublicGetKlines(this.extend(request, params));
20408
20409
  }
20409
20410
  else if (market['inverse']) {
20410
- method = 'dapiPublicGetKlines';
20411
+ response = await this.dapiPublicGetKlines(this.extend(request, params));
20412
+ }
20413
+ else {
20414
+ response = await this.publicGetKlines(this.extend(request, params));
20411
20415
  }
20412
- const response = await this[method](this.extend(request, params));
20413
20416
  //
20414
20417
  // [
20415
20418
  // [1591478520000,"0.02501300","0.02501800","0.02500000","0.02500000","22.19000000",1591478579999,"0.55490906",40,"10.92900000","0.27336462","0"],
@@ -21825,22 +21828,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21825
21828
  const request = {
21826
21829
  'symbol': market['id'],
21827
21830
  };
21828
- let method = 'privateGetOrder';
21829
- if (market['option']) {
21830
- method = 'eapiPrivateGetOrder';
21831
- }
21832
- else if (market['linear']) {
21833
- method = 'fapiPrivateGetOrder';
21834
- }
21835
- else if (market['inverse']) {
21836
- method = 'dapiPrivateGetOrder';
21837
- }
21838
- else if (type === 'margin' || marginMode !== undefined) {
21839
- method = 'sapiGetMarginOrder';
21840
- if (marginMode === 'isolated') {
21841
- request['isIsolated'] = true;
21842
- }
21843
- }
21844
21831
  const clientOrderId = this.safeValue2(params, 'origClientOrderId', 'clientOrderId');
21845
21832
  if (clientOrderId !== undefined) {
21846
21833
  if (market['option']) {
@@ -21854,7 +21841,25 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21854
21841
  request['orderId'] = id;
21855
21842
  }
21856
21843
  const requestParams = this.omit(query, ['type', 'clientOrderId', 'origClientOrderId']);
21857
- const response = await this[method](this.extend(request, requestParams));
21844
+ let response = undefined;
21845
+ if (market['option']) {
21846
+ response = await this.eapiPrivateGetOrder(this.extend(request, requestParams));
21847
+ }
21848
+ else if (market['linear']) {
21849
+ response = await this.fapiPrivateGetOrder(this.extend(request, requestParams));
21850
+ }
21851
+ else if (market['inverse']) {
21852
+ response = await this.dapiPrivateGetOrder(this.extend(request, requestParams));
21853
+ }
21854
+ else if (type === 'margin' || marginMode !== undefined) {
21855
+ if (marginMode === 'isolated') {
21856
+ request['isIsolated'] = true;
21857
+ }
21858
+ response = await this.sapiGetMarginOrder(this.extend(request, requestParams));
21859
+ }
21860
+ else {
21861
+ response = await this.privateGetOrder(this.extend(request, requestParams));
21862
+ }
21858
21863
  return this.parseOrder(response, market);
21859
21864
  }
21860
21865
  async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -21892,34 +21897,36 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
21892
21897
  const request = {
21893
21898
  'symbol': market['id'],
21894
21899
  };
21895
- let method = 'privateGetAllOrders';
21900
+ const until = this.safeInteger(params, 'until');
21901
+ if (until !== undefined) {
21902
+ params = this.omit(params, 'until');
21903
+ request['endTime'] = until;
21904
+ }
21905
+ if (since !== undefined) {
21906
+ request['startTime'] = since;
21907
+ }
21908
+ if (limit !== undefined) {
21909
+ request['limit'] = limit;
21910
+ }
21911
+ let response = undefined;
21896
21912
  if (market['option']) {
21897
- method = 'eapiPrivateGetHistoryOrders';
21913
+ response = await this.eapiPrivateGetHistoryOrders(this.extend(request, query));
21898
21914
  }
21899
21915
  else if (market['linear']) {
21900
- method = 'fapiPrivateGetAllOrders';
21916
+ response = await this.fapiPrivateGetAllOrders(this.extend(request, query));
21901
21917
  }
21902
21918
  else if (market['inverse']) {
21903
- method = 'dapiPrivateGetAllOrders';
21919
+ response = await this.dapiPrivateGetAllOrders(this.extend(request, query));
21904
21920
  }
21905
21921
  else if (type === 'margin' || marginMode !== undefined) {
21906
- method = 'sapiGetMarginAllOrders';
21907
21922
  if (marginMode === 'isolated') {
21908
21923
  request['isIsolated'] = true;
21909
21924
  }
21925
+ response = await this.sapiGetMarginAllOrders(this.extend(request, query));
21910
21926
  }
21911
- const until = this.safeInteger(params, 'until');
21912
- if (until !== undefined) {
21913
- params = this.omit(params, 'until');
21914
- request['endTime'] = until;
21915
- }
21916
- if (since !== undefined) {
21917
- request['startTime'] = since;
21918
- }
21919
- if (limit !== undefined) {
21920
- request['limit'] = limit;
21927
+ else {
21928
+ response = await this.privateGetAllOrders(this.extend(request, query));
21921
21929
  }
21922
- const response = await this[method](this.extend(request, query));
21923
21930
  //
21924
21931
  // spot
21925
21932
  //
@@ -22044,32 +22051,34 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22044
22051
  let subType = undefined;
22045
22052
  [subType, query] = this.handleSubTypeAndParams('fetchOpenOrders', market, query);
22046
22053
  const requestParams = this.omit(query, 'type');
22047
- let method = 'privateGetOpenOrders';
22054
+ let response = undefined;
22048
22055
  if (type === 'option') {
22049
- method = 'eapiPrivateGetOpenOrders';
22050
22056
  if (since !== undefined) {
22051
22057
  request['startTime'] = since;
22052
22058
  }
22053
22059
  if (limit !== undefined) {
22054
22060
  request['limit'] = limit;
22055
22061
  }
22062
+ response = await this.eapiPrivateGetOpenOrders(this.extend(request, requestParams));
22056
22063
  }
22057
22064
  else if (this.isLinear(type, subType)) {
22058
- method = 'fapiPrivateGetOpenOrders';
22065
+ response = await this.fapiPrivateGetOpenOrders(this.extend(request, requestParams));
22059
22066
  }
22060
22067
  else if (this.isInverse(type, subType)) {
22061
- method = 'dapiPrivateGetOpenOrders';
22068
+ response = await this.dapiPrivateGetOpenOrders(this.extend(request, requestParams));
22062
22069
  }
22063
22070
  else if (type === 'margin' || marginMode !== undefined) {
22064
- method = 'sapiGetMarginOpenOrders';
22065
22071
  if (marginMode === 'isolated') {
22066
22072
  request['isIsolated'] = true;
22067
22073
  if (symbol === undefined) {
22068
22074
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument for isolated markets');
22069
22075
  }
22070
22076
  }
22077
+ response = await this.sapiGetMarginOpenOrders(this.extend(request, requestParams));
22078
+ }
22079
+ else {
22080
+ response = await this.privateGetOpenOrders(this.extend(request, requestParams));
22071
22081
  }
22072
- const response = await this[method](this.extend(request, requestParams));
22073
22082
  return this.parseOrders(response, market, since, limit);
22074
22083
  }
22075
22084
  async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -22160,24 +22169,26 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22160
22169
  else {
22161
22170
  request['orderId'] = id;
22162
22171
  }
22163
- let method = 'privateDeleteOrder';
22172
+ const requestParams = this.omit(query, ['type', 'origClientOrderId', 'clientOrderId']);
22173
+ let response = undefined;
22164
22174
  if (market['option']) {
22165
- method = 'eapiPrivateDeleteOrder';
22175
+ response = await this.eapiPrivateDeleteOrder(this.extend(request, requestParams));
22166
22176
  }
22167
22177
  else if (market['linear']) {
22168
- method = 'fapiPrivateDeleteOrder';
22178
+ response = await this.fapiPrivateDeleteOrder(this.extend(request, requestParams));
22169
22179
  }
22170
22180
  else if (market['inverse']) {
22171
- method = 'dapiPrivateDeleteOrder';
22181
+ response = await this.dapiPrivateDeleteOrder(this.extend(request, requestParams));
22172
22182
  }
22173
22183
  else if (type === 'margin' || marginMode !== undefined) {
22174
- method = 'sapiDeleteMarginOrder';
22175
22184
  if (marginMode === 'isolated') {
22176
22185
  request['isIsolated'] = true;
22177
22186
  }
22187
+ response = await this.sapiDeleteMarginOrder(this.extend(request, requestParams));
22188
+ }
22189
+ else {
22190
+ response = await this.privateDeleteOrder(this.extend(request, requestParams));
22178
22191
  }
22179
- const requestParams = this.omit(query, ['type', 'origClientOrderId', 'clientOrderId']);
22180
- const response = await this[method](this.extend(request, requestParams));
22181
22192
  return this.parseOrder(response, market);
22182
22193
  }
22183
22194
  async cancelAllOrders(symbol = undefined, params = {}) {
@@ -22206,23 +22217,25 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22206
22217
  const type = this.safeString(params, 'type', market['type']);
22207
22218
  params = this.omit(params, ['type']);
22208
22219
  const [marginMode, query] = this.handleMarginModeAndParams('cancelAllOrders', params);
22209
- let method = 'privateDeleteOpenOrders';
22220
+ let response = undefined;
22210
22221
  if (market['option']) {
22211
- method = 'eapiPrivateDeleteAllOpenOrders';
22222
+ response = await this.eapiPrivateDeleteAllOpenOrders(this.extend(request, query));
22212
22223
  }
22213
22224
  else if (market['linear']) {
22214
- method = 'fapiPrivateDeleteAllOpenOrders';
22225
+ response = await this.fapiPrivateDeleteAllOpenOrders(this.extend(request, query));
22215
22226
  }
22216
22227
  else if (market['inverse']) {
22217
- method = 'dapiPrivateDeleteAllOpenOrders';
22228
+ response = await this.dapiPrivateDeleteAllOpenOrders(this.extend(request, query));
22218
22229
  }
22219
22230
  else if ((type === 'margin') || (marginMode !== undefined)) {
22220
- method = 'sapiDeleteMarginOpenOrders';
22221
22231
  if (marginMode === 'isolated') {
22222
22232
  request['isIsolated'] = true;
22223
22233
  }
22234
+ response = await this.sapiDeleteMarginOpenOrders(this.extend(request, query));
22235
+ }
22236
+ else {
22237
+ response = await this.privateDeleteOpenOrders(this.extend(request, query));
22224
22238
  }
22225
- const response = await this[method](this.extend(request, query));
22226
22239
  if (Array.isArray(response)) {
22227
22240
  return this.parseOrders(response, market);
22228
22241
  }
@@ -22359,37 +22372,12 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22359
22372
  const request = {};
22360
22373
  let market = undefined;
22361
22374
  let type = undefined;
22362
- let method = undefined;
22363
22375
  let marginMode = undefined;
22364
22376
  if (symbol !== undefined) {
22365
22377
  market = this.market(symbol);
22366
22378
  request['symbol'] = market['id'];
22367
22379
  }
22368
22380
  [type, params] = this.handleMarketTypeAndParams('fetchMyTrades', market, params);
22369
- if (type === 'option') {
22370
- method = 'eapiPrivateGetUserTrades';
22371
- }
22372
- else {
22373
- if (symbol === undefined) {
22374
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
22375
- }
22376
- [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
22377
- if (type === 'spot' || type === 'margin') {
22378
- method = 'privateGetMyTrades';
22379
- if ((type === 'margin') || (marginMode !== undefined)) {
22380
- method = 'sapiGetMarginMyTrades';
22381
- if (marginMode === 'isolated') {
22382
- request['isIsolated'] = true;
22383
- }
22384
- }
22385
- }
22386
- else if (market['linear']) {
22387
- method = 'fapiPrivateGetUserTrades';
22388
- }
22389
- else if (market['inverse']) {
22390
- method = 'dapiPrivateGetUserTrades';
22391
- }
22392
- }
22393
22381
  let endTime = this.safeInteger2(params, 'until', 'endTime');
22394
22382
  if (since !== undefined) {
22395
22383
  const startTime = since;
@@ -22417,7 +22405,33 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
22417
22405
  }
22418
22406
  request['limit'] = limit;
22419
22407
  }
22420
- const response = await this[method](this.extend(request, params));
22408
+ let response = undefined;
22409
+ if (type === 'option') {
22410
+ response = await this.eapiPrivateGetUserTrades(this.extend(request, params));
22411
+ }
22412
+ else {
22413
+ if (symbol === undefined) {
22414
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' fetchMyTrades() requires a symbol argument');
22415
+ }
22416
+ [marginMode, params] = this.handleMarginModeAndParams('fetchMyTrades', params);
22417
+ if (type === 'spot' || type === 'margin') {
22418
+ if ((type === 'margin') || (marginMode !== undefined)) {
22419
+ if (marginMode === 'isolated') {
22420
+ request['isIsolated'] = true;
22421
+ }
22422
+ response = await this.sapiGetMarginMyTrades(this.extend(request, params));
22423
+ }
22424
+ else {
22425
+ response = await this.privateGetMyTrades(this.extend(request, params));
22426
+ }
22427
+ }
22428
+ else if (market['linear']) {
22429
+ response = await this.fapiPrivateGetUserTrades(this.extend(request, params));
22430
+ }
22431
+ else if (market['inverse']) {
22432
+ response = await this.dapiPrivateGetUserTrades(this.extend(request, params));
22433
+ }
22434
+ }
22421
22435
  //
22422
22436
  // spot trade
22423
22437
  //
@@ -23747,7 +23761,6 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23747
23761
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
23748
23762
  */
23749
23763
  await this.loadMarkets();
23750
- let method = undefined;
23751
23764
  let type = undefined;
23752
23765
  [type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
23753
23766
  let subType = undefined;
@@ -23755,16 +23768,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23755
23768
  const isSpotOrMargin = (type === 'spot') || (type === 'margin');
23756
23769
  const isLinear = this.isLinear(type, subType);
23757
23770
  const isInverse = this.isInverse(type, subType);
23771
+ let response = undefined;
23758
23772
  if (isSpotOrMargin) {
23759
- method = 'sapiGetAssetTradeFee';
23773
+ response = await this.sapiGetAssetTradeFee(params);
23760
23774
  }
23761
23775
  else if (isLinear) {
23762
- method = 'fapiPrivateV2GetAccount';
23776
+ response = await this.fapiPrivateV2GetAccount(params);
23763
23777
  }
23764
23778
  else if (isInverse) {
23765
- method = 'dapiPrivateGetAccount';
23779
+ response = await this.dapiPrivateGetAccount(params);
23766
23780
  }
23767
- const response = await this[method](params);
23768
23781
  //
23769
23782
  // sapi / spot
23770
23783
  //
@@ -23962,17 +23975,16 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
23962
23975
  const request = {
23963
23976
  'symbol': market['id'],
23964
23977
  };
23965
- let method = undefined;
23978
+ let response = undefined;
23966
23979
  if (market['linear']) {
23967
- method = 'fapiPublicGetPremiumIndex';
23980
+ response = await this.fapiPublicGetPremiumIndex(this.extend(request, params));
23968
23981
  }
23969
23982
  else if (market['inverse']) {
23970
- method = 'dapiPublicGetPremiumIndex';
23983
+ response = await this.dapiPublicGetPremiumIndex(this.extend(request, params));
23971
23984
  }
23972
23985
  else {
23973
23986
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchFundingRate() supports linear and inverse contracts only');
23974
23987
  }
23975
- let response = await this[method](this.extend(request, params));
23976
23988
  if (market['inverse']) {
23977
23989
  response = response[0];
23978
23990
  }
@@ -24610,20 +24622,20 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
24610
24622
  * @returns {object} a dictionary of [leverage tiers structures]{@link https://docs.ccxt.com/#/?id=leverage-tiers-structure}, indexed by market symbols
24611
24623
  */
24612
24624
  await this.loadMarkets();
24613
- const [type, query] = this.handleMarketTypeAndParams('fetchLeverageTiers', undefined, params);
24625
+ let type = undefined;
24626
+ [type, params] = this.handleMarketTypeAndParams('fetchLeverageTiers', undefined, params);
24614
24627
  let subType = undefined;
24615
- [subType, params] = this.handleSubTypeAndParams('fetchLeverageTiers', undefined, query, 'linear');
24616
- let method = undefined;
24628
+ [subType, params] = this.handleSubTypeAndParams('fetchLeverageTiers', undefined, params, 'linear');
24629
+ let response = undefined;
24617
24630
  if (this.isLinear(type, subType)) {
24618
- method = 'fapiPrivateGetLeverageBracket';
24631
+ response = await this.fapiPrivateGetLeverageBracket(params);
24619
24632
  }
24620
24633
  else if (this.isInverse(type, subType)) {
24621
- method = 'dapiPrivateV2GetLeverageBracket';
24634
+ response = await this.dapiPrivateV2GetLeverageBracket(params);
24622
24635
  }
24623
24636
  else {
24624
24637
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' fetchLeverageTiers() supports linear and inverse contracts only');
24625
24638
  }
24626
- const response = await this[method](query);
24627
24639
  //
24628
24640
  // usdm
24629
24641
  //
@@ -25097,21 +25109,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25097
25109
  }
25098
25110
  await this.loadMarkets();
25099
25111
  const market = this.market(symbol);
25100
- let method;
25112
+ const request = {
25113
+ 'symbol': market['id'],
25114
+ 'leverage': leverage,
25115
+ };
25116
+ let response = undefined;
25101
25117
  if (market['linear']) {
25102
- method = 'fapiPrivatePostLeverage';
25118
+ response = await this.fapiPrivatePostLeverage(this.extend(request, params));
25103
25119
  }
25104
25120
  else if (market['inverse']) {
25105
- method = 'dapiPrivatePostLeverage';
25121
+ response = await this.dapiPrivatePostLeverage(this.extend(request, params));
25106
25122
  }
25107
25123
  else {
25108
25124
  throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' setLeverage() supports linear and inverse contracts only');
25109
25125
  }
25110
- const request = {
25111
- 'symbol': market['id'],
25112
- 'leverage': leverage,
25113
- };
25114
- return await this[method](this.extend(request, params));
25126
+ return response;
25115
25127
  }
25116
25128
  async setMarginMode(marginMode, symbol = undefined, params = {}) {
25117
25129
  /**
@@ -25144,23 +25156,21 @@ class binance extends _abstract_binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
25144
25156
  }
25145
25157
  await this.loadMarkets();
25146
25158
  const market = this.market(symbol);
25147
- let method = undefined;
25148
- if (market['linear']) {
25149
- method = 'fapiPrivatePostMarginType';
25150
- }
25151
- else if (market['inverse']) {
25152
- method = 'dapiPrivatePostMarginType';
25153
- }
25154
- else {
25155
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' setMarginMode() supports linear and inverse contracts only');
25156
- }
25157
25159
  const request = {
25158
25160
  'symbol': market['id'],
25159
25161
  'marginType': marginMode,
25160
25162
  };
25161
25163
  let response = undefined;
25162
25164
  try {
25163
- response = await this[method](this.extend(request, params));
25165
+ if (market['linear']) {
25166
+ response = await this.fapiPrivatePostMarginType(this.extend(request, params));
25167
+ }
25168
+ else if (market['inverse']) {
25169
+ response = await this.dapiPrivatePostMarginType(this.extend(request, params));
25170
+ }
25171
+ else {
25172
+ throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' setMarginMode() supports linear and inverse contracts only');
25173
+ }
25164
25174
  }
25165
25175
  catch (e) {
25166
25176
  // not an error
@@ -27297,6 +27307,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
27297
27307
  '100202': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InsufficientFunds,
27298
27308
  '100204': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
27299
27309
  '100400': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest,
27310
+ '100421': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadSymbol,
27300
27311
  '100440': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
27301
27312
  '100500': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
27302
27313
  '100503': _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ExchangeError,
@@ -28272,7 +28283,7 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28272
28283
  // }
28273
28284
  //
28274
28285
  const marketId = this.safeString(ticker, 'symbol');
28275
- const change = this.safeString(ticker, 'priceChange');
28286
+ // const change = this.safeString (ticker, 'priceChange'); // this is not ccxt's change because it does high-low instead of last-open
28276
28287
  const lastQty = this.safeString(ticker, 'lastQty');
28277
28288
  // in spot markets, lastQty is not present
28278
28289
  // it's (bad, but) the only way we can check the tickers origin
@@ -28284,10 +28295,10 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28284
28295
  const close = this.safeString(ticker, 'lastPrice');
28285
28296
  const quoteVolume = this.safeString(ticker, 'quoteVolume');
28286
28297
  const baseVolume = this.safeString(ticker, 'volume');
28287
- let percentage = this.safeString(ticker, 'priceChangePercent');
28288
- if (percentage !== undefined) {
28289
- percentage = percentage.replace('%', '');
28290
- }
28298
+ // let percentage = this.safeString (ticker, 'priceChangePercent');
28299
+ // if (percentage !== undefined) {
28300
+ // percentage = percentage.replace ('%', '');
28301
+ // } similarly to change, it's not ccxt's percentage because it does priceChange/open, and priceChange is high-low
28291
28302
  const ts = this.safeInteger(ticker, 'closeTime');
28292
28303
  const datetime = this.iso8601(ts);
28293
28304
  const bid = this.safeString(ticker, 'bidPrice');
@@ -28309,8 +28320,8 @@ class bingx extends _abstract_bingx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
28309
28320
  'close': close,
28310
28321
  'last': undefined,
28311
28322
  'previousClose': undefined,
28312
- 'change': change,
28313
- 'percentage': percentage,
28323
+ 'change': undefined,
28324
+ 'percentage': undefined,
28314
28325
  'average': undefined,
28315
28326
  'baseVolume': baseVolume,
28316
28327
  'quoteVolume': quoteVolume,
@@ -30741,14 +30752,13 @@ class bit2c extends _abstract_bit2c_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
30741
30752
  }
30742
30753
  parseTicker(ticker, market = undefined) {
30743
30754
  const symbol = this.safeSymbol(undefined, market);
30744
- const timestamp = this.milliseconds();
30745
30755
  const averagePrice = this.safeString(ticker, 'av');
30746
30756
  const baseVolume = this.safeString(ticker, 'a');
30747
30757
  const last = this.safeString(ticker, 'll');
30748
30758
  return this.safeTicker({
30749
30759
  'symbol': symbol,
30750
- 'timestamp': timestamp,
30751
- 'datetime': this.iso8601(timestamp),
30760
+ 'timestamp': undefined,
30761
+ 'datetime': undefined,
30752
30762
  'high': undefined,
30753
30763
  'low': undefined,
30754
30764
  'bid': this.safeString(ticker, 'h'),
@@ -36421,15 +36431,14 @@ class bitfinex2 extends _abstract_bitfinex2_js__WEBPACK_IMPORTED_MODULE_0__/* ["
36421
36431
  // FRR_AMOUNT_AVAILABLE
36422
36432
  // ]
36423
36433
  //
36424
- const timestamp = this.milliseconds();
36425
36434
  const symbol = this.safeSymbol(undefined, market);
36426
36435
  const length = ticker.length;
36427
36436
  const last = this.safeString(ticker, length - 4);
36428
36437
  const percentage = this.safeString(ticker, length - 5);
36429
36438
  return this.safeTicker({
36430
36439
  'symbol': symbol,
36431
- 'timestamp': timestamp,
36432
- 'datetime': this.iso8601(timestamp),
36440
+ 'timestamp': undefined,
36441
+ 'datetime': undefined,
36433
36442
  'high': this.safeString(ticker, length - 2),
36434
36443
  'low': this.safeString(ticker, length - 1),
36435
36444
  'bid': this.safeString(ticker, length - 10),
@@ -45276,26 +45285,35 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45276
45285
  * @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
45277
45286
  * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
45278
45287
  */
45279
- if (symbol === undefined) {
45280
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
45281
- }
45282
45288
  await this.loadMarkets();
45283
45289
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
45284
45290
  let market = undefined;
45285
- if (sandboxMode) {
45286
- const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45287
- market = this.market(sandboxSymbol);
45291
+ let type = undefined;
45292
+ let request = {};
45293
+ let marginMode = undefined;
45294
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
45295
+ if (symbol !== undefined) {
45296
+ if (sandboxMode) {
45297
+ const sandboxSymbol = this.convertSymbolForSandbox(symbol);
45298
+ market = this.market(sandboxSymbol);
45299
+ }
45300
+ else {
45301
+ market = this.market(symbol);
45302
+ }
45303
+ request['symbol'] = market['id'];
45304
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
45305
+ const marketType = ('type' in market) ? market['type'] : defaultType;
45306
+ type = this.safeString(params, 'type', marketType);
45288
45307
  }
45289
45308
  else {
45290
- market = this.market(symbol);
45309
+ const defaultType = this.safeString2(this.options, 'fetchOpenOrders', 'defaultType', 'spot');
45310
+ type = this.safeString(params, 'type', defaultType);
45291
45311
  }
45292
- let marginMode = undefined;
45293
- [marginMode, params] = this.handleMarginModeAndParams('fetchOpenOrders', params);
45294
45312
  let paginate = false;
45295
45313
  [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenOrders', 'paginate');
45296
45314
  if (paginate) {
45297
45315
  let cursorReceived = undefined;
45298
- if (market['spot']) {
45316
+ if (type === 'spot') {
45299
45317
  if (marginMode !== undefined) {
45300
45318
  cursorReceived = 'minId';
45301
45319
  }
@@ -45305,9 +45323,6 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45305
45323
  }
45306
45324
  return await this.fetchPaginatedCallCursor('fetchOpenOrders', symbol, since, limit, params, cursorReceived, 'idLessThan');
45307
45325
  }
45308
- let request = {
45309
- 'symbol': market['id'],
45310
- };
45311
45326
  let response = undefined;
45312
45327
  const stop = this.safeValue2(params, 'stop', 'trigger');
45313
45328
  params = this.omit(params, ['stop', 'trigger']);
@@ -45318,46 +45333,48 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45318
45333
  if (limit !== undefined) {
45319
45334
  request['limit'] = limit;
45320
45335
  }
45321
- if ((market['swap']) || (market['future']) || (marginMode !== undefined)) {
45336
+ if ((type === 'swap') || (type === 'future') || (marginMode !== undefined)) {
45322
45337
  const clientOrderId = this.safeString2(params, 'clientOid', 'clientOrderId');
45323
45338
  params = this.omit(params, 'clientOrderId');
45324
45339
  if (clientOrderId !== undefined) {
45325
45340
  request['clientOid'] = clientOrderId;
45326
45341
  }
45327
45342
  }
45328
- if (market['spot']) {
45343
+ let query = undefined;
45344
+ query = this.omit(params, ['type']);
45345
+ if (type === 'spot') {
45329
45346
  if (marginMode !== undefined) {
45330
45347
  if (since === undefined) {
45331
45348
  since = this.milliseconds() - 7776000000;
45332
45349
  request['startTime'] = since;
45333
45350
  }
45334
45351
  if (marginMode === 'isolated') {
45335
- response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, params));
45352
+ response = await this.privateMarginGetV2MarginIsolatedOpenOrders(this.extend(request, query));
45336
45353
  }
45337
45354
  else if (marginMode === 'cross') {
45338
- response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, params));
45355
+ response = await this.privateMarginGetV2MarginCrossedOpenOrders(this.extend(request, query));
45339
45356
  }
45340
45357
  }
45341
45358
  else {
45342
45359
  if (stop) {
45343
- response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, params));
45360
+ response = await this.privateSpotGetV2SpotTradeCurrentPlanOrder(this.extend(request, query));
45344
45361
  }
45345
45362
  else {
45346
- response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, params));
45363
+ response = await this.privateSpotGetV2SpotTradeUnfilledOrders(this.extend(request, query));
45347
45364
  }
45348
45365
  }
45349
45366
  }
45350
45367
  else {
45351
45368
  let productType = undefined;
45352
- [productType, params] = this.handleProductTypeAndParams(market, params);
45369
+ [productType, query] = this.handleProductTypeAndParams(market, query);
45353
45370
  request['productType'] = productType;
45354
45371
  if (stop) {
45355
- const planType = this.safeString(params, 'planType', 'normal_plan');
45372
+ const planType = this.safeString(query, 'planType', 'normal_plan');
45356
45373
  request['planType'] = planType;
45357
- response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, params));
45374
+ response = await this.privateMixGetV2MixOrderOrdersPlanPending(this.extend(request, query));
45358
45375
  }
45359
45376
  else {
45360
- response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, params));
45377
+ response = await this.privateMixGetV2MixOrderOrdersPending(this.extend(request, query));
45361
45378
  }
45362
45379
  }
45363
45380
  //
@@ -45536,7 +45553,7 @@ class bitget extends _abstract_bitget_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
45536
45553
  // }
45537
45554
  //
45538
45555
  const data = this.safeValue(response, 'data');
45539
- if (market['spot']) {
45556
+ if (type === 'spot') {
45540
45557
  if ((marginMode !== undefined) || stop) {
45541
45558
  const resultList = this.safeValue(data, 'orderList', []);
45542
45559
  return this.parseOrders(resultList, market, since, limit);
@@ -50651,7 +50668,7 @@ class bitmart extends _abstract_bitmart_js__WEBPACK_IMPORTED_MODULE_0__/* ["defa
50651
50668
  // "legal_coin_price":"0.1302699"
50652
50669
  // }
50653
50670
  //
50654
- const timestamp = this.safeInteger(ticker, 'timestamp', this.milliseconds());
50671
+ const timestamp = this.safeInteger(ticker, 'timestamp');
50655
50672
  const marketId = this.safeString2(ticker, 'symbol', 'contract_symbol');
50656
50673
  market = this.safeMarket(marketId, market);
50657
50674
  const symbol = market['symbol'];
@@ -72349,13 +72366,12 @@ class btcbox extends _abstract_btcbox_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
72349
72366
  return this.parseOrderBook(response, market['symbol']);
72350
72367
  }
72351
72368
  parseTicker(ticker, market = undefined) {
72352
- const timestamp = this.milliseconds();
72353
72369
  const symbol = this.safeSymbol(undefined, market);
72354
72370
  const last = this.safeString(ticker, 'last');
72355
72371
  return this.safeTicker({
72356
72372
  'symbol': symbol,
72357
- 'timestamp': timestamp,
72358
- 'datetime': this.iso8601(timestamp),
72373
+ 'timestamp': undefined,
72374
+ 'datetime': undefined,
72359
72375
  'high': this.safeString(ticker, 'high'),
72360
72376
  'low': this.safeString(ticker, 'low'),
72361
72377
  'bid': this.safeString(ticker, 'buy'),
@@ -86637,6 +86653,12 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86637
86653
  // "base_size": "0.2",
86638
86654
  // "limit_price": "0.006",
86639
86655
  // "post_only": false
86656
+ // },
86657
+ // "stop_limit_stop_limit_gtc": {
86658
+ // "base_size": "48.54",
86659
+ // "limit_price": "6.998",
86660
+ // "stop_price": "7.0687",
86661
+ // "stop_direction": "STOP_DIRECTION_STOP_DOWN"
86640
86662
  // }
86641
86663
  // },
86642
86664
  // "side": "SELL",
@@ -86670,11 +86692,11 @@ class coinbase extends _abstract_coinbase_js__WEBPACK_IMPORTED_MODULE_0__/* ["de
86670
86692
  market = this.market(symbol);
86671
86693
  }
86672
86694
  const orderConfiguration = this.safeValue(order, 'order_configuration', {});
86673
- const limitGTC = this.safeValue(orderConfiguration, 'limit_limit_gtc', {});
86674
- const limitGTD = this.safeValue(orderConfiguration, 'limit_limit_gtd', {});
86675
- const stopLimitGTC = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtc', {});
86676
- const stopLimitGTD = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtd', {});
86677
- const marketIOC = this.safeValue(orderConfiguration, 'market_market_ioc', {});
86695
+ const limitGTC = this.safeValue(orderConfiguration, 'limit_limit_gtc');
86696
+ const limitGTD = this.safeValue(orderConfiguration, 'limit_limit_gtd');
86697
+ const stopLimitGTC = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtc');
86698
+ const stopLimitGTD = this.safeValue(orderConfiguration, 'stop_limit_stop_limit_gtd');
86699
+ const marketIOC = this.safeValue(orderConfiguration, 'market_market_ioc');
86678
86700
  const isLimit = ((limitGTC !== undefined) || (limitGTD !== undefined));
86679
86701
  const isStop = ((stopLimitGTC !== undefined) || (stopLimitGTD !== undefined));
86680
86702
  let price = undefined;
@@ -104593,6 +104615,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
104593
104615
  const timestamp = this.safeInteger(ticker, 't');
104594
104616
  const marketId = this.safeString(ticker, 'i');
104595
104617
  market = this.safeMarket(marketId, market, '_');
104618
+ const quote = this.safeString(market, 'quote');
104596
104619
  const last = this.safeString(ticker, 'a');
104597
104620
  return this.safeTicker({
104598
104621
  'symbol': market['symbol'],
@@ -104613,7 +104636,7 @@ class cryptocom extends _abstract_cryptocom_js__WEBPACK_IMPORTED_MODULE_0__/* ["
104613
104636
  'percentage': this.safeString(ticker, 'c'),
104614
104637
  'average': undefined,
104615
104638
  'baseVolume': this.safeString(ticker, 'v'),
104616
- 'quoteVolume': this.safeString(ticker, 'vv'),
104639
+ 'quoteVolume': (quote === 'USD') ? this.safeString(ticker, 'vv') : undefined,
104617
104640
  'info': ticker,
104618
104641
  }, market);
104619
104642
  }
@@ -107756,6 +107779,8 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
107756
107779
  'addMargin': true,
107757
107780
  'cancelAllOrders': true,
107758
107781
  'cancelOrder': true,
107782
+ 'closeAllPositions': true,
107783
+ 'closePosition': false,
107759
107784
  'createOrder': true,
107760
107785
  'createReduceOnlyOrder': true,
107761
107786
  'editOrder': true,
@@ -110900,6 +110925,29 @@ class delta extends _abstract_delta_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"
110900
110925
  'info': greeks,
110901
110926
  };
110902
110927
  }
110928
+ async closeAllPositions(params = {}) {
110929
+ /**
110930
+ * @method
110931
+ * @name delta#closeAllPositions
110932
+ * @description closes all open positions for a market type
110933
+ * @see https://docs.delta.exchange/#close-all-positions
110934
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
110935
+ * @param {int} [params.user_id] the users id
110936
+ * @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
110937
+ */
110938
+ await this.loadMarkets();
110939
+ const request = {
110940
+ 'close_all_portfolio': true,
110941
+ 'close_all_isolated': true,
110942
+ // 'user_id': 12345,
110943
+ };
110944
+ const response = await this.privatePostPositionsCloseAll(this.extend(request, params));
110945
+ //
110946
+ // {"result":{},"success":true}
110947
+ //
110948
+ const position = this.parsePosition(this.safeValue(response, 'result', {}));
110949
+ return [position];
110950
+ }
110903
110951
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
110904
110952
  const requestPath = '/' + this.version + '/' + this.implodeParams(path, params);
110905
110953
  let url = this.urls['api'][api] + requestPath;
@@ -128284,7 +128332,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
128284
128332
  async closePosition(symbol, side = undefined, params = {}) {
128285
128333
  /**
128286
128334
  * @method
128287
- * @name gate#closePositions
128335
+ * @name gate#closePosition
128288
128336
  * @description closes open positions for a market
128289
128337
  * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order
128290
128338
  * @see https://www.gate.io/docs/developers/apiv4/en/#create-a-futures-order-2
@@ -128292,7 +128340,7 @@ class gate extends _abstract_gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"]
128292
128340
  * @param {string} symbol Unified CCXT market symbol
128293
128341
  * @param {string} side 'buy' or 'sell'
128294
128342
  * @param {object} [params] extra parameters specific to the okx api endpoint
128295
- * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
128343
+ * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
128296
128344
  */
128297
128345
  const request = {
128298
128346
  'close': true,
@@ -150981,7 +151029,6 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
150981
151029
  // "o":"2571.56000"
150982
151030
  // }
150983
151031
  //
150984
- const timestamp = this.milliseconds();
150985
151032
  const symbol = this.safeSymbol(undefined, market);
150986
151033
  const v = this.safeValue(ticker, 'v', []);
150987
151034
  const baseVolume = this.safeString(v, 1);
@@ -150996,8 +151043,8 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
150996
151043
  const ask = this.safeValue(ticker, 'a', []);
150997
151044
  return this.safeTicker({
150998
151045
  'symbol': symbol,
150999
- 'timestamp': timestamp,
151000
- 'datetime': this.iso8601(timestamp),
151046
+ 'timestamp': undefined,
151047
+ 'datetime': undefined,
151001
151048
  'high': this.safeString(high, 1),
151002
151049
  'low': this.safeString(low, 1),
151003
151050
  'bid': this.safeString(bid, 0),
@@ -151511,8 +151558,12 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151511
151558
  * @param {float} amount how much of currency you want to trade in units of base currency
151512
151559
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
151513
151560
  * @param {object} [params] extra parameters specific to the exchange API endpoint
151514
- * @param {bool} params.postOnly
151515
- * @param {bool} params.reduceOnly
151561
+ * @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
151562
+ * @param {bool} [params.reduceOnly] *margin only* indicates if this order is to reduce the size of a position
151563
+ * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
151564
+ * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
151565
+ * @param {string} [params.trailingStopPrice] *margin only* the quote amount to trail away from the current market price
151566
+ * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
151516
151567
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
151517
151568
  */
151518
151569
  await this.loadMarkets();
@@ -151767,50 +151818,48 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151767
151818
  if (clientOrderId !== undefined) {
151768
151819
  request['userref'] = clientOrderId;
151769
151820
  }
151770
- //
151771
- // market
151772
- // limit (price = limit price)
151773
- // stop-loss (price = stop loss trigger price)
151774
- // take-profit (price = take profit trigger price)
151775
- // stop-loss-limit (price = stop loss trigger price, price2 = triggered limit price)
151776
- // take-profit-limit (price = take profit trigger price, price2 = triggered limit price)
151777
- // settle-position
151778
- //
151821
+ const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
151822
+ const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
151823
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
151824
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
151825
+ const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
151826
+ const trailingStopPrice = this.safeString(params, 'trailingStopPrice');
151827
+ const isTrailingStopPriceOrder = trailingStopPrice !== undefined;
151779
151828
  if (type === 'limit') {
151780
151829
  request['price'] = this.priceToPrecision(symbol, price);
151781
151830
  }
151782
- else if ((type === 'stop-loss') || (type === 'take-profit')) {
151783
- const stopPrice = this.safeNumber2(params, 'price', 'stopPrice', price);
151784
- if (stopPrice === undefined) {
151785
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + method + ' requires a price argument or a price/stopPrice parameter for a ' + type + ' order');
151831
+ let reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only');
151832
+ if (isStopLossOrTakeProfitTrigger) {
151833
+ if (isStopLossTriggerOrder) {
151834
+ request['price'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
151835
+ request['ordertype'] = 'stop-loss-limit';
151786
151836
  }
151787
- else {
151788
- request['price'] = this.priceToPrecision(symbol, stopPrice);
151837
+ else if (isTakeProfitTriggerOrder) {
151838
+ request['price'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
151839
+ request['ordertype'] = 'take-profit-limit';
151789
151840
  }
151841
+ request['price2'] = this.priceToPrecision(symbol, price);
151842
+ reduceOnly = true;
151790
151843
  }
151791
- else if ((type === 'stop-loss-limit') || (type === 'take-profit-limit')) {
151792
- const stopPrice = this.safeNumber2(params, 'price', 'stopPrice');
151793
- const limitPrice = this.safeNumber(params, 'price2');
151794
- const stopPriceDefined = (stopPrice !== undefined);
151795
- const limitPriceDefined = (limitPrice !== undefined);
151796
- if (stopPriceDefined && limitPriceDefined) {
151797
- request['price'] = this.priceToPrecision(symbol, stopPrice);
151798
- request['price2'] = this.priceToPrecision(symbol, limitPrice);
151799
- }
151800
- else if ((price === undefined) || (!(stopPriceDefined || limitPriceDefined))) {
151801
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + method + ' requires a price argument and/or price/stopPrice/price2 parameters for a ' + type + ' order');
151844
+ else if (isTrailingStopPriceOrder) {
151845
+ const trailingStopActivationPriceType = this.safeString(params, 'trigger', 'last');
151846
+ const trailingStopPriceString = '+' + trailingStopPrice;
151847
+ request['trigger'] = trailingStopActivationPriceType;
151848
+ reduceOnly = true;
151849
+ if (type === 'limit') {
151850
+ const trailingStopLimitPriceString = '+' + this.numberToString(price);
151851
+ request['price'] = trailingStopPriceString;
151852
+ request['price2'] = trailingStopLimitPriceString;
151853
+ request['ordertype'] = 'trailing-stop-limit';
151802
151854
  }
151803
151855
  else {
151804
- if (stopPriceDefined) {
151805
- request['price'] = this.priceToPrecision(symbol, stopPrice);
151806
- request['price2'] = this.priceToPrecision(symbol, price);
151807
- }
151808
- else if (limitPriceDefined) {
151809
- request['price'] = this.priceToPrecision(symbol, price);
151810
- request['price2'] = this.priceToPrecision(symbol, limitPrice);
151811
- }
151856
+ request['price'] = trailingStopPriceString;
151857
+ request['ordertype'] = 'trailing-stop';
151812
151858
  }
151813
151859
  }
151860
+ if (reduceOnly) {
151861
+ request['reduce_only'] = 'true'; // not using boolean in this case, because the urlencodedNested transforms it into 'True' string
151862
+ }
151814
151863
  let close = this.safeValue(params, 'close');
151815
151864
  if (close !== undefined) {
151816
151865
  close = this.extend({}, close);
@@ -151834,11 +151883,7 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151834
151883
  if (postOnly) {
151835
151884
  request['oflags'] = 'post';
151836
151885
  }
151837
- const reduceOnly = this.safeValue(params, 'reduceOnly');
151838
- if (reduceOnly) {
151839
- request['reduce_only'] = true;
151840
- }
151841
- params = this.omit(params, ['price', 'stopPrice', 'price2', 'close', 'timeInForce', 'reduceOnly']);
151886
+ params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingStopPrice']);
151842
151887
  return [request, params];
151843
151888
  }
151844
151889
  async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
@@ -151854,6 +151899,10 @@ class kraken extends _abstract_kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
151854
151899
  * @param {float} amount how much of the currency you want to trade in units of the base currency
151855
151900
  * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
151856
151901
  * @param {object} [params] extra parameters specific to the exchange API endpoint
151902
+ * @param {float} [params.stopLossPrice] *margin only* the price that a stop loss order is triggered at
151903
+ * @param {float} [params.takeProfitPrice] *margin only* the price that a take profit order is triggered at
151904
+ * @param {string} [params.trailingStopPrice] *margin only* the quote price away from the current market price
151905
+ * @param {string} [params.trigger] *margin only* the activation price type, 'last' or 'index', default is 'last'
151857
151906
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
151858
151907
  */
151859
151908
  await this.loadMarkets();
@@ -153863,20 +153912,12 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
153863
153912
  });
153864
153913
  }
153865
153914
  createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
153915
+ const market = this.market(symbol);
153866
153916
  type = this.safeString(params, 'orderType', type);
153867
153917
  const timeInForce = this.safeString(params, 'timeInForce');
153868
- const stopPrice = this.safeString(params, 'stopPrice');
153869
153918
  let postOnly = false;
153870
153919
  [postOnly, params] = this.handlePostOnly(type === 'market', type === 'post', params);
153871
- const clientOrderId = this.safeString2(params, 'clientOrderId', 'cliOrdId');
153872
- params = this.omit(params, ['clientOrderId', 'cliOrdId']);
153873
- if ((type === 'stp' || type === 'take_profit') && stopPrice === undefined) {
153874
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_1__.ArgumentsRequired(this.id + ' createOrder requires params.stopPrice when type is ' + type);
153875
- }
153876
- if (stopPrice !== undefined && type !== 'take_profit') {
153877
- type = 'stp';
153878
- }
153879
- else if (postOnly) {
153920
+ if (postOnly) {
153880
153921
  type = 'post';
153881
153922
  }
153882
153923
  else if (timeInForce === 'ioc') {
@@ -153889,17 +153930,49 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
153889
153930
  type = 'mkt';
153890
153931
  }
153891
153932
  const request = {
153892
- 'orderType': type,
153893
- 'symbol': this.marketId(symbol),
153933
+ 'symbol': market['id'],
153894
153934
  'side': side,
153895
153935
  'size': amount,
153896
153936
  };
153897
- if (price !== undefined) {
153898
- request['limitPrice'] = price;
153899
- }
153937
+ const clientOrderId = this.safeString2(params, 'clientOrderId', 'cliOrdId');
153900
153938
  if (clientOrderId !== undefined) {
153901
153939
  request['cliOrdId'] = clientOrderId;
153902
153940
  }
153941
+ const triggerPrice = this.safeString2(params, 'triggerPrice', 'stopPrice');
153942
+ const isTriggerOrder = triggerPrice !== undefined;
153943
+ const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
153944
+ const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
153945
+ const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
153946
+ const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
153947
+ const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
153948
+ const triggerSignal = this.safeString(params, 'triggerSignal', 'last');
153949
+ let reduceOnly = this.safeValue(params, 'reduceOnly');
153950
+ if (isStopLossOrTakeProfitTrigger || isTriggerOrder) {
153951
+ request['triggerSignal'] = triggerSignal;
153952
+ }
153953
+ if (isTriggerOrder) {
153954
+ type = 'stp';
153955
+ request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
153956
+ }
153957
+ else if (isStopLossOrTakeProfitTrigger) {
153958
+ reduceOnly = true;
153959
+ if (isStopLossTriggerOrder) {
153960
+ type = 'stp';
153961
+ request['stopPrice'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
153962
+ }
153963
+ else if (isTakeProfitTriggerOrder) {
153964
+ type = 'take_profit';
153965
+ request['stopPrice'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
153966
+ }
153967
+ }
153968
+ if (reduceOnly) {
153969
+ request['reduceOnly'] = true;
153970
+ }
153971
+ request['orderType'] = type;
153972
+ if (price !== undefined) {
153973
+ request['limitPrice'] = price;
153974
+ }
153975
+ params = this.omit(params, ['clientOrderId', 'timeInForce', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
153903
153976
  return this.extend(request, params);
153904
153977
  }
153905
153978
  async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
@@ -153907,19 +153980,22 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
153907
153980
  * @method
153908
153981
  * @name krakenfutures#createOrder
153909
153982
  * @description Create an order on the exchange
153910
- * @param {string} symbol market symbol
153911
- * @param {string} type One of 'limit', 'market', 'take_profit'
153912
- * @param {string} side buy or sell
153913
- * @param {int} amount Contract quantity
153914
- * @param {float} [price] Limit order price
153915
- * @param {float} [params.stopPrice] The stop price associated with a stop or take profit order, Required if orderType is stp or take_profit, Must not have more than 2 decimal places, Note that for stop orders, limitPrice denotes the worst price at which the stop or take_profit order can get filled at. If no limitPrice is provided the stop or take_profit order will trigger a market order,
153916
- * @param {bool} [params.reduceOnly] Set as true if you wish the order to only reduce an existing position, Any order which increases an existing position will be rejected, Default false,
153917
- * @param {bool} [params.postOnly] Set as true if you wish to make a postOnly order, Default false
153918
- * @param {string} [params.triggerSignal] If placing a stp or take_profit, the signal used for trigger, One of: 'mark', 'index', 'last', last is market price
153919
- * @param {string} [params.cliOrdId] UUID The order identity that is specified from the user, It must be globally unique
153983
+ * @see https://docs.futures.kraken.com/#http-api-trading-v3-api-order-management-send-order
153984
+ * @param {string} symbol unified market symbol
153985
+ * @param {string} type 'limit' or 'market'
153986
+ * @param {string} side 'buy' or 'sell'
153987
+ * @param {float} amount number of contracts
153988
+ * @param {float} [price] limit order price
153989
+ * @param {bool} [params.reduceOnly] set as true if you wish the order to only reduce an existing position, any order which increases an existing position will be rejected, default is false
153990
+ * @param {bool} [params.postOnly] set as true if you wish to make a postOnly order, default is false
153920
153991
  * @param {string} [params.clientOrderId] UUID The order identity that is specified from the user, It must be globally unique
153992
+ * @param {float} [params.triggerPrice] the price that a stop order is triggered at
153993
+ * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
153994
+ * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
153995
+ * @param {string} [params.triggerSignal] for triggerPrice, stopLossPrice and takeProfitPrice orders, the trigger price type, 'last', 'mark' or 'index', default is 'last'
153921
153996
  */
153922
153997
  await this.loadMarkets();
153998
+ const market = this.market(symbol);
153923
153999
  const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
153924
154000
  const response = await this.privatePostSendorder(orderRequest);
153925
154001
  //
@@ -153955,7 +154031,7 @@ class krakenfutures extends _abstract_krakenfutures_js__WEBPACK_IMPORTED_MODULE_
153955
154031
  const sendStatus = this.safeValue(response, 'sendStatus');
153956
154032
  const status = this.safeString(sendStatus, 'status');
153957
154033
  this.verifyOrderActionSuccess(status, 'createOrder', ['filled']);
153958
- return this.parseOrder(sendStatus);
154034
+ return this.parseOrder(sendStatus, market);
153959
154035
  }
153960
154036
  async createOrders(orders, params = {}) {
153961
154037
  /**
@@ -155456,6 +155532,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155456
155532
  'createStopLimitOrder': true,
155457
155533
  'createStopMarketOrder': true,
155458
155534
  'createStopOrder': true,
155535
+ 'createMarketBuyOrderWithCost': true,
155536
+ 'createMarketOrderWithCost': true,
155537
+ 'createMarketSellOrderWithCost': true,
155459
155538
  'editOrder': true,
155460
155539
  'fetchAccounts': true,
155461
155540
  'fetchBalance': true,
@@ -155617,6 +155696,10 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155617
155696
  'stop-order': 8,
155618
155697
  'stop-order/{orderId}': 3,
155619
155698
  'stop-order/queryOrderByClientOid': 3,
155699
+ 'oco/order/{orderId}': 2,
155700
+ 'oco/order/details/{orderId}': 2,
155701
+ 'oco/client-order/{clientOid}': 2,
155702
+ 'oco/orders': 2,
155620
155703
  // margin trading
155621
155704
  'hf/margin/orders/active': 4,
155622
155705
  'hf/margin/orders/done': 10,
@@ -155624,6 +155707,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155624
155707
  'hf/margin/orders/client-order/{clientOid}': 5,
155625
155708
  'hf/margin/fills': 5,
155626
155709
  'etf/info': 25,
155710
+ 'margin/currencies': 20,
155627
155711
  'risk/limit/strategy': 20,
155628
155712
  'isolated/symbols': 20,
155629
155713
  'isolated/account/{symbol}': 50,
@@ -155659,6 +155743,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155659
155743
  'orders/test': 2,
155660
155744
  'orders/multi': 3,
155661
155745
  'stop-order': 2,
155746
+ 'oco/order': 2,
155662
155747
  // margin trading
155663
155748
  'hf/margin/order': 5,
155664
155749
  'hf/margin/order/test': 5,
@@ -155684,12 +155769,16 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155684
155769
  'hf/orders/sync/client-order/{clientOid}': 1,
155685
155770
  'hf/orders/cancel/{orderId}': 2,
155686
155771
  'hf/orders': 2,
155772
+ 'hf/orders/cancelAll': 30,
155687
155773
  'orders/{orderId}': 3,
155688
155774
  'order/client-order/{clientOid}': 5,
155689
155775
  'orders': 20,
155690
155776
  'stop-order/{orderId}': 3,
155691
155777
  'stop-order/cancelOrderByClientOid': 5,
155692
155778
  'stop-order/cancel': 3,
155779
+ 'oco/order/{orderId}': 3,
155780
+ 'oco/client-order/{clientOid}': 3,
155781
+ 'oco/orders': 3,
155693
155782
  // margin trading
155694
155783
  'hf/margin/orders/{orderId}': 5,
155695
155784
  'hf/margin/orders/client-order/{clientOid}': 5,
@@ -155710,6 +155799,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155710
155799
  'index/query': 3,
155711
155800
  'mark-price/{symbol}/current': 4.5,
155712
155801
  'premium/query': 4.5,
155802
+ 'trade-statistics': 4.5,
155713
155803
  'funding-rate/{symbol}/current': 3,
155714
155804
  'timestamp': 3,
155715
155805
  'status': 6,
@@ -155758,6 +155848,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155758
155848
  },
155759
155849
  'delete': {
155760
155850
  'orders/{orderId}': 1.5,
155851
+ 'orders/client-order/{clientOid}': 1.5,
155761
155852
  'orders': 45,
155762
155853
  'stopOrders': 22.5, // 15FW
155763
155854
  },
@@ -155945,6 +156036,10 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155945
156036
  'market/orderbook/level2': 'v3',
155946
156037
  'market/orderbook/level3': 'v3',
155947
156038
  'market/orderbook/level{level}': 'v3',
156039
+ 'oco/order/{orderId}': 'v3',
156040
+ 'oco/order/details/{orderId}': 'v3',
156041
+ 'oco/client-order/{clientOid}': 'v3',
156042
+ 'oco/orders': 'v3',
155948
156043
  // margin trading
155949
156044
  'hf/margin/orders/active': 'v3',
155950
156045
  'hf/margin/orders/done': 'v3',
@@ -155952,6 +156047,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155952
156047
  'hf/margin/orders/client-order/{clientOid}': 'v3',
155953
156048
  'hf/margin/fills': 'v3',
155954
156049
  'etf/info': 'v3',
156050
+ 'margin/currencies': 'v3',
155955
156051
  'margin/borrow': 'v3',
155956
156052
  'margin/repay': 'v3',
155957
156053
  'project/list': 'v3',
@@ -155968,6 +156064,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155968
156064
  'accounts/inner-transfer': 'v2',
155969
156065
  'transfer-out': 'v3',
155970
156066
  // spot trading
156067
+ 'oco/order': 'v3',
155971
156068
  // margin trading
155972
156069
  'hf/margin/order': 'v3',
155973
156070
  'hf/margin/order/test': 'v3',
@@ -155984,6 +156081,9 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
155984
156081
  'hf/margin/orders/{orderId}': 'v3',
155985
156082
  'hf/margin/orders/client-order/{clientOid}': 'v3',
155986
156083
  'hf/margin/orders': 'v3',
156084
+ 'oco/order/{orderId}': 'v3',
156085
+ 'oco/client-order/{clientOid}': 'v3',
156086
+ 'oco/orders': 'v3',
155987
156087
  // margin trading
155988
156088
  },
155989
156089
  },
@@ -157339,6 +157439,50 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
157339
157439
  const data = this.safeValue(response, 'data', {});
157340
157440
  return this.parseOrder(data, market);
157341
157441
  }
157442
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
157443
+ /**
157444
+ * @method
157445
+ * @name kucoin#createMarketOrderWithCost
157446
+ * @description create a market order by providing the symbol, side and cost
157447
+ * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
157448
+ * @param {string} symbol unified symbol of the market to create an order in
157449
+ * @param {string} side 'buy' or 'sell'
157450
+ * @param {float} cost how much you want to trade in units of the quote currency
157451
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
157452
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
157453
+ */
157454
+ await this.loadMarkets();
157455
+ params['cost'] = cost;
157456
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
157457
+ }
157458
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
157459
+ /**
157460
+ * @method
157461
+ * @name kucoin#createMarketBuyOrderWithCost
157462
+ * @description create a market buy order by providing the symbol and cost
157463
+ * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
157464
+ * @param {string} symbol unified symbol of the market to create an order in
157465
+ * @param {float} cost how much you want to trade in units of the quote currency
157466
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
157467
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
157468
+ */
157469
+ await this.loadMarkets();
157470
+ return await this.createMarketOrderWithCost(symbol, 'buy', cost, params);
157471
+ }
157472
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
157473
+ /**
157474
+ * @method
157475
+ * @name kucoin#createMarketSellOrderWithCost
157476
+ * @description create a market sell order by providing the symbol and cost
157477
+ * @see https://www.kucoin.com/docs/rest/spot-trading/orders/place-order
157478
+ * @param {string} symbol unified symbol of the market to create an order in
157479
+ * @param {float} cost how much you want to trade in units of the quote currency
157480
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
157481
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
157482
+ */
157483
+ await this.loadMarkets();
157484
+ return await this.createMarketOrderWithCost(symbol, 'sell', cost, params);
157485
+ }
157342
157486
  async createOrders(orders, params = {}) {
157343
157487
  /**
157344
157488
  * @method
@@ -157637,9 +157781,11 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
157637
157781
  }
157638
157782
  else if (hf) {
157639
157783
  if (symbol === undefined) {
157640
- throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelAllOrders() requires a symbol parameter for hf orders');
157784
+ response = await this.privateDeleteHfOrdersCancelAll(this.extend(request, query));
157785
+ }
157786
+ else {
157787
+ response = await this.privateDeleteHfOrders(this.extend(request, query));
157641
157788
  }
157642
- response = await this.privateDeleteHfOrders(this.extend(request, query));
157643
157789
  }
157644
157790
  else {
157645
157791
  response = await this.privateDeleteOrders(this.extend(request, query));
@@ -157896,7 +158042,7 @@ class kucoin extends _abstract_kucoin_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
157896
158042
  response = await this.privateGetOrdersOrderId(this.extend(request, params));
157897
158043
  }
157898
158044
  }
157899
- let responseData = this.safeValue(response, 'data');
158045
+ let responseData = this.safeValue(response, 'data', {});
157900
158046
  if (Array.isArray(responseData)) {
157901
158047
  responseData = this.safeValue(responseData, 0);
157902
158048
  }
@@ -162256,7 +162402,7 @@ class kucoinfutures extends _abstract_kucoinfutures_js__WEBPACK_IMPORTED_MODULE_
162256
162402
  * @param {string} side not used by kucoinfutures closePositions
162257
162403
  * @param {object} [params] extra parameters specific to the okx api endpoint
162258
162404
  * @param {string} [params.clientOrderId] client order id of the order
162259
- * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
162405
+ * @returns {object[]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
162260
162406
  */
162261
162407
  await this.loadMarkets();
162262
162408
  const market = this.market(symbol);
@@ -206339,14 +206485,13 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
206339
206485
  event = 'ticker';
206340
206486
  }
206341
206487
  let timestamp = undefined;
206342
- const now = this.milliseconds();
206343
206488
  if (event === 'bookTicker') {
206344
206489
  // take the event timestamp, if available, for spot tickers it is not
206345
- timestamp = this.safeInteger(message, 'E', now);
206490
+ timestamp = this.safeInteger(message, 'E');
206346
206491
  }
206347
206492
  else {
206348
206493
  // take the timestamp of the closing price for candlestick streams
206349
- timestamp = this.safeInteger(message, 'C', now);
206494
+ timestamp = this.safeInteger(message, 'C');
206350
206495
  }
206351
206496
  const marketId = this.safeString(message, 's');
206352
206497
  const symbol = this.safeSymbol(marketId, undefined, undefined, marketType);
@@ -209464,7 +209609,6 @@ class bitfinex extends _bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
209464
209609
  // 220.05, // 10 LOW float Daily low
209465
209610
  // ]
209466
209611
  //
209467
- const timestamp = this.milliseconds();
209468
209612
  const marketId = this.safeString(subscription, 'pair');
209469
209613
  const symbol = this.safeSymbol(marketId);
209470
209614
  const channel = 'ticker';
@@ -209477,8 +209621,8 @@ class bitfinex extends _bitfinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] *
209477
209621
  }
209478
209622
  const result = {
209479
209623
  'symbol': symbol,
209480
- 'timestamp': timestamp,
209481
- 'datetime': this.iso8601(timestamp),
209624
+ 'timestamp': undefined,
209625
+ 'datetime': undefined,
209482
209626
  'high': this.safeFloat(message, 9),
209483
209627
  'low': this.safeFloat(message, 10),
209484
209628
  'bid': this.safeFloat(message, 1),
@@ -222694,7 +222838,7 @@ class cex extends _cex_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
222694
222838
  'rate': undefined,
222695
222839
  };
222696
222840
  }
222697
- const timestamp = this.safeInteger(data, 'time', this.milliseconds());
222841
+ const timestamp = this.safeInteger(data, 'time');
222698
222842
  order['timestamp'] = timestamp;
222699
222843
  order['datetime'] = this.iso8601(timestamp);
222700
222844
  order = this.safeOrder(order);
@@ -229875,7 +230019,7 @@ class gate extends _gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229875
230019
  // }
229876
230020
  //
229877
230021
  const result = this.safeValue(message, 'result', []);
229878
- const timestamp = this.safeInteger(message, 'time');
230022
+ const timestamp = this.safeInteger(message, 'time_ms');
229879
230023
  this.balance['info'] = result;
229880
230024
  this.balance['timestamp'] = timestamp;
229881
230025
  this.balance['datetime'] = this.iso8601(timestamp);
@@ -229951,7 +230095,7 @@ class gate extends _gate_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
229951
230095
  if (this.newUpdates) {
229952
230096
  return positions;
229953
230097
  }
229954
- return this.filterBySymbolsSinceLimit(this.positions, symbols, since, limit, true);
230098
+ return this.filterBySymbolsSinceLimit(this.positions[type], symbols, since, limit, true);
229955
230099
  }
229956
230100
  setPositionsCache(client, type, symbols = undefined) {
229957
230101
  if (this.positions === undefined) {
@@ -237429,11 +237573,10 @@ class kraken extends _kraken_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z
237429
237573
  quoteVolume = _base_Precise_js__WEBPACK_IMPORTED_MODULE_2__/* .Precise */ .O.stringMul(baseVolume, vwap);
237430
237574
  }
237431
237575
  const last = this.safeString(ticker['c'], 0);
237432
- const timestamp = this.milliseconds();
237433
237576
  const result = this.safeTicker({
237434
237577
  'symbol': symbol,
237435
- 'timestamp': timestamp,
237436
- 'datetime': this.iso8601(timestamp),
237578
+ 'timestamp': undefined,
237579
+ 'datetime': undefined,
237437
237580
  'high': this.safeString(ticker['h'], 0),
237438
237581
  'low': this.safeString(ticker['l'], 0),
237439
237582
  'bid': this.safeString(ticker['b'], 0),
@@ -245643,7 +245786,7 @@ class okx extends _okx_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
245643
245786
  'side': this.safeString(order, 'side'),
245644
245787
  'price': this.safeNumber(info, 'fillPx'),
245645
245788
  'amount': this.safeNumber(info, 'fillSz'),
245646
- 'cost': undefined,
245789
+ 'cost': this.safeNumber(order, 'cost'),
245647
245790
  'fee': {
245648
245791
  'cost': this.safeNumber(info, 'fillFee'),
245649
245792
  'currency': this.safeCurrencyCode(feeMarketId),
@@ -252929,11 +253072,10 @@ class woo extends _woo_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */ .Z {
252929
253072
  // "count": 3689
252930
253073
  // }
252931
253074
  //
252932
- const timestamp = this.safeInteger(ticker, 'date', this.milliseconds());
252933
253075
  return this.safeTicker({
252934
253076
  'symbol': this.safeSymbol(undefined, market),
252935
- 'timestamp': timestamp,
252936
- 'datetime': this.iso8601(timestamp),
253077
+ 'timestamp': undefined,
253078
+ 'datetime': undefined,
252937
253079
  'high': this.safeString(ticker, 'high'),
252938
253080
  'low': this.safeString(ticker, 'low'),
252939
253081
  'bid': undefined,
@@ -288427,7 +288569,7 @@ SOFTWARE.
288427
288569
 
288428
288570
  //-----------------------------------------------------------------------------
288429
288571
  // this is updated by vss.js when building
288430
- const version = '4.1.94';
288572
+ const version = '4.1.96';
288431
288573
  _src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
288432
288574
  //-----------------------------------------------------------------------------
288433
288575