ccxt 4.3.77 → 4.3.79

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 (49) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +62 -40
  5. package/dist/cjs/src/binance.js +40 -70
  6. package/dist/cjs/src/bingx.js +0 -1
  7. package/dist/cjs/src/bitget.js +1 -0
  8. package/dist/cjs/src/bitteam.js +0 -1
  9. package/dist/cjs/src/gate.js +2 -2
  10. package/dist/cjs/src/kraken.js +10 -11
  11. package/dist/cjs/src/kuna.js +0 -1
  12. package/dist/cjs/src/pro/binance.js +17 -6
  13. package/dist/cjs/src/pro/bybit.js +1 -1
  14. package/dist/cjs/src/pro/cryptocom.js +1 -1
  15. package/dist/cjs/src/pro/gate.js +1 -1
  16. package/dist/cjs/src/pro/kucoinfutures.js +1 -1
  17. package/dist/cjs/src/pro/paradex.js +2 -0
  18. package/dist/cjs/src/pro/vertex.js +1 -1
  19. package/dist/cjs/src/pro/woo.js +1 -1
  20. package/dist/cjs/src/pro/woofipro.js +1 -1
  21. package/dist/cjs/src/vertex.js +7 -4
  22. package/dist/cjs/src/woo.js +4 -0
  23. package/dist/cjs/src/woofipro.js +4 -0
  24. package/dist/cjs/src/xt.js +0 -1
  25. package/js/ccxt.d.ts +1 -1
  26. package/js/ccxt.js +1 -1
  27. package/js/src/base/Exchange.d.ts +3 -1
  28. package/js/src/base/Exchange.js +62 -40
  29. package/js/src/binance.js +40 -70
  30. package/js/src/bingx.js +0 -1
  31. package/js/src/bitget.js +1 -0
  32. package/js/src/bitteam.js +0 -1
  33. package/js/src/gate.js +2 -2
  34. package/js/src/kraken.js +10 -11
  35. package/js/src/kuna.js +0 -1
  36. package/js/src/pro/binance.js +17 -6
  37. package/js/src/pro/bybit.js +1 -1
  38. package/js/src/pro/cryptocom.js +1 -1
  39. package/js/src/pro/gate.js +1 -1
  40. package/js/src/pro/kucoinfutures.js +1 -1
  41. package/js/src/pro/paradex.js +2 -0
  42. package/js/src/pro/vertex.js +1 -1
  43. package/js/src/pro/woo.js +1 -1
  44. package/js/src/pro/woofipro.js +1 -1
  45. package/js/src/vertex.js +7 -4
  46. package/js/src/woo.js +4 -0
  47. package/js/src/woofipro.js +4 -0
  48. package/js/src/xt.js +0 -1
  49. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -194,7 +194,7 @@ var xt$1 = require('./src/pro/xt.js');
194
194
 
195
195
  //-----------------------------------------------------------------------------
196
196
  // this is updated by vss.js when building
197
- const version = '4.3.77';
197
+ const version = '4.3.79';
198
198
  Exchange["default"].ccxtVersion = version;
199
199
  const exchanges = {
200
200
  'ace': ace,
@@ -2987,48 +2987,61 @@ class Exchange {
2987
2987
  }
2988
2988
  cost = Precise["default"].stringMul(multiplyPrice, amount);
2989
2989
  }
