ccxt 4.4.7 → 4.4.8

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.
@@ -23,6 +23,7 @@ class bitmart extends bitmart$1 {
23
23
  'watchBalance': true,
24
24
  'watchTicker': true,
25
25
  'watchTickers': true,
26
+ 'watchBidsAsks': true,
26
27
  'watchOrderBook': true,
27
28
  'watchOrderBookForSymbols': true,
28
29
  'watchOrders': true,
@@ -334,6 +335,7 @@ class bitmart extends bitmart$1 {
334
335
  /**
335
336
  * @method
336
337
  * @name bitmart#watchTickers
338
+ * @see https://developer-pro.bitmart.com/en/spot/#public-ticker-channel
337
339
  * @see https://developer-pro.bitmart.com/en/futuresv2/#public-ticker-channel
338
340
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
339
341
  * @param {string[]} symbols unified symbol of the market to fetch the ticker for
@@ -352,6 +354,84 @@ class bitmart extends bitmart$1 {
352
354
  }
353
355
  return this.filterByArray(this.tickers, 'symbol', symbols);
354
356
  }
357
+ async watchBidsAsks(symbols = undefined, params = {}) {
358
+ /**
359
+ * @method
360
+ * @name bitmart#watchBidsAsks
361
+ * @see https://developer-pro.bitmart.com/en/spot/#public-ticker-channel
362
+ * @see https://developer-pro.bitmart.com/en/futuresv2/#public-ticker-channel
363
+ * @description watches best bid & ask for symbols
364
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
365
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
366
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
367
+ */
368
+ await this.loadMarkets();
369
+ symbols = this.marketSymbols(symbols, undefined, false);
370
+ const firstMarket = this.getMarketFromSymbols(symbols);
371
+ let marketType = undefined;
372
+ [marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', firstMarket, params);
373
+ const url = this.implodeHostname(this.urls['api']['ws'][marketType]['public']);
374
+ const channelType = (marketType === 'spot') ? 'spot' : 'futures';
375
+ const actionType = (marketType === 'spot') ? 'op' : 'action';
376
+ let rawSubscriptions = [];
377
+ const messageHashes = [];
378
+ for (let i = 0; i < symbols.length; i++) {
379
+ const market = this.market(symbols[i]);
380
+ rawSubscriptions.push(channelType + '/ticker:' + market['id']);
381
+ messageHashes.push('bidask:' + symbols[i]);
382
+ }
383
+ if (marketType !== 'spot') {
384
+ rawSubscriptions = [channelType + '/ticker'];
385
+ }
386
+ const request = {
387
+ 'args': rawSubscriptions,
388
+ };
389
+ request[actionType] = 'subscribe';
390
+ const newTickers = await this.watchMultiple(url, messageHashes, request, rawSubscriptions);
391
+ if (this.newUpdates) {
392
+ const tickers = {};
393
+ tickers[newTickers['symbol']] = newTickers;
394
+ return tickers;
395
+ }
396
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
397
+ }
398
+ handleBidAsk(client, message) {
399
+ const table = this.safeString(message, 'table');
400
+ const isSpot = (table !== undefined);
401
+ let rawTickers = [];
402
+ if (isSpot) {
403
+ rawTickers = this.safeList(message, 'data', []);
404
+ }
405
+ else {
406
+ rawTickers = [this.safeValue(message, 'data', {})];
407
+ }
408
+ if (!rawTickers.length) {
409
+ return;
410
+ }
411
+ for (let i = 0; i < rawTickers.length; i++) {
412
+ const ticker = this.parseWsBidAsk(rawTickers[i]);
413
+ const symbol = ticker['symbol'];
414
+ this.bidsasks[symbol] = ticker;
415
+ const messageHash = 'bidask:' + symbol;
416
+ client.resolve(ticker, messageHash);
417
+ }
418
+ }
419
+ parseWsBidAsk(ticker, market = undefined) {
420
+ const marketId = this.safeString(ticker, 'symbol');
421
+ market = this.safeMarket(marketId, market);
422
+ const symbol = this.safeString(market, 'symbol');
423
+ const timestamp = this.safeInteger(ticker, 'ms_t');
424
+ return this.safeTicker({
425
+ 'symbol': symbol,
426
+ 'timestamp': timestamp,
427
+ 'datetime': this.iso8601(timestamp),
428
+ 'ask': this.safeString2(ticker, 'ask_px', 'ask_price'),
429
+ 'askVolume': this.safeString2(ticker, 'ask_sz', 'ask_vol'),
430
+ 'bid': this.safeString2(ticker, 'bid_px', 'bid_price'),
431
+ 'bidVolume': this.safeString2(ticker, 'bid_sz', 'bid_vol'),
432
+ 'info': ticker,
433
+ }, market);
434
+ }
355
435
  async watchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
356
436
  /**
357
437
  * @method
@@ -931,6 +1011,7 @@ class bitmart extends bitmart$1 {
931
1011
  // }
932
1012
  // }
933
1013
  //
1014
+ this.handleBidAsk(client, message);
934
1015
  const table = this.safeString(message, 'table');
935
1016
  const isSpot = (table !== undefined);
936
1017
  let rawTickers = [];
@@ -17,6 +17,8 @@ class bitvavo extends bitvavo$1 {
17
17
  'watchOrderBook': true,
18
18
  'watchTrades': true,
19
19
  'watchTicker': true,
20
+ 'watchTickers': true,
21
+ 'watchBidsAsks': true,
20
22
  'watchOHLCV': true,
21
23
  'watchOrders': true,
22
24
  'watchMyTrades': true,
@@ -77,17 +79,56 @@ class bitvavo extends bitvavo$1 {
77
79
  const message = this.extend(request, params);
78
80
  return await this.watch(url, messageHash, message, messageHash);
79
81
  }
82
+ async watchPublicMultiple(methodName, channelName, symbols, params = {}) {
83
+ await this.loadMarkets();
84
+ symbols = this.marketSymbols(symbols);
85
+ const messageHashes = [methodName];
86
+ const args = [];
87
+ for (let i = 0; i < symbols.length; i++) {
88
+ const market = this.market(symbols[i]);
89
+ args.push(market['id']);
90
+ }
91
+ const url = this.urls['api']['ws'];
92
+ const request = {
93
+ 'action': 'subscribe',
94
+ 'channels': [
95
+ {
96
+ 'name': channelName,
97
+ 'markets': args,
98
+ },
99
+ ],
100
+ };
101
+ const message = this.extend(request, params);
102
+ return await this.watchMultiple(url, messageHashes, message, messageHashes);
103
+ }
80
104
  async watchTicker(symbol, params = {}) {
81
105
  /**
82
106
  * @method
83
107
  * @name bitvavo#watchTicker
84
108
  * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
109
+ * @see https://docs.bitvavo.com/#tag/Market-data-subscription-WebSocket/paths/~1subscribeTicker24h/post
85
110
  * @param {string} symbol unified symbol of the market to fetch the ticker for
86
111
  * @param {object} [params] extra parameters specific to the exchange API endpoint
87
112
  * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
88
113
  */
89
114
  return await this.watchPublic('ticker24h', symbol, params);
90
115
  }
116
+ async watchTickers(symbols = undefined, params = {}) {
117
+ /**
118
+ * @method
119
+ * @name bitvavo#watchTickers
120
+ * @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
121
+ * @see https://docs.bitvavo.com/#tag/Market-data-subscription-WebSocket/paths/~1subscribeTicker24h/post
122
+ * @param {string[]} [symbols] unified symbol of the market to fetch the ticker for
123
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
124
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
125
+ */
126
+ await this.loadMarkets();
127
+ symbols = this.marketSymbols(symbols, undefined, false);
128
+ const channel = 'ticker24h';
129
+ const tickers = await this.watchPublicMultiple(channel, channel, symbols, params);
130
+ return this.filterByArray(tickers, 'symbol', symbols);
131
+ }
91
132
  handleTicker(client, message) {
92
133
  //
93
134
  // {
@@ -110,8 +151,10 @@ class bitvavo extends bitvavo$1 {
110
151
  // ]
111
152
  // }
112
153
  //
154
+ this.handleBidAsk(client, message);
113
155
  const event = this.safeString(message, 'event');
114
156
  const tickers = this.safeValue(message, 'data', []);
157
+ const result = [];
115
158
  for (let i = 0; i < tickers.length; i++) {
116
159
  const data = tickers[i];
117
160
  const marketId = this.safeString(data, 'market');
@@ -120,9 +163,57 @@ class bitvavo extends bitvavo$1 {
120
163
  const ticker = this.parseTicker(data, market);
121
164
  const symbol = ticker['symbol'];
122
165
  this.tickers[symbol] = ticker;
166
+ result.push(ticker);
123
167
  client.resolve(ticker, messageHash);
124
168
  }
125
- return message;
169
+ client.resolve(result, event);
170
+ }
171
+ async watchBidsAsks(symbols = undefined, params = {}) {
172
+ /**
173
+ * @method
174
+ * @name mexc#watchBidsAsks
175
+ * @description watches best bid & ask for symbols
176
+ * @see https://docs.bitvavo.com/#tag/Market-data-subscription-WebSocket/paths/~1subscribeTicker24h/post
177
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
178
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
179
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
180
+ */
181
+ await this.loadMarkets();
182
+ symbols = this.marketSymbols(symbols, undefined, false);
183
+ const channel = 'ticker24h';
184
+ const tickers = await this.watchPublicMultiple('bidask', channel, symbols, params);
185
+ return this.filterByArray(tickers, 'symbol', symbols);
186
+ }
187
+ handleBidAsk(client, message) {
188
+ const event = 'bidask';
189
+ const tickers = this.safeValue(message, 'data', []);
190
+ const result = [];
191
+ for (let i = 0; i < tickers.length; i++) {
192
+ const data = tickers[i];
193
+ const ticker = this.parseWsBidAsk(data);
194
+ const symbol = ticker['symbol'];
195
+ this.bidsasks[symbol] = ticker;
196
+ result.push(ticker);
197
+ const messageHash = event + ':' + symbol;
198
+ client.resolve(ticker, messageHash);
199
+ }
200
+ client.resolve(result, event);
201
+ }
202
+ parseWsBidAsk(ticker, market = undefined) {
203
+ const marketId = this.safeString(ticker, 'market');
204
+ market = this.safeMarket(marketId, undefined, '-');
205
+ const symbol = this.safeString(market, 'symbol');
206
+ const timestamp = this.safeInteger(ticker, 'timestamp');
207
+ return this.safeTicker({
208
+ 'symbol': symbol,
209
+ 'timestamp': timestamp,
210
+ 'datetime': this.iso8601(timestamp),
211
+ 'ask': this.safeNumber(ticker, 'ask'),
212
+ 'askVolume': this.safeNumber(ticker, 'askSize'),
213
+ 'bid': this.safeNumber(ticker, 'bid'),
214
+ 'bidVolume': this.safeNumber(ticker, 'bidSize'),
215
+ 'info': ticker,
216
+ }, market);
126
217
  }
127
218
  async watchTrades(symbol, since = undefined, limit = undefined, params = {}) {
128
219
  /**
@@ -18,6 +18,7 @@ class blofin extends blofin$1 {
18
18
  'watchOrderBookForSymbols': true,
19
19
  'watchTicker': true,
20
20
  'watchTickers': true,
21
+ 'watchBidsAsks': true,
21
22
  'watchOHLCV': true,
22
23
  'watchOHLCVForSymbols': true,
23
24
  'watchOrders': true,
@@ -270,6 +271,7 @@ class blofin extends blofin$1 {
270
271
  // ],
271
272
  // }
272
273
  //
274
+ this.handleBidAsk(client, message);
273
275
  const arg = this.safeDict(message, 'arg');
274
276
  const channelName = this.safeString(arg, 'channel');
275
277
  const data = this.safeList(message, 'data');
@@ -284,6 +286,68 @@ class blofin extends blofin$1 {
284
286
  parseWsTicker(ticker, market = undefined) {
285
287
  return this.parseTicker(ticker, market);
286
288
  }
289
+ async watchBidsAsks(symbols = undefined, params = {}) {
290
+ /**
291
+ * @method
292
+ * @name blofin#watchBidsAsks
293
+ * @description watches best bid & ask for symbols
294
+ * @see https://docs.blofin.com/index.html#ws-tickers-channel
295
+ * @param {string[]} symbols unified symbol of the market to fetch the ticker for
296
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
297
+ * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
298
+ */
299
+ await this.loadMarkets();
300
+ symbols = this.marketSymbols(symbols, undefined, false);
301
+ const firstMarket = this.market(symbols[0]);
302
+ const channel = 'tickers';
303
+ let marketType = undefined;
304
+ [marketType, params] = this.handleMarketTypeAndParams('watchBidsAsks', firstMarket, params);
305
+ const url = this.implodeHostname(this.urls['api']['ws'][marketType]['public']);
306
+ const messageHashes = [];
307
+ const args = [];
308
+ for (let i = 0; i < symbols.length; i++) {
309
+ const market = this.market(symbols[i]);
310
+ messageHashes.push('bidask:' + market['symbol']);
311
+ args.push({
312
+ 'channel': channel,
313
+ 'instId': market['id'],
314
+ });
315
+ }
316
+ const request = this.getSubscriptionRequest(args);
317
+ const ticker = await this.watchMultiple(url, messageHashes, this.deepExtend(request, params), messageHashes);
318
+ if (this.newUpdates) {
319
+ const tickers = {};
320
+ tickers[ticker['symbol']] = ticker;
321
+ return tickers;
322
+ }
323
+ return this.filterByArray(this.bidsasks, 'symbol', symbols);
324
+ }
325
+ handleBidAsk(client, message) {
326
+ const data = this.safeList(message, 'data');
327
+ for (let i = 0; i < data.length; i++) {
328
+ const ticker = this.parseWsBidAsk(data[i]);
329
+ const symbol = ticker['symbol'];
330
+ const messageHash = 'bidask:' + symbol;
331
+ this.bidsasks[symbol] = ticker;
332
+ client.resolve(ticker, messageHash);
333
+ }
334
+ }
335
+ parseWsBidAsk(ticker, market = undefined) {
336
+ const marketId = this.safeString(ticker, 'instId');
337
+ market = this.safeMarket(marketId, market, '-');
338
+ const symbol = this.safeString(market, 'symbol');
339
+ const timestamp = this.safeInteger(ticker, 'ts');
340
+ return this.safeTicker({
341
+ 'symbol': symbol,
342
+ 'timestamp': timestamp,
343
+ 'datetime': this.iso8601(timestamp),
344
+ 'ask': this.safeString(ticker, 'askPrice'),
345
+ 'askVolume': this.safeString(ticker, 'askSize'),
346
+ 'bid': this.safeString(ticker, 'bidPrice'),
347
+ 'bidVolume': this.safeString(ticker, 'bidSize'),
348
+ 'info': ticker,
349
+ }, market);
350
+ }
287
351
  async watchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
288
352
  /**
289
353
  * @method
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.6";
7
+ declare const version = "4.4.7";
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.7';
41
+ const version = '4.4.8';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -701,6 +701,7 @@ interface Exchange {
701
701
  papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
702
702
  papiPostListenKey(params?: {}): Promise<implicitReturnType>;
703
703
  papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
704
+ papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
704
705
  papiPutListenKey(params?: {}): Promise<implicitReturnType>;
705
706
  papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
706
707
  papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
@@ -701,6 +701,7 @@ interface binance {
701
701
  papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
702
702
  papiPostListenKey(params?: {}): Promise<implicitReturnType>;
703
703
  papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
704
+ papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
704
705
  papiPutListenKey(params?: {}): Promise<implicitReturnType>;
705
706
  papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
706
707
  papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
@@ -753,6 +753,7 @@ interface binance {
753
753
  papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
754
754
  papiPostListenKey(params?: {}): Promise<implicitReturnType>;
755
755
  papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
756
+ papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
756
757
  papiPutListenKey(params?: {}): Promise<implicitReturnType>;
757
758
  papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
758
759
  papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
@@ -701,6 +701,7 @@ interface binance {
701
701
  papiPostRepayFuturesNegativeBalance(params?: {}): Promise<implicitReturnType>;
702
702
  papiPostListenKey(params?: {}): Promise<implicitReturnType>;
703
703
  papiPostAssetCollection(params?: {}): Promise<implicitReturnType>;
704
+ papiPostMarginRepayDebt(params?: {}): Promise<implicitReturnType>;
704
705
  papiPutListenKey(params?: {}): Promise<implicitReturnType>;
705
706
  papiDeleteUmOrder(params?: {}): Promise<implicitReturnType>;
706
707
  papiDeleteUmConditionalOrder(params?: {}): Promise<implicitReturnType>;
@@ -131,6 +131,9 @@ interface Exchange {
131
131
  privateGetV5AccountContractTransactionLog(params?: {}): Promise<implicitReturnType>;
132
132
  privateGetV5AccountSmpGroup(params?: {}): Promise<implicitReturnType>;
133
133
  privateGetV5AccountMmpState(params?: {}): Promise<implicitReturnType>;
134
+ privateGetV5AssetExchangeQueryCoinList(params?: {}): Promise<implicitReturnType>;
135
+ privateGetV5AssetExchangeConvertResultQuery(params?: {}): Promise<implicitReturnType>;
136
+ privateGetV5AssetExchangeQueryConvertHistory(params?: {}): Promise<implicitReturnType>;
134
137
  privateGetV5AssetExchangeOrderRecord(params?: {}): Promise<implicitReturnType>;
135
138
  privateGetV5AssetDeliveryRecord(params?: {}): Promise<implicitReturnType>;
136
139
  privateGetV5AssetSettlementRecord(params?: {}): Promise<implicitReturnType>;
@@ -269,6 +272,8 @@ interface Exchange {
269
272
  privatePostV5AccountSetHedgingMode(params?: {}): Promise<implicitReturnType>;
270
273
  privatePostV5AccountMmpModify(params?: {}): Promise<implicitReturnType>;
271
274
  privatePostV5AccountMmpReset(params?: {}): Promise<implicitReturnType>;
275
+ privatePostV5AssetExchangeQuoteApply(params?: {}): Promise<implicitReturnType>;
276
+ privatePostV5AssetExchangeConvertExecute(params?: {}): Promise<implicitReturnType>;
272
277
  privatePostV5AssetTransferInterTransfer(params?: {}): Promise<implicitReturnType>;
273
278
  privatePostV5AssetTransferSaveTransferSubMember(params?: {}): Promise<implicitReturnType>;
274
279
  privatePostV5AssetTransferUniversalTransfer(params?: {}): Promise<implicitReturnType>;
@@ -78,6 +78,7 @@ interface Exchange {
78
78
  publicGetCopytradingPublicPreferenceCurrency(params?: {}): Promise<implicitReturnType>;
79
79
  publicGetCopytradingPublicCurrentSubpositions(params?: {}): Promise<implicitReturnType>;
80
80
  publicGetCopytradingPublicSubpositionsHistory(params?: {}): Promise<implicitReturnType>;
81
+ publicGetSupportAnnouncementsTypes(params?: {}): Promise<implicitReturnType>;
81
82
  privateGetRfqCounterparties(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetRfqMakerInstrumentSettings(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetRfqMmpConfig(params?: {}): Promise<implicitReturnType>;
@@ -207,6 +208,7 @@ interface Exchange {
207
208
  privateGetBrokerFdIfRebate(params?: {}): Promise<implicitReturnType>;
208
209
  privateGetAffiliateInviteeDetail(params?: {}): Promise<implicitReturnType>;
209
210
  privateGetUsersPartnerIfRebate(params?: {}): Promise<implicitReturnType>;
211
+ privateGetSupportAnnouncements(params?: {}): Promise<implicitReturnType>;
210
212
  privatePostRfqCreateRfq(params?: {}): Promise<implicitReturnType>;
211
213
  privatePostRfqCancelRfq(params?: {}): Promise<implicitReturnType>;
212
214
  privatePostRfqCancelBatchRfqs(params?: {}): Promise<implicitReturnType>;
@@ -303,46 +303,46 @@ export default class binance extends Exchange {
303
303
  repayCrossMargin(code: string, amount: any, params?: {}): Promise<{
304
304
  id: number;
305
305
  currency: string;
306
- amount: any;
306
+ amount: number;
307
307
  symbol: any;
308
- timestamp: any;
309
- datetime: any;
308
+ timestamp: number;
309
+ datetime: string;
310
310
  info: any;
311
311
  }>;
312
312
  repayIsolatedMargin(symbol: string, code: string, amount: any, params?: {}): Promise<{
313
313
  id: number;
314
314
  currency: string;
315
- amount: any;
315
+ amount: number;
316
316
  symbol: any;
317
- timestamp: any;
318
- datetime: any;
317
+ timestamp: number;
318
+ datetime: string;
319
319
  info: any;
320
320
  }>;
321
321
  borrowCrossMargin(code: string, amount: number, params?: {}): Promise<{
322
322
  id: number;
323
323
  currency: string;
324
- amount: any;
324
+ amount: number;
325
325
  symbol: any;
326
- timestamp: any;
327
- datetime: any;
326
+ timestamp: number;
327
+ datetime: string;
328
328
  info: any;
329
329
  }>;
330
330
  borrowIsolatedMargin(symbol: string, code: string, amount: number, params?: {}): Promise<{
331
331
  id: number;
332
332
  currency: string;
333
- amount: any;
333
+ amount: number;
334
334
  symbol: any;
335
- timestamp: any;
336
- datetime: any;
335
+ timestamp: number;
336
+ datetime: string;
337
337
  info: any;
338
338
  }>;
339
339
  parseMarginLoan(info: any, currency?: Currency): {
340
340
  id: number;
341
341
  currency: string;
342
- amount: any;
342
+ amount: number;
343
343
  symbol: any;
344
- timestamp: any;
345
- datetime: any;
344
+ timestamp: number;
345
+ datetime: string;
346
346
  info: any;
347
347
  };
348
348
  fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
package/js/src/binance.js CHANGED
@@ -1094,6 +1094,7 @@ export default class binance extends Exchange {
1094
1094
  'repay-futures-negative-balance': 150,
1095
1095
  'listenKey': 1,
1096
1096
  'asset-collection': 3,
1097
+ 'margin/repay-debt': 0.4, // Weight(Order): 0.4 => (1000 / (50 * 0.4)) * 60 = 3000
1097
1098
  },
1098
1099
  'put': {
1099
1100
  'listenKey': 1, // 1
@@ -1211,6 +1212,7 @@ export default class binance extends Exchange {
1211
1212
  ],
1212
1213
  'fetchCurrencies': true,
1213
1214
  // 'fetchTradesMethod': 'publicGetAggTrades', // publicGetTrades, publicGetHistoricalTrades, eapiPublicGetTrades
1215
+ // 'repayCrossMarginMethod': 'papiPostRepayLoan', // papiPostMarginRepayDebt
1214
1216
  'defaultTimeInForce': 'GTC',
1215
1217
  'defaultType': 'spot',
1216
1218
  'defaultSubType': undefined,
@@ -2907,7 +2909,7 @@ export default class binance extends Exchange {
2907
2909
  const res = this.safeValue(results, i);
2908
2910
  if (fetchMargins && Array.isArray(res)) {
2909
2911
  const keysList = Object.keys(this.indexBy(res, 'symbol'));
2910
- const length = (Object.keys(this.options['crossMarginPairsData'])).length;
2912
+ const length = this.options['crossMarginPairsData'].length;
2911
2913
  // first one is the cross-margin promise
2912
2914
  if (length === 0) {
2913
2915
  this.options['crossMarginPairsData'] = keysList;
@@ -12220,10 +12222,13 @@ export default class binance extends Exchange {
12220
12222
  * @description repay borrowed margin and interest
12221
12223
  * @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay
12222
12224
  * @see https://developers.binance.com/docs/margin_trading/borrow-and-repay/Margin-Account-Borrow-Repay
12225
+ * @see https://developers.binance.com/docs/derivatives/portfolio-margin/trade/Margin-Account-Repay-Debt
12223
12226
  * @param {string} code unified currency code of the currency to repay
12224
12227
  * @param {float} amount the amount to repay
12225
12228
  * @param {object} [params] extra parameters specific to the exchange API endpoint
12226
12229
  * @param {boolean} [params.portfolioMargin] set to true if you would like to repay margin in a portfolio margin account
12230
+ * @param {string} [params.repayCrossMarginMethod] *portfolio margin only* 'papiPostRepayLoan' (default), 'papiPostMarginRepayDebt' (alternative)
12231
+ * @param {string} [params.specifyRepayAssets] *portfolio margin papiPostMarginRepayDebt only* specific asset list to repay debt
12227
12232
  * @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/#/?id=margin-loan-structure}
12228
12233
  */
12229
12234
  await this.loadMarkets();
@@ -12236,19 +12241,41 @@ export default class binance extends Exchange {
12236
12241
  let isPortfolioMargin = undefined;
12237
12242
  [isPortfolioMargin, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'papi', 'portfolioMargin', false);
12238
12243
  if (isPortfolioMargin) {
12239
- response = await this.papiPostRepayLoan(this.extend(request, params));
12244
+ let method = undefined;
12245
+ [method, params] = this.handleOptionAndParams2(params, 'repayCrossMargin', 'repayCrossMarginMethod', 'method');
12246
+ if (method === 'papiPostMarginRepayDebt') {
12247
+ response = await this.papiPostMarginRepayDebt(this.extend(request, params));
12248
+ //
12249
+ // {
12250
+ // "asset": "USDC",
12251
+ // "amount": 10,
12252
+ // "specifyRepayAssets": null,
12253
+ // "updateTime": 1727170761267,
12254
+ // "success": true
12255
+ // }
12256
+ //
12257
+ }
12258
+ else {
12259
+ response = await this.papiPostRepayLoan(this.extend(request, params));
12260
+ //
12261
+ // {
12262
+ // "tranId": 108988250265,
12263
+ // "clientTag":""
12264
+ // }
12265
+ //
12266
+ }
12240
12267
  }
12241
12268
  else {
12242
12269
  request['isIsolated'] = 'FALSE';
12243
12270
  request['type'] = 'REPAY';
12244
12271
  response = await this.sapiPostMarginBorrowRepay(this.extend(request, params));
12272
+ //
12273
+ // {
12274
+ // "tranId": 108988250265,
12275
+ // "clientTag":""
12276
+ // }
12277
+ //
12245
12278
  }
12246
- //
12247
- // {
12248
- // "tranId": 108988250265,
12249
- // "clientTag":""
12250
- // }
12251
- //
12252
12279
  return this.parseMarginLoan(response, currency);
12253
12280
  }
12254
12281
  async repayIsolatedMargin(symbol, code, amount, params = {}) {
@@ -12358,13 +12385,25 @@ export default class binance extends Exchange {
12358
12385
  // "clientTag":""
12359
12386
  // }
12360
12387
  //
12388
+ // repayCrossMargin alternative endpoint
12389
+ //
12390
+ // {
12391
+ // "asset": "USDC",
12392
+ // "amount": 10,
12393
+ // "specifyRepayAssets": null,
12394
+ // "updateTime": 1727170761267,
12395
+ // "success": true
12396
+ // }
12397
+ //
12398
+ const currencyId = this.safeString(info, 'asset');
12399
+ const timestamp = this.safeInteger(info, 'updateTime');
12361
12400
  return {
12362
12401
  'id': this.safeInteger(info, 'tranId'),
12363
- 'currency': this.safeCurrencyCode(undefined, currency),
12364
- 'amount': undefined,
12402
+ 'currency': this.safeCurrencyCode(currencyId, currency),
12403
+ 'amount': this.safeNumber(info, 'amount'),
12365
12404
  'symbol': undefined,
12366
- 'timestamp': undefined,
12367
- 'datetime': undefined,
12405
+ 'timestamp': timestamp,
12406
+ 'datetime': this.iso8601(timestamp),
12368
12407
  'info': info,
12369
12408
  };
12370
12409
  }
package/js/src/bybit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bybit.js';
2
- import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest, Position, CrossBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, Order, OHLCV, FundingRateHistory, OpenInterest, OrderRequest, Balances, Str, Transaction, Ticker, OrderBook, Tickers, Greeks, Strings, Market, Currency, MarketInterface, TransferEntry, Liquidation, Leverage, Num, FundingHistory, Option, OptionChain, TradingFeeInterface, Currencies, TradingFees, CancellationRequest, Position, CrossBorrowRate, Dict, LeverageTier, LeverageTiers, int, LedgerEntry, Conversion } from './base/types.js';
3
3
  /**
4
4
  * @class bybit
5
5
  * @augments Exchange
@@ -204,6 +204,12 @@ export default class bybit extends Exchange {
204
204
  fetchOptionChain(code: string, params?: {}): Promise<OptionChain>;
205
205
  parseOption(chain: Dict, currency?: Currency, market?: Market): Option;
206
206
  fetchPositionsHistory(symbols?: Strings, since?: Int, limit?: Int, params?: {}): Promise<Position[]>;
207
+ fetchConvertCurrencies(params?: {}): Promise<Currencies>;
208
+ fetchConvertQuote(fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
209
+ createConvertTrade(id: string, fromCode: string, toCode: string, amount?: Num, params?: {}): Promise<Conversion>;
210
+ fetchConvertTrade(id: string, code?: Str, params?: {}): Promise<Conversion>;
211
+ fetchConvertTradeHistory(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Conversion[]>;
212
+ parseConversion(conversion: Dict, fromCurrency?: Currency, toCurrency?: Currency): Conversion;
207
213
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
208
214
  url: string;
209
215
  method: string;