ccxt 4.4.12 → 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 (64) hide show
  1. package/README.md +3 -4
  2. package/dist/ccxt.browser.min.js +2 -2
  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 +49 -1
  7. package/dist/cjs/src/bingx.js +75 -3
  8. package/dist/cjs/src/bitget.js +1 -0
  9. package/dist/cjs/src/bitmex.js +1 -0
  10. package/dist/cjs/src/bybit.js +2 -0
  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 +2 -2
  18. package/dist/cjs/src/krakenfutures.js +2 -0
  19. package/dist/cjs/src/kucoinfutures.js +2 -0
  20. package/dist/cjs/src/okx.js +41 -0
  21. package/dist/cjs/src/oxfun.js +1 -0
  22. package/dist/cjs/src/paradex.js +1 -0
  23. package/dist/cjs/src/poloniex.js +1 -0
  24. package/dist/cjs/src/pro/binance.js +80 -5
  25. package/dist/cjs/src/pro/bitfinex.js +8 -8
  26. package/dist/cjs/src/pro/krakenfutures.js +2 -0
  27. package/dist/cjs/src/pro/phemex.js +2 -0
  28. package/dist/cjs/src/pro/woo.js +73 -0
  29. package/examples/README.md +4 -0
  30. package/js/ccxt.d.ts +1 -1
  31. package/js/ccxt.js +1 -1
  32. package/js/src/base/Exchange.d.ts +2 -0
  33. package/js/src/base/Exchange.js +6 -0
  34. package/js/src/base/types.d.ts +18 -16
  35. package/js/src/bigone.js +2 -0
  36. package/js/src/binance.d.ts +1 -0
  37. package/js/src/binance.js +49 -1
  38. package/js/src/bingx.d.ts +1 -0
  39. package/js/src/bingx.js +75 -3
  40. package/js/src/bitget.js +1 -0
  41. package/js/src/bitmex.js +1 -0
  42. package/js/src/bybit.js +2 -0
  43. package/js/src/coinbaseinternational.js +2 -0
  44. package/js/src/coinex.js +2 -0
  45. package/js/src/delta.js +2 -0
  46. package/js/src/deribit.js +2 -0
  47. package/js/src/digifinex.js +2 -0
  48. package/js/src/gate.js +2 -0
  49. package/js/src/htx.js +2 -2
  50. package/js/src/krakenfutures.js +2 -0
  51. package/js/src/kucoinfutures.js +2 -0
  52. package/js/src/okx.d.ts +1 -0
  53. package/js/src/okx.js +41 -0
  54. package/js/src/oxfun.js +1 -0
  55. package/js/src/paradex.js +1 -0
  56. package/js/src/poloniex.js +1 -0
  57. package/js/src/pro/binance.d.ts +5 -0
  58. package/js/src/pro/binance.js +80 -5
  59. package/js/src/pro/bitfinex.js +8 -8
  60. package/js/src/pro/krakenfutures.js +2 -0
  61. package/js/src/pro/phemex.js +2 -0
  62. package/js/src/pro/woo.d.ts +3 -0
  63. package/js/src/pro/woo.js +73 -0
  64. package/package.json +2 -2
@@ -221,15 +221,15 @@ class bitfinex extends bitfinex$1 {
221
221
  if ((last !== undefined) && (change !== undefined)) {
222
222
  open = Precise["default"].stringSub(last, change);
223
223
  }
224
- const result = {
224
+ const result = this.safeTicker({
225
225
  'symbol': symbol,
226
226
  'timestamp': undefined,
227
227
  'datetime': undefined,
228
- 'high': this.safeFloat(message, 9),
229
- 'low': this.safeFloat(message, 10),
230
- 'bid': this.safeFloat(message, 1),
228
+ 'high': this.safeString(message, 9),
229
+ 'low': this.safeString(message, 10),
230
+ 'bid': this.safeString(message, 1),
231
231
  'bidVolume': undefined,
232
- 'ask': this.safeFloat(message, 3),
232
+ 'ask': this.safeString(message, 3),
233
233
  'askVolume': undefined,
234
234
  'vwap': undefined,
235
235
  'open': this.parseNumber(open),
@@ -237,12 +237,12 @@ class bitfinex extends bitfinex$1 {
237
237
  'last': this.parseNumber(last),
238
238
  'previousClose': undefined,
239
239
  'change': this.parseNumber(change),
240
- 'percentage': this.safeFloat(message, 6),
240
+ 'percentage': this.safeString(message, 6),
241
241
  'average': undefined,
242
- 'baseVolume': this.safeFloat(message, 8),
242
+ 'baseVolume': this.safeString(message, 8),
243
243
  'quoteVolume': undefined,
244
244
  'info': message,
245
- };
245
+ });
246
246
  this.tickers[symbol] = result;
247
247
  client.resolve(result, messageHash);
248
248
  }
@@ -1062,6 +1062,8 @@ class krakenfutures extends krakenfutures$1 {
1062
1062
  'average': undefined,
1063
1063
  'baseVolume': this.safeString(ticker, 'volume'),
1064
1064
  'quoteVolume': this.safeString(ticker, 'volumeQuote'),
1065
+ 'markPrice': this.safeString(ticker, 'markPrice'),
1066
+ 'indexPrice': this.safeString(ticker, 'index'),
1065
1067
  });
