ccxt 4.4.11 → 4.4.13

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 (70) hide show
  1. package/README.md +3 -4
  2. package/dist/ccxt.browser.min.js +4 -4
  3. package/dist/cjs/ccxt.js +1 -1
  4. package/dist/cjs/src/base/Exchange.js +6 -0
  5. package/dist/cjs/src/bigone.js +2 -0
  6. package/dist/cjs/src/binance.js +61 -3
  7. package/dist/cjs/src/bingx.js +96 -6
  8. package/dist/cjs/src/bitget.js +2 -0
  9. package/dist/cjs/src/bitmex.js +1 -0
  10. package/dist/cjs/src/bybit.js +4 -1
  11. package/dist/cjs/src/coinbaseinternational.js +2 -0
  12. package/dist/cjs/src/coinex.js +2 -0
  13. package/dist/cjs/src/delta.js +2 -0
  14. package/dist/cjs/src/deribit.js +2 -0
  15. package/dist/cjs/src/digifinex.js +2 -0
  16. package/dist/cjs/src/gate.js +2 -0
  17. package/dist/cjs/src/htx.js +8 -2
  18. package/dist/cjs/src/kraken.js +4 -4
  19. package/dist/cjs/src/krakenfutures.js +2 -0
  20. package/dist/cjs/src/kucoinfutures.js +2 -0
  21. package/dist/cjs/src/mexc.js +19 -4
  22. package/dist/cjs/src/okx.js +56 -23
  23. package/dist/cjs/src/oxfun.js +1 -0
  24. package/dist/cjs/src/paradex.js +1 -0
  25. package/dist/cjs/src/phemex.js +13 -4
  26. package/dist/cjs/src/poloniex.js +1 -0
  27. package/dist/cjs/src/pro/binance.js +80 -5
  28. package/dist/cjs/src/pro/bitfinex.js +8 -8
  29. package/dist/cjs/src/pro/krakenfutures.js +2 -0
  30. package/dist/cjs/src/pro/phemex.js +2 -0
  31. package/dist/cjs/src/pro/woo.js +73 -0
  32. package/examples/README.md +4 -0
  33. package/js/ccxt.d.ts +1 -1
  34. package/js/ccxt.js +1 -1
  35. package/js/src/base/Exchange.d.ts +2 -0
  36. package/js/src/base/Exchange.js +6 -0
  37. package/js/src/base/types.d.ts +18 -16
  38. package/js/src/bigone.js +2 -0
  39. package/js/src/binance.d.ts +1 -0
  40. package/js/src/binance.js +61 -3
  41. package/js/src/bingx.d.ts +1 -0
  42. package/js/src/bingx.js +96 -6
  43. package/js/src/bitget.js +2 -0
  44. package/js/src/bitmex.js +1 -0
  45. package/js/src/bybit.js +4 -1
  46. package/js/src/coinbaseinternational.js +2 -0
  47. package/js/src/coinex.js +2 -0
  48. package/js/src/delta.js +2 -0
  49. package/js/src/deribit.js +2 -0
  50. package/js/src/digifinex.js +2 -0
  51. package/js/src/gate.js +2 -0
  52. package/js/src/htx.js +8 -2
  53. package/js/src/kraken.js +4 -4
  54. package/js/src/krakenfutures.js +2 -0
  55. package/js/src/kucoinfutures.js +2 -0
  56. package/js/src/mexc.js +19 -4
  57. package/js/src/okx.d.ts +1 -0
  58. package/js/src/okx.js +56 -23
  59. package/js/src/oxfun.js +1 -0
  60. package/js/src/paradex.js +1 -0
  61. package/js/src/phemex.js +13 -4
  62. package/js/src/poloniex.js +1 -0
  63. package/js/src/pro/binance.d.ts +5 -0
  64. package/js/src/pro/binance.js +80 -5
  65. package/js/src/pro/bitfinex.js +8 -8
  66. package/js/src/pro/krakenfutures.js +2 -0
  67. package/js/src/pro/phemex.js +2 -0
  68. package/js/src/pro/woo.d.ts +3 -0
  69. package/js/src/pro/woo.js +73 -0
  70. package/package.json +2 -2
