ccxt 4.0.94 → 4.0.96

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.0.94';
183
+ const version = '4.0.96';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -61,6 +61,8 @@ class bitmart extends bitmart$1 {
61
61
  'fetchMarkets': true,
62
62
  'fetchMyTrades': true,
63
63
  'fetchOHLCV': true,
64
+ 'fetchOpenInterest': true,
65
+ 'fetchOpenInterestHistory': false,
64
66
  'fetchOpenOrders': true,
65
67
  'fetchOrder': true,
66
68
  'fetchOrderBook': true,
@@ -3147,6 +3149,61 @@ class bitmart extends bitmart$1 {
3147
3149
  'info': info,
3148
3150
  };
3149
3151
  }
3152
+ async fetchOpenInterest(symbol, params = {}) {
3153
+ /**
3154
+ * @method
3155
+ * @name bitmart#fetchOpenInterest
3156
+ * @description Retrieves the open interest of a currency
3157
+ * @see https://developer-pro.bitmart.com/en/futures/#get-futures-openinterest
3158
+ * @param {string} symbol Unified CCXT market symbol
3159
+ * @param {object} [params] exchange specific parameters
3160
+ * @returns {object} an open interest structure{@link https://github.com/ccxt/ccxt/wiki/Manual#interest-history-structure}
3161
+ */
3162
+ await this.loadMarkets();
3163
+ const market = this.market(symbol);
3164
+ if (!market['contract']) {
3165
+ throw new errors.BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
3166
+ }
3167
+ const request = {
3168
+ 'symbol': market['id'],
3169
+ };
3170
+ const response = await this.publicGetContractPublicOpenInterest(this.extend(request, params));
3171
+ //
3172
+ // {
3173
+ // "code": 1000,
3174
+ // "message": "Ok",
3175
+ // "data": {
3176
+ // "timestamp": 1694657502415,
3177
+ // "symbol": "BTCUSDT",
3178
+ // "open_interest": "265231.721368593081729069",
3179
+ // "open_interest_value": "7006353.83988919"
3180
+ // },
3181
+ // "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.72.16946575108274991"
3182
+ // }
3183
+ //
3184
+ const data = this.safeValue(response, 'data', {});
3185
+ return this.parseOpenInterest(data, market);
3186
+ }
3187
+ parseOpenInterest(interest, market = undefined) {
3188
+ //
3189
+ // {
3190
+ // "timestamp": 1694657502415,
3191
+ // "symbol": "BTCUSDT",
3192
+ // "open_interest": "265231.721368593081729069",
3193
+ // "open_interest_value": "7006353.83988919"
3194
+ // }
3195
+ //
3196
+ const timestamp = this.safeInteger(interest, 'timestamp');
3197
+ const id = this.safeString(interest, 'symbol');
3198
+ return {
3199
+ 'symbol': this.safeSymbol(id, market),
3200
+ 'openInterestAmount': this.safeNumber(interest, 'open_interest'),
3201
+ 'openInterestValue': this.safeNumber(interest, 'open_interest_value'),
3202
+ 'timestamp': timestamp,
3203
+ 'datetime': this.iso8601(timestamp),
3204
+ 'info': interest,
3205
+ };
3206
+ }
3150
3207
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
3151
3208
  /**
3152
3209
  * @ignore
@@ -758,14 +758,24 @@ class bitso extends bitso$1 {
758
758
  const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
759
759
  const marketId = this.safeString(trade, 'book');
760
760
  const symbol = this.safeSymbol(marketId, market, '_');
761
- const side = this.safeString2(trade, 'side', 'maker_side');
761
+ let side = this.safeString(trade, 'side');
762
762
  const makerSide = this.safeString(trade, 'maker_side');
763
763
  let takerOrMaker = undefined;
764
- if (side === makerSide) {
765
- takerOrMaker = 'maker';
764
+ if (side !== undefined) {
765
+ if (side === makerSide) {
766
+ takerOrMaker = 'maker';
767
+ }
768
+ else {
769
+ takerOrMaker = 'taker';
770
+ }
766
771
  }
767
772
  else {
768
- takerOrMaker = 'taker';
773
+ if (makerSide === 'buy') {
774
+ side = 'sell';
775
+ }
776
+ else {
777
+ side = 'buy';
778
+ }
769
779
  }
770
780
  let amount = this.safeString2(trade, 'amount', 'major');
771
781
  if (amount !== undefined) {
@@ -363,6 +363,21 @@ class btctradeua extends btctradeua$1 {
363
363
  return timestamp - 10800000;
364
364
  }
365
365
  parseTrade(trade, market = undefined) {
366
+ //
367
+ // fetchTrades
368
+ //
369
+ // {
370
+ // "amnt_base": "2220.1204701750",
371
+ // "order_id": 247644861,
372
+ // "unixtime": 1694340398,
373
+ // "price": "1019739.3229211044",
374
+ // "amnt_trade": "0.0021771451",
375
+ // "user": "Vasily1989",
376
+ // "type": "sell",
377
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
378
+ // "id": 7498807
379
+ // }
380
+ //
366
381
  const timestamp = this.parseExchangeSpecificDatetime(this.safeString(trade, 'pub_date'));
367
382
  const id = this.safeString(trade, 'id');
368
383
  const type = 'limit';
@@ -403,6 +418,21 @@ class btctradeua extends btctradeua$1 {
403
418
  'symbol': market['id'],
404
419
  };
405
420
  const response = await this.publicGetDealsSymbol(this.extend(request, params));
421
+ //
422
+ // [
423
+ // {
424
+ // "amnt_base": "2220.1204701750",
425
+ // "order_id": 247644861,
426
+ // "unixtime": 1694340398,
427
+ // "price": "1019739.3229211044",
428
+ // "amnt_trade": "0.0021771451",
429
+ // "user": "Vasily1989",
430
+ // "type": "sell",
431
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
432
+ // "id": 7498807
433
+ // },
434
+ // ]
435
+ //
406
436
  // they report each trade twice (once for both of the two sides of the fill)
407
437
  // deduplicate trades for that reason
408
438
  const trades = [];
@@ -1366,7 +1366,7 @@ class digifinex extends digifinex$1 {
1366
1366
  request['symbol'] = market['id'];
1367
1367
  }
1368
1368
  if (limit !== undefined) {
1369
- request['limit'] = limit;
1369
+ request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
1370
1370
  }
1371
1371
  const response = await this[method](this.extend(request, params));
1372
1372
  //
@@ -1107,7 +1107,7 @@ class hitbtc extends hitbtc$1 {
1107
1107
  request['symbols'] = market['id'];
1108
1108
  }
1109
1109
  if (limit !== undefined) {
1110
- request['limit'] = limit;
1110
+ request['limit'] = Math.min(limit, 1000);
1111
1111
  }
1112
1112
  if (since !== undefined) {
1113
1113
  request['from'] = since;
@@ -795,10 +795,10 @@ class latoken extends latoken$1 {
795
795
  'currency': market['baseId'],
796
796
  'quote': market['quoteId'],
797
797
  // 'from': since.toString (), // milliseconds
798
- // 'limit': limit, // default 100, max 1000
798
+ // 'limit': limit, // default 100, limit 100
799
799
  };
800
800
  if (limit !== undefined) {
801
- request['limit'] = limit; // default 100, max 1000
801
+ request['limit'] = Math.min(limit, 100); // default 100, limit 100
802
802
  }
803
803
  const response = await this.publicGetTradeHistoryCurrencyQuote(this.extend(request, params));
804
804
  //
@@ -773,7 +773,7 @@ class probit extends probit$1 {
773
773
  request['start_time'] = this.iso8601(since);
774
774
  }
775
775
  if (limit !== undefined) {
776
- request['limit'] = limit;
776
+ request['limit'] = Math.min(limit, 10000);
777
777
  }
778
778
  const response = await this.publicGetTrade(this.extend(request, params));
779
779
  //
@@ -444,7 +444,7 @@ class wazirx extends wazirx$1 {
444
444
  'symbol': market['id'],
445
445
  };
446
446
  if (limit !== undefined) {
447
- request['limit'] = limit; // Default 500; max 1000.
447
+ request['limit'] = Math.min(limit, 1000); // Default 500; max 1000.
448
448
  }
449
449
  const method = this.safeString(this.options, 'fetchTradesMethod', 'publicGetTrades');
450
450
  const response = await this[method](this.extend(request, params));
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 } 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 } from './src/base/errors.js';
7
- declare const version = "4.0.93";
7
+ declare const version = "4.0.95";
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 } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.0.94';
41
+ const version = '4.0.96';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -208,6 +208,22 @@ export default class bitmart extends Exchange {
208
208
  datetime: string;
209
209
  info: any;
210
210
  };
211
+ fetchOpenInterest(symbol: string, params?: {}): Promise<{
212
+ symbol: any;
213
+ openInterestAmount: number;
214
+ openInterestValue: number;
215
+ timestamp: number;
216
+ datetime: string;
217
+ info: any;
218
+ }>;
219
+ parseOpenInterest(interest: any, market?: any): {
220
+ symbol: any;
221
+ openInterestAmount: number;
222
+ openInterestValue: number;
223
+ timestamp: number;
224
+ datetime: string;
225
+ info: any;
226
+ };
211
227
  handleMarginModeAndParams(methodName: any, params?: {}, defaultValue?: any): any[];
212
228
  nonce(): number;
213
229
  sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
package/js/src/bitmart.js CHANGED
@@ -64,6 +64,8 @@ export default class bitmart extends Exchange {
64
64
  'fetchMarkets': true,
65
65
  'fetchMyTrades': true,
66
66
  'fetchOHLCV': true,
67
+ 'fetchOpenInterest': true,
68
+ 'fetchOpenInterestHistory': false,
67
69
  'fetchOpenOrders': true,
68
70
  'fetchOrder': true,
69
71
  'fetchOrderBook': true,
@@ -3150,6 +3152,61 @@ export default class bitmart extends Exchange {
3150
3152
  'info': info,
3151
3153
  };
3152
3154
  }
3155
+ async fetchOpenInterest(symbol, params = {}) {
3156
+ /**
3157
+ * @method
3158
+ * @name bitmart#fetchOpenInterest
3159
+ * @description Retrieves the open interest of a currency
3160
+ * @see https://developer-pro.bitmart.com/en/futures/#get-futures-openinterest
3161
+ * @param {string} symbol Unified CCXT market symbol
3162
+ * @param {object} [params] exchange specific parameters
3163
+ * @returns {object} an open interest structure{@link https://github.com/ccxt/ccxt/wiki/Manual#interest-history-structure}
3164
+ */
3165
+ await this.loadMarkets();
3166
+ const market = this.market(symbol);
3167
+ if (!market['contract']) {
3168
+ throw new BadRequest(this.id + ' fetchOpenInterest() supports contract markets only');
3169
+ }
3170
+ const request = {
3171
+ 'symbol': market['id'],
3172
+ };
3173
+ const response = await this.publicGetContractPublicOpenInterest(this.extend(request, params));
3174
+ //
3175
+ // {
3176
+ // "code": 1000,
3177
+ // "message": "Ok",
3178
+ // "data": {
3179
+ // "timestamp": 1694657502415,
3180
+ // "symbol": "BTCUSDT",
3181
+ // "open_interest": "265231.721368593081729069",
3182
+ // "open_interest_value": "7006353.83988919"
3183
+ // },
3184
+ // "trace": "7f9c94e10f9d4513bc08a7bfc2a5559a.72.16946575108274991"
3185
+ // }
3186
+ //
3187
+ const data = this.safeValue(response, 'data', {});
3188
+ return this.parseOpenInterest(data, market);
3189
+ }
3190
+ parseOpenInterest(interest, market = undefined) {
3191
+ //
3192
+ // {
3193
+ // "timestamp": 1694657502415,
3194
+ // "symbol": "BTCUSDT",
3195
+ // "open_interest": "265231.721368593081729069",
3196
+ // "open_interest_value": "7006353.83988919"
3197
+ // }
3198
+ //
3199
+ const timestamp = this.safeInteger(interest, 'timestamp');
3200
+ const id = this.safeString(interest, 'symbol');
3201
+ return {
3202
+ 'symbol': this.safeSymbol(id, market),
3203
+ 'openInterestAmount': this.safeNumber(interest, 'open_interest'),
3204
+ 'openInterestValue': this.safeNumber(interest, 'open_interest_value'),
3205
+ 'timestamp': timestamp,
3206
+ 'datetime': this.iso8601(timestamp),
3207
+ 'info': interest,
3208
+ };
3209
+ }
3153
3210
  handleMarginModeAndParams(methodName, params = {}, defaultValue = undefined) {
3154
3211
  /**
3155
3212
  * @ignore
package/js/src/bitso.js CHANGED
@@ -761,14 +761,24 @@ export default class bitso extends Exchange {
761
761
  const timestamp = this.parse8601(this.safeString(trade, 'created_at'));
762
762
  const marketId = this.safeString(trade, 'book');
763
763
  const symbol = this.safeSymbol(marketId, market, '_');
764
- const side = this.safeString2(trade, 'side', 'maker_side');
764
+ let side = this.safeString(trade, 'side');
765
765
  const makerSide = this.safeString(trade, 'maker_side');
766
766
  let takerOrMaker = undefined;
767
- if (side === makerSide) {
768
- takerOrMaker = 'maker';
767
+ if (side !== undefined) {
768
+ if (side === makerSide) {
769
+ takerOrMaker = 'maker';
770
+ }
771
+ else {
772
+ takerOrMaker = 'taker';
773
+ }
769
774
  }
770
775
  else {
771
- takerOrMaker = 'taker';
776
+ if (makerSide === 'buy') {
777
+ side = 'sell';
778
+ }
779
+ else {
780
+ side = 'buy';
781
+ }
772
782
  }
773
783
  let amount = this.safeString2(trade, 'amount', 'major');
774
784
  if (amount !== undefined) {
@@ -366,6 +366,21 @@ export default class btctradeua extends Exchange {
366
366
  return timestamp - 10800000;
367
367
  }
368
368
  parseTrade(trade, market = undefined) {
369
+ //
370
+ // fetchTrades
371
+ //
372
+ // {
373
+ // "amnt_base": "2220.1204701750",
374
+ // "order_id": 247644861,
375
+ // "unixtime": 1694340398,
376
+ // "price": "1019739.3229211044",
377
+ // "amnt_trade": "0.0021771451",
378
+ // "user": "Vasily1989",
379
+ // "type": "sell",
380
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
381
+ // "id": 7498807
382
+ // }
383
+ //
369
384
  const timestamp = this.parseExchangeSpecificDatetime(this.safeString(trade, 'pub_date'));
370
385
  const id = this.safeString(trade, 'id');
371
386
  const type = 'limit';
@@ -406,6 +421,21 @@ export default class btctradeua extends Exchange {
406
421
  'symbol': market['id'],
407
422
  };
408
423
  const response = await this.publicGetDealsSymbol(this.extend(request, params));
424
+ //
425
+ // [
426
+ // {
427
+ // "amnt_base": "2220.1204701750",
428
+ // "order_id": 247644861,
429
+ // "unixtime": 1694340398,
430
+ // "price": "1019739.3229211044",
431
+ // "amnt_trade": "0.0021771451",
432
+ // "user": "Vasily1989",
433
+ // "type": "sell",
434
+ // "pub_date": "Sept. 10, 2023, 1:06 p.m.",
435
+ // "id": 7498807
436
+ // },
437
+ // ]
438
+ //
409
439
  // they report each trade twice (once for both of the two sides of the fill)
410
440
  // deduplicate trades for that reason
411
441
  const trades = [];
@@ -1369,7 +1369,7 @@ export default class digifinex extends Exchange {
1369
1369
  request['symbol'] = market['id'];
1370
1370
  }
1371
1371
  if (limit !== undefined) {
1372
- request['limit'] = limit;
1372
+ request['limit'] = market['swap'] ? Math.min(limit, 100) : limit;
1373
1373
  }
1374
1374
  const response = await this[method](this.extend(request, params));
1375
1375
  //
package/js/src/hitbtc.js CHANGED
@@ -1110,7 +1110,7 @@ export default class hitbtc extends Exchange {
1110
1110
  request['symbols'] = market['id'];
1111
1111
  }
1112
1112
  if (limit !== undefined) {
1113
- request['limit'] = limit;
1113
+ request['limit'] = Math.min(limit, 1000);
1114
1114
  }
1115
1115
  if (since !== undefined) {
1116
1116
  request['from'] = since;
package/js/src/latoken.js CHANGED
@@ -798,10 +798,10 @@ export default class latoken extends Exchange {
798
798
  'currency': market['baseId'],
799
799
  'quote': market['quoteId'],
800
800
  // 'from': since.toString (), // milliseconds
801
- // 'limit': limit, // default 100, max 1000
801
+ // 'limit': limit, // default 100, limit 100
802
802
  };
803
803
  if (limit !== undefined) {
804
- request['limit'] = limit; // default 100, max 1000
804
+ request['limit'] = Math.min(limit, 100); // default 100, limit 100
805
805
  }
806
806
  const response = await this.publicGetTradeHistoryCurrencyQuote(this.extend(request, params));
807
807
  //
package/js/src/probit.js CHANGED
@@ -776,7 +776,7 @@ export default class probit extends Exchange {
776
776
  request['start_time'] = this.iso8601(since);
777
777
  }
778
778
  if (limit !== undefined) {
779
- request['limit'] = limit;
779
+ request['limit'] = Math.min(limit, 10000);
780
780
  }
781
781
  const response = await this.publicGetTrade(this.extend(request, params));
782
782
  //
package/js/src/wazirx.js CHANGED
@@ -447,7 +447,7 @@ export default class wazirx extends Exchange {
447
447
  'symbol': market['id'],
448
448
  };
449
449
  if (limit !== undefined) {
450
- request['limit'] = limit; // Default 500; max 1000.
450
+ request['limit'] = Math.min(limit, 1000); // Default 500; max 1000.
451
451
  }
452
452
  const method = this.safeString(this.options, 'fetchTradesMethod', 'publicGetTrades');
453
453
  const response = await this[method](this.extend(request, params));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.94",
3
+ "version": "4.0.96",
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",