1066
1068
  }
1067
1069
  handleOrderBookSnapshot(client, message) {
@@ -131,6 +131,8 @@ class phemex extends phemex$1 {
131
131
  'average': average,
132
132
  'baseVolume': baseVolume,
133
133
  'quoteVolume': quoteVolume,
134
+ 'markPrice': this.parseNumber(this.fromEp(this.safeString(ticker, 'markPrice'), market)),
135
+ 'indexPrice': this.parseNumber(this.fromEp(this.safeString(ticker, 'indexPrice'), market)),
134
136
  'info': ticker,
135
137
  };
136
138
  return result;
@@ -20,6 +20,7 @@ class woo extends woo$1 {
20
20
  'watchOrders': true,
21
21
  'watchTicker': true,
22
22
  'watchTickers': true,
23
+ 'watchBidsAsks': true,
23
24
  'watchTrades': true,
24
25
  'watchTradesForSymbols': false,
25
26
  'watchPositions': true,
@@ -401,6 +402,77 @@ class woo extends woo$1 {
401
402
  }
402
403
  client.resolve(result, topic);
403
404
  }
405
+ async watchBidsAsks(symbols = undefined, params = {}) {
406
+ /**
407
+ * @method
408
+ * @name woo#watchBidsAsks
409
+ * @see https://docs.woox.io/#bbos
410
+ * @description watches best bid & ask for symbols
411
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
412
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
413
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
414
+ */
415
+ await this.loadMarkets();
416
+ symbols = this.marketSymbols(symbols, undefined, false);
417
+ const name = 'bbos';
418
+ const topic = name;
419
+ const request = {
420
+ 'event': 'subscribe',
421
+ 'topic': topic,
422
+ };
423
+ const message = this.extend(request, params);
424
+ const tickers = await this.watchPublic(topic, message);
425
+ if (this.newUpdates) {
426
+ return tickers;
427
+ }
428
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
429
+ }
430
+ handleBidAsk(client, message) {
431
+ //
432
+ // {
433
+ // "topic": "bbos",
434
+ // "ts": 1618822376000,
435
+ // "data": [
436
+ // {
437
+ // "symbol": "SPOT_FIL_USDT",
438
+ // "ask": 159.0318,
439
+ // "askSize": 370.43,
440
+ // "bid": 158.9158,
441
+ // "bidSize": 16
442
+ // }
443
+ // ]
444
+ // }
445
+ //
446
+ const topic = this.safeString(message, 'topic');
447
+ const data = this.safeList(message, 'data', []);
448
+ const timestamp = this.safeInteger(message, 'ts');
449
+ const result = {};
450
+ for (let i = 0; i < data.length; i++) {
451
+ const ticker = this.safeDict(data, i);
452
+ ticker['ts'] = timestamp;
453
+ const parsedTicker = this.parseWsBidAsk(ticker);
454
+ const symbol = parsedTicker['symbol'];
455
+ this.bidsasks[symbol] = parsedTicker;
456
+ result[symbol] = parsedTicker;
457
+ }
458
+ client.resolve(result, topic);
459
+ }
460
+ parseWsBidAsk(ticker, market = undefined) {
461
+ const marketId = this.safeString(ticker, 'symbol');
462
+ market = this.safeMarket(marketId, market);
463
+ const symbol = this.safeString(market, 'symbol');
464
+ const timestamp = this.safeInteger(ticker, 'ts');
465
+ return this.safeTicker({
466
+ 'symbol': symbol,
467
+ 'timestamp': timestamp,
468
+ 'datetime': this.iso8601(timestamp),
469
+ 'ask': this.safeString(ticker, 'ask'),
470
+ 'askVolume': this.safeString(ticker, 'askSize'),
471
+ 'bid': this.safeString(ticker, 'bid'),
472
+ 'bidVolume': this.safeString(ticker, 'bidSize'),
473
+ 'info': ticker,
474
+ }, market);
475
+ }
404
476
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
405
477
  /**
406
478
  * @method
@@ -1181,6 +1253,7 @@ class woo extends woo$1 {
1181
1253
  'trade': this.handleTrade,
1182
1254
  'balance': this.handleBalance,
1183
1255
  'position': this.handlePositions,
1256
+ 'bbos': this.handleBidAsk,
1184
1257
  };
1185
1258
  const event = this.safeString(message, 'event');
1186
1259
  let method = this.safeValue(methods, event);
@@ -145,6 +145,8 @@ python path/to/example.py # substitute for actual filename here
145
145
 
146
146
  [How to make your own trading bot](https://codeburst.io/how-to-make-your-own-trading-bot-83b5c6e35036) – A tutorial on algortrading in Python.
147
147
 
148
+ [Comprehensive Cryptocurrency Trading Utility with ccxt: Real-time and Historical Data Analysis](https://medium.com/@deepml1818/comprehensive-cryptocurrency-trading-utility-with-ccxt-real-time-and-historical-data-analysis-6b9cbba57375) – A tutorial on technical analysis with CCXT.
149
+
148
150
  [Writing crypto trading bot in Python with Telegram and ccxt](https://medium.com/@maxAvdyushkin/writing-crypto-trading-bot-in-python-with-telegram-and-ccxt-80632a00c637) – A tutorial on programming a Telegram bot in Python with CCXT
149
151
 
150
152
  [Data science is eating the world — Here’s how you can start exploring it](https://medium.com/covee-network/data-science-is-eating-the-world-heres-how-you-can-start-exploring-it-37501414af15) – An article on collecting and analyzing financial big data.
@@ -197,6 +199,8 @@ python path/to/example.py # substitute for actual filename here
197
199
 
198
200
  [CryptoCurrency eXchange Trading library - CCXT](https://barbotine.medium.com/crypto-currency-exchange-trading-library-ccxt-34ed66ebede8) – An overview of CCXT.
199
201
 
202
+ [Simplifying Trading Automation with CCXT](https://j4nt4ncrypto.medium.com/simplifying-trading-automation-with-ccxt-creating-orders-and-fetching-positions-on-kucoin-futures-d42c329577de) – Creating Orders and Fetching Positions on Kucoin Futures.
203
+
200
204
  [https://python.plainenglish.io/cryptocurrency-trading-with-python-5f655d06a4bd](Cryptocurrency Trading with Python) – How to trade cryptocurrencies with CCXT in Python.
201
205
 
202
206
  [비트코인 해외 거래소 API - 바이낸스 CCXT설치](https://www.youtube.com/watch?v=7dMGbjwZwlU) – Using CCXT to trade with Binance API, a video overview of CCXT in Korean.
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import type { Int, int, Str, Strings, Num, Bool, IndexType, OrderSide, OrderType, MarketType, SubType, Dict, NullableDict, List, NullableList, Fee, OHLCV, OHLCVC, implicitReturnType, Market, Currency, Dictionary, MinMax, FeeInterface, TradingFeeInterface, MarketInterface, Trade, Order, OrderBook, Ticker, Transaction, Tickers, CurrencyInterface, Balance, BalanceAccount, Account, PartialBalances, Balances, DepositAddress, WithdrawalResponse, DepositAddressResponse, FundingRate, FundingRates, Position, BorrowInterest, LeverageTier, LedgerEntry, DepositWithdrawFeeNetwork, DepositWithdrawFee, TransferEntry, CrossBorrowRate, IsolatedBorrowRate, FundingRateHistory, OpenInterest, Liquidation, OrderRequest, CancellationRequest, FundingHistory, MarketMarginModes, MarginMode, Greeks, Conversion, Option, LastPrice, Leverage, MarginModification, Leverages, LastPrices, Currencies, TradingFees, MarginModes, OptionChain, IsolatedBorrowRates, CrossBorrowRates, LeverageTiers } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
7
- declare const version = "4.4.11";
7
+ declare const version = "4.4.12";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, AuthenticationError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, OperationRejected, NoChange, MarginModeAlreadySet, MarketClosed, ManualInteractionNeeded, InsufficientFunds, InvalidAddress, AddressPending, InvalidOrder, OrderNotFound, OrderNotCached, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, ContractUnavailable, NotSupported, InvalidProxySettings, ExchangeClosedByUser, OperationFailed, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, ChecksumError, RequestTimeout, BadResponse, NullResponse, CancelPending, UnsubscribeError } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.4.12';
41
+ const version = '4.4.13';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -555,6 +555,7 @@ export default class Exchange {
555
555
  fetchTicker: boolean;
556
556
  fetchTickerWs: any;
557
557
  fetchTickers: any;
558
+ fetchMarkPrices: any;
558
559
  fetchTickersWs: any;
559
560
  fetchTime: any;
560
561
  fetchTrades: boolean;
@@ -967,6 +968,7 @@ export default class Exchange {
967
968
  fetchTickerWs(symbol: string, params?: {}): Promise<Ticker>;
968
969
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
969
970
  fetchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
971
+ fetchMarkPrices(symbols?: Strings, params?: {}): Promise<Tickers>;
970
972
  fetchTickersWs(symbols?: Strings, params?: {}): Promise<Tickers>;
971
973
  fetchOrderBooks(symbols?: Strings, limit?: Int, params?: {}): Promise<Dictionary<OrderBook>>;
972
974
  watchBidsAsks(symbols?: Strings, params?: {}): Promise<Tickers>;
@@ -1443,6 +1443,7 @@ export default class Exchange {
1443
1443
  'fetchTicker': true,
1444
1444
  'fetchTickerWs': undefined,
1445
1445
  'fetchTickers': undefined,
1446
+ 'fetchMarkPrices': undefined,
1446
1447
  'fetchTickersWs': undefined,
1447
1448
  'fetchTime': undefined,
1448
1449
  'fetchTrades': true,
@@ -3197,6 +3198,8 @@ export default class Exchange {
3197
3198
  'baseVolume': this.parseNumber(baseVolume),
3198
3199
  'quoteVolume': this.parseNumber(quoteVolume),
3199
3200
  'previousClose': this.safeNumber(ticker, 'previousClose'),
3201
+ 'indexPrice': this.safeNumber(ticker, 'indexPrice'),
3202
+ 'markPrice': this.safeNumber(ticker, 'markPrice'),
3200
3203
  });
3201
3204
  }
3202
3205
  async fetchBorrowRate(code, amount, params = {}) {
@@ -4421,6 +4424,9 @@ export default class Exchange {
4421
4424
  async fetchTickers(symbols = undefined, params = {}) {
4422
4425
  throw new NotSupported(this.id + ' fetchTickers() is not supported yet');
4423
4426
  }
4427
+ async fetchMarkPrices(symbols = undefined, params = {}) {
4428
+ throw new NotSupported(this.id + ' fetchMarkPrices() is not supported yet');
4429
+ }
4424
4430
  async fetchTickersWs(symbols = undefined, params = {}) {
4425
4431
  throw new NotSupported(this.id + ' fetchTickers() is not supported yet');
4426
4432
  }
@@ -144,22 +144,24 @@ export interface Ticker {
144
144
  info: any;
145
145
  timestamp: Int;
146
146
  datetime: Str;
147
- high: Int;
148
- low: Int;
149
- bid: Int;
150
- bidVolume: Int;
151
- ask: Int;
152
- askVolume: Int;
153
- vwap: Int;
154
- open: Int;
155
- close: Int;
156
- last: Int;
157
- previousClose: Int;
158
- change: Int;
159
- percentage: Int;
160
- average: Int;
161
- quoteVolume: Int;
162
- baseVolume: Int;
147
+ high: Num;
148
+ low: Num;
149
+ bid: Num;
150
+ bidVolume: Num;
151
+ ask: Num;
152
+ askVolume: Num;
153
+ vwap: Num;
154
+ open: Num;
155
+ close: Num;
156
+ last: Num;
157
+ previousClose: Num;
158
+ change: Num;
159
+ percentage: Num;
160
+ average: Num;
161
+ quoteVolume: Num;
162
+ baseVolume: Num;
163
+ indexPrice: Num;
164
+ markPrice: Num;
163
165
  }
164
166
  export interface Transaction {
165
167
  info: any;
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
  // [
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
  }
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
  }
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
  }
@@ -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
@@ -4382,7 +4382,7 @@ export default class htx extends Exchange {
4382
4382
  await this.loadAccounts();
4383
4383
  for (let i = 0; i < this.accounts.length; i++) {
4384
4384
  const account = this.accounts[i];
4385
- if (account['type'] === 'spot') {
4385
+ if (this.safeString(account, 'type') === 'spot') {
4386
4386
  accountId = this.safeString(account, 'id');
4387
4387
  if (accountId !== undefined) {
4388
4388
  break;
@@ -5074,7 +5074,7 @@ export default class htx extends Exchange {
5074
5074
  }
5075
5075
  else {
5076
5076
  amount = this.safeString2(order, 'volume', 'amount');
5077
- 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
5078
5078
  }
5079
5079
  const filled = this.safeStringN(order, ['filled-amount', 'field-amount', 'trade_volume']); // typo in their API, filled amount
5080
5080
  const price = this.safeString2(order, 'price', 'order_price');
@@ -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
  }