ccxt 4.2.24 → 4.2.25

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
@@ -174,7 +174,7 @@ var woo$1 = require('./src/pro/woo.js');
174
174
 
175
175
  //-----------------------------------------------------------------------------
176
176
  // this is updated by vss.js when building
177
- const version = '4.2.24';
177
+ const version = '4.2.25';
178
178
  Exchange["default"].ccxtVersion = version;
179
179
  const exchanges = {
180
180
  'ace': ace,
@@ -50,6 +50,7 @@ class bitfinex2 extends bitfinex2$1 {
50
50
  'fetchFundingRates': true,
51
51
  'fetchIndexOHLCV': false,
52
52
  'fetchLedger': true,
53
+ 'fetchLiquidations': true,
53
54
  'fetchMarginMode': false,
54
55
  'fetchMarkOHLCV': false,
55
56
  'fetchMyTrades': true,
@@ -3171,6 +3172,96 @@ class bitfinex2 extends bitfinex2$1 {
3171
3172
  'info': interest,
3172
3173
  }, market);
3173
3174
  }
3175
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
3176
+ /**
3177
+ * @method
3178
+ * @name bitfinex2#fetchLiquidations
3179
+ * @description retrieves the public liquidations of a trading pair
3180
+ * @see https://docs.bitfinex.com/reference/rest-public-liquidations
3181
+ * @param {string} symbol unified CCXT market symbol
3182
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3183
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3184
+ * @param {object} [params] exchange specific parameters
3185
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
3186
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3187
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
3188
+ */
3189
+ await this.loadMarkets();
3190
+ let paginate = false;
3191
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
3192
+ if (paginate) {
3193
+ return await this.fetchPaginatedCallDeterministic('fetchLiquidations', symbol, since, limit, '8h', params, 500);
3194
+ }
3195
+ const market = this.market(symbol);
3196
+ let request = {};
3197
+ if (since !== undefined) {
3198
+ request['start'] = since;
3199
+ }
3200
+ if (limit !== undefined) {
3201
+ request['limit'] = limit;
3202
+ }
3203
+ [request, params] = this.handleUntilOption('end', request, params);
3204
+ const response = await this.publicGetLiquidationsHist(this.extend(request, params));
3205
+ //
3206
+ // [
3207
+ // [
3208
+ // [
3209
+ // "pos",
3210
+ // 171085137,
3211
+ // 1706395919788,
3212
+ // null,
3213
+ // "tAVAXF0:USTF0",
3214
+ // -8,
3215
+ // 32.868,
3216
+ // null,
3217
+ // 1,
3218
+ // 1,
3219
+ // null,
3220
+ // 33.255
3221
+ // ]
3222
+ // ],
3223
+ // ]
3224
+ //
3225
+ return this.parseLiquidations(response, market, since, limit);
3226
+ }
3227
+ parseLiquidation(liquidation, market = undefined) {
3228
+ //
3229
+ // [
3230
+ // [
3231
+ // "pos",
3232
+ // 171085137, // position id
3233
+ // 1706395919788, // timestamp
3234
+ // null,
3235
+ // "tAVAXF0:USTF0", // market id
3236
+ // -8, // amount in contracts
3237
+ // 32.868, // base price
3238
+ // null,
3239
+ // 1,
3240
+ // 1,
3241
+ // null,
3242
+ // 33.255 // acquired price
3243
+ // ]
3244
+ // ]
3245
+ //
3246
+ const entry = liquidation[0];
3247
+ const timestamp = this.safeInteger(entry, 2);
3248
+ const marketId = this.safeString(entry, 4);
3249
+ const contracts = Precise["default"].stringAbs(this.safeString(entry, 5));
3250
+ const contractSize = this.safeString(market, 'contractSize');
3251
+ const baseValue = Precise["default"].stringMul(contracts, contractSize);
3252
+ const price = this.safeString(entry, 11);
3253
+ return this.safeLiquidation({
3254
+ 'info': entry,
3255
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3256
+ 'contracts': this.parseNumber(contracts),
3257
+ 'contractSize': this.parseNumber(contractSize),
3258
+ 'price': this.parseNumber(price),
3259
+ 'baseValue': this.parseNumber(baseValue),
3260
+ 'quoteValue': this.parseNumber(Precise["default"].stringMul(baseValue, price)),
3261
+ 'timestamp': timestamp,
3262
+ 'datetime': this.iso8601(timestamp),
3263
+ });
3264
+ }
3174
3265
  }
3175
3266
 
3176
3267
  module.exports = bitfinex2;
