ccxt 4.2.23 → 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.
@@ -243,6 +243,37 @@ interface binance {
243
243
  sapiGetSimpleEarnFlexibleHistoryRewardsRecord(params?: {}): Promise<implicitReturnType>;
244
244
  sapiGetSimpleEarnLockedHistoryRewardsRecord(params?: {}): Promise<implicitReturnType>;
245
245
  sapiGetSimpleEarnFlexibleHistoryCollateralRecord(params?: {}): Promise<implicitReturnType>;
246
+ sapiGetAssetAssetDistributionHistory(params?: {}): Promise<implicitReturnType>;
247
+ sapiGetAssetQueryTradingFee(params?: {}): Promise<implicitReturnType>;
248
+ sapiGetAssetQueryTradingVolume(params?: {}): Promise<implicitReturnType>;
249
+ sapiGetOtcCoinPairs(params?: {}): Promise<implicitReturnType>;
250
+ sapiGetOtcOrdersOrderId(params?: {}): Promise<implicitReturnType>;
251
+ sapiGetOtcOrders(params?: {}): Promise<implicitReturnType>;
252
+ sapiGetOcbsOrders(params?: {}): Promise<implicitReturnType>;
253
+ sapiGetFiatpaymentQueryWithdrawHistory(params?: {}): Promise<implicitReturnType>;
254
+ sapiGetFiatpaymentQueryDepositHistory(params?: {}): Promise<implicitReturnType>;
255
+ sapiGetCapitalSubAccountDepositAddress(params?: {}): Promise<implicitReturnType>;
256
+ sapiGetCapitalSubAccountDepositHistory(params?: {}): Promise<implicitReturnType>;
257
+ sapiGetAssetQueryDustLogs(params?: {}): Promise<implicitReturnType>;
258
+ sapiGetAssetQueryDustAssets(params?: {}): Promise<implicitReturnType>;
259
+ sapiGetMarketingReferralRewardHistory(params?: {}): Promise<implicitReturnType>;
260
+ sapiGetStakingAsset(params?: {}): Promise<implicitReturnType>;
261
+ sapiGetStakingStakingBalance(params?: {}): Promise<implicitReturnType>;
262
+ sapiGetStakingHistory(params?: {}): Promise<implicitReturnType>;
263
+ sapiGetStakingStakingRewardsHistory(params?: {}): Promise<implicitReturnType>;
264
+ sapiGetCustodianBalance(params?: {}): Promise<implicitReturnType>;
265
+ sapiGetCustodianSupportedAssetList(params?: {}): Promise<implicitReturnType>;
266
+ sapiGetCustodianWalletTransferHistory(params?: {}): Promise<implicitReturnType>;
267
+ sapiGetCustodianCustodianTransferHistory(params?: {}): Promise<implicitReturnType>;
268
+ sapiGetCustodianOpenOrders(params?: {}): Promise<implicitReturnType>;
269
+ sapiGetCustodianOrder(params?: {}): Promise<implicitReturnType>;
270
+ sapiGetCustodianOrderHistory(params?: {}): Promise<implicitReturnType>;
271
+ sapiGetCustodianTradeHistory(params?: {}): Promise<implicitReturnType>;
272
+ sapiGetCustodianSettlementSetting(params?: {}): Promise<implicitReturnType>;
273
+ sapiGetCustodianSettlementHistory(params?: {}): Promise<implicitReturnType>;
274
+ sapiGetClTransferHistory(params?: {}): Promise<implicitReturnType>;
275
+ sapiGetApipartnerCheckEligibility(params?: {}): Promise<implicitReturnType>;
276
+ sapiGetApipartnerRebateHistory(params?: {}): Promise<implicitReturnType>;
246
277
  sapiPostAssetDust(params?: {}): Promise<implicitReturnType>;
247
278
  sapiPostAssetDustBtc(params?: {}): Promise<implicitReturnType>;
248
279
  sapiPostAssetTransfer(params?: {}): Promise<implicitReturnType>;
@@ -357,6 +388,17 @@ interface binance {
357
388
  sapiPostSimpleEarnLockedRedeem(params?: {}): Promise<implicitReturnType>;
358
389
  sapiPostSimpleEarnFlexibleSetAutoSubscribe(params?: {}): Promise<implicitReturnType>;
359
390
  sapiPostSimpleEarnLockedSetAutoSubscribe(params?: {}): Promise<implicitReturnType>;
391
+ sapiPostOtcQuotes(params?: {}): Promise<implicitReturnType>;
392
+ sapiPostOtcOrders(params?: {}): Promise<implicitReturnType>;
393
+ sapiPostFiatpaymentWithdrawApply(params?: {}): Promise<implicitReturnType>;
394
+ sapiPostStakingStake(params?: {}): Promise<implicitReturnType>;
395
+ sapiPostStakingUnstake(params?: {}): Promise<implicitReturnType>;
396
+ sapiPostCustodianWalletTransfer(params?: {}): Promise<implicitReturnType>;
397
+ sapiPostCustodianCustodianTransfer(params?: {}): Promise<implicitReturnType>;
398
+ sapiPostCustodianUndoTransfer(params?: {}): Promise<implicitReturnType>;
399
+ sapiPostCustodianOrder(params?: {}): Promise<implicitReturnType>;
400
+ sapiPostCustodianOcoOrder(params?: {}): Promise<implicitReturnType>;
401
+ sapiPostClTransfer(params?: {}): Promise<implicitReturnType>;
360
402
  sapiPutUserDataStream(params?: {}): Promise<implicitReturnType>;
361
403
  sapiPutUserDataStreamIsolated(params?: {}): Promise<implicitReturnType>;
362
404
  sapiDeleteMarginOpenOrders(params?: {}): Promise<implicitReturnType>;
@@ -370,14 +412,24 @@ interface binance {
370
412
  sapiDeleteAlgoSpotOrder(params?: {}): Promise<implicitReturnType>;
371
413
  sapiDeleteAlgoFuturesOrder(params?: {}): Promise<implicitReturnType>;
372
414
  sapiDeleteSubAccountSubAccountApiIpRestrictionIpList(params?: {}): Promise<implicitReturnType>;
415
+ sapiDeleteCustodianCancelOrder(params?: {}): Promise<implicitReturnType>;
416
+ sapiDeleteCustodianCancelOrdersBySymbol(params?: {}): Promise<implicitReturnType>;
417
+ sapiDeleteCustodianCancelOcoOrder(params?: {}): Promise<implicitReturnType>;
373
418
  sapiV2GetEthStakingAccount(params?: {}): Promise<implicitReturnType>;
374
419
  sapiV2GetSubAccountFuturesAccount(params?: {}): Promise<implicitReturnType>;
375
420
  sapiV2GetSubAccountFuturesAccountSummary(params?: {}): Promise<implicitReturnType>;
376
421
  sapiV2GetSubAccountFuturesPositionRisk(params?: {}): Promise<implicitReturnType>;
422
+ sapiV2GetClAccount(params?: {}): Promise<implicitReturnType>;
423
+ sapiV2GetClAlertHistory(params?: {}): Promise<implicitReturnType>;
377
424
  sapiV2PostEthStakingEthStake(params?: {}): Promise<implicitReturnType>;
378
425
  sapiV2PostSubAccountSubAccountApiIpRestriction(params?: {}): Promise<implicitReturnType>;
379
426
  sapiV3GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
427
+ sapiV3GetAccountStatus(params?: {}): Promise<implicitReturnType>;
428
+ sapiV3GetApiTradingStatus(params?: {}): Promise<implicitReturnType>;
429
+ sapiV3GetSubAccountList(params?: {}): Promise<implicitReturnType>;
430
+ sapiV3GetSubAccountTransferHistory(params?: {}): Promise<implicitReturnType>;
380
431
  sapiV3PostAssetGetUserAsset(params?: {}): Promise<implicitReturnType>;
432
+ sapiV3PostSubAccountTransfer(params?: {}): Promise<implicitReturnType>;
381
433
  sapiV4GetSubAccountAssets(params?: {}): Promise<implicitReturnType>;
382
434
  dapiPublicGetPing(params?: {}): Promise<implicitReturnType>;
383
435
  dapiPublicGetTime(params?: {}): Promise<implicitReturnType>;
@@ -594,7 +646,6 @@ interface binance {
594
646
  privateGetMyPreventedMatches(params?: {}): Promise<implicitReturnType>;
595
647
  privateGetMyAllocations(params?: {}): Promise<implicitReturnType>;
596
648
  privateGetAccountCommission(params?: {}): Promise<implicitReturnType>;
597
- privateGetStatus(params?: {}): Promise<implicitReturnType>;
598
649
  privatePostOrderOco(params?: {}): Promise<implicitReturnType>;
599
650
  privatePostSorOrder(params?: {}): Promise<implicitReturnType>;
600
651
  privatePostSorOrderTest(params?: {}): Promise<implicitReturnType>;
@@ -13,6 +13,7 @@ export default class binanceus extends binance {
13
13
  'id': 'binanceus',
14
14
  'name': 'Binance US',
15
15
  'countries': ['US'],
16
+ 'hostname': 'binance.us',
16
17
  'rateLimit': 50,
17
18
  'certified': false,
18
19
  'pro': true,
@@ -20,10 +21,11 @@ export default class binanceus extends binance {
20
21
  'logo': 'https://user-images.githubusercontent.com/1294454/65177307-217b7c80-da5f-11e9-876e-0b748ba0a358.jpg',
21
22
  'api': {
22
23
  'web': 'https://www.binance.us',
23
- 'sapi': 'https://api.binance.us/sapi/v1',
24
- 'wapi': 'https://api.binance.us/wapi/v3',
25
24
  'public': 'https://api.binance.us/api/v3',
26
25
  'private': 'https://api.binance.us/api/v3',
26
+ 'sapi': 'https://api.binance.us/sapi/v1',
27
+ 'sapiV2': 'https://api.binance.us/sapi/v2',
28
+ 'sapiV3': 'https://api.binance.us/sapi/v3',
27
29
  },
28
30
  'www': 'https://www.binance.us',
29
31
  'referral': 'https://www.binance.us/?ref=35005074',
@@ -84,13 +86,13 @@ export default class binanceus extends binance {
84
86
  'api': {
85
87
  'public': {
86
88
  'get': {
87
- 'exchangeInfo': 10,
88
89
  'ping': 1,
89
90
  'time': 1,
90
- 'depth': { 'cost': 1, 'byLimit': [[100, 1], [500, 5], [1000, 10], [5000, 50]] },
91
+ 'exchangeInfo': 10,
91
92
  'trades': 1,
92
- 'aggTrades': 1,
93
93
  'historicalTrades': 5,
94
+ 'aggTrades': 1,
95
+ 'depth': { 'cost': 1, 'byLimit': [[100, 1], [500, 5], [1000, 10], [5000, 50]] },
94
96
  'klines': 1,
95
97
  'ticker/price': { 'cost': 1, 'noSymbol': 2 },
96
98
  'avgPrice': 1,
@@ -101,7 +103,107 @@ export default class binanceus extends binance {
101
103
  },
102
104
  'private': {
103
105
  'get': {
104
- 'status': 1,
106
+ 'account': 10,
107
+ 'rateLimit/order': 20,
108
+ 'order': 2,
109
+ 'openOrders': { 'cost': 3, 'noSymbol': 40 },
110
+ 'myTrades': 10,
111
+ 'myPreventedMatches': 10,
112
+ 'allOrders': 10,
113
+ 'orderList': 2,
114
+ 'allOrderList': 10,
115
+ 'openOrderList': 3,
116
+ },
117
+ 'post': {
118
+ 'order': 1,
119
+ 'order/test': 1,
120
+ 'order/cancelReplace': 1,
121
+ 'order/oco': 1,
122
+ },
123
+ 'delete': {
124
+ 'order': 1,
125
+ 'openOrders': 1,
126
+ 'orderList': 1,
127
+ },
128
+ },
129
+ 'sapi': {
130
+ 'get': {
131
+ 'system/status': 1,
132
+ 'asset/assetDistributionHistory': 1,
133
+ 'asset/query/trading-fee': 1,
134
+ 'asset/query/trading-volume': 1,
135
+ 'sub-account/spotSummary': 1,
136
+ 'sub-account/status': 1,
137
+ 'otc/coinPairs': 1,
138
+ 'otc/orders/{orderId}': 1,
139
+ 'otc/orders': 1,
140
+ 'ocbs/orders': 1,
141
+ 'capital/config/getall': 1,
142
+ 'capital/withdraw/history': 1,
143
+ 'fiatpayment/query/withdraw/history': 1,
144
+ 'capital/deposit/address': 1,
145
+ 'capital/deposit/hisrec': 1,
146
+ 'fiatpayment/query/deposit/history': 1,
147
+ 'capital/sub-account/deposit/address': 1,
148
+ 'capital/sub-account/deposit/history': 1,
149
+ 'asset/query/dust-logs': 1,
150
+ 'asset/query/dust-assets': 1,
151
+ 'marketing/referral/reward/history': 1,
152
+ 'staking/asset': 1,
153
+ 'staking/stakingBalance': 1,
154
+ 'staking/history': 1,
155
+ 'staking/stakingRewardsHistory': 1,
156
+ 'custodian/balance': 1,
157
+ 'custodian/supportedAssetList': 1,
158
+ 'custodian/walletTransferHistory': 1,
159
+ 'custodian/custodianTransferHistory': 1,
160
+ 'custodian/openOrders': 1,
161
+ 'custodian/order': 1,
162
+ 'custodian/orderHistory': 1,
163
+ 'custodian/tradeHistory': 1,
164
+ 'custodian/settlementSetting': 1,
165
+ 'custodian/settlementHistory': 1,
166
+ 'cl/transferHistory': 1,
167
+ 'apipartner/checkEligibility': 1,
168
+ 'apipartner/rebateHistory': 1,
169
+ },
170
+ 'post': {
171
+ 'otc/quotes': 1,
172
+ 'otc/orders': 1,
173
+ 'fiatpayment/withdraw/apply': 1,
174
+ 'capital/withdraw/apply': 1,
175
+ 'asset/dust': 10,
176
+ 'staking/stake': 1,
177
+ 'staking/unstake': 1,
178
+ 'custodian/walletTransfer': 1,
179
+ 'custodian/custodianTransfer': 1,
180
+ 'custodian/undoTransfer': 1,
181
+ 'custodian/order': 1,
182
+ 'custodian/ocoOrder': 1,
183
+ 'cl/transfer': 1,
184
+ },
185
+ 'delete': {
186
+ 'custodian/cancelOrder': 1,
187
+ 'custodian/cancelOrdersBySymbol': 1,
188
+ 'custodian/cancelOcoOrder': 1,
189
+ },
190
+ },
191
+ 'sapiV2': {
192
+ 'get': {
193
+ 'cl/account': 10,
194
+ 'cl/alertHistory': 1,
195
+ },
196
+ },
197
+ 'sapiV3': {
198
+ 'get': {
199
+ 'accountStatus': 1,
200
+ 'apiTradingStatus': 1,
201
+ 'sub-account/list': 1,
202
+ 'sub-account/transfer/history': 1,
203
+ 'sub-account/assets': 1,
204
+ },
205
+ 'post': {
206
+ 'sub-account/transfer': 1,
105
207
  },
106
208
  },
107
209
  },
package/js/src/bingx.js CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  // ---------------------------------------------------------------------------
8
8
  import Exchange from './abstract/bingx.js';
9
- import { AuthenticationError, ExchangeNotAvailable, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported } from './base/errors.js';
9
+ import { AuthenticationError, PermissionDenied, AccountSuspended, ExchangeError, InsufficientFunds, BadRequest, OrderNotFound, DDoSProtection, BadSymbol, ArgumentsRequired, NotSupported } from './base/errors.js';
10
10
  import { Precise } from './base/Precise.js';
11
11
  import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
12
12
  import { DECIMAL_PLACES } from './base/functions/number.js';
@@ -363,7 +363,7 @@ export default class bingx extends Exchange {
363
363
  '100500': ExchangeError,
364
364
  '100503': ExchangeError,
365
365
  '80001': BadRequest,
366
- '80012': ExchangeNotAvailable,
366
+ '80012': InsufficientFunds,
367
367
  '80014': BadRequest,
368
368
  '80016': OrderNotFound,
369
369
  '80017': OrderNotFound,
@@ -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 } 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
@@ -156,6 +156,9 @@ export default class bitfinex2 extends Exchange {
156
156
  previousFundingTimestamp: any;
157
157
  previousFundingDatetime: any;
158
158
  };
159
- fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
160
- parseOpenInterest(interest: any, market?: Market): import("./base/types.js").OpenInterest;
159
+ fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
160
+ fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
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;
161
164
  }
@@ -53,11 +53,13 @@ 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,
59
60
  'fetchOHLCV': true,
60
61
  'fetchOpenInterest': true,
62
+ 'fetchOpenInterestHistory': true,
61
63
  'fetchOpenOrder': true,
62
64
  'fetchOpenOrders': true,
63
65
  'fetchOrder': true,
@@ -3037,7 +3039,73 @@ export default class bitfinex2 extends Exchange {
3037
3039
  //
3038
3040
  return this.parseOpenInterest(response[0], market);
3039
3041
  }
3042
+ async fetchOpenInterestHistory(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
3043
+ /**
3044
+ * @method
3045
+ * @name bitfinex2#fetchOpenInterestHistory
3046
+ * @description retrieves the open interest history of a currency
3047
+ * @see https://docs.bitfinex.com/reference/rest-public-derivatives-status-history
3048
+ * @param {string} symbol unified CCXT market symbol
3049
+ * @param {string} timeframe the time period of each row of data, not used by bitfinex2
3050
+ * @param {int} [since] the time in ms of the earliest record to retrieve as a unix timestamp
3051
+ * @param {int} [limit] the number of records in the response
3052
+ * @param {object} [params] exchange specific parameters
3053
+ * @param {int} [params.until] the time in ms of the latest record to retrieve as a unix timestamp
3054
+ * @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)
3055
+ * @returns An array of [open interest structures]{@link https://docs.ccxt.com/#/?id=open-interest-structure}
3056
+ */
3057
+ await this.loadMarkets();
3058
+ let paginate = false;
3059
+ [paginate, params] = this.handleOptionAndParams(params, 'fetchOpenInterestHistory', 'paginate');
3060
+ if (paginate) {
3061
+ return await this.fetchPaginatedCallDeterministic('fetchOpenInterestHistory', symbol, since, limit, '8h', params, 5000);
3062
+ }
3063
+ const market = this.market(symbol);
3064
+ let request = {
3065
+ 'symbol': market['id'],
3066
+ };
3067
+ if (since !== undefined) {
3068
+ request['start'] = since;
3069
+ }
3070
+ if (limit !== undefined) {
3071
+ request['limit'] = limit;
3072
+ }
3073
+ [request, params] = this.handleUntilOption('end', request, params);
3074
+ const response = await this.publicGetStatusDerivSymbolHist(this.extend(request, params));
3075
+ //
3076
+ // [
3077
+ // [
3078
+ // 1706295191000, // timestamp
3079
+ // null,
3080
+ // 42152.425382, // derivative mid price
3081
+ // 42133, // spot mid price
3082
+ // null,
3083
+ // 37671589.7853521, // insurance fund balance
3084
+ // null,
3085
+ // 1706313600000, // timestamp of next funding
3086
+ // 0.00018734, // accrued funding for next period
3087
+ // 3343, // next funding step
3088
+ // null,
3089
+ // 0.00007587, // current funding
3090
+ // null,
3091
+ // null,
3092
+ // 42134.1, // mark price
3093
+ // null,
3094
+ // null,
3095
+ // 5775.20348804, // open interest number of contracts
3096
+ // null,
3097
+ // null,
3098
+ // null,
3099
+ // 0.0005, // average spread without funding payment
3100
+ // 0.0025 // funding payment cap
3101
+ // ],
3102
+ // ]
3103
+ //
3104
+ return this.parseOpenInterests(response, market, since, limit);
3105
+ }
3040
3106
  parseOpenInterest(interest, market = undefined) {
3107
+ //
3108
+ // fetchOpenInterest:
3041
3109
  //
3042
3110
  // [
3043
3111
  // "tXRPF0:USTF0", // market id
@@ -3066,15 +3134,135 @@ export default class bitfinex2 extends Exchange {
3066
3134
  // 0.0025 // funding payment cap
3067
3135
  // ]
3068
3136
  //
3137
+ // fetchOpenInterestHistory:
3138
+ //
3139
+ // [
3140
+ // 1706295191000, // timestamp
3141
+ // null,
3142
+ // 42152.425382, // derivative mid price
3143
+ // 42133, // spot mid price
3144
+ // null,
3145
+ // 37671589.7853521, // insurance fund balance
3146
+ // null,
3147
+ // 1706313600000, // timestamp of next funding
3148
+ // 0.00018734, // accrued funding for next period
3149
+ // 3343, // next funding step
3150
+ // null,
3151
+ // 0.00007587, // current funding
3152
+ // null,
3153
+ // null,
3154
+ // 42134.1, // mark price
3155
+ // null,
3156
+ // null,
3157
+ // 5775.20348804, // open interest number of contracts
3158
+ // null,
3159
+ // null,
3160
+ // null,
3161
+ // 0.0005, // average spread without funding payment
3162
+ // 0.0025 // funding payment cap
3163
+ // ]
3164
+ //
3165
+ const interestLength = interest.length;
3166
+ const openInterestIndex = (interestLength === 23) ? 17 : 18;
3069
3167
  const timestamp = this.safeInteger(interest, 1);
3070
3168
  const marketId = this.safeString(interest, 0);
3071
3169
  return this.safeOpenInterest({
3072
3170
  'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
3073
- 'openInterestAmount': this.safeNumber(interest, 18),
3171
+ 'openInterestAmount': this.safeNumber(interest, openInterestIndex),
3074
3172
  'openInterestValue': undefined,
3075
3173
  'timestamp': timestamp,
3076
3174
  'datetime': this.iso8601(timestamp),
3077
3175
  'info': interest,
3078
3176
  }, market);
3079
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
+ }
3080
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/js/src/phemex.js CHANGED
@@ -3769,7 +3769,7 @@ export default class phemex extends Exchange {
3769
3769
  const contracts = this.safeString(position, 'size');
3770
3770
  const contractSize = this.safeValue(market, 'contractSize');
3771
3771
  const contractSizeString = this.numberToString(contractSize);
3772
- const leverage = this.parseNumber(Precise.stringAbs((this.safeString(position, 'leverage', 'leverageRr'))));
3772
+ const leverage = this.parseNumber(Precise.stringAbs((this.safeString2(position, 'leverage', 'leverageRr'))));
3773
3773
  const entryPriceString = this.safeString2(position, 'avgEntryPrice', 'avgEntryPriceRp');
3774
3774
  const rawSide = this.safeString(position, 'side');
3775
3775
  let side = undefined;
@@ -1,5 +1,5 @@
1
1
  import bitoproRest from '../bitopro.js';
2
- import type { Int, OrderBook, Trade, Ticker, Balances } from '../base/types.js';
2
+ import type { Int, OrderBook, Trade, Ticker, Balances, Market, Str } from '../base/types.js';
3
3
  import Client from '../base/ws/Client.js';
4
4
  export default class bitopro extends bitoproRest {
5
5
  describe(): any;
@@ -8,6 +8,9 @@ export default class bitopro extends bitoproRest {
8
8
  handleOrderBook(client: Client, message: any): void;
9
9
  watchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
10
10
  handleTrade(client: Client, message: any): void;
11
+ watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
12
+ handleMyTrade(client: Client, message: any): void;
13
+ parseWsTrade(trade: any, market?: Market): Trade;
11
14
  watchTicker(symbol: string, params?: {}): Promise<Ticker>;
12
15
  handleTicker(client: Client, message: any): void;
13
16
  authenticate(url: any): void;