package/js/src/bigone.js CHANGED
@@ -725,6 +725,8 @@ export default class bigone extends Exchange {
725
725
  'average': undefined,
726
726
  'baseVolume': this.safeString2(ticker, 'volume', 'volume24h'),
727
727
  'quoteVolume': this.safeString(ticker, 'volume24hInUsd'),
728
+ 'markPrice': this.safeString(ticker, 'markPrice'),
729
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
728
730
  'info': ticker,
729
731
  }, market);
730
732
  }
@@ -43,6 +43,7 @@ export default class binance extends Exchange {
43
43
  info: any;
44
44
  };
45
45
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
46
+ fetchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
46
47
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;
47
48
  fetchOHLCV(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OHLCV[]>;
48
49
  parseTrade(trade: Dict, market?: Market): Trade;
package/js/src/binance.js CHANGED
@@ -112,6 +112,7 @@ export default class binance extends Exchange {
112
112
  'fetchMarketLeverageTiers': 'emulated',
113
113
  'fetchMarkets': true,
114
114
  'fetchMarkOHLCV': true,
115
+ 'fetchMarkPrices': true,
115
116
  'fetchMyLiquidations': true,
116
117
  'fetchMySettlementHistory': true,
117
118
  'fetchMyTrades': true,
@@ -1196,6 +1197,9 @@ export default class binance extends Exchange {
1196
1197
  },
1197
1198
  'option': {},
1198
1199
  },
1200
+ 'currencies': {
1201
+ 'BNFCR': this.safeCurrencyStructure({ 'id': 'BNFCR', 'code': 'BNFCR', 'precision': this.parseNumber('0.001') }),
1202
+ },
1199
1203
  'commonCurrencies': {
1200
1204
  'BCC': 'BCC',
1201
1205
  'YOYO': 'YOYOW',
@@ -3814,6 +3818,18 @@ export default class binance extends Exchange {
3814
3818
  return orderbook;
3815
3819
  }
3816
3820
  parseTicker(ticker, market = undefined) {
3821
+ // markPrices
3822
+ //
3823
+ // {
3824
+ // "symbol": "BTCUSDT",
3825
+ // "markPrice": "11793.63104562", // mark price
3826
+ // "indexPrice": "11781.80495970", // index price
3827
+ // "estimatedSettlePrice": "11781.16138815", // Estimated Settle Price, only useful in the last hour before the settlement starts.
3828
+ // "lastFundingRate": "0.00038246", // This is the lastest estimated funding rate
3829
+ // "nextFundingTime": 1597392000000,
3830
+ // "interestRate": "0.00010000",
3831
+ // "time": 1597370495002
3832
+ // }
3817
3833
  //
3818
3834
  // {
3819
3835
  // "symbol": "ETHBTC",
@@ -3917,7 +3933,7 @@ export default class binance extends Exchange {
3917
3933
  // "time":"1673899278514"
3918
3934
  // }
3919
3935
  //
3920
- const timestamp = this.safeInteger(ticker, 'closeTime');
3936
+ const timestamp = this.safeInteger2(ticker, 'closeTime', 'time');
3921
3937
  let marketType = undefined;
3922
3938
  if (('time' in ticker)) {
3923
3939
  marketType = 'contract';
@@ -3961,6 +3977,8 @@ export default class binance extends Exchange {
3961
3977
  'average': undefined,
3962
3978
  'baseVolume': baseVolume,
3963
3979
  'quoteVolume': quoteVolume,
3980
+ 'markPrice': this.safeString(ticker, 'markPrice'),
3981
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
3964
3982
  'info': ticker,
3965
3983
  }, market);
3966
3984
  }
@@ -4223,6 +4241,36 @@ export default class binance extends Exchange {
4223
4241
  }
4224
4242
  return this.parseTickers(response, symbols);
4225
4243
  }
4244
+ async fetchMarkPrices(symbols = undefined, params = {}) {
4245
+ /**
4246
+ * @method
4247
+ * @name binance#fetchMarkPrices
4248
+ * @description fetches mark prices for multiple markets
4249
+ * @see https://binance-docs.github.io/apidocs/futures/en/#mark-price
4250
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
4251
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4252
+ * @param {string} [params.subType] "linear" or "inverse"
4253
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
4254
+ */
4255
+ await this.loadMarkets();
4256
+ symbols = this.marketSymbols(symbols, undefined, true, true, true);
4257
+ const market = this.getMarketFromSymbols(symbols);
4258
+ let type = undefined;
4259
+ [type, params] = this.handleMarketTypeAndParams('fetchTickers', market, params, 'swap');
4260
+ let subType = undefined;
4261
+ [subType, params] = this.handleSubTypeAndParams('fetchTickers', market, params, 'linear');
4262
+ let response = undefined;
4263
+ if (this.isLinear(type, subType)) {
4264
+ response = await this.fapiPublicGetPremiumIndex(params);
4265
+ }
4266
+ else if (this.isInverse(type, subType)) {
4267
+ response = await this.dapiPublicGetPremiumIndex(params);
4268
+ }
4269
+ else {
4270
+ throw new NotSupported(this.id + ' fetchMarkPrices() does not support ' + type + ' markets yet');
4271
+ }
4272
+ return this.parseTickers(response, symbols);
4273
+ }
4226
4274
  parseOHLCV(ohlcv, market = undefined) {
4227
4275
  // when api method = publicGetKlines || fapiPublicGetKlines || dapiPublicGetKlines
4228
4276
  // [
@@ -5842,6 +5890,8 @@ export default class binance extends Exchange {
5842
5890
  * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
5843
5891
  * @param {boolean} [params.portfolioMargin] set to true if you would like to create an order in a portfolio margin account
5844
5892
  * @param {string} [params.stopLossOrTakeProfit] 'stopLoss' or 'takeProfit', required for spot trailing orders
5893
+ * @param {string} [params.positionSide] *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
5894
+ * @param {bool} [params.hedged] *swap and portfolio margin only* true for hedged mode, false for one way mode, default is false
5845
5895
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
5846
5896
  */
5847
5897
  await this.loadMarkets();
@@ -5950,9 +6000,9 @@ export default class binance extends Exchange {
5950
6000
  [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'createOrder', 'papi', 'portfolioMargin', false);
5951
6001
  let marginMode = undefined;
5952
6002
  [marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
6003
+ const reduceOnly = this.safeBool(params, 'reduceOnly', false);
5953
6004
  if ((marketType === 'margin') || (marginMode !== undefined) || market['option']) {
5954
6005
  // for swap and future reduceOnly is a string that cant be sent with close position set to true or in hedge mode
5955
- const reduceOnly = this.safeBool(params, 'reduceOnly', false);
5956
6006
  params = this.omit(params, 'reduceOnly');
5957
6007
  if (market['option']) {
5958
6008
  request['reduceOnly'] = reduceOnly;
@@ -6222,7 +6272,15 @@ export default class binance extends Exchange {
6222
6272
  if (this.safeString(params, 'timeInForce') === 'PO') {
6223
6273
  params = this.omit(params, 'timeInForce');
6224
6274
  }
6225
- const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test']);
6275
+ const hedged = this.safeBool(params, 'hedged', false);
6276
+ if (!market['spot'] && !market['option'] && hedged) {
6277
+ if (reduceOnly) {
6278
+ params = this.omit(params, 'reduceOnly');
6279
+ side = (side === 'buy') ? 'sell' : 'buy';
6280
+ }
6281
+ request['positionSide'] = (side === 'buy') ? 'LONG' : 'SHORT';
6282
+ }
6283
+ const requestParams = this.omit(params, ['type', 'newClientOrderId', 'clientOrderId', 'postOnly', 'stopLossPrice', 'takeProfitPrice', 'stopPrice', 'triggerPrice', 'trailingTriggerPrice', 'trailingPercent', 'quoteOrderQty', 'cost', 'test', 'hedged']);
6226
6284
  return this.extend(request, requestParams);
6227
6285
  }
6228
6286
  async createMarketOrderWithCost(symbol, side, cost, params = {}) {
package/js/src/bingx.d.ts CHANGED
@@ -26,6 +26,7 @@ export default class bingx extends Exchange {
26
26
  parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
27
27
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
28
28
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
29
+ fetchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
29
30
  parseTicker(ticker: Dict, market?: Market): Ticker;
30
31
  fetchBalance(params?: {}): Promise<Balances>;
31
32
  parseBalance(response: any): Balances;
package/js/src/bingx.js CHANGED
@@ -68,6 +68,7 @@ export default class bingx extends Exchange {
68
68
  'fetchMarginMode': true,
69
69
  'fetchMarkets': true,
70
70
  'fetchMarkOHLCV': true,
71
+ 'fetchMarkPrices': true,
71
72
  'fetchMyLiquidations': true,
72
73
  'fetchOHLCV': true,
73
74
  'fetchOpenInterest': true,
@@ -584,8 +585,8 @@ export default class bingx extends Exchange {
584
585
  const networkList = this.safeList(entry, 'networkList');
585
586
  const networks = {};
586
587
  let fee = undefined;
587
- let depositEnabled = undefined;
588
- let withdrawEnabled = undefined;
588
+ let depositEnabled = false;
589
+ let withdrawEnabled = false;
589
590
  let defaultLimits = {};
590
591
  for (let j = 0; j < networkList.length; j++) {
591
592
  const rawNetwork = networkList[j];
@@ -597,7 +598,7 @@ export default class bingx extends Exchange {
597
598
  depositEnabled = true;
598
599
  }
599
600
  const networkWithdrawEnabled = this.safeBool(rawNetwork, 'withdrawEnable');
600
- if (networkDepositEnabled) {
601
+ if (networkWithdrawEnabled) {
601
602
  withdrawEnabled = true;
602
603
  }
603
604
  const limits = {
@@ -1732,7 +1733,76 @@ export default class bingx extends Exchange {
1732
1733
  const tickers = this.safeList(response, 'data');
1733
1734
  return this.parseTickers(tickers, symbols);
1734
1735
  }
1736
+ async fetchMarkPrices(symbols = undefined, params = {}) {
1737
+ /**
1738
+ * @method
1739
+ * @name bingx#fetchMarkPrices
1740
+ * @description fetches mark prices for multiple markets
1741
+ * @see https://bingx-api.github.io/docs/#/en-us/swapV2/market-api.html#Mark%20Price%20and%20Funding%20Rate
1742
+ * @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1743
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
1744
+ * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
1745
+ */
1746
+ await this.loadMarkets();
1747
+ let market = undefined;
1748
+ if (symbols !== undefined) {
1749
+ symbols = this.marketSymbols(symbols);
1750
+ const firstSymbol = this.safeString(symbols, 0);
1751
+ if (firstSymbol !== undefined) {
1752
+ market = this.market(firstSymbol);
1753
+ }
1754
+ }
1755
+ let subType = undefined;
1756
+ [subType, params] = this.handleSubTypeAndParams('fetchMarkPrices', market, params, 'linear');
1757
+ let response = undefined;
1758
+ if (subType === 'inverse') {
1759
+ response = await this.cswapV1PublicGetMarketPremiumIndex(params);
1760
+ }
1761
+ else {
1762
+ response = await this.swapV2PublicGetQuotePremiumIndex(params);
1763
+ }
1764
+ //
1765
+ // spot and swap
1766
+ //
1767
+ // {
1768
+ // "code": 0,
1769
+ // "msg": "",
1770
+ // "timestamp": 1720647285296,
1771
+ // "data": [
1772
+ // {
1773
+ // "symbol": "SOL-USD",
1774
+ // "priceChange": "-2.418",
1775
+ // "priceChangePercent": "-1.6900%",
1776
+ // "lastPrice": "140.574",
1777
+ // "lastQty": "1",
1778
+ // "highPrice": "146.190",
1779
+ // "lowPrice": "138.586",
1780
+ // "volume": "1464648.00",
1781
+ // "quoteVolume": "102928.12",
1782
+ // "openPrice": "142.994",
1783
+ // "closeTime": "1720647284976",
1784
+ // "bidPrice": "140.573",
1785
+ // "bidQty": "372",
1786
+ // "askPrice": "140.577",
1787
+ // "askQty": "58"
1788
+ // },
1789
+ // ...
1790
+ // ]
1791
+ // }
1792
+ //
1793
+ const tickers = this.safeList(response, 'data');
1794
+ return this.parseTickers(tickers, symbols);
1795
+ }
1735
1796
  parseTicker(ticker, market = undefined) {
1797
+ //
1798
+ // mark price
1799
+ // {
1800
+ // "symbol": "string",
1801
+ // "lastFundingRate": "string",
1802
+ // "markPrice": "string",
1803
+ // "indexPrice": "string",
1804
+ // "nextFundingTime": "int64"
1805
+ // }
1736
1806
  //
1737
1807
  // spot
1738
1808
  // {
@@ -1820,6 +1890,8 @@ export default class bingx extends Exchange {
1820
1890
  'average': undefined,
1821
1891
  'baseVolume': baseVolume,
1822
1892
  'quoteVolume': quoteVolume,
1893
+ 'markPrice': this.safeString(ticker, 'markPrice'),
1894
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
1823
1895
  'info': ticker,
1824
1896
  }, market);
1825
1897
  }
@@ -2615,6 +2687,7 @@ export default class bingx extends Exchange {
2615
2687
  * @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered
2616
2688
  * @param {float} [params.stopLoss.triggerPrice] stop loss trigger price
2617
2689
  * @param {boolean} [params.test] *swap only* whether to use the test endpoint or not, default is false
2690
+ * @param {string} [params.positionSide] *contracts only* "BOTH" for one way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode
2618
2691
  * @param {boolean} [params.hedged] *swap only* whether the order is in hedged mode or one way mode
2619
2692
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
2620
2693
  */
@@ -4450,18 +4523,35 @@ export default class bingx extends Exchange {
4450
4523
  // "tag": ''
4451
4524
  // }
4452
4525
  //
4453
- const address = this.safeString(depositAddress, 'address');
4526
+ let address = this.safeString(depositAddress, 'address');
4454
4527
  const tag = this.safeString(depositAddress, 'tag');
4455
4528
  const currencyId = this.safeString(depositAddress, 'coin');
4456
4529
  currency = this.safeCurrency(currencyId, currency);
4457
4530
  const code = currency['code'];
4458
- const network = this.safeString(depositAddress, 'network');
4531
+ // the exchange API returns deposit addresses without the leading '0x' prefix
4532
+ // however, the exchange API does require the 0x prefix to withdraw
4533
+ // so we append the prefix before returning the address to the user
4534
+ // that is only if the underlying contract address has the 0x prefix as well
4535
+ const networkCode = this.safeString(depositAddress, 'network');
4536
+ if (networkCode !== undefined) {
4537
+ if (networkCode in currency['networks']) {
4538
+ const network = currency['networks'][networkCode];
4539
+ const contractAddress = this.safeString(network['info'], 'contractAddress');
4540
+ if (contractAddress !== undefined) {
4541
+ if (contractAddress[0] === '0' && contractAddress[1] === 'x') {
4542
+ if (address[0] !== '0' || address[1] !== 'x') {
4543
+ address = '0x' + address;
4544
+ }
4545
+ }
4546
+ }
4547
+ }
4548
+ }
4459
4549
  this.checkAddress(address);
4460
4550
  return {
4461
4551
  'currency': code,
4462
4552
  'address': address,
4463
4553
  'tag': tag,
4464
- 'network': network,
4554
+ 'network': networkCode,
4465
4555
  'info': depositAddress,
4466
4556
  };
4467
4557
  }
package/js/src/bitget.js CHANGED
@@ -2643,6 +2643,7 @@ export default class bitget extends Exchange {
2643
2643
  'average': undefined,
2644
2644
  'baseVolume': this.safeString(ticker, 'baseVolume'),
2645
2645
  'quoteVolume': this.safeString(ticker, 'quoteVolume'),
2646
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
2646
2647
  'info': ticker,
2647
2648
  }, market);
2648
2649
  }
@@ -4123,6 +4124,7 @@ export default class bitget extends Exchange {
4123
4124
  * @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
4124
4125
  * @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
4125
4126
  * @param {boolean} [params.oneWayMode] *swap and future only* required to set this to true in one_way_mode and you can leave this as undefined in hedge_mode, can adjust the mode using the setPositionMode() method
4127
+ * @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode, default is false
4126
4128
  * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
4127
4129
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4128
4130
  */
package/js/src/bitmex.js CHANGED
@@ -1440,6 +1440,7 @@ export default class bitmex extends Exchange {
1440
1440
  'average': undefined,
1441
1441
  'baseVolume': this.safeString(ticker, 'homeNotional24h'),
1442
1442
  'quoteVolume': this.safeString(ticker, 'foreignNotional24h'),
1443
+ 'markPrice': this.safeString(ticker, 'markPrice'),
1443
1444
  'info': ticker,
1444
1445
  }, market);
1445
1446
  }
package/js/src/bybit.js CHANGED
@@ -2111,6 +2111,8 @@ export default class bybit extends Exchange {
2111
2111
  'average': undefined,
2112
2112
  'baseVolume': baseVolume,
2113
2113
  'quoteVolume': quoteVolume,
2114
+ 'markPrice': this.safeString(ticker, 'markPrice'),
2115
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
2114
2116
  'info': ticker,
2115
2117
  }, market);
2116
2118
  }
@@ -3621,7 +3623,8 @@ export default class bybit extends Exchange {
3621
3623
  * @param {string} [params.timeInForce] "GTC", "IOC", "FOK"
3622
3624
  * @param {bool} [params.postOnly] true or false whether the order is post-only
3623
3625
  * @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
3624
- * @param {string} [params.positionIdx] *contracts only* 0 for one-way mode, 1 buy side of hedged mode, 2 sell side of hedged mode
3626
+ * @param {string} [params.positionIdx] *contracts only* 0 for one-way mode, 1 buy side of hedged mode, 2 sell side of hedged mode
3627
+ * @param {bool} [params.hedged] *contracts only* true for hedged mode, false for one way mode, default is false
3625
3628
  * @param {boolean} [params.isLeverage] *unified spot only* false then spot trading true then margin trading
3626
3629
  * @param {string} [params.tpslMode] *contract only* 'full' or 'partial'
3627
3630
  * @param {string} [params.mmp] *option only* market maker protection
@@ -1508,6 +1508,8 @@ export default class coinbaseinternational extends Exchange {
1508
1508
  'baseVolume': undefined,
1509
1509
  'quoteVolume': undefined,
1510
1510
  'previousClose': undefined,
1511
+ 'markPrice': this.safeNumber(ticker, 'mark_price'),
1512
+ 'indexPrice': this.safeNumber(ticker, 'index_price'),
1511
1513
  });
1512
1514
  }
1513
1515
  async fetchBalance(params = {}) {
package/js/src/coinex.js CHANGED
@@ -920,6 +920,8 @@ export default class coinex extends Exchange {
920
920
  'average': undefined,
921
921
  'baseVolume': this.safeString(ticker, 'volume'),
922
922
  'quoteVolume': undefined,
923
+ 'markPrice': this.safeString(ticker, 'mark_price'),
924
+ 'indexPrice': this.safeString(ticker, 'index_price'),
923
925
  'info': ticker,
924
926
  }, market);
925
927
  }
package/js/src/delta.js CHANGED
@@ -966,6 +966,8 @@ export default class delta extends Exchange {
966
966
  'average': undefined,
967
967
  'baseVolume': this.safeNumber(ticker, 'volume'),
968
968
  'quoteVolume': this.safeNumber(ticker, 'turnover'),
969
+ 'markPrice': this.safeNumber(ticker, 'mark_price'),
970
+ 'indexPrice': this.safeNumber(ticker, 'spot_price'),
969
971
  'info': ticker,
970
972
  }, market);
971
973
  }
package/js/src/deribit.js CHANGED
@@ -1160,6 +1160,8 @@ export default class deribit extends Exchange {
1160
1160
  'average': undefined,
1161
1161
  'baseVolume': undefined,
1162
1162
  'quoteVolume': this.safeString(stats, 'volume'),
1163
+ 'markPrice': this.safeString(ticker, 'mark_price'),
1164
+ 'indexPrice': this.safeString(ticker, 'index_price'),
1163
1165
  'info': ticker,
1164
1166
  }, market);
1165
1167
  }
@@ -1195,6 +1195,8 @@ export default class digifinex extends Exchange {
1195
1195
  'average': undefined,
1196
1196
  'baseVolume': this.safeString2(ticker, 'vol', 'volume_24h'),
1197
1197
  'quoteVolume': this.safeString(ticker, 'base_vol'),
1198
+ 'markPrice': this.safeString(ticker, 'mark_price'),
1199
+ 'indexPrice': indexPrice,
1198
1200
  'info': ticker,
1199
1201
  }, market);
1200
1202
  }
package/js/src/gate.js CHANGED
@@ -2613,6 +2613,8 @@ export default class gate extends Exchange {
2613
2613
  'average': undefined,
2614
2614
  'baseVolume': baseVolume,
2615
2615
  'quoteVolume': quoteVolume,
2616
+ 'markPrice': this.safeString(ticker, 'mark_price'),
2617
+ 'indexPrice': this.safeString(ticker, 'index_price'),
2616
2618
  'info': ticker,
2617
2619
  }, market);
2618
2620
  }
