ccxt 4.1.22 → 4.1.23

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.
package/dist/cjs/ccxt.js CHANGED
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.1.22';
183
+ const version = '4.1.23';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -220,6 +220,7 @@ class ascendex extends ascendex$1 {
220
220
  'futures/position': 1,
221
221
  'futures/free-margin': 1,
222
222
  'futures/order/hist/current': 1,
223
+ 'futures/funding-payments': 1,
223
224
  'futures/order/open': 1,
224
225
  'futures/order/status': 1,
225
226
  },
@@ -180,14 +180,22 @@ class IndexedOrderBookSide extends Array {
180
180
  // in case price is not sent
181
181
  delta[0] = Math.abs(index_price);
182
182
  if (index_price === old_price) {
183
- const index = bisectLeft(this.index, index_price);
183
+ // find index by price and advance till the id is found
184
+ let index = bisectLeft(this.index, index_price);
185
+ while (this[index][2] !== id) {
186
+ index++;
187
+ }
184
188
  this.index[index] = index_price;
185
189
  this[index] = delta;
186
190
  return;
187
191
  }
188
192
  else {
189
193
  // remove old price from index
190
- const old_index = bisectLeft(this.index, old_price);
194
+ // find index by price and advance till the id is found
195
+ let old_index = bisectLeft(this.index, old_price);
196
+ while (this[old_index][2] !== id) {
197
+ old_index++;
198
+ }
191
199
  this.index.copyWithin(old_index, old_index + 1, this.index.length);
192
200
  this.index[this.length - 1] = Number.MAX_VALUE;
193
201
  this.copyWithin(old_index, old_index + 1, this.length);
@@ -196,7 +204,12 @@ class IndexedOrderBookSide extends Array {
196
204
  }
197
205
  // insert new price level
198
206
  this.hashmap.set(id, index_price);
199
- const index = bisectLeft(this.index, index_price);
207
+ // find index by price to insert
208
+ let index = bisectLeft(this.index, index_price);
209
+ // if several with the same price order by id
210
+ while (index < this.length && this.index[index] === index_price && this[index][2] < id) {
211
+ index++;
212
+ }
200
213
  // insert new price level into index
201
214
  this.length++;
202
215
  this.index.copyWithin(index + 1, index, this.index.length);
@@ -213,7 +226,10 @@ class IndexedOrderBookSide extends Array {
213
226
  }
214
227
  else if (this.hashmap.has(id)) {
215
228
  const old_price = this.hashmap.get(id);
216
- const index = bisectLeft(this.index, old_price);
229
+ let index = bisectLeft(this.index, old_price);
230
+ while (this[index][2] !== id) {
231
+ index++;
232
+ }
217
233
  this.index.copyWithin(index, index + 1, this.index.length);
218
234
  this.index[this.length - 1] = Number.MAX_VALUE;
219
235
  this.copyWithin(index, index + 1, this.length);
@@ -3285,8 +3285,10 @@ class bybit extends bybit$1 {
3285
3285
  request['accountType'] = unifiedType;
3286
3286
  response = await this.privateGetV5AssetTransferQueryAccountCoinsBalance(this.extend(request, params));
3287
3287
  }
3288
- request['accountType'] = unifiedType;
3289
- response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
3288
+ else {
3289
+ request['accountType'] = unifiedType;
3290
+ response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
3291
+ }
3290
3292
  //
3291
3293
  // cross
3292
3294
  // {
@@ -574,7 +574,6 @@ class bitfinex2 extends bitfinex2$1 {
574
574
  const messageHash = channel + ':' + marketId;
575
575
  const prec = this.safeString(subscription, 'prec', 'P0');
576
576
  const isRaw = (prec === 'R0');
577
- const id = this.safeString(message, 0);
578
577
  // if it is an initial snapshot
579
578
  let orderbook = this.safeValue(this.orderbooks, symbol);
580
579
  if (orderbook === undefined) {
@@ -613,6 +612,7 @@ class bitfinex2 extends bitfinex2$1 {
613
612
  bookside.store(price, size, counter);
614
613
  }
615
614
  }
615
+ orderbook['symbol'] = symbol;
616
616
  client.resolve(orderbook, messageHash);
617
617
  }
618
618
  else {
@@ -625,7 +625,8 @@ class bitfinex2 extends bitfinex2$1 {
625
625
  const bookside = orderbookItem[side];
626
626
  // price = 0 means that you have to remove the order from your book
627
627
  const amount = Precise["default"].stringGt(price, '0') ? size : '0';
628
- bookside.store(this.parseNumber(price), this.parseNumber(amount), id);
628
+ const idString = this.safeString(deltas, 0);
629
+ bookside.store(this.parseNumber(price), this.parseNumber(amount), idString);
629
630
  }
630
631
  else {
631
632
  const amount = this.safeString(deltas, 2);
@@ -655,16 +656,19 @@ class bitfinex2 extends bitfinex2$1 {
655
656
  const stringArray = [];
656
657
  const bids = book['bids'];
657
658
  const asks = book['asks'];
659
+ const prec = this.safeString(subscription, 'prec', 'P0');
660
+ const isRaw = (prec === 'R0');
661
+ const idToCheck = isRaw ? 2 : 0;
658
662
  // pepperoni pizza from bitfinex
659
663
  for (let i = 0; i < depth; i++) {
660
664
  const bid = this.safeValue(bids, i);
661
665
  const ask = this.safeValue(asks, i);
662
666
  if (bid !== undefined) {
663
- stringArray.push(this.numberToString(bids[i][0]));
667
+ stringArray.push(this.numberToString(bids[i][idToCheck]));
664
668
  stringArray.push(this.numberToString(bids[i][1]));
665
669
  }
666
670
  if (ask !== undefined) {
667
- stringArray.push(this.numberToString(asks[i][0]));
671
+ stringArray.push(this.numberToString(asks[i][idToCheck]));
668
672
  stringArray.push(this.numberToString(-asks[i][1]));
669
673
  }
670
674
  }
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.21";
7
+ declare const version = "4.1.22";
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, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.22';
41
+ const version = '4.1.23';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -58,6 +58,7 @@ interface Exchange {
58
58
  v2PrivateAccountGroupGetFuturesPosition(params?: {}): Promise<implicitReturnType>;
59
59
  v2PrivateAccountGroupGetFuturesFreeMargin(params?: {}): Promise<implicitReturnType>;
60
60
  v2PrivateAccountGroupGetFuturesOrderHistCurrent(params?: {}): Promise<implicitReturnType>;
61
+ v2PrivateAccountGroupGetFuturesFundingPayments(params?: {}): Promise<implicitReturnType>;
61
62
  v2PrivateAccountGroupGetFuturesOrderOpen(params?: {}): Promise<implicitReturnType>;
62
63
  v2PrivateAccountGroupGetFuturesOrderStatus(params?: {}): Promise<implicitReturnType>;
63
64
  v2PrivateAccountGroupPostFuturesIsolatedPositionMargin(params?: {}): Promise<implicitReturnType>;
@@ -223,6 +223,7 @@ export default class ascendex extends Exchange {
223
223
  'futures/position': 1,
224
224
  'futures/free-margin': 1,
225
225
  'futures/order/hist/current': 1,
226
+ 'futures/funding-payments': 1,
226
227
  'futures/order/open': 1,
227
228
  'futures/order/status': 1,
228
229
  },
@@ -182,14 +182,22 @@ class IndexedOrderBookSide extends Array {
182
182
  // in case price is not sent
183
183
  delta[0] = Math.abs(index_price);
184
184
  if (index_price === old_price) {
185
- const index = bisectLeft(this.index, index_price);
185
+ // find index by price and advance till the id is found
186
+ let index = bisectLeft(this.index, index_price);
187
+ while (this[index][2] !== id) {
188
+ index++;
189
+ }
186
190
  this.index[index] = index_price;
187
191
  this[index] = delta;
188
192
  return;
189
193
  }
190
194
  else {
191
195
  // remove old price from index
192
- const old_index = bisectLeft(this.index, old_price);
196
+ // find index by price and advance till the id is found
197
+ let old_index = bisectLeft(this.index, old_price);
198
+ while (this[old_index][2] !== id) {
199
+ old_index++;
200
+ }
193
201
  this.index.copyWithin(old_index, old_index + 1, this.index.length);
194
202
  this.index[this.length - 1] = Number.MAX_VALUE;
195
203
  this.copyWithin(old_index, old_index + 1, this.length);
@@ -198,7 +206,12 @@ class IndexedOrderBookSide extends Array {
198
206
  }
199
207
  // insert new price level
200
208
  this.hashmap.set(id, index_price);
201
- const index = bisectLeft(this.index, index_price);
209
+ // find index by price to insert
210
+ let index = bisectLeft(this.index, index_price);
211
+ // if several with the same price order by id
212
+ while (index < this.length && this.index[index] === index_price && this[index][2] < id) {
213
+ index++;
214
+ }
202
215
  // insert new price level into index
203
216
  this.length++;
204
217
  this.index.copyWithin(index + 1, index, this.index.length);
@@ -215,7 +228,10 @@ class IndexedOrderBookSide extends Array {
215
228
  }
216
229
  else if (this.hashmap.has(id)) {
217
230
  const old_price = this.hashmap.get(id);
218
- const index = bisectLeft(this.index, old_price);
231
+ let index = bisectLeft(this.index, old_price);
232
+ while (this[index][2] !== id) {
233
+ index++;
234
+ }
219
235
  this.index.copyWithin(index, index + 1, this.index.length);
220
236
  this.index[this.length - 1] = Number.MAX_VALUE;
221
237
  this.copyWithin(index, index + 1, this.length);
package/js/src/bybit.js CHANGED
@@ -3288,8 +3288,10 @@ export default class bybit extends Exchange {
3288
3288
  request['accountType'] = unifiedType;
3289
3289
  response = await this.privateGetV5AssetTransferQueryAccountCoinsBalance(this.extend(request, params));
3290
3290
  }
3291
- request['accountType'] = unifiedType;
3292
- response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
3291
+ else {
3292
+ request['accountType'] = unifiedType;
3293
+ response = await this.privateGetV5AccountWalletBalance(this.extend(request, params));
3294
+ }
3293
3295
  //
3294
3296
  // cross
3295
3297
  // {
@@ -577,7 +577,6 @@ export default class bitfinex2 extends bitfinex2Rest {
577
577
  const messageHash = channel + ':' + marketId;
578
578
  const prec = this.safeString(subscription, 'prec', 'P0');
579
579
  const isRaw = (prec === 'R0');
580
- const id = this.safeString(message, 0);
581
580
  // if it is an initial snapshot
582
581
  let orderbook = this.safeValue(this.orderbooks, symbol);
583
582
  if (orderbook === undefined) {
@@ -616,6 +615,7 @@ export default class bitfinex2 extends bitfinex2Rest {
616
615
  bookside.store(price, size, counter);
617
616
  }
618
617
  }
618
+ orderbook['symbol'] = symbol;
619
619
  client.resolve(orderbook, messageHash);
620
620
  }
621
621
  else {
@@ -628,7 +628,8 @@ export default class bitfinex2 extends bitfinex2Rest {
628
628
  const bookside = orderbookItem[side];
629
629
  // price = 0 means that you have to remove the order from your book
630
630
  const amount = Precise.stringGt(price, '0') ? size : '0';
631
- bookside.store(this.parseNumber(price), this.parseNumber(amount), id);
631
+ const idString = this.safeString(deltas, 0);
632
+ bookside.store(this.parseNumber(price), this.parseNumber(amount), idString);
632
633
  }
633
634
  else {
634
635
  const amount = this.safeString(deltas, 2);
@@ -658,16 +659,19 @@ export default class bitfinex2 extends bitfinex2Rest {
658
659
  const stringArray = [];
659
660
  const bids = book['bids'];
660
661
  const asks = book['asks'];
662
+ const prec = this.safeString(subscription, 'prec', 'P0');
663
+ const isRaw = (prec === 'R0');
664
+ const idToCheck = isRaw ? 2 : 0;
661
665
  // pepperoni pizza from bitfinex
662
666
  for (let i = 0; i < depth; i++) {
663
667
  const bid = this.safeValue(bids, i);
664
668
  const ask = this.safeValue(asks, i);
665
669
  if (bid !== undefined) {
666
- stringArray.push(this.numberToString(bids[i][0]));
670
+ stringArray.push(this.numberToString(bids[i][idToCheck]));
667
671
  stringArray.push(this.numberToString(bids[i][1]));
668
672
  }
669
673
  if (ask !== undefined) {
670
- stringArray.push(this.numberToString(asks[i][0]));
674
+ stringArray.push(this.numberToString(asks[i][idToCheck]));
671
675
  stringArray.push(this.numberToString(-asks[i][1]));
672
676
  }
673
677
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.1.22",
3
+ "version": "4.1.23",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",
package/skip-tests.json CHANGED
@@ -174,7 +174,7 @@
174
174
  }
175
175
  },
176
176
  "bitfinex2": {
177
- "skipWs": true,
177
+ "//skipWs": true,
178
178
  "skipMethods": {
179
179
  "loadMarkets": {
180
180
  "currencyIdAndCode": "broken currencies"
@@ -509,6 +509,7 @@
509
509
  }
510
510
  },
511
511
  "btcalpha": {
512
+ "skip": true,
512
513
  "skipMethods": {
513
514
  "fetchOrderBook": "bids[0][0] is not < asks[0][0]",
514
515
  "fetchL2OrderBook": "same",