ccxt 4.4.5 → 4.4.6

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.
@@ -30,6 +30,9 @@ class mexc extends mexc$1 {
30
30
  'future': false,
31
31
  'option': false,
32
32
  'addMargin': true,
33
+ 'borrowCrossMargin': false,
34
+ 'borrowIsolatedMargin': false,
35
+ 'borrowMargin': false,
33
36
  'cancelAllOrders': true,
34
37
  'cancelOrder': true,
35
38
  'cancelOrders': undefined,
@@ -43,12 +46,21 @@ class mexc extends mexc$1 {
43
46
  'createOrders': true,
44
47
  'createPostOnlyOrder': true,
45
48
  'createReduceOnlyOrder': true,
49
+ 'createStopLimitOrder': true,
50
+ 'createStopMarketOrder': true,
51
+ 'createStopOrder': true,
52
+ 'createTriggerOrder': true,
46
53
  'deposit': undefined,
47
54
  'editOrder': undefined,
48
55
  'fetchAccounts': true,
49
56
  'fetchBalance': true,
50
57
  'fetchBidsAsks': true,
51
- 'fetchBorrowRateHistory': undefined,
58
+ 'fetchBorrowInterest': false,
59
+ 'fetchBorrowRate': false,
60
+ 'fetchBorrowRateHistories': false,
61
+ 'fetchBorrowRateHistory': false,
62
+ 'fetchBorrowRates': false,
63
+ 'fetchBorrowRatesPerSymbol': false,
52
64
  'fetchCanceledOrders': true,
53
65
  'fetchClosedOrder': undefined,
54
66
  'fetchClosedOrders': true,
@@ -69,6 +81,7 @@ class mexc extends mexc$1 {
69
81
  'fetchIndexOHLCV': true,
70
82
  'fetchIsolatedBorrowRate': false,
71
83
  'fetchIsolatedBorrowRates': false,
84
+ 'fetchIsolatedPositions': false,
72
85
  'fetchL2OrderBook': true,
73
86
  'fetchLedger': undefined,
74
87
  'fetchLedgerEntry': undefined,
@@ -77,11 +90,13 @@ class mexc extends mexc$1 {
77
90
  'fetchLeverageTiers': true,
78
91
  'fetchMarginAdjustmentHistory': false,
79
92
  'fetchMarginMode': false,
80
- 'fetchMarketLeverageTiers': undefined,
93
+ 'fetchMarketLeverageTiers': 'emulated',
81
94
  'fetchMarkets': true,
82
95
  'fetchMarkOHLCV': true,
83
96
  'fetchMyTrades': true,
84
97
  'fetchOHLCV': true,
98
+ 'fetchOpenInterest': false,
99
+ 'fetchOpenInterestHistory': false,
85
100
  'fetchOpenOrder': undefined,
86
101
  'fetchOpenOrders': true,
87
102
  'fetchOrder': true,
@@ -399,6 +414,8 @@ class mexc extends mexc$1 {
399
414
  },
400
415
  },
401
416
  'options': {
417
+ 'adjustForTimeDifference': false,
418
+ 'timeDifference': 0,
402
419
  'createMarketBuyOrderRequiresPrice': true,
403
420
  'unavailableContracts': {
404
421
  'BTC/USDT:USDT': true,
@@ -453,6 +470,7 @@ class mexc extends mexc$1 {
453
470
  'AVAXC': 'AVAX_CCHAIN',
454
471
  'ERC20': 'ETH',
455
472
  'ACA': 'ACALA',
473
+ 'BEP20': 'BSC',
456
474
  // 'ADA': 'Cardano(ADA)',
457
475
  // 'AE': 'AE',
458
476
  // 'ALGO': 'Algorand(ALGO)',
@@ -1014,6 +1032,9 @@ class mexc extends mexc$1 {
1014
1032
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1015
1033
  * @returns {object[]} an array of objects representing market data
1016
1034
  */
1035
+ if (this.options['adjustForTimeDifference']) {
1036
+ await this.loadTimeDifference();
1037
+ }
1017
1038
  const spotMarketPromise = this.fetchSpotMarkets(params);
1018
1039
  const swapMarketPromise = this.fetchSwapMarkets(params);
1019
1040
  const [spotMarket, swapMarket] = await Promise.all([spotMarketPromise, swapMarketPromise]);
@@ -4542,7 +4563,7 @@ class mexc extends mexc$1 {
4542
4563
  // 'coin': currency['id'] + network example: USDT-TRX,
4543
4564
  // 'status': 'status',
4544
4565
  // 'startTime': since, // default 90 days
4545
- // 'endTime': this.milliseconds (),
4566
+ // 'endTime': this.nonce(),
4546
4567
  // 'limit': limit, // default 1000, maximum 1000
4547
4568
  };
4548
4569
  let currency = undefined;
@@ -4602,7 +4623,7 @@ class mexc extends mexc$1 {
4602
4623
  // 'coin': currency['id'],
4603
4624
  // 'status': 'status',
4604
4625
  // 'startTime': since, // default 90 days
4605
- // 'endTime': this.milliseconds (),
4626
+ // 'endTime': this.nonce(),
4606
4627
  // 'limit': limit, // default 1000, maximum 1000
4607
4628
  };
4608
4629
  let currency = undefined;
@@ -5628,6 +5649,9 @@ class mexc extends mexc$1 {
5628
5649
  const positions = this.parsePositions(data, symbols, params);
5629
5650
  return this.filterBySinceLimit(positions, since, limit);
5630
5651
  }
5652
+ nonce() {
5653
+ return this.milliseconds() - this.safeInteger(this.options, 'timeDifference', 0);
5654
+ }
5631
5655
  sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
5632
5656
  const section = this.safeString(api, 0);
5633
5657
  const access = this.safeString(api, 1);
@@ -5642,7 +5666,7 @@ class mexc extends mexc$1 {
5642
5666
  }
5643
5667
  let paramsEncoded = '';
5644
5668
  if (access === 'private') {
5645
- params['timestamp'] = this.milliseconds();
5669
+ params['timestamp'] = this.nonce();
5646
5670
  params['recvWindow'] = this.safeInteger(this.options, 'recvWindow', 5000);
5647
5671
  }
5648
5672
  if (Object.keys(params).length) {
@@ -5672,7 +5696,7 @@ class mexc extends mexc$1 {
5672
5696
  }
5673
5697
  else {
5674
5698
  this.checkRequiredCredentials();
5675
- const timestamp = this.milliseconds().toString();
5699
+ const timestamp = this.nonce().toString();
5676
5700
  let auth = '';
5677
5701
  headers = {
5678
5702
  'ApiKey': this.apiKey,
@@ -132,6 +132,8 @@ class htx extends htx$1 {
132
132
  * @method
133
133
  * @name huobi#watchTicker
134
134
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
135
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53561-7773-11ed-9966-0242ac110003
136
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c33ab2-77ae-11ed-9966-0242ac110003
135
137
  * @param {string} symbol unified symbol of the market to fetch the ticker for
136
138
  * @param {object} [params] extra parameters specific to the exchange API endpoint
137
139
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
@@ -200,6 +202,9 @@ class htx extends htx$1 {
200
202
  * @method
201
203
  * @name huobi#watchTrades
202
204
  * @description get the list of most recent trades for a particular symbol
205
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53b69-7773-11ed-9966-0242ac110003
206
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c33c21-77ae-11ed-9966-0242ac110003
207
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c33cfe-77ae-11ed-9966-0242ac110003
203
208
  * @param {string} symbol unified symbol of the market to fetch trades for
204
209
  * @param {int} [since] timestamp in ms of the earliest trade to fetch
205
210
  * @param {int} [limit] the maximum amount of trades to fetch
@@ -263,6 +268,9 @@ class htx extends htx$1 {
263
268
  * @method
264
269
  * @name huobi#watchOHLCV
265
270
  * @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
271
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53241-7773-11ed-9966-0242ac110003
272
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c3346a-77ae-11ed-9966-0242ac110003
273
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c33563-77ae-11ed-9966-0242ac110003
266
274
  * @param {string} symbol unified symbol of the market to fetch OHLCV data for
267
275
  * @param {string} timeframe the length of time each candle represents
268
276
  * @param {int} [since] timestamp in ms of the earliest candle to fetch
@@ -669,6 +677,7 @@ class htx extends htx$1 {
669
677
  * @method
670
678
  * @name huobi#watchMyTrades
671
679
  * @description watches information on multiple trades made by the user
680
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53dd5-7773-11ed-9966-0242ac110003
672
681
  * @param {string} symbol unified market symbol of the market trades were made in
673
682
  * @param {int} [since] the earliest time in ms to fetch trades for
674
683
  * @param {int} [limit] the maximum number of trade structures to retrieve
@@ -772,6 +781,7 @@ class htx extends htx$1 {
772
781
  * @method
773
782
  * @name huobi#watchOrders
774
783
  * @description watches information on multiple orders made by the user
784
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec53c8f-7773-11ed-9966-0242ac110003
775
785
  * @param {string} symbol unified market symbol of the market orders were made in
776
786
  * @param {int} [since] the earliest time in ms to fetch orders for
777
787
  * @param {int} [limit] the maximum number of order structures to retrieve
@@ -1346,6 +1356,10 @@ class htx extends htx$1 {
1346
1356
  * @method
1347
1357
  * @name huobi#watchBalance
1348
1358
  * @description watch balance and get the amount of funds available for trading or funds locked in orders
1359
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=7ec52e28-7773-11ed-9966-0242ac110003
1360
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=10000084-77b7-11ed-9966-0242ac110003
1361
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=8cb7dcca-77b5-11ed-9966-0242ac110003
1362
+ * @see https://www.htx.com/en-us/opend/newApiPages/?id=28c34995-77ae-11ed-9966-0242ac110003
1349
1363
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1350
1364
  * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1351
1365
  */
@@ -20,6 +20,7 @@ class kraken extends kraken$1 {
20
20
  'watchOrders': true,
21
21
  'watchTicker': true,
22
22
  'watchTickers': true,
23
+ 'watchBidsAsks': true,
23
24
  'watchTrades': true,
24
25
  'watchTradesForSymbols': true,
25
26
  'createOrderWs': true,
@@ -496,6 +497,64 @@ class kraken extends kraken$1 {
496
497
  }
497
498
  return this.filterByArray(this.tickers, 'symbol', symbols);
498
499
  }
500
+ async watchBidsAsks(symbols = undefined, params = {}) {
501
+ /**
502
+ * @method
503
+ * @name kraken#watchBidsAsks
504
+ * @see https://docs.kraken.com/api/docs/websocket-v1/spread
505
+ * @description watches best bid & ask for symbols
506
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
507
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
508
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
509
+ */
510
+ await this.loadMarkets();
511
+ symbols = this.marketSymbols(symbols, undefined, false);
512
+ const ticker = await this.watchMultiHelper('bidask', 'spread', symbols, undefined, params);
513
+ if (this.newUpdates) {
514
+ const result = {};
515
+ result[ticker['symbol']] = ticker;
516
+ return result;
517
+ }
518
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
519
+ }
520
+ handleBidAsk(client, message, subscription) {
521
+ //
522
+ // [
523
+ // 7208974, // channelID
524
+ // [
525
+ // "63758.60000", // bid
526
+ // "63759.10000", // ask
527
+ // "1726814731.089778", // timestamp
528
+ // "0.00057917", // bid_volume
529
+ // "0.15681688" // ask_volume
530
+ // ],
531
+ // "spread",
532
+ // "XBT/USDT"
533
+ // ]
534
+ //
535
+ const parsedTicker = this.parseWsBidAsk(message);
536
+ const symbol = parsedTicker['symbol'];
537
+ this.bidsasks[symbol] = parsedTicker;
538
+ const messageHash = this.getMessageHash('bidask', undefined, symbol);
539
+ client.resolve(parsedTicker, messageHash);
540
+ }
541
+ parseWsBidAsk(ticker, market = undefined) {
542
+ const data = this.safeList(ticker, 1, []);
543
+ const marketId = this.safeString(ticker, 3);
544
+ market = this.safeValue(this.options['marketsByWsName'], marketId);
545
+ const symbol = this.safeString(market, 'symbol');
546
+ const timestamp = this.parseToInt(this.safeInteger(data, 2)) * 1000;
547
+ return this.safeTicker({
548
+ 'symbol': symbol,
549
+ 'timestamp': timestamp,
550
+ 'datetime': this.iso8601(timestamp),
551
+ 'ask': this.safeString(data, 1),
552
+ 'askVolume': this.safeString(data, 4),
553
+ 'bid': this.safeString(data, 0),
554
+ 'bidVolume': this.safeString(data, 3),
555
+ 'info': ticker,
556
+ }, market);
557
+ }
499
558
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
500
559
  /**
501
560
  * @method
@@ -1490,6 +1549,7 @@ class kraken extends kraken$1 {
1490
1549
  'book': this.handleOrderBook,
1491
1550
  'ohlc': this.handleOHLCV,
1492
1551
  'ticker': this.handleTicker,
1552
+ 'spread': this.handleBidAsk,
1493
1553
  'trade': this.handleTrades,
1494
1554
  // private
1495
1555
  'openOrders': this.handleOrders,
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.4";
7
+ declare const version = "4.4.5";
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.5';
41
+ const version = '4.4.6';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -100,6 +100,10 @@ interface Exchange {
100
100
  privatePostContractPrivateSubmitPlanOrder(params?: {}): Promise<implicitReturnType>;
101
101
  privatePostContractPrivateCancelPlanOrder(params?: {}): Promise<implicitReturnType>;
102
102
  privatePostContractPrivateSubmitLeverage(params?: {}): Promise<implicitReturnType>;
103
+ privatePostContractPrivateSubmitTpSlOrder(params?: {}): Promise<implicitReturnType>;
104
+ privatePostContractPrivateModifyPlanOrder(params?: {}): Promise<implicitReturnType>;
105
+ privatePostContractPrivateModifyPresetPlanOrder(params?: {}): Promise<implicitReturnType>;
106
+ privatePostContractPrivateModifyTpSlOrder(params?: {}): Promise<implicitReturnType>;
103
107
  }
104
108
  declare abstract class Exchange extends _Exchange {
105
109
  }
@@ -1065,10 +1065,10 @@ export default class bitflyer extends Exchange {
1065
1065
  const feedback = this.id + ' ' + body;
1066
1066
  // i.e. {"status":-2,"error_message":"Under maintenance","data":null}
1067
1067
  const errorMessage = this.safeString(response, 'error_message');
1068
- const statusCode = this.safeNumber(response, 'status');
1068
+ const statusCode = this.safeInteger(response, 'status');
1069
1069
  if (errorMessage !== undefined) {
1070
1070
  this.throwExactlyMatchedException(this.exceptions['exact'], statusCode, feedback);
1071
- this.throwBroadlyMatchedException(this.exceptions['broad'], errorMessage, feedback);
1071
+ throw new ExchangeError(feedback);
1072
1072
  }
1073
1073
  return undefined;
1074
1074
  }
@@ -224,6 +224,7 @@ export default class bitget extends Exchange {
224
224
  parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
225
225
  fetchConvertCurrencies(params?: {}): Promise<Currencies>;
226
226
  handleErrors(code: int, reason: string, url: string, method: string, headers: Dict, body: string, response: any, requestHeaders: any, requestBody: any): any;
227
+ nonce(): number;
227
228
  sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
228
229
  url: string;
229
230
  method: string;
package/js/src/bitget.js CHANGED
@@ -1318,6 +1318,8 @@ export default class bitget extends Exchange {
1318
1318
  'TONCOIN': 'TON',
1319
1319
  },
1320
1320
  'options': {
1321
+ 'timeDifference': 0,
1322
+ 'adjustForTimeDifference': false,
1321
1323
  'timeframes': {
1322
1324
  'spot': {
1323
1325
  '1m': '1min',
@@ -1540,6 +1542,9 @@ export default class bitget extends Exchange {
1540
1542
  * @param {object} [params] extra parameters specific to the exchange API endpoint
1541
1543
  * @returns {object[]} an array of objects representing market data
1542
1544
  */
1545
+ if (this.options['adjustForTimeDifference']) {
1546
+ await this.loadTimeDifference();
1547
+ }
1543
1548
  const sandboxMode = this.safeBool(this.options, 'sandboxMode', false);
1544
1549
  let types = this.safeValue(this.options, 'fetchMarkets', ['spot', 'swap']);
1545
1550
  if (sandboxMode) {
@@ -8825,6 +8830,9 @@ export default class bitget extends Exchange {
8825
8830
  }
8826
8831
  return undefined;
8827
8832
  }
8833
+ nonce() {
8834
+ return this.milliseconds() - this.options['timeDifference'];
8835
+ }
8828
8836
  sign(path, api = [], method = 'GET', params = {}, headers = undefined, body = undefined) {
8829
8837
  const signed = api[0] === 'private';
8830
8838
  const endpoint = api[1];
@@ -8842,7 +8850,7 @@ export default class bitget extends Exchange {
8842
8850
  }
8843
8851
  if (signed) {
8844
8852
  this.checkRequiredCredentials();
8845
- const timestamp = this.milliseconds().toString();
8853
+ const timestamp = this.nonce().toString();
8846
8854
  let auth = timestamp + method + payload;
8847
8855
  if (method === 'POST') {
8848
8856
  body = this.json(params);