package/js/src/htx.js CHANGED
@@ -3705,6 +3705,12 @@ export default class htx extends Exchange {
3705
3705
  * @method
3706
3706
  * @name htx#fetchOrder
3707
3707
  * @description fetches information on an order made by the user
3708
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order-based-on-client-order-id
3709
+ * @see https://huobiapi.github.io/docs/spot/v1/en/#get-the-order-detail-of-an-order
3710
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-get-information-of-an-order
3711
+ * @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-get-information-of-order
3712
+ * @see https://huobiapi.github.io/docs/dm/v1/en/#get-information-of-an-order
3713
+ * @see https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#get-information-of-an-order
3708
3714
  * @param {string} symbol unified symbol of the market the order was made in
3709
3715
  * @param {object} [params] extra parameters specific to the exchange API endpoint
3710
3716
  * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
@@ -4376,7 +4382,7 @@ export default class htx extends Exchange {
4376
4382
  await this.loadAccounts();
4377
4383
  for (let i = 0; i < this.accounts.length; i++) {
4378
4384
  const account = this.accounts[i];
4379
- if (account['type'] === 'spot') {
4385
+ if (this.safeString(account, 'type') === 'spot') {
4380
4386
  accountId = this.safeString(account, 'id');
4381
4387
  if (accountId !== undefined) {
4382
4388
  break;
@@ -5068,7 +5074,7 @@ export default class htx extends Exchange {
5068
5074
  }
5069
5075
  else {
5070
5076
  amount = this.safeString2(order, 'volume', 'amount');
5071
- cost = this.safeStringN(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']); // same typo
5077
+ cost = this.safeStringN(order, ['filled-cash-amount', 'field-cash-amount', 'trade_turnover']); // same typo here
5072
5078
  }
5073
5079
  const filled = this.safeStringN(order, ['filled-amount', 'field-amount', 'trade_volume']); // typo in their API, filled amount
5074
5080
  const price = this.safeString2(order, 'price', 'order_price');
package/js/src/kraken.js CHANGED
@@ -1826,7 +1826,7 @@ export default class kraken extends Exchange {
1826
1826
  const extendedOflags = (flags !== undefined) ? flags + ',viqc' : 'viqc';
1827
1827
  request['oflags'] = extendedOflags;
1828
1828
  }
1829
- else if (isLimitOrder && !isTrailingAmountOrder) {
1829
+ else if (isLimitOrder && !isTrailingAmountOrder && !isTrailingPercentOrder) {
1830
1830
  request['price'] = this.priceToPrecision(symbol, price);
1831
1831
  }
1832
1832
  const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only');
@@ -1855,8 +1855,8 @@ export default class kraken extends Exchange {
1855
1855
  }
1856
1856
  else if (isTrailingAmountOrder || isTrailingPercentOrder) {
1857
1857
  let trailingPercentString = undefined;
1858
- if (isTrailingPercentOrder) {
1859
- trailingPercentString = (trailingPercent.endsWith('%')) ? trailingPercent : '+' + (this.numberToString(trailingPercent) + '%');
1858
+ if (trailingPercent !== undefined) {
1859
+ trailingPercentString = (trailingPercent.endsWith('%')) ? ('+' + trailingPercent) : ('+' + trailingPercent + '%');
1860
1860
  }
1861
1861
  const trailingAmountString = (trailingAmount !== undefined) ? '+' + trailingAmount : undefined; // must use + for this
1862
1862
  const offset = this.safeString(params, 'offset', '-'); // can use + or - for this
@@ -1866,7 +1866,7 @@ export default class kraken extends Exchange {
1866
1866
  if (isLimitOrder || (trailingLimitAmount !== undefined) || (trailingLimitPercent !== undefined)) {
1867
1867
  request['ordertype'] = 'trailing-stop-limit';
1868
1868
  if (trailingLimitPercent !== undefined) {
1869
- const trailingLimitPercentString = (trailingLimitPercent.endsWith('%')) ? trailingLimitPercent : (this.numberToString(trailingLimitPercent) + '%');
1869
+ const trailingLimitPercentString = (trailingLimitPercent.endsWith('%')) ? (offset + trailingLimitPercent) : (offset + trailingLimitPercent + '%');
1870
1870
  request['price'] = trailingPercentString;
1871
1871
  request['price2'] = trailingLimitPercentString;
1872
1872
  }
@@ -616,6 +616,8 @@ export default class krakenfutures extends Exchange {
616
616
  'average': average,
617
617
  'baseVolume': baseVolume,
618
618
  'quoteVolume': quoteVolume,
619
+ 'markPrice': this.safeString(ticker, 'markPrice'),
620
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
619
621
  'info': ticker,
620
622
  });
621
623
  }
@@ -969,6 +969,8 @@ export default class kucoinfutures extends kucoin {
969
969
  'average': undefined,
970
970
  'baseVolume': this.safeString(ticker, 'volumeOf24h'),
971
971
  'quoteVolume': this.safeString(ticker, 'turnoverOf24h'),
972
+ 'markPrice': this.safeString(ticker, 'markPrice'),
973
+ 'indexPrice': this.safeString(ticker, 'indexPrice'),
972
974
  'info': ticker,
973
975
  }, market);
974
976
  }
package/js/src/mexc.js CHANGED
@@ -2150,6 +2150,7 @@ export default class mexc extends Exchange {
2150
2150
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2151
2151
  * @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
2152
2152
  * @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
2153
+ * @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
2153
2154
  *
2154
2155
  * EXCHANGE SPECIFIC PARAMETERS
2155
2156
  * @param {int} [params.leverage] *contract only* leverage is necessary on isolated margin
@@ -2294,6 +2295,7 @@ export default class mexc extends Exchange {
2294
2295
  * @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
2295
2296
  * @param {bool} [params.postOnly] if true, the order will only be posted if it will be a maker order
2296
2297
  * @param {bool} [params.reduceOnly] indicates if this order is to reduce the size of a position
2298
+ * @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode, default is false
2297
2299
  *
2298
2300
  * EXCHANGE SPECIFIC PARAMETERS
2299
2301
  * @param {int} [params.leverage] leverage is necessary on isolated margin
@@ -2374,18 +2376,31 @@ export default class mexc extends Exchange {
2374
2376
  }
2375
2377
  }
2376
2378
  const reduceOnly = this.safeBool(params, 'reduceOnly', false);
2377
- if (reduceOnly) {
2378
- request['side'] = (side === 'buy') ? 2 : 4;
2379
+ const hedged = this.safeBool(params, 'hedged', false);
2380
+ let sideInteger = undefined;
2381
+ if (hedged) {
2382
+ if (reduceOnly) {
2383
+ params = this.omit(params, 'reduceOnly'); // hedged mode does not accept this parameter
2384
+ side = (side === 'buy') ? 'sell' : 'buy';
2385
+ }
2386
+ sideInteger = (side === 'buy') ? 1 : 3;
2387
+ request['positionMode'] = 1;
2379
2388
  }
2380
2389
  else {
2381
- request['side'] = (side === 'buy') ? 1 : 3;
2390
+ if (reduceOnly) {
2391
+ sideInteger = (side === 'buy') ? 2 : 4;
2392
+ }
2393
+ else {
2394
+ sideInteger = (side === 'buy') ? 1 : 3;
2395
+ }
2382
2396
  }
2397
+ request['side'] = sideInteger;
2383
2398
  const clientOrderId = this.safeString2(params, 'clientOrderId', 'externalOid');
2384
2399
  if (clientOrderId !== undefined) {
2385
2400
  request['externalOid'] = clientOrderId;
2386
2401
  }
2387
2402
  const stopPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
2388
- params = this.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice']);
2403
+ params = this.omit(params, ['clientOrderId', 'externalOid', 'postOnly', 'stopPrice', 'triggerPrice', 'hedged']);
2389
2404
  let response = undefined;
2390
2405
  if (stopPrice) {
2391
2406
  request['triggerPrice'] = this.priceToPrecision(symbol, stopPrice);
package/js/src/okx.d.ts CHANGED
@@ -21,6 +21,7 @@ export default class okx extends Exchange {
21
21
  parseTicker(ticker: Dict, market?: Market): Ticker;
22
22
  fetchTicker(symbol: string, params?: {}): Promise<Ticker>;
23
23
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
24
+ fetchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
24
25
  parseTrade(trade: Dict, market?: Market): Trade;
25
26
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
26
27
  parseOHLCV(ohlcv: any, market?: Market): OHLCV;