@@ -3437,7 +3437,7 @@ class gate extends gate$1 {
3437
3437
  // "price": "333"
3438
3438
  // }
3439
3439
  //
3440
- const id = this.safeString(trade, 'id');
3440
+ const id = this.safeString2(trade, 'id', 'trade_id');
3441
3441
  let timestamp = this.safeTimestamp2(trade, 'time', 'create_time');
3442
3442
  timestamp = this.safeInteger(trade, 'create_time_ms', timestamp);
3443
3443
  const marketId = this.safeString2(trade, 'currency_pair', 'contract');
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 { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } 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.2.23";
7
+ declare const version = "4.2.24";
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.2.24';
41
+ const version = '4.2.25';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -1,5 +1,5 @@
1
1
  import Exchange from './abstract/bitfinex2.js';
2
- import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest } from './base/types.js';
2
+ import type { Int, OrderSide, OrderType, Trade, OHLCV, Order, FundingRateHistory, OrderBook, Str, Transaction, Ticker, Balances, Tickers, Strings, Currency, Market, OpenInterest, Liquidation } from './base/types.js';
3
3
  /**
4
4
  * @class bitfinex2
5
5
  * @augments Exchange
@@ -159,4 +159,6 @@ export default class bitfinex2 extends Exchange {
159
159
  fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
160
160
  fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
161
161
  parseOpenInterest(interest: any, market?: Market): OpenInterest;
162
+ fetchLiquidations(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Liquidation[]>;
163
+ parseLiquidation(liquidation: any, market?: Market): Liquidation;
162
164
  }
@@ -53,6 +53,7 @@ export default class bitfinex2 extends Exchange {
53
53
  'fetchFundingRates': true,
54
54
  'fetchIndexOHLCV': false,
55
55
  'fetchLedger': true,
56
+ 'fetchLiquidations': true,
56
57
  'fetchMarginMode': false,
57
58
  'fetchMarkOHLCV': false,
58
59
  'fetchMyTrades': true,
@@ -3174,4 +3175,94 @@ export default class bitfinex2 extends Exchange {
3174
3175
  'info': interest,
3175
3176
  }, market);
3176
3177
  }
3178
+ async fetchLiquidations(symbol, since = undefined, limit = undefined, params = {}) {
3179
+ /**
3180
+ * @method
3181
+ * @name bitfinex2#fetchLiquidations
3182
+ * @description retrieves the public liquidations of a trading pair
3183
+ * @see https://docs.bitfinex.com/reference/rest-public-liquidations
3184
+ * @param {string} symbol unified CCXT market symbol
3185
+ * @param {int} [since] the earliest time in ms to fetch liquidations for
3186
+ * @param {int} [limit] the maximum number of liquidation structures to retrieve
3187
+ * @param {object} [params] exchange specific parameters
3188
+ * @param {int} [params.until] timestamp in ms of the latest liquidation
3189
+ * @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
3190
+ * @returns {object} an array of [liquidation structures]{@link https://docs.ccxt.com/#/?id=liquidation-structure}
3191
+ */
3192
+ await this.loadMarkets();
3193
+ let paginate = false;
3194
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchLiquidations', 'paginate');
3195
+ if (paginate) {
3196
+ return await this.fetchPaginatedCallDeterministic('fetchLiquidations', symbol, since, limit, '8h', params, 500);
3197
+ }
3198
+ const market = this.market(symbol);
3199
+ let request = {};
3200
+ if (since !== undefined) {
3201
+ request['start'] = since;
3202
+ }
3203
+ if (limit !== undefined) {
3204
+ request['limit'] = limit;
3205
+ }
3206
+ [request, params] = this.handleUntilOption('end', request, params);
3207
+ const response = await this.publicGetLiquidationsHist(this.extend(request, params));
3208
+ //
3209
+ // [
3210
+ // [
3211
+ // [
3212
+ // "pos",
3213
+ // 171085137,
3214
+ // 1706395919788,
3215
+ // null,
3216
+ // "tAVAXF0:USTF0",
3217
+ // -8,
3218
+ // 32.868,
3219
+ // null,
3220
+ // 1,
3221
+ // 1,
3222
+ // null,
3223
+ // 33.255
3224
+ // ]
3225
+ // ],
3226
+ // ]
3227
+ //
3228
+ return this.parseLiquidations(response, market, since, limit);
3229
+ }
3230
+ parseLiquidation(liquidation, market = undefined) {
3231
+ //
3232
+ // [
3233
+ // [
3234
+ // "pos",
3235
+ // 171085137, // position id
3236
+ // 1706395919788, // timestamp
3237
+ // null,
3238
+ // "tAVAXF0:USTF0", // market id
3239
+ // -8, // amount in contracts
3240
+ // 32.868, // base price
3241
+ // null,
3242
+ // 1,
3243
+ // 1,
3244
+ // null,
3245
+ // 33.255 // acquired price
3246
+ // ]
3247
+ // ]
3248
+ //
3249
+ const entry = liquidation[0];
3250
+ const timestamp = this.safeInteger(entry, 2);
3251
+ const marketId = this.safeString(entry, 4);
3252
+ const contracts = Precise.stringAbs(this.safeString(entry, 5));
3253
+ const contractSize = this.safeString(market, 'contractSize');
3254
+ const baseValue = Precise.stringMul(contracts, contractSize);
3255
+ const price = this.safeString(entry, 11);
3256
+ return this.safeLiquidation({
3257
+ 'info': entry,
3258
+ 'symbol': this.safeSymbol(marketId, market, undefined, 'contract'),
3259
+ 'contracts': this.parseNumber(contracts),
3260
+ 'contractSize': this.parseNumber(contractSize),
3261
+ 'price': this.parseNumber(price),
3262
+ 'baseValue': this.parseNumber(baseValue),
3263
+ 'quoteValue': this.parseNumber(Precise.stringMul(baseValue, price)),
3264
+ 'timestamp': timestamp,
3265
+ 'datetime': this.iso8601(timestamp),
3266
+ });
3267
+ }
3177
3268
  }
package/js/src/gate.js CHANGED
@@ -3440,7 +3440,7 @@ export default class gate extends Exchange {
3440
3440
  // "price": "333"
3441
3441
  // }
3442
3442
  //
3443
- const id = this.safeString(trade, 'id');
3443
+ const id = this.safeString2(trade, 'id', 'trade_id');
3444
3444
  let timestamp = this.safeTimestamp2(trade, 'time', 'create_time');
3445
3445
  timestamp = this.safeInteger(trade, 'create_time_ms', timestamp);
3446
3446
  const marketId = this.safeString2(trade, 'currency_pair', 'contract');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.2.24",
3
+ "version": "4.2.25",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",