2990
- const parseFee = this.safeValue(trade, 'fee') === undefined;
2991
- const parseFees = this.safeValue(trade, 'fees') === undefined;
2992
- const shouldParseFees = parseFee || parseFees;
2993
- const fees = [];
2994
- const fee = this.safeValue(trade, 'fee');
2990
+ const [resultFee, resultFees] = this.parsedFeeAndFees(trade);
2991
+ trade['fee'] = resultFee;
2992
+ trade['fees'] = resultFees;
2993
+ trade['amount'] = this.parseNumber(amount);
2994
+ trade['price'] = this.parseNumber(price);
2995
+ trade['cost'] = this.parseNumber(cost);
2996
+ return trade;
2997
+ }
2998
+ parsedFeeAndFees(container) {
2999
+ let fee = this.safeDict(container, 'fee');
3000
+ let fees = this.safeList(container, 'fees');
3001
+ const feeDefined = fee !== undefined;
3002
+ const feesDefined = fees !== undefined;
3003
+ // parsing only if at least one of them is defined
3004
+ const shouldParseFees = (feeDefined || feesDefined);
2995
3005
  if (shouldParseFees) {
3006
+ if (feeDefined) {
3007
+ fee = this.parseFeeNumeric(fee);
3008
+ }
3009
+ if (!feesDefined) {
3010
+ // just set it directly, no further processing needed
3011
+ fees = [fee];
3012
+ }
3013
+ // 'fees' were set, so reparse them
2996
3014
  const reducedFees = this.reduceFees ? this.reduceFeesByCurrency(fees) : fees;
2997
3015
  const reducedLength = reducedFees.length;
2998
3016
  for (let i = 0; i < reducedLength; i++) {
2999
- reducedFees[i]['cost'] = this.safeNumber(reducedFees[i], 'cost');
3000
- if ('rate' in reducedFees[i]) {
3001
- reducedFees[i]['rate'] = this.safeNumber(reducedFees[i], 'rate');
3002
- }
3017
+ reducedFees[i] = this.parseFeeNumeric(reducedFees[i]);
3003
3018
  }
3004
- if (!parseFee && (reducedLength === 0)) {
3005
- // copy fee to avoid modification by reference
3006
- const feeCopy = this.deepExtend(fee);
3007
- feeCopy['cost'] = this.safeNumber(feeCopy, 'cost');
3008
- if ('rate' in feeCopy) {
3009
- feeCopy['rate'] = this.safeNumber(feeCopy, 'rate');
3010
- }
3011
- reducedFees.push(feeCopy);
3012
- }
3013
- if (parseFees) {
3014
- trade['fees'] = reducedFees;
3019
+ fees = reducedFees;
3020
+ if (reducedLength === 1) {
3021
+ fee = reducedFees[0];
3015
3022
  }
3016
- if (parseFee && (reducedLength === 1)) {
3017
- trade['fee'] = reducedFees[0];
3018
- }
3019
- const tradeFee = this.safeValue(trade, 'fee');
3020
- if (tradeFee !== undefined) {
3021
- tradeFee['cost'] = this.safeNumber(tradeFee, 'cost');
3022
- if ('rate' in tradeFee) {
3023
- tradeFee['rate'] = this.safeNumber(tradeFee, 'rate');
3024
- }
3025
- trade['fee'] = tradeFee;
3023
+ else if (reducedLength === 0) {
3024
+ fee = undefined;
3026
3025
  }
3027
3026
  }
3028
- trade['amount'] = this.parseNumber(amount);
3029
- trade['price'] = this.parseNumber(price);
3030
- trade['cost'] = this.parseNumber(cost);
3031
- return trade;
3027
+ // in case `fee & fees` are undefined, set `fees` as empty array
3028
+ if (fee === undefined) {
3029
+ fee = {
3030
+ 'cost': undefined,
3031
+ 'currency': undefined,
3032
+ };
3033
+ }
3034
+ if (fees === undefined) {
3035
+ fees = [];
3036
+ }
3037
+ return [fee, fees];
3038
+ }
3039
+ parseFeeNumeric(fee) {
3040
+ fee['cost'] = this.safeNumber(fee, 'cost'); // ensure numeric
3041
+ if ('rate' in fee) {
3042
+ fee['rate'] = this.safeNumber(fee, 'rate');
3043
+ }
3044
+ return fee;
3032
3045
  }
3033
3046
  findNearestCeiling(arr, providedValue) {
3034
3047
  // i.e. findNearestCeiling ([ 10, 30, 50], 23) returns 30
@@ -3102,12 +3115,13 @@ class Exchange {
3102
3115
  const reduced = {};
3103
3116
  for (let i = 0; i < fees.length; i++) {
3104
3117
  const fee = fees[i];
3105
- const feeCurrencyCode = this.safeString(fee, 'currency');
3118
+ const code = this.safeString(fee, 'currency');
3119
+ const feeCurrencyCode = code !== undefined ? code : i.toString();
3106
3120
  if (feeCurrencyCode !== undefined) {
3107
3121
  const rate = this.safeString(fee, 'rate');
3108
- const cost = this.safeValue(fee, 'cost');
3109
- if (Precise["default"].stringEq(cost, '0')) {
3110
- // omit zero cost fees
3122
+ const cost = this.safeString(fee, 'cost');
3123
+ if (cost === undefined) {
3124
+ // omit undefined cost, as it does not make sense, however, don't omit '0' costs, as they still make sense
3111
3125
  continue;
3112
3126
  }
3113
3127
  if (!(feeCurrencyCode in reduced)) {
@@ -3119,7 +3133,7 @@ class Exchange {
3119
3133
  }
3120
3134
  else {
3121
3135
  reduced[feeCurrencyCode][rateKey] = {
3122
- 'currency': feeCurrencyCode,
3136
+ 'currency': code,
3123
3137
  'cost': cost,
3124
3138
  };
3125
3139
  if (rate !== undefined) {
@@ -3160,7 +3174,15 @@ class Exchange {
3160
3174
  change = Precise["default"].stringSub(last, open);
3161
3175
  }
3162
3176
  if (average === undefined) {
3163
- average = Precise["default"].stringDiv(Precise["default"].stringAdd(last, open), '2');
3177
+ let precision = 18;
3178
+ if (market !== undefined && this.isTickPrecision()) {
3179
+ const marketPrecision = this.safeDict(market, 'precision');
3180
+ const precisionPrice = this.safeString(marketPrecision, 'price');
3181
+ if (precisionPrice !== undefined) {
3182
+ precision = this.precisionFromString(precisionPrice);
3183
+ }
3184
+ }
3185
+ average = Precise["default"].stringDiv(Precise["default"].stringAdd(last, open), '2', precision);
3164
3186
  }
3165
3187
  }
3166
3188
  if ((percentage === undefined) && (change !== undefined) && (open !== undefined) && Precise["default"].stringGt(open, '0')) {
@@ -3553,7 +3553,7 @@ class binance extends binance$1 {
3553
3553
  //
3554
3554
  // futures (fapi)
3555
3555
  //
3556
- // fapiPrivateV2GetAccount
3556
+ // fapiPrivateV3GetAccount
3557
3557
  //
3558
3558
  // {
3559
3559
  // "feeTier":0,
@@ -8997,6 +8997,7 @@ class binance extends binance$1 {
8997
8997
  * @see https://developers.binance.com/docs/wallet/asset/trade-fee
8998
8998
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
8999
8999
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
9000
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Config
9000
9001
  * @param {object} [params] extra parameters specific to the exchange API endpoint
9001
9002
  * @param {string} [params.subType] "linear" or "inverse"
9002
9003
  * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/#/?id=fee-structure} indexed by market symbols
@@ -9014,7 +9015,7 @@ class binance extends binance$1 {
9014
9015
  response = await this.sapiGetAssetTradeFee(params);
9015
9016
  }
9016
9017
  else if (isLinear) {
9017
- response = await this.fapiPrivateV2GetAccount(params);
9018
+ response = await this.fapiPrivateGetAccountConfig(params);
9018
9019
  }
9019
9020
  else if (isInverse) {
9020
9021
  response = await this.dapiPrivateGetAccount(params);
@@ -10319,6 +10320,7 @@ class binance extends binance$1 {
10319
10320
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10320
10321
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V2
10321
10322
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10323
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V3
10322
10324
  * @param {string[]} [symbols] list of unified market symbols
10323
10325
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10324
10326
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions in a portfolio margin account
@@ -10450,6 +10452,7 @@ class binance extends binance$1 {
10450
10452
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/Position-Information
10451
10453
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-UM-Position-Information
10452
10454
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Query-CM-Position-Information
10455
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/Position-Information-V3
10453
10456
  * @param {string[]|undefined} symbols list of unified market symbols
10454
10457
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10455
10458
  * @param {boolean} [params.portfolioMargin] set to true if you would like to fetch positions for a portfolio margin account
@@ -10867,6 +10870,7 @@ class binance extends binance$1 {
10867
10870
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
10868
10871
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-UM-Account-Detail
10869
10872
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/account/Get-CM-Account-Detail
10873
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
10870
10874
  * @param {string[]} [symbols] a list of unified market symbols
10871
10875
  * @param {object} [params] extra parameters specific to the exchange API endpoint
10872
10876
  * @param {string} [params.subType] "linear" or "inverse"
@@ -10886,7 +10890,7 @@ class binance extends binance$1 {
10886
10890
  response = await this.papiGetUmAccount(params);
10887
10891
  }
10888
10892
  else {
10889
- response = await this.fapiPrivateV2GetAccount(params);
10893
+ response = await this.fapiPrivateGetSymbolConfig(params);
10890
10894
  }
10891
10895
  }
10892
10896
  else if (this.isInverse(type, subType)) {
@@ -10900,7 +10904,10 @@ class binance extends binance$1 {
10900
10904
  else {
10901
10905
  throw new errors.NotSupported(this.id + ' fetchLeverages() supports linear and inverse contracts only');
10902
10906
  }
10903
- const leverages = this.safeList(response, 'positions', []);
10907
+ let leverages = this.safeList(response, 'positions', []);
10908
+ if (Array.isArray(response)) {
10909
+ leverages = response;
10910
+ }
10904
10911
  return this.parseLeverages(leverages, symbols, 'symbol');
10905
10912
  }
10906
10913
  parseLeverage(leverage, market = undefined) {
@@ -10910,6 +10917,10 @@ class binance extends binance$1 {
10910
10917
  if (marginModeRaw !== undefined) {
10911
10918
  marginMode = marginModeRaw ? 'isolated' : 'cross';
10912
10919
  }
10920
+ const marginTypeRaw = this.safeStringLower(leverage, 'marginType');
10921
+ if (marginTypeRaw !== undefined) {
10922
+ marginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
10923
+ }
10913
10924
  const side = this.safeStringLower(leverage, 'positionSide');
10914
10925
  let longLeverage = undefined;
10915
10926
  let shortLeverage = undefined;
@@ -12789,6 +12800,7 @@ class binance extends binance$1 {
12789
12800
  * @description fetches margin modes ("isolated" or "cross") that the market for the symbol in in, with symbol=undefined all markets for a subType (linear/inverse) are returned
12790
12801
  * @see https://developers.binance.com/docs/derivatives/coin-margined-futures/account/Account-Information
12791
12802
  * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Account-Information-V2
12803
+ * @see https://developers.binance.com/docs/derivatives/usds-margined-futures/account/rest-api/Symbol-Config
12792
12804
  * @param {string} symbol unified symbol of the market the order was made in
12793
12805
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12794
12806
  * @param {string} [params.subType] "linear" or "inverse"
@@ -12804,70 +12816,17 @@ class binance extends binance$1 {
12804
12816
  [subType, params] = this.handleSubTypeAndParams('fetchMarginMode', market, params);
12805
12817
  let response = undefined;
12806
12818
  if (subType === 'linear') {
12807
- response = await this.fapiPrivateV2GetAccount(params);
12819
+ response = await this.fapiPrivateGetSymbolConfig(params);
12808
12820
  //
12809
- // {
12810
- // feeTier: '0',
12811
- // canTrade: true,
12812
- // canDeposit: true,
12813
- // canWithdraw: true,
12814
- // tradeGroupId: '-1',
12815
- // updateTime: '0',
12816
- // multiAssetsMargin: true,
12817
- // totalInitialMargin: '438.31134352',
12818
- // totalMaintMargin: '5.90847101',
12819
- // totalWalletBalance: '4345.15626338',
12820
- // totalUnrealizedProfit: '376.45220224',
12821
- // totalMarginBalance: '4721.60846562',
12822
- // totalPositionInitialMargin: '425.45252687',
12823
- // totalOpenOrderInitialMargin: '12.85881664',
12824
- // totalCrossWalletBalance: '4345.15626338',
12825
- // totalCrossUnPnl: '376.45220224',
12826
- // availableBalance: '4281.84764041',
12827
- // maxWithdrawAmount: '4281.84764041',
12828
- // assets: [
12829
- // {
12830
- // asset: 'ETH',
12831
- // walletBalance: '0.00000000',
12832
- // unrealizedProfit: '0.00000000',
12833
- // marginBalance: '0.00000000',
12834
- // maintMargin: '0.00000000',
12835
- // initialMargin: '0.00000000',
12836
- // positionInitialMargin: '0.00000000',
12837
- // openOrderInitialMargin: '0.00000000',
12838
- // maxWithdrawAmount: '0.00000000',
12839
- // crossWalletBalance: '0.00000000',
12840
- // crossUnPnl: '0.00000000',
12841
- // availableBalance: '1.26075574',
12842
- // marginAvailable: true,
12843
- // updateTime: '0'
12844
- // },
12845
- // ...
12846
- // ],
12847
- // positions: [
12848
- // {
12849
- // symbol: 'SNTUSDT',
12850
- // initialMargin: '0',
12851
- // maintMargin: '0',
12852
- // unrealizedProfit: '0.00000000',
12853
- // positionInitialMargin: '0',
12854
- // openOrderInitialMargin: '0',
12855
- // leverage: '20',
12856
- // isolated: false,
12857
- // entryPrice: '0.0',
12858
- // breakEvenPrice: '0.0',
12859
- // maxNotional: '25000',
12860
- // positionSide: 'BOTH',
12861
- // positionAmt: '0',
12862
- // notional: '0',
12863
- // isolatedWallet: '0',
12864
- // updateTime: '0',
12865
- // bidNotional: '0',
12866
- // askNotional: '0'
12867
- // },
12868
- // ...
12869
- // ]
12870
- // }
12821
+ // [
12822
+ // {
12823
+ // "symbol": "BTCUSDT",
12824
+ // "marginType": "CROSSED",
12825
+ // "isAutoAddMargin": "false",
12826
+ // "leverage": 21,
12827
+ // "maxNotionalValue": "1000000",
12828
+ // }
12829
+ // ]
12871
12830
  //
12872
12831
  }
12873
12832
  else if (subType === 'inverse') {
@@ -12924,17 +12883,28 @@ class binance extends binance$1 {
12924
12883
  else {
12925
12884
  throw new errors.BadRequest(this.id + ' fetchMarginModes () supports linear and inverse subTypes only');
12926
12885
  }
12927
- const assets = this.safeList(response, 'positions', []);
12886
+ let assets = this.safeList(response, 'positions', []);
12887
+ if (Array.isArray(response)) {
12888
+ assets = response;
12889
+ }
12928
12890
  return this.parseMarginModes(assets, symbols, 'symbol', 'swap');
12929
12891
  }
12930
12892
  parseMarginMode(marginMode, market = undefined) {
12931
12893
  const marketId = this.safeString(marginMode, 'symbol');
12932
12894
  market = this.safeMarket(marketId, market);
12933
- const isIsolated = this.safeBool(marginMode, 'isolated');
12895
+ const marginModeRaw = this.safeBool(marginMode, 'isolated');
12896
+ let reMarginMode = undefined;
12897
+ if (marginModeRaw !== undefined) {
12898
+ reMarginMode = marginModeRaw ? 'isolated' : 'cross';
12899
+ }
12900
+ const marginTypeRaw = this.safeStringLower(marginMode, 'marginType');
12901
+ if (marginTypeRaw !== undefined) {
12902
+ reMarginMode = (marginTypeRaw === 'crossed') ? 'cross' : 'isolated';
12903
+ }
12934
12904
  return {
12935
12905
  'info': marginMode,
12936
12906
  'symbol': market['symbol'],
12937
- 'marginMode': isIsolated ? 'isolated' : 'cross',
12907
+ 'marginMode': reMarginMode,
12938
12908
  };
12939
12909
  }
12940
12910
  async fetchOption(symbol, params = {}) {
@@ -1209,7 +1209,6 @@ class bingx extends bingx$1 {
1209
1209
  'fee': {
1210
1210
  'cost': this.parseNumber(Precise["default"].stringAbs(this.safeString2(trade, 'commission', 'n'))),
1211
1211
  'currency': currencyCode,
1212
- 'rate': undefined,
1213
1212
  },
1214
1213
  }, market);
1215
1214
  }
@@ -1309,6 +1309,7 @@ class bitget extends bitget$1 {
1309
1309
  'JADE': 'Jade Protocol',
1310
1310
  'DEGEN': 'DegenReborn',
1311
1311
  'TONCOIN': 'TON',
1312
+ 'OMNI': 'omni', // conflict with Omni Network
1312
1313
  },
1313
1314
  'options': {
1314
1315
  'timeframes': {
@@ -1937,7 +1937,6 @@ class bitteam extends bitteam$1 {
1937
1937
  const fee = {
1938
1938
  'currency': this.safeCurrencyCode(feeCurrencyId),
1939
1939
  'cost': feeCost,
1940
- 'rate': undefined,
1941
1940
  };
1942
1941
  const intTs = this.parseToInt(timestamp);
1943
1942
  return this.safeTrade({
@@ -3467,8 +3467,8 @@ class gate extends gate$1 {
3467
3467
  const side = this.safeString2(trade, 'side', 'type', contractSide);
3468
3468
  const orderId = this.safeString(trade, 'order_id');
3469
3469
  const feeAmount = this.safeString(trade, 'fee');
3470
- const gtFee = this.safeString(trade, 'gt_fee');
3471
- const pointFee = this.safeString(trade, 'point_fee');
3470
+ const gtFee = this.omitZero(this.safeString(trade, 'gt_fee'));
3471
+ const pointFee = this.omitZero(this.safeString(trade, 'point_fee'));
3472
3472
  const fees = [];
3473
3473
  if (feeAmount !== undefined) {
3474
3474
  const feeCurrencyId = this.safeString(trade, 'fee_currency');
@@ -1382,7 +1382,7 @@ class kraken extends kraken$1 {
1382
1382
  * @method
1383
1383
  * @name kraken#createMarketOrderWithCost
1384
1384
  * @description create a market order by providing the symbol, side and cost
1385
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1385
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder
1386
1386
  * @param {string} symbol unified symbol of the market to create an order in (only USD markets are supported)
1387
1387
  * @param {string} side 'buy' or 'sell'
1388
1388
  * @param {float} cost how much you want to trade in units of the quote currency
@@ -1399,7 +1399,7 @@ class kraken extends kraken$1 {
1399
1399
  * @method
1400
1400
  * @name kraken#createMarketBuyOrderWithCost
1401
1401
  * @description create a market buy order by providing the symbol, side and cost
1402
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1402
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder
1403
1403
  * @param {string} symbol unified symbol of the market to create an order in
1404
1404
  * @param {float} cost how much you want to trade in units of the quote currency
1405
1405
  * @param {object} [params] extra parameters specific to the exchange API endpoint
@@ -1412,7 +1412,7 @@ class kraken extends kraken$1 {
1412
1412
  /**
1413
1413
  * @method
1414
1414
  * @name kraken#createOrder
1415
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/addOrder
1415
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/addOrder
1416
1416
  * @description create a trade order
1417
1417
  * @param {string} symbol unified symbol of the market to create an order in
1418
1418
  * @param {string} type 'market' or 'limit'
@@ -1551,6 +1551,8 @@ class kraken extends kraken$1 {
1551
1551
  // "status": "ok",
1552
1552
  // "txid": "OAW2BO-7RWEK-PZY5UO",
1553
1553
  // "originaltxid": "OXL6SS-UPNMC-26WBE7",
1554
+ // "newuserref": 1234,
1555
+ // "olduserref": 123,
1554
1556
  // "volume": "0.00075000",
1555
1557
  // "price": "13500.0",
1556
1558
  // "orders_cancelled": 1,
@@ -1694,7 +1696,7 @@ class kraken extends kraken$1 {
1694
1696
  const txid = this.safeList(order, 'txid');
1695
1697
  id = this.safeString(txid, 0);
1696
1698
  }
1697
- const clientOrderId = this.safeString(order, 'userref');
1699
+ const clientOrderId = this.safeString2(order, 'userref', 'newuserref');
1698
1700
  const rawTrades = this.safeValue(order, 'trades', []);
1699
1701
  const trades = [];
1700
1702
  for (let i = 0; i < rawTrades.length; i++) {
@@ -1850,7 +1852,7 @@ class kraken extends kraken$1 {
1850
1852
  const extendedPostFlags = (flags !== undefined) ? flags + ',post' : 'post';
1851
1853
  request['oflags'] = extendedPostFlags;
1852
1854
  }
1853
- if ((flags !== undefined) && (request['oflags'] === undefined)) {
1855
+ if ((flags !== undefined) && !('oflags' in request)) {
1854
1856
  request['oflags'] = flags;
1855
1857
  }
1856
1858
  params = this.omit(params, ['timeInForce', 'reduceOnly', 'stopLossPrice', 'takeProfitPrice', 'trailingAmount', 'trailingLimitAmount', 'offset']);
@@ -1861,7 +1863,7 @@ class kraken extends kraken$1 {
1861
1863
  * @method
1862
1864
  * @name kraken#editOrder
1863
1865
  * @description edit a trade order
1864
- * @see https://docs.kraken.com/rest/#tag/Trading/operation/editOrder
1866
+ * @see https://docs.kraken.com/rest/#tag/Spot-Trading/operation/editOrder
1865
1867
  * @param {string} id order id
1866
1868
  * @param {string} symbol unified symbol of the market to create an order in
1867
1869
  * @param {string} type 'market' or 'limit'
@@ -1923,8 +1925,8 @@ class kraken extends kraken$1 {
1923
1925
  await this.loadMarkets();
1924
1926
  const clientOrderId = this.safeValue2(params, 'userref', 'clientOrderId');
1925
1927
  const request = {
1926
- 'trades': true, // whether or not to include trades in output (optional, default false)
1927
- // 'txid': id, // do not comma separate a list of ids - use fetchOrdersByIds instead
1928
+ 'trades': true,
1929
+ 'txid': id, // do not comma separate a list of ids - use fetchOrdersByIds instead
1928
1930
  // 'userref': 'optional', // restrict results to given user reference id (optional)
1929
1931
  };
1930
1932
  let query = params;
@@ -1932,9 +1934,6 @@ class kraken extends kraken$1 {
1932
1934
  request['userref'] = clientOrderId;
1933
1935
  query = this.omit(params, ['userref', 'clientOrderId']);
1934
1936
  }
1935
- else {
1936
- request['txid'] = id;
1937
- }
1938
1937
  const response = await this.privatePostQueryOrders(this.extend(request, query));
1939
1938
  //
1940
1939
  // {
@@ -885,7 +885,6 @@ class kuna extends kuna$1 {
885
885
  'fee': {
886
886
  'cost': this.safeString(trade, 'fee'),
887
887
  'currency': this.safeCurrencyCode(this.safeString(trade, 'feeCurrency')),
888
- 'rate': undefined,
889
888
  },
890
889
  }, market);
891
890
  }
@@ -203,7 +203,7 @@ class binance extends binance$1 {
203
203
  * @param {object} [params] exchange specific parameters for the bitmex api endpoint
204
204
  * @returns {object} an array of [liquidation structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#liquidation-structure}
205
205
  */
206
- return this.watchLiquidationsForSymbols([symbol], since, limit, params);
206
+ return await this.watchLiquidationsForSymbols([symbol], since, limit, params);
207
207
  }
208
208
  async watchLiquidationsForSymbols(symbols = undefined, since = undefined, limit = undefined, params = {}) {
209
209
  /**
@@ -2064,7 +2064,7 @@ class binance extends binance$1 {
2064
2064
  * @param {string|undefined} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
2065
2065
  * @param {string|undefined} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
2066
2066
  * @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
2067
- * @param {string|undefined} [params.method] method to use. Can be account.balance or account.status
2067
+ * @param {string|undefined} [params.method] method to use. Can be account.balance, account.status, v2/account.balance or v2/account.status
2068
2068
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
2069
2069
  */
2070
2070
  await this.loadMarkets();
@@ -2096,8 +2096,16 @@ class binance extends binance$1 {
2096
2096
  //
2097
2097
  //
2098
2098
  const messageHash = this.safeString(message, 'id');
2099
- const result = this.safeDict(message, 'result', {});
2100
- const rawBalance = this.safeList(result, 0, []);
2099
+ let rawBalance = undefined;
2100
+ if (Array.isArray(message['result'])) {
2101
+ // account.balance
2102
+ rawBalance = this.safeList(message, 'result', []);
2103
+ }
2104
+ else {
2105
+ // account.status
2106
+ const result = this.safeDict(message, 'result', {});
2107
+ rawBalance = this.safeList(result, 'assets', []);
2108
+ }
2101
2109
  const parsedBalances = this.parseBalanceCustom(rawBalance);
2102
2110
  client.resolve(parsedBalances, messageHash);
2103
2111
  }
@@ -2174,6 +2182,7 @@ class binance extends binance$1 {
2174
2182
  * @param {string[]} [symbols] list of unified market symbols
2175
2183
  * @param {object} [params] extra parameters specific to the exchange API endpoint
2176
2184
  * @param {boolean} [params.returnRateLimits] set to true to return rate limit informations, defaults to false.
2185
+ * @param {string|undefined} [params.method] method to use. Can be account.position or v2/account.position
2177
2186
  * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure}
2178
2187
  */
2179
2188
  await this.loadMarkets();
@@ -2191,9 +2200,11 @@ class binance extends binance$1 {
2191
2200
  let returnRateLimits = false;
2192
2201
  [returnRateLimits, params] = this.handleOptionAndParams(params, 'fetchPositionsWs', 'returnRateLimits', false);
2193
2202
  payload['returnRateLimits'] = returnRateLimits;
2203
+ let method = undefined;
2204
+ [method, params] = this.handleOptionAndParams(params, 'fetchPositionsWs', 'method', 'account.position');
2194
2205
  const message = {
2195
2206
  'id': messageHash,
2196
- 'method': 'account.position',
2207
+ 'method': method,
2197
2208
  'params': this.signParams(this.extend(payload, params)),
2198
2209
  };
2199
2210
  const subscription = {
@@ -3291,7 +3302,7 @@ class binance extends binance$1 {
3291
3302
  this.setBalanceCache(client, type, isPortfolioMargin);
3292
3303
  this.setPositionsCache(client, type, symbols, isPortfolioMargin);
3293
3304
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
3294
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
3305
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
3295
3306
  const cache = this.safeValue(this.positions, type);
3296
3307
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
3297
3308
  const snapshot = await client.future(type + ':fetchPositionsSnapshot');
@@ -1127,7 +1127,7 @@ class bybit extends bybit$1 {
1127
1127
  this.setPositionsCache(client, symbols);
1128
1128
  const cache = this.positions;
1129
1129
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
1130
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
1130
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
1131
1131
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
1132
1132
  const snapshot = await client.future('fetchPositionsSnapshot');
1133
1133
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -561,7 +561,7 @@ class cryptocom extends cryptocom$1 {
561
561
  const client = this.client(url);
562
562
  this.setPositionsCache(client, symbols);
563
563
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
564
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
564
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
565
565
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
566
566
  const snapshot = await client.future('fetchPositionsSnapshot');
567
567
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -1086,7 +1086,7 @@ class gate extends gate$1 {
1086
1086
  const client = this.client(url);
1087
1087
  this.setPositionsCache(client, type, symbols);
1088
1088
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
1089
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
1089
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
1090
1090
  const cache = this.safeValue(this.positions, type);
1091
1091
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && cache === undefined) {
1092
1092
  return await client.future(type + ':fetchPositionsSnapshot');
@@ -351,7 +351,7 @@ class kucoinfutures extends kucoinfutures$1 {
351
351
  const client = this.client(url);
352
352
  this.setPositionCache(client, symbol);
353
353
  const fetchPositionSnapshot = this.handleOption('watchPosition', 'fetchPositionSnapshot', true);
354
- const awaitPositionSnapshot = this.safeBool('watchPosition', 'awaitPositionSnapshot', true);
354
+ const awaitPositionSnapshot = this.handleOption('watchPosition', 'awaitPositionSnapshot', true);
355
355
  const currentPosition = this.getCurrentPosition(symbol);
356
356
  if (fetchPositionSnapshot && awaitPositionSnapshot && currentPosition === undefined) {
357
357
  const snapshot = await client.future('fetchPositionSnapshot:' + symbol);
@@ -114,6 +114,7 @@ class paradex extends paradex$1 {
114
114
  * @param {object} [params] extra parameters specific to the exchange API endpoint
115
115
  * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
116
116
  */
117
+ await this.loadMarkets();
117
118
  const market = this.market(symbol);
118
119
  const messageHash = 'order_book.' + market['id'] + '.snapshot@15@100ms';
119
120
  const url = this.urls['api']['ws'];
@@ -223,6 +224,7 @@ class paradex extends paradex$1 {
223
224
  * @param {object} [params] extra parameters specific to the exchange API endpoint
224
225
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
225
226
  */
227
+ await this.loadMarkets();
226
228
  symbols = this.marketSymbols(symbols);
227
229
  const channel = 'markets_summary';
228
230
  const url = this.urls['api']['ws'];
@@ -572,7 +572,7 @@ class vertex extends vertex$1 {
572
572
  const client = this.client(url);
573
573
  this.setPositionsCache(client, symbols, params);
574
574
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
575
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
575
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
576
576
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
577
577
  const snapshot = await client.future('fetchPositionsSnapshot');
578
578
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);
@@ -968,7 +968,7 @@ class woo extends woo$1 {
968
968
  const client = this.client(url);
969
969
  this.setPositionsCache(client, symbols);
970
970
  const fetchPositionsSnapshot = this.handleOption('watchPositions', 'fetchPositionsSnapshot', true);
971
- const awaitPositionsSnapshot = this.safeBool('watchPositions', 'awaitPositionsSnapshot', true);
971
+ const awaitPositionsSnapshot = this.handleOption('watchPositions', 'awaitPositionsSnapshot', true);
972
972
  if (fetchPositionsSnapshot && awaitPositionsSnapshot && this.positions === undefined) {
973
973
  const snapshot = await client.future('fetchPositionsSnapshot');
974
974
  return this.filterBySymbolsSinceLimit(snapshot, symbols, since, limit, true);