ccxt 4.3.21 → 4.3.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/README.md +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/binance.js +1 -1
- package/dist/cjs/src/coinbase.js +5 -0
- package/dist/cjs/src/coinex.js +158 -182
- package/dist/cjs/src/phemex.js +65 -13
- package/dist/cjs/src/pro/poloniexfutures.js +22 -17
- package/dist/cjs/src/probit.js +1 -20
- package/dist/cjs/src/whitebit.js +9 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/whitebit.d.ts +9 -0
- package/js/src/binance.js +1 -1
- package/js/src/coinbase.js +5 -0
- package/js/src/coinex.d.ts +12 -12
- package/js/src/coinex.js +159 -183
- package/js/src/phemex.d.ts +1 -0
- package/js/src/phemex.js +65 -13
- package/js/src/pro/poloniexfutures.js +22 -17
- package/js/src/probit.js +1 -20
- package/js/src/whitebit.js +9 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -215,13 +215,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
215
215
|
|
|
216
216
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
217
217
|
|
|
218
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
|
219
|
-
* unpkg: https://unpkg.com/ccxt@4.3.
|
|
218
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.23/dist/ccxt.browser.js
|
|
219
|
+
* unpkg: https://unpkg.com/ccxt@4.3.23/dist/ccxt.browser.js
|
|
220
220
|
|
|
221
221
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
222
222
|
|
|
223
223
|
```HTML
|
|
224
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
|
224
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.23/dist/ccxt.browser.js"></script>
|
|
225
225
|
```
|
|
226
226
|
|
|
227
227
|
Creates a global `ccxt` object:
|
package/dist/cjs/ccxt.js
CHANGED
|
@@ -184,7 +184,7 @@ var woofipro$1 = require('./src/pro/woofipro.js');
|
|
|
184
184
|
|
|
185
185
|
//-----------------------------------------------------------------------------
|
|
186
186
|
// this is updated by vss.js when building
|
|
187
|
-
const version = '4.3.
|
|
187
|
+
const version = '4.3.23';
|
|
188
188
|
Exchange["default"].ccxtVersion = version;
|
|
189
189
|
const exchanges = {
|
|
190
190
|
'ace': ace,
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -9689,7 +9689,7 @@ class binance extends binance$1 {
|
|
|
9689
9689
|
await this.loadMarkets();
|
|
9690
9690
|
// by default cache the leverage bracket
|
|
9691
9691
|
// it contains useful stuff like the maintenance margin and initial margin for positions
|
|
9692
|
-
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets'
|
|
9692
|
+
const leverageBrackets = this.safeDict(this.options, 'leverageBrackets');
|
|
9693
9693
|
if ((leverageBrackets === undefined) || (reload)) {
|
|
9694
9694
|
const defaultType = this.safeString(this.options, 'defaultType', 'future');
|
|
9695
9695
|
const type = this.safeString(params, 'type', defaultType);
|
package/dist/cjs/src/coinbase.js
CHANGED
|
@@ -1810,6 +1810,11 @@ class coinbase extends coinbase$1 {
|
|
|
1810
1810
|
if (symbols !== undefined) {
|
|
1811
1811
|
request['product_ids'] = this.marketIds(symbols);
|
|
1812
1812
|
}
|
|
1813
|
+
let marketType = undefined;
|
|
1814
|
+
[marketType, params] = this.handleMarketTypeAndParams('fetchTickers', this.getMarketFromSymbols(symbols), params, 'default');
|
|
1815
|
+
if (marketType !== undefined && marketType !== 'default') {
|
|
1816
|
+
request['product_type'] = (marketType === 'swap') ? 'FUTURE' : 'SPOT';
|
|
1817
|
+
}
|
|
1813
1818
|
const response = await this.v3PublicGetBrokerageMarketProducts(this.extend(request, params));
|
|
1814
1819
|
//
|
|
1815
1820
|
// {
|
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -468,10 +468,53 @@ class coinex extends coinex$1 {
|
|
|
468
468
|
'36': errors.RequestTimeout,
|
|
469
469
|
'213': errors.RateLimitExceeded,
|
|
470
470
|
'107': errors.InsufficientFunds,
|
|
471
|
+
'158': errors.PermissionDenied,
|
|
471
472
|
'600': errors.OrderNotFound,
|
|
472
473
|
'601': errors.InvalidOrder,
|
|
473
474
|
'602': errors.InvalidOrder,
|
|
474
475
|
'606': errors.InvalidOrder,
|
|
476
|
+
'3008': errors.RequestTimeout,
|
|
477
|
+
'3109': errors.InsufficientFunds,
|
|
478
|
+
'3127': errors.InvalidOrder,
|
|
479
|
+
'3606': errors.InvalidOrder,
|
|
480
|
+
'3610': errors.ExchangeError,
|
|
481
|
+
'3612': errors.InvalidOrder,
|
|
482
|
+
'3613': errors.InvalidOrder,
|
|
483
|
+
'3614': errors.InvalidOrder,
|
|
484
|
+
'3615': errors.InvalidOrder,
|
|
485
|
+
'3616': errors.InvalidOrder,
|
|
486
|
+
'3617': errors.InvalidOrder,
|
|
487
|
+
'3618': errors.InvalidOrder,
|
|
488
|
+
'3619': errors.InvalidOrder,
|
|
489
|
+
'3620': errors.InvalidOrder,
|
|
490
|
+
'3621': errors.InvalidOrder,
|
|
491
|
+
'3622': errors.InvalidOrder,
|
|
492
|
+
'3627': errors.InvalidOrder,
|
|
493
|
+
'3628': errors.InvalidOrder,
|
|
494
|
+
'3629': errors.InvalidOrder,
|
|
495
|
+
'3632': errors.InvalidOrder,
|
|
496
|
+
'3633': errors.InvalidOrder,
|
|
497
|
+
'3634': errors.InvalidOrder,
|
|
498
|
+
'3635': errors.InvalidOrder,
|
|
499
|
+
'4001': errors.ExchangeNotAvailable,
|
|
500
|
+
'4002': errors.RequestTimeout,
|
|
501
|
+
'4003': errors.ExchangeError,
|
|
502
|
+
'4004': errors.BadRequest,
|
|
503
|
+
'4005': errors.AuthenticationError,
|
|
504
|
+
'4006': errors.AuthenticationError,
|
|
505
|
+
'4007': errors.PermissionDenied,
|
|
506
|
+
'4008': errors.AuthenticationError,
|
|
507
|
+
'4009': errors.ExchangeError,
|
|
508
|
+
'4010': errors.ExchangeError,
|
|
509
|
+
'4011': errors.PermissionDenied,
|
|
510
|
+
'4017': errors.ExchangeError,
|
|
511
|
+
'4115': errors.AccountSuspended,
|
|
512
|
+
'4117': errors.BadSymbol,
|
|
513
|
+
'4123': errors.RateLimitExceeded,
|
|
514
|
+
'4130': errors.ExchangeError,
|
|
515
|
+
'4158': errors.ExchangeError,
|
|
516
|
+
'4213': errors.RateLimitExceeded,
|
|
517
|
+
'4512': errors.PermissionDenied, // Insufficient sub-account permissions, please check.
|
|
475
518
|
},
|
|
476
519
|
'broad': {
|
|
477
520
|
'ip not allow visit': errors.PermissionDenied,
|
|
@@ -4394,8 +4437,8 @@ class coinex extends coinex$1 {
|
|
|
4394
4437
|
/**
|
|
4395
4438
|
* @method
|
|
4396
4439
|
* @name coinex#fetchFundingHistory
|
|
4397
|
-
* @description fetch the history of funding payments paid and received on this account
|
|
4398
|
-
* @see https://
|
|
4440
|
+
* @description fetch the history of funding fee payments paid and received on this account
|
|
4441
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
|
|
4399
4442
|
* @param {string} symbol unified market symbol
|
|
4400
4443
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
4401
4444
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
@@ -4405,54 +4448,47 @@ class coinex extends coinex$1 {
|
|
|
4405
4448
|
if (symbol === undefined) {
|
|
4406
4449
|
throw new errors.ArgumentsRequired(this.id + ' fetchFundingHistory() requires a symbol argument');
|
|
4407
4450
|
}
|
|
4408
|
-
limit = (limit === undefined) ? 100 : limit;
|
|
4409
4451
|
await this.loadMarkets();
|
|
4410
4452
|
const market = this.market(symbol);
|
|
4411
|
-
|
|
4453
|
+
let request = {
|
|
4412
4454
|
'market': market['id'],
|
|
4413
|
-
'
|
|
4414
|
-
// 'offset': 0,
|
|
4415
|
-
// 'end_time': 1638990636000,
|
|
4416
|
-
// 'windowtime': 1638990636000,
|
|
4455
|
+
'market_type': 'FUTURES',
|
|
4417
4456
|
};
|
|
4457
|
+
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
4418
4458
|
if (since !== undefined) {
|
|
4419
4459
|
request['start_time'] = since;
|
|
4420
4460
|
}
|
|
4421
|
-
|
|
4461
|
+
if (limit !== undefined) {
|
|
4462
|
+
request['limit'] = limit;
|
|
4463
|
+
}
|
|
4464
|
+
const response = await this.v2PrivateGetFuturesPositionFundingHistory(this.extend(request, params));
|
|
4422
4465
|
//
|
|
4423
4466
|
// {
|
|
4424
4467
|
// "code": 0,
|
|
4425
|
-
// "data":
|
|
4426
|
-
//
|
|
4427
|
-
//
|
|
4428
|
-
//
|
|
4429
|
-
//
|
|
4430
|
-
//
|
|
4431
|
-
//
|
|
4432
|
-
//
|
|
4433
|
-
//
|
|
4434
|
-
//
|
|
4435
|
-
//
|
|
4436
|
-
//
|
|
4437
|
-
//
|
|
4438
|
-
//
|
|
4439
|
-
//
|
|
4440
|
-
//
|
|
4441
|
-
// "user_id": 3620173,
|
|
4442
|
-
// "value": "47.76294"
|
|
4443
|
-
// },
|
|
4444
|
-
// ]
|
|
4445
|
-
// },
|
|
4446
|
-
// "message": "OK"
|
|
4468
|
+
// "data": [
|
|
4469
|
+
// {
|
|
4470
|
+
// "ccy": "USDT",
|
|
4471
|
+
// "created_at": 1715673620183,
|
|
4472
|
+
// "funding_rate": "0",
|
|
4473
|
+
// "funding_value": "0",
|
|
4474
|
+
// "market": "BTCUSDT",
|
|
4475
|
+
// "market_type": "FUTURES",
|
|
4476
|
+
// "position_id": 306458800,
|
|
4477
|
+
// "side": "long"
|
|
4478
|
+
// },
|
|
4479
|
+
// ],
|
|
4480
|
+
// "message": "OK",
|
|
4481
|
+
// "pagination": {
|
|
4482
|
+
// "has_next": true
|
|
4483
|
+
// }
|
|
4447
4484
|
// }
|
|
4448
4485
|
//
|
|
4449
|
-
const data = this.
|
|
4450
|
-
const resultList = this.safeValue(data, 'records', []);
|
|
4486
|
+
const data = this.safeList(response, 'data', []);
|
|
4451
4487
|
const result = [];
|
|
4452
|
-
for (let i = 0; i <
|
|
4453
|
-
const entry =
|
|
4454
|
-
const timestamp = this.
|
|
4455
|
-
const currencyId = this.safeString(entry, '
|
|
4488
|
+
for (let i = 0; i < data.length; i++) {
|
|
4489
|
+
const entry = data[i];
|
|
4490
|
+
const timestamp = this.safeInteger(entry, 'created_at');
|
|
4491
|
+
const currencyId = this.safeString(entry, 'ccy');
|
|
4456
4492
|
const code = this.safeCurrencyCode(currencyId);
|
|
4457
4493
|
result.push({
|
|
4458
4494
|
'info': entry,
|
|
@@ -4461,7 +4497,7 @@ class coinex extends coinex$1 {
|
|
|
4461
4497
|
'timestamp': timestamp,
|
|
4462
4498
|
'datetime': this.iso8601(timestamp),
|
|
4463
4499
|
'id': this.safeNumber(entry, 'position_id'),
|
|
4464
|
-
'amount': this.safeNumber(entry, '
|
|
4500
|
+
'amount': this.safeNumber(entry, 'funding_value'),
|
|
4465
4501
|
});
|
|
4466
4502
|
}
|
|
4467
4503
|
return result;
|
|
@@ -4471,7 +4507,7 @@ class coinex extends coinex$1 {
|
|
|
4471
4507
|
* @method
|
|
4472
4508
|
* @name coinex#fetchFundingRate
|
|
4473
4509
|
* @description fetch the current funding rate
|
|
4474
|
-
* @see https://
|
|
4510
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
|
4475
4511
|
* @param {string} symbol unified market symbol
|
|
4476
4512
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4477
4513
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -4484,93 +4520,63 @@ class coinex extends coinex$1 {
|
|
|
4484
4520
|
const request = {
|
|
4485
4521
|
'market': market['id'],
|
|
4486
4522
|
};
|
|
4487
|
-
const response = await this.
|
|
4523
|
+
const response = await this.v2PublicGetFuturesFundingRate(this.extend(request, params));
|
|
4488
4524
|
//
|
|
4489
4525
|
// {
|
|
4490
|
-
//
|
|
4491
|
-
// "data":
|
|
4492
|
-
//
|
|
4493
|
-
//
|
|
4494
|
-
//
|
|
4495
|
-
// "
|
|
4496
|
-
// "
|
|
4497
|
-
// "
|
|
4498
|
-
// "
|
|
4499
|
-
// "
|
|
4500
|
-
// "
|
|
4501
|
-
// "period": 86400,
|
|
4502
|
-
// "funding_time": 372,
|
|
4503
|
-
// "position_amount": "270.1956",
|
|
4504
|
-
// "funding_rate_last": "0.00022913",
|
|
4505
|
-
// "funding_rate_next": "0.00013158",
|
|
4506
|
-
// "funding_rate_predict": "0.00016552",
|
|
4507
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4508
|
-
// "sign_price": "39652.48",
|
|
4509
|
-
// "index_price": "39648.44250000",
|
|
4510
|
-
// "sell_total": "22.3913",
|
|
4511
|
-
// "buy_total": "19.4498",
|
|
4512
|
-
// "buy_amount": "12.8942",
|
|
4513
|
-
// "sell": "39663.80",
|
|
4514
|
-
// "sell_amount": "0.9388"
|
|
4526
|
+
// "code": 0,
|
|
4527
|
+
// "data": [
|
|
4528
|
+
// {
|
|
4529
|
+
// "latest_funding_rate": "0",
|
|
4530
|
+
// "latest_funding_time": 1715731200000,
|
|
4531
|
+
// "mark_price": "61602.22",
|
|
4532
|
+
// "market": "BTCUSDT",
|
|
4533
|
+
// "max_funding_rate": "0.00375",
|
|
4534
|
+
// "min_funding_rate": "-0.00375",
|
|
4535
|
+
// "next_funding_rate": "0.00021074",
|
|
4536
|
+
// "next_funding_time": 1715760000000
|
|
4515
4537
|
// }
|
|
4516
|
-
//
|
|
4538
|
+
// ],
|
|
4517
4539
|
// "message": "OK"
|
|
4518
4540
|
// }
|
|
4519
4541
|
//
|
|
4520
|
-
const data = this.
|
|
4521
|
-
const
|
|
4522
|
-
|
|
4523
|
-
ticker['timestamp'] = timestamp; // avoid changing parseFundingRate signature
|
|
4524
|
-
return this.parseFundingRate(ticker, market);
|
|
4542
|
+
const data = this.safeList(response, 'data', []);
|
|
4543
|
+
const first = this.safeDict(data, 0, {});
|
|
4544
|
+
return this.parseFundingRate(first, market);
|
|
4525
4545
|
}
|
|
4526
4546
|
parseFundingRate(contract, market = undefined) {
|
|
4527
4547
|
//
|
|
4528
|
-
// fetchFundingRate
|
|
4548
|
+
// fetchFundingRate, fetchFundingRates
|
|
4529
4549
|
//
|
|
4530
4550
|
// {
|
|
4531
|
-
// "
|
|
4532
|
-
// "
|
|
4533
|
-
// "
|
|
4534
|
-
// "
|
|
4535
|
-
// "
|
|
4536
|
-
// "
|
|
4537
|
-
// "
|
|
4538
|
-
// "
|
|
4539
|
-
// "position_amount": "270.1956",
|
|
4540
|
-
// "funding_rate_last": "0.00022913",
|
|
4541
|
-
// "funding_rate_next": "0.00013158",
|
|
4542
|
-
// "funding_rate_predict": "0.00016552",
|
|
4543
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4544
|
-
// "sign_price": "39652.48",
|
|
4545
|
-
// "index_price": "39648.44250000",
|
|
4546
|
-
// "sell_total": "22.3913",
|
|
4547
|
-
// "buy_total": "19.4498",
|
|
4548
|
-
// "buy_amount": "12.8942",
|
|
4549
|
-
// "sell": "39663.80",
|
|
4550
|
-
// "sell_amount": "0.9388"
|
|
4551
|
+
// "latest_funding_rate": "0",
|
|
4552
|
+
// "latest_funding_time": 1715731200000,
|
|
4553
|
+
// "mark_price": "61602.22",
|
|
4554
|
+
// "market": "BTCUSDT",
|
|
4555
|
+
// "max_funding_rate": "0.00375",
|
|
4556
|
+
// "min_funding_rate": "-0.00375",
|
|
4557
|
+
// "next_funding_rate": "0.00021074",
|
|
4558
|
+
// "next_funding_time": 1715760000000
|
|
4551
4559
|
// }
|
|
4552
4560
|
//
|
|
4553
|
-
const
|
|
4554
|
-
|
|
4555
|
-
const
|
|
4556
|
-
const fundingHour = (timestamp + fundingDelta) / 3600000;
|
|
4557
|
-
const fundingTimestamp = Math.round(fundingHour) * 3600000;
|
|
4561
|
+
const currentFundingTimestamp = this.safeInteger(contract, 'latest_funding_time');
|
|
4562
|
+
const futureFundingTimestamp = this.safeInteger(contract, 'next_funding_time');
|
|
4563
|
+
const marketId = this.safeString(contract, 'market');
|
|
4558
4564
|
return {
|
|
4559
4565
|
'info': contract,
|
|
4560
|
-
'symbol': this.safeSymbol(undefined,
|
|
4561
|
-
'markPrice': this.safeNumber(contract, '
|
|
4562
|
-
'indexPrice':
|
|
4566
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
4567
|
+
'markPrice': this.safeNumber(contract, 'mark_price'),
|
|
4568
|
+
'indexPrice': undefined,
|
|
4563
4569
|
'interestRate': undefined,
|
|
4564
4570
|
'estimatedSettlePrice': undefined,
|
|
4565
|
-
'timestamp':
|
|
4566
|
-
'datetime':
|
|
4567
|
-
'fundingRate': this.safeNumber(contract, '
|
|
4568
|
-
'fundingTimestamp':
|
|
4569
|
-
'fundingDatetime': this.iso8601(
|
|
4570
|
-
'nextFundingRate': this.safeNumber(contract, '
|
|
4571
|
-
'nextFundingTimestamp':
|
|
4572
|
-
'nextFundingDatetime':
|
|
4573
|
-
'previousFundingRate':
|
|
4571
|
+
'timestamp': undefined,
|
|
4572
|
+
'datetime': undefined,
|
|
4573
|
+
'fundingRate': this.safeNumber(contract, 'latest_funding_rate'),
|
|
4574
|
+
'fundingTimestamp': currentFundingTimestamp,
|
|
4575
|
+
'fundingDatetime': this.iso8601(currentFundingTimestamp),
|
|
4576
|
+
'nextFundingRate': this.safeNumber(contract, 'next_funding_rate'),
|
|
4577
|
+
'nextFundingTimestamp': futureFundingTimestamp,
|
|
4578
|
+
'nextFundingDatetime': this.iso8601(futureFundingTimestamp),
|
|
4579
|
+
'previousFundingRate': undefined,
|
|
4574
4580
|
'previousFundingTimestamp': undefined,
|
|
4575
4581
|
'previousFundingDatetime': undefined,
|
|
4576
4582
|
};
|
|
@@ -4580,13 +4586,14 @@ class coinex extends coinex$1 {
|
|
|
4580
4586
|
* @method
|
|
4581
4587
|
* @name coinex#fetchFundingRates
|
|
4582
4588
|
* @description fetch the current funding rates
|
|
4583
|
-
* @see https://
|
|
4589
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
|
4584
4590
|
* @param {string[]} symbols unified market symbols
|
|
4585
4591
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4586
4592
|
* @returns {object[]} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
4587
4593
|
*/
|
|
4588
4594
|
await this.loadMarkets();
|
|
4589
4595
|
symbols = this.marketSymbols(symbols);
|
|
4596
|
+
const request = {};
|
|
4590
4597
|
let market = undefined;
|
|
4591
4598
|
if (symbols !== undefined) {
|
|
4592
4599
|
const symbol = this.safeValue(symbols, 0);
|
|
@@ -4594,55 +4601,30 @@ class coinex extends coinex$1 {
|
|
|
4594
4601
|
if (!market['swap']) {
|
|
4595
4602
|
throw new errors.BadSymbol(this.id + ' fetchFundingRates() supports swap contracts only');
|
|
4596
4603
|
}
|
|
4604
|
+
const marketIds = this.marketIds(symbols);
|
|
4605
|
+
request['market'] = marketIds.join(',');
|
|
4597
4606
|
}
|
|
4598
|
-
const response = await this.
|
|
4607
|
+
const response = await this.v2PublicGetFuturesFundingRate(this.extend(request, params));
|
|
4599
4608
|
//
|
|
4600
4609
|
// {
|
|
4601
4610
|
// "code": 0,
|
|
4602
|
-
// "data":
|
|
4603
|
-
//
|
|
4604
|
-
//
|
|
4605
|
-
//
|
|
4606
|
-
// "
|
|
4607
|
-
//
|
|
4608
|
-
//
|
|
4609
|
-
//
|
|
4610
|
-
//
|
|
4611
|
-
//
|
|
4612
|
-
// "buy": "39663.79",
|
|
4613
|
-
// "period": 86400,
|
|
4614
|
-
// "funding_time": 372,
|
|
4615
|
-
// "position_amount": "270.1956",
|
|
4616
|
-
// "funding_rate_last": "0.00022913",
|
|
4617
|
-
// "funding_rate_next": "0.00013158",
|
|
4618
|
-
// "funding_rate_predict": "0.00016552",
|
|
4619
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4620
|
-
// "sign_price": "39652.48",
|
|
4621
|
-
// "index_price": "39648.44250000",
|
|
4622
|
-
// "sell_total": "22.3913",
|
|
4623
|
-
// "buy_total": "19.4498",
|
|
4624
|
-
// "buy_amount": "12.8942",
|
|
4625
|
-
// "sell": "39663.80",
|
|
4626
|
-
// "sell_amount": "0.9388"
|
|
4627
|
-
// }
|
|
4611
|
+
// "data": [
|
|
4612
|
+
// {
|
|
4613
|
+
// "latest_funding_rate": "0",
|
|
4614
|
+
// "latest_funding_time": 1715731200000,
|
|
4615
|
+
// "mark_price": "61602.22",
|
|
4616
|
+
// "market": "BTCUSDT",
|
|
4617
|
+
// "max_funding_rate": "0.00375",
|
|
4618
|
+
// "min_funding_rate": "-0.00375",
|
|
4619
|
+
// "next_funding_rate": "0.00021074",
|
|
4620
|
+
// "next_funding_time": 1715760000000
|
|
4628
4621
|
// }
|
|
4629
|
-
//
|
|
4622
|
+
// ],
|
|
4630
4623
|
// "message": "OK"
|
|
4631
4624
|
// }
|
|
4632
|
-
|
|
4633
|
-
const
|
|
4634
|
-
const
|
|
4635
|
-
const result = [];
|
|
4636
|
-
const marketIds = Object.keys(tickers);
|
|
4637
|
-
for (let i = 0; i < marketIds.length; i++) {
|
|
4638
|
-
const marketId = marketIds[i];
|
|
4639
|
-
if (marketId.indexOf('_') === -1) { // skip _signprice and _indexprice
|
|
4640
|
-
const marketInner = this.safeMarket(marketId, undefined, undefined, 'swap');
|
|
4641
|
-
const ticker = tickers[marketId];
|
|
4642
|
-
ticker['timestamp'] = timestamp;
|
|
4643
|
-
result.push(this.parseFundingRate(ticker, marketInner));
|
|
4644
|
-
}
|
|
4645
|
-
}
|
|
4625
|
+
//
|
|
4626
|
+
const data = this.safeList(response, 'data', []);
|
|
4627
|
+
const result = this.parseFundingRates(data, market);
|
|
4646
4628
|
return this.filterByArray(result, 'symbol', symbols);
|
|
4647
4629
|
}
|
|
4648
4630
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
@@ -4716,13 +4698,13 @@ class coinex extends coinex$1 {
|
|
|
4716
4698
|
/**
|
|
4717
4699
|
* @method
|
|
4718
4700
|
* @name coinex#fetchFundingRateHistory
|
|
4719
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
|
|
4720
4701
|
* @description fetches historical funding rate prices
|
|
4702
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
|
|
4721
4703
|
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
4722
4704
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
4723
4705
|
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
4724
4706
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4725
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
4707
|
+
* @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)
|
|
4726
4708
|
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
4727
4709
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
4728
4710
|
*/
|
|
@@ -4735,52 +4717,46 @@ class coinex extends coinex$1 {
|
|
|
4735
4717
|
if (paginate) {
|
|
4736
4718
|
return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
|
|
4737
4719
|
}
|
|
4738
|
-
if (limit === undefined) {
|
|
4739
|
-
limit = 100;
|
|
4740
|
-
}
|
|
4741
4720
|
const market = this.market(symbol);
|
|
4742
4721
|
let request = {
|
|
4743
4722
|
'market': market['id'],
|
|
4744
|
-
'limit': limit,
|
|
4745
|
-
'offset': 0,
|
|
4746
|
-
// 'end_time': 1638990636,
|
|
4747
4723
|
};
|
|
4748
4724
|
if (since !== undefined) {
|
|
4749
4725
|
request['start_time'] = since;
|
|
4750
4726
|
}
|
|
4727
|
+
if (limit !== undefined) {
|
|
4728
|
+
request['limit'] = limit;
|
|
4729
|
+
}
|
|
4751
4730
|
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
4752
|
-
const response = await this.
|
|
4731
|
+
const response = await this.v2PublicGetFuturesFundingRateHistory(this.extend(request, params));
|
|
4753
4732
|
//
|
|
4754
4733
|
// {
|
|
4755
4734
|
// "code": 0,
|
|
4756
|
-
// "data":
|
|
4757
|
-
//
|
|
4758
|
-
//
|
|
4759
|
-
//
|
|
4760
|
-
//
|
|
4761
|
-
//
|
|
4762
|
-
//
|
|
4763
|
-
//
|
|
4764
|
-
//
|
|
4765
|
-
//
|
|
4766
|
-
//
|
|
4767
|
-
//
|
|
4768
|
-
// },
|
|
4769
|
-
// "message": "OK"
|
|
4735
|
+
// "data": [
|
|
4736
|
+
// {
|
|
4737
|
+
// "actual_funding_rate": "0",
|
|
4738
|
+
// "funding_time": 1715731221761,
|
|
4739
|
+
// "market": "BTCUSDT",
|
|
4740
|
+
// "theoretical_funding_rate": "0"
|
|
4741
|
+
// },
|
|
4742
|
+
// ],
|
|
4743
|
+
// "message": "OK",
|
|
4744
|
+
// "pagination": {
|
|
4745
|
+
// "has_next": true
|
|
4746
|
+
// }
|
|
4770
4747
|
// }
|
|
4771
4748
|
//
|
|
4772
|
-
const data = this.
|
|
4773
|
-
const result = this.safeValue(data, 'records', []);
|
|
4749
|
+
const data = this.safeList(response, 'data', []);
|
|
4774
4750
|
const rates = [];
|
|
4775
|
-
for (let i = 0; i <
|
|
4776
|
-
const entry =
|
|
4751
|
+
for (let i = 0; i < data.length; i++) {
|
|
4752
|
+
const entry = data[i];
|
|
4777
4753
|
const marketId = this.safeString(entry, 'market');
|
|
4778
4754
|
const symbolInner = this.safeSymbol(marketId, market, undefined, 'swap');
|
|
4779
|
-
const timestamp = this.
|
|
4755
|
+
const timestamp = this.safeInteger(entry, 'funding_time');
|
|
4780
4756
|
rates.push({
|
|
4781
4757
|
'info': entry,
|
|
4782
4758
|
'symbol': symbolInner,
|
|
4783
|
-
'fundingRate': this.safeNumber(entry, '
|
|
4759
|
+
'fundingRate': this.safeNumber(entry, 'actual_funding_rate'),
|
|
4784
4760
|
'timestamp': timestamp,
|
|
4785
4761
|
'datetime': this.iso8601(timestamp),
|
|
4786
4762
|
});
|
|
@@ -5912,7 +5888,7 @@ class coinex extends coinex$1 {
|
|
|
5912
5888
|
const code = this.safeString(response, 'code');
|
|
5913
5889
|
const data = this.safeValue(response, 'data');
|
|
5914
5890
|
const message = this.safeString(response, 'message');
|
|
5915
|
-
if ((code !== '0') || ((message !== 'Success') && (message !== 'Succeeded') && (message !== '
|
|
5891
|
+
if ((code !== '0') || ((message !== 'Success') && (message !== 'Succeeded') && (message.toLowerCase() !== 'ok') && !data)) {
|
|
5916
5892
|
const feedback = this.id + ' ' + message;
|
|
5917
5893
|
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
5918
5894
|
this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
|