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/js/src/coinex.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
import Exchange from './abstract/coinex.js';
|
|
9
|
-
import { ExchangeError, ArgumentsRequired, BadSymbol, InsufficientFunds, OrderNotFound, InvalidOrder, AuthenticationError, PermissionDenied, ExchangeNotAvailable, RequestTimeout, BadRequest, RateLimitExceeded, NotSupported } from './base/errors.js';
|
|
9
|
+
import { ExchangeError, ArgumentsRequired, BadSymbol, InsufficientFunds, OrderNotFound, InvalidOrder, AuthenticationError, PermissionDenied, ExchangeNotAvailable, RequestTimeout, BadRequest, RateLimitExceeded, NotSupported, AccountSuspended } from './base/errors.js';
|
|
10
10
|
import { Precise } from './base/Precise.js';
|
|
11
11
|
import { TICK_SIZE } from './base/functions/number.js';
|
|
12
12
|
import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
|
|
@@ -471,10 +471,53 @@ export default class coinex extends Exchange {
|
|
|
471
471
|
'36': RequestTimeout,
|
|
472
472
|
'213': RateLimitExceeded,
|
|
473
473
|
'107': InsufficientFunds,
|
|
474
|
+
'158': PermissionDenied,
|
|
474
475
|
'600': OrderNotFound,
|
|
475
476
|
'601': InvalidOrder,
|
|
476
477
|
'602': InvalidOrder,
|
|
477
478
|
'606': InvalidOrder,
|
|
479
|
+
'3008': RequestTimeout,
|
|
480
|
+
'3109': InsufficientFunds,
|
|
481
|
+
'3127': InvalidOrder,
|
|
482
|
+
'3606': InvalidOrder,
|
|
483
|
+
'3610': ExchangeError,
|
|
484
|
+
'3612': InvalidOrder,
|
|
485
|
+
'3613': InvalidOrder,
|
|
486
|
+
'3614': InvalidOrder,
|
|
487
|
+
'3615': InvalidOrder,
|
|
488
|
+
'3616': InvalidOrder,
|
|
489
|
+
'3617': InvalidOrder,
|
|
490
|
+
'3618': InvalidOrder,
|
|
491
|
+
'3619': InvalidOrder,
|
|
492
|
+
'3620': InvalidOrder,
|
|
493
|
+
'3621': InvalidOrder,
|
|
494
|
+
'3622': InvalidOrder,
|
|
495
|
+
'3627': InvalidOrder,
|
|
496
|
+
'3628': InvalidOrder,
|
|
497
|
+
'3629': InvalidOrder,
|
|
498
|
+
'3632': InvalidOrder,
|
|
499
|
+
'3633': InvalidOrder,
|
|
500
|
+
'3634': InvalidOrder,
|
|
501
|
+
'3635': InvalidOrder,
|
|
502
|
+
'4001': ExchangeNotAvailable,
|
|
503
|
+
'4002': RequestTimeout,
|
|
504
|
+
'4003': ExchangeError,
|
|
505
|
+
'4004': BadRequest,
|
|
506
|
+
'4005': AuthenticationError,
|
|
507
|
+
'4006': AuthenticationError,
|
|
508
|
+
'4007': PermissionDenied,
|
|
509
|
+
'4008': AuthenticationError,
|
|
510
|
+
'4009': ExchangeError,
|
|
511
|
+
'4010': ExchangeError,
|
|
512
|
+
'4011': PermissionDenied,
|
|
513
|
+
'4017': ExchangeError,
|
|
514
|
+
'4115': AccountSuspended,
|
|
515
|
+
'4117': BadSymbol,
|
|
516
|
+
'4123': RateLimitExceeded,
|
|
517
|
+
'4130': ExchangeError,
|
|
518
|
+
'4158': ExchangeError,
|
|
519
|
+
'4213': RateLimitExceeded,
|
|
520
|
+
'4512': PermissionDenied, // Insufficient sub-account permissions, please check.
|
|
478
521
|
},
|
|
479
522
|
'broad': {
|
|
480
523
|
'ip not allow visit': PermissionDenied,
|
|
@@ -4397,8 +4440,8 @@ export default class coinex extends Exchange {
|
|
|
4397
4440
|
/**
|
|
4398
4441
|
* @method
|
|
4399
4442
|
* @name coinex#fetchFundingHistory
|
|
4400
|
-
* @description fetch the history of funding payments paid and received on this account
|
|
4401
|
-
* @see https://
|
|
4443
|
+
* @description fetch the history of funding fee payments paid and received on this account
|
|
4444
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/list-position-funding-history
|
|
4402
4445
|
* @param {string} symbol unified market symbol
|
|
4403
4446
|
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
4404
4447
|
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
@@ -4408,54 +4451,47 @@ export default class coinex extends Exchange {
|
|
|
4408
4451
|
if (symbol === undefined) {
|
|
4409
4452
|
throw new ArgumentsRequired(this.id + ' fetchFundingHistory() requires a symbol argument');
|
|
4410
4453
|
}
|
|
4411
|
-
limit = (limit === undefined) ? 100 : limit;
|
|
4412
4454
|
await this.loadMarkets();
|
|
4413
4455
|
const market = this.market(symbol);
|
|
4414
|
-
|
|
4456
|
+
let request = {
|
|
4415
4457
|
'market': market['id'],
|
|
4416
|
-
'
|
|
4417
|
-
// 'offset': 0,
|
|
4418
|
-
// 'end_time': 1638990636000,
|
|
4419
|
-
// 'windowtime': 1638990636000,
|
|
4458
|
+
'market_type': 'FUTURES',
|
|
4420
4459
|
};
|
|
4460
|
+
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
4421
4461
|
if (since !== undefined) {
|
|
4422
4462
|
request['start_time'] = since;
|
|
4423
4463
|
}
|
|
4424
|
-
|
|
4464
|
+
if (limit !== undefined) {
|
|
4465
|
+
request['limit'] = limit;
|
|
4466
|
+
}
|
|
4467
|
+
const response = await this.v2PrivateGetFuturesPositionFundingHistory(this.extend(request, params));
|
|
4425
4468
|
//
|
|
4426
4469
|
// {
|
|
4427
4470
|
// "code": 0,
|
|
4428
|
-
// "data":
|
|
4429
|
-
//
|
|
4430
|
-
//
|
|
4431
|
-
//
|
|
4432
|
-
//
|
|
4433
|
-
//
|
|
4434
|
-
//
|
|
4435
|
-
//
|
|
4436
|
-
//
|
|
4437
|
-
//
|
|
4438
|
-
//
|
|
4439
|
-
//
|
|
4440
|
-
//
|
|
4441
|
-
//
|
|
4442
|
-
//
|
|
4443
|
-
//
|
|
4444
|
-
// "user_id": 3620173,
|
|
4445
|
-
// "value": "47.76294"
|
|
4446
|
-
// },
|
|
4447
|
-
// ]
|
|
4448
|
-
// },
|
|
4449
|
-
// "message": "OK"
|
|
4471
|
+
// "data": [
|
|
4472
|
+
// {
|
|
4473
|
+
// "ccy": "USDT",
|
|
4474
|
+
// "created_at": 1715673620183,
|
|
4475
|
+
// "funding_rate": "0",
|
|
4476
|
+
// "funding_value": "0",
|
|
4477
|
+
// "market": "BTCUSDT",
|
|
4478
|
+
// "market_type": "FUTURES",
|
|
4479
|
+
// "position_id": 306458800,
|
|
4480
|
+
// "side": "long"
|
|
4481
|
+
// },
|
|
4482
|
+
// ],
|
|
4483
|
+
// "message": "OK",
|
|
4484
|
+
// "pagination": {
|
|
4485
|
+
// "has_next": true
|
|
4486
|
+
// }
|
|
4450
4487
|
// }
|
|
4451
4488
|
//
|
|
4452
|
-
const data = this.
|
|
4453
|
-
const resultList = this.safeValue(data, 'records', []);
|
|
4489
|
+
const data = this.safeList(response, 'data', []);
|
|
4454
4490
|
const result = [];
|
|
4455
|
-
for (let i = 0; i <
|
|
4456
|
-
const entry =
|
|
4457
|
-
const timestamp = this.
|
|
4458
|
-
const currencyId = this.safeString(entry, '
|
|
4491
|
+
for (let i = 0; i < data.length; i++) {
|
|
4492
|
+
const entry = data[i];
|
|
4493
|
+
const timestamp = this.safeInteger(entry, 'created_at');
|
|
4494
|
+
const currencyId = this.safeString(entry, 'ccy');
|
|
4459
4495
|
const code = this.safeCurrencyCode(currencyId);
|
|
4460
4496
|
result.push({
|
|
4461
4497
|
'info': entry,
|
|
@@ -4464,7 +4500,7 @@ export default class coinex extends Exchange {
|
|
|
4464
4500
|
'timestamp': timestamp,
|
|
4465
4501
|
'datetime': this.iso8601(timestamp),
|
|
4466
4502
|
'id': this.safeNumber(entry, 'position_id'),
|
|
4467
|
-
'amount': this.safeNumber(entry, '
|
|
4503
|
+
'amount': this.safeNumber(entry, 'funding_value'),
|
|
4468
4504
|
});
|
|
4469
4505
|
}
|
|
4470
4506
|
return result;
|
|
@@ -4474,7 +4510,7 @@ export default class coinex extends Exchange {
|
|
|
4474
4510
|
* @method
|
|
4475
4511
|
* @name coinex#fetchFundingRate
|
|
4476
4512
|
* @description fetch the current funding rate
|
|
4477
|
-
* @see https://
|
|
4513
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
|
4478
4514
|
* @param {string} symbol unified market symbol
|
|
4479
4515
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4480
4516
|
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
@@ -4487,93 +4523,63 @@ export default class coinex extends Exchange {
|
|
|
4487
4523
|
const request = {
|
|
4488
4524
|
'market': market['id'],
|
|
4489
4525
|
};
|
|
4490
|
-
const response = await this.
|
|
4526
|
+
const response = await this.v2PublicGetFuturesFundingRate(this.extend(request, params));
|
|
4491
4527
|
//
|
|
4492
4528
|
// {
|
|
4493
|
-
//
|
|
4494
|
-
// "data":
|
|
4495
|
-
//
|
|
4496
|
-
//
|
|
4497
|
-
//
|
|
4498
|
-
// "
|
|
4499
|
-
// "
|
|
4500
|
-
// "
|
|
4501
|
-
// "
|
|
4502
|
-
// "
|
|
4503
|
-
// "
|
|
4504
|
-
// "period": 86400,
|
|
4505
|
-
// "funding_time": 372,
|
|
4506
|
-
// "position_amount": "270.1956",
|
|
4507
|
-
// "funding_rate_last": "0.00022913",
|
|
4508
|
-
// "funding_rate_next": "0.00013158",
|
|
4509
|
-
// "funding_rate_predict": "0.00016552",
|
|
4510
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4511
|
-
// "sign_price": "39652.48",
|
|
4512
|
-
// "index_price": "39648.44250000",
|
|
4513
|
-
// "sell_total": "22.3913",
|
|
4514
|
-
// "buy_total": "19.4498",
|
|
4515
|
-
// "buy_amount": "12.8942",
|
|
4516
|
-
// "sell": "39663.80",
|
|
4517
|
-
// "sell_amount": "0.9388"
|
|
4529
|
+
// "code": 0,
|
|
4530
|
+
// "data": [
|
|
4531
|
+
// {
|
|
4532
|
+
// "latest_funding_rate": "0",
|
|
4533
|
+
// "latest_funding_time": 1715731200000,
|
|
4534
|
+
// "mark_price": "61602.22",
|
|
4535
|
+
// "market": "BTCUSDT",
|
|
4536
|
+
// "max_funding_rate": "0.00375",
|
|
4537
|
+
// "min_funding_rate": "-0.00375",
|
|
4538
|
+
// "next_funding_rate": "0.00021074",
|
|
4539
|
+
// "next_funding_time": 1715760000000
|
|
4518
4540
|
// }
|
|
4519
|
-
//
|
|
4541
|
+
// ],
|
|
4520
4542
|
// "message": "OK"
|
|
4521
4543
|
// }
|
|
4522
4544
|
//
|
|
4523
|
-
const data = this.
|
|
4524
|
-
const
|
|
4525
|
-
|
|
4526
|
-
ticker['timestamp'] = timestamp; // avoid changing parseFundingRate signature
|
|
4527
|
-
return this.parseFundingRate(ticker, market);
|
|
4545
|
+
const data = this.safeList(response, 'data', []);
|
|
4546
|
+
const first = this.safeDict(data, 0, {});
|
|
4547
|
+
return this.parseFundingRate(first, market);
|
|
4528
4548
|
}
|
|
4529
4549
|
parseFundingRate(contract, market = undefined) {
|
|
4530
4550
|
//
|
|
4531
|
-
// fetchFundingRate
|
|
4551
|
+
// fetchFundingRate, fetchFundingRates
|
|
4532
4552
|
//
|
|
4533
4553
|
// {
|
|
4534
|
-
// "
|
|
4535
|
-
// "
|
|
4536
|
-
// "
|
|
4537
|
-
// "
|
|
4538
|
-
// "
|
|
4539
|
-
// "
|
|
4540
|
-
// "
|
|
4541
|
-
// "
|
|
4542
|
-
// "position_amount": "270.1956",
|
|
4543
|
-
// "funding_rate_last": "0.00022913",
|
|
4544
|
-
// "funding_rate_next": "0.00013158",
|
|
4545
|
-
// "funding_rate_predict": "0.00016552",
|
|
4546
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4547
|
-
// "sign_price": "39652.48",
|
|
4548
|
-
// "index_price": "39648.44250000",
|
|
4549
|
-
// "sell_total": "22.3913",
|
|
4550
|
-
// "buy_total": "19.4498",
|
|
4551
|
-
// "buy_amount": "12.8942",
|
|
4552
|
-
// "sell": "39663.80",
|
|
4553
|
-
// "sell_amount": "0.9388"
|
|
4554
|
+
// "latest_funding_rate": "0",
|
|
4555
|
+
// "latest_funding_time": 1715731200000,
|
|
4556
|
+
// "mark_price": "61602.22",
|
|
4557
|
+
// "market": "BTCUSDT",
|
|
4558
|
+
// "max_funding_rate": "0.00375",
|
|
4559
|
+
// "min_funding_rate": "-0.00375",
|
|
4560
|
+
// "next_funding_rate": "0.00021074",
|
|
4561
|
+
// "next_funding_time": 1715760000000
|
|
4554
4562
|
// }
|
|
4555
4563
|
//
|
|
4556
|
-
const
|
|
4557
|
-
|
|
4558
|
-
const
|
|
4559
|
-
const fundingHour = (timestamp + fundingDelta) / 3600000;
|
|
4560
|
-
const fundingTimestamp = Math.round(fundingHour) * 3600000;
|
|
4564
|
+
const currentFundingTimestamp = this.safeInteger(contract, 'latest_funding_time');
|
|
4565
|
+
const futureFundingTimestamp = this.safeInteger(contract, 'next_funding_time');
|
|
4566
|
+
const marketId = this.safeString(contract, 'market');
|
|
4561
4567
|
return {
|
|
4562
4568
|
'info': contract,
|
|
4563
|
-
'symbol': this.safeSymbol(undefined,
|
|
4564
|
-
'markPrice': this.safeNumber(contract, '
|
|
4565
|
-
'indexPrice':
|
|
4569
|
+
'symbol': this.safeSymbol(marketId, market, undefined, 'swap'),
|
|
4570
|
+
'markPrice': this.safeNumber(contract, 'mark_price'),
|
|
4571
|
+
'indexPrice': undefined,
|
|
4566
4572
|
'interestRate': undefined,
|
|
4567
4573
|
'estimatedSettlePrice': undefined,
|
|
4568
|
-
'timestamp':
|
|
4569
|
-
'datetime':
|
|
4570
|
-
'fundingRate': this.safeNumber(contract, '
|
|
4571
|
-
'fundingTimestamp':
|
|
4572
|
-
'fundingDatetime': this.iso8601(
|
|
4573
|
-
'nextFundingRate': this.safeNumber(contract, '
|
|
4574
|
-
'nextFundingTimestamp':
|
|
4575
|
-
'nextFundingDatetime':
|
|
4576
|
-
'previousFundingRate':
|
|
4574
|
+
'timestamp': undefined,
|
|
4575
|
+
'datetime': undefined,
|
|
4576
|
+
'fundingRate': this.safeNumber(contract, 'latest_funding_rate'),
|
|
4577
|
+
'fundingTimestamp': currentFundingTimestamp,
|
|
4578
|
+
'fundingDatetime': this.iso8601(currentFundingTimestamp),
|
|
4579
|
+
'nextFundingRate': this.safeNumber(contract, 'next_funding_rate'),
|
|
4580
|
+
'nextFundingTimestamp': futureFundingTimestamp,
|
|
4581
|
+
'nextFundingDatetime': this.iso8601(futureFundingTimestamp),
|
|
4582
|
+
'previousFundingRate': undefined,
|
|
4577
4583
|
'previousFundingTimestamp': undefined,
|
|
4578
4584
|
'previousFundingDatetime': undefined,
|
|
4579
4585
|
};
|
|
@@ -4583,13 +4589,14 @@ export default class coinex extends Exchange {
|
|
|
4583
4589
|
* @method
|
|
4584
4590
|
* @name coinex#fetchFundingRates
|
|
4585
4591
|
* @description fetch the current funding rates
|
|
4586
|
-
* @see https://
|
|
4592
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate
|
|
4587
4593
|
* @param {string[]} symbols unified market symbols
|
|
4588
4594
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4589
4595
|
* @returns {object[]} an array of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-structure}
|
|
4590
4596
|
*/
|
|
4591
4597
|
await this.loadMarkets();
|
|
4592
4598
|
symbols = this.marketSymbols(symbols);
|
|
4599
|
+
const request = {};
|
|
4593
4600
|
let market = undefined;
|
|
4594
4601
|
if (symbols !== undefined) {
|
|
4595
4602
|
const symbol = this.safeValue(symbols, 0);
|
|
@@ -4597,55 +4604,30 @@ export default class coinex extends Exchange {
|
|
|
4597
4604
|
if (!market['swap']) {
|
|
4598
4605
|
throw new BadSymbol(this.id + ' fetchFundingRates() supports swap contracts only');
|
|
4599
4606
|
}
|
|
4607
|
+
const marketIds = this.marketIds(symbols);
|
|
4608
|
+
request['market'] = marketIds.join(',');
|
|
4600
4609
|
}
|
|
4601
|
-
const response = await this.
|
|
4610
|
+
const response = await this.v2PublicGetFuturesFundingRate(this.extend(request, params));
|
|
4602
4611
|
//
|
|
4603
4612
|
// {
|
|
4604
4613
|
// "code": 0,
|
|
4605
|
-
// "data":
|
|
4606
|
-
//
|
|
4607
|
-
//
|
|
4608
|
-
//
|
|
4609
|
-
// "
|
|
4610
|
-
//
|
|
4611
|
-
//
|
|
4612
|
-
//
|
|
4613
|
-
//
|
|
4614
|
-
//
|
|
4615
|
-
// "buy": "39663.79",
|
|
4616
|
-
// "period": 86400,
|
|
4617
|
-
// "funding_time": 372,
|
|
4618
|
-
// "position_amount": "270.1956",
|
|
4619
|
-
// "funding_rate_last": "0.00022913",
|
|
4620
|
-
// "funding_rate_next": "0.00013158",
|
|
4621
|
-
// "funding_rate_predict": "0.00016552",
|
|
4622
|
-
// "insurance": "16045554.83969682659674035672",
|
|
4623
|
-
// "sign_price": "39652.48",
|
|
4624
|
-
// "index_price": "39648.44250000",
|
|
4625
|
-
// "sell_total": "22.3913",
|
|
4626
|
-
// "buy_total": "19.4498",
|
|
4627
|
-
// "buy_amount": "12.8942",
|
|
4628
|
-
// "sell": "39663.80",
|
|
4629
|
-
// "sell_amount": "0.9388"
|
|
4630
|
-
// }
|
|
4614
|
+
// "data": [
|
|
4615
|
+
// {
|
|
4616
|
+
// "latest_funding_rate": "0",
|
|
4617
|
+
// "latest_funding_time": 1715731200000,
|
|
4618
|
+
// "mark_price": "61602.22",
|
|
4619
|
+
// "market": "BTCUSDT",
|
|
4620
|
+
// "max_funding_rate": "0.00375",
|
|
4621
|
+
// "min_funding_rate": "-0.00375",
|
|
4622
|
+
// "next_funding_rate": "0.00021074",
|
|
4623
|
+
// "next_funding_time": 1715760000000
|
|
4631
4624
|
// }
|
|
4632
|
-
//
|
|
4625
|
+
// ],
|
|
4633
4626
|
// "message": "OK"
|
|
4634
4627
|
// }
|
|
4635
|
-
|
|
4636
|
-
const
|
|
4637
|
-
const
|
|
4638
|
-
const result = [];
|
|
4639
|
-
const marketIds = Object.keys(tickers);
|
|
4640
|
-
for (let i = 0; i < marketIds.length; i++) {
|
|
4641
|
-
const marketId = marketIds[i];
|
|
4642
|
-
if (marketId.indexOf('_') === -1) { // skip _signprice and _indexprice
|
|
4643
|
-
const marketInner = this.safeMarket(marketId, undefined, undefined, 'swap');
|
|
4644
|
-
const ticker = tickers[marketId];
|
|
4645
|
-
ticker['timestamp'] = timestamp;
|
|
4646
|
-
result.push(this.parseFundingRate(ticker, marketInner));
|
|
4647
|
-
}
|
|
4648
|
-
}
|
|
4628
|
+
//
|
|
4629
|
+
const data = this.safeList(response, 'data', []);
|
|
4630
|
+
const result = this.parseFundingRates(data, market);
|
|
4649
4631
|
return this.filterByArray(result, 'symbol', symbols);
|
|
4650
4632
|
}
|
|
4651
4633
|
async withdraw(code, amount, address, tag = undefined, params = {}) {
|
|
@@ -4719,13 +4701,13 @@ export default class coinex extends Exchange {
|
|
|
4719
4701
|
/**
|
|
4720
4702
|
* @method
|
|
4721
4703
|
* @name coinex#fetchFundingRateHistory
|
|
4722
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http038_funding_history
|
|
4723
4704
|
* @description fetches historical funding rate prices
|
|
4705
|
+
* @see https://docs.coinex.com/api/v2/futures/market/http/list-market-funding-rate-history
|
|
4724
4706
|
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
|
|
4725
4707
|
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
|
|
4726
4708
|
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure} to fetch
|
|
4727
4709
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4728
|
-
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [
|
|
4710
|
+
* @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)
|
|
4729
4711
|
* @param {int} [params.until] timestamp in ms of the latest funding rate
|
|
4730
4712
|
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/#/?id=funding-rate-history-structure}
|
|
4731
4713
|
*/
|
|
@@ -4738,52 +4720,46 @@ export default class coinex extends Exchange {
|
|
|
4738
4720
|
if (paginate) {
|
|
4739
4721
|
return await this.fetchPaginatedCallDeterministic('fetchFundingRateHistory', symbol, since, limit, '8h', params, 1000);
|
|
4740
4722
|
}
|
|
4741
|
-
if (limit === undefined) {
|
|
4742
|
-
limit = 100;
|
|
4743
|
-
}
|
|
4744
4723
|
const market = this.market(symbol);
|
|
4745
4724
|
let request = {
|
|
4746
4725
|
'market': market['id'],
|
|
4747
|
-
'limit': limit,
|
|
4748
|
-
'offset': 0,
|
|
4749
|
-
// 'end_time': 1638990636,
|
|
4750
4726
|
};
|
|
4751
4727
|
if (since !== undefined) {
|
|
4752
4728
|
request['start_time'] = since;
|
|
4753
4729
|
}
|
|
4730
|
+
if (limit !== undefined) {
|
|
4731
|
+
request['limit'] = limit;
|
|
4732
|
+
}
|
|
4754
4733
|
[request, params] = this.handleUntilOption('end_time', request, params);
|
|
4755
|
-
const response = await this.
|
|
4734
|
+
const response = await this.v2PublicGetFuturesFundingRateHistory(this.extend(request, params));
|
|
4756
4735
|
//
|
|
4757
4736
|
// {
|
|
4758
4737
|
// "code": 0,
|
|
4759
|
-
// "data":
|
|
4760
|
-
//
|
|
4761
|
-
//
|
|
4762
|
-
//
|
|
4763
|
-
//
|
|
4764
|
-
//
|
|
4765
|
-
//
|
|
4766
|
-
//
|
|
4767
|
-
//
|
|
4768
|
-
//
|
|
4769
|
-
//
|
|
4770
|
-
//
|
|
4771
|
-
// },
|
|
4772
|
-
// "message": "OK"
|
|
4738
|
+
// "data": [
|
|
4739
|
+
// {
|
|
4740
|
+
// "actual_funding_rate": "0",
|
|
4741
|
+
// "funding_time": 1715731221761,
|
|
4742
|
+
// "market": "BTCUSDT",
|
|
4743
|
+
// "theoretical_funding_rate": "0"
|
|
4744
|
+
// },
|
|
4745
|
+
// ],
|
|
4746
|
+
// "message": "OK",
|
|
4747
|
+
// "pagination": {
|
|
4748
|
+
// "has_next": true
|
|
4749
|
+
// }
|
|
4773
4750
|
// }
|
|
4774
4751
|
//
|
|
4775
|
-
const data = this.
|
|
4776
|
-
const result = this.safeValue(data, 'records', []);
|
|
4752
|
+
const data = this.safeList(response, 'data', []);
|
|
4777
4753
|
const rates = [];
|
|
4778
|
-
for (let i = 0; i <
|
|
4779
|
-
const entry =
|
|
4754
|
+
for (let i = 0; i < data.length; i++) {
|
|
4755
|
+
const entry = data[i];
|
|
4780
4756
|
const marketId = this.safeString(entry, 'market');
|
|
4781
4757
|
const symbolInner = this.safeSymbol(marketId, market, undefined, 'swap');
|
|
4782
|
-
const timestamp = this.
|
|
4758
|
+
const timestamp = this.safeInteger(entry, 'funding_time');
|
|
4783
4759
|
rates.push({
|
|
4784
4760
|
'info': entry,
|
|
4785
4761
|
'symbol': symbolInner,
|
|
4786
|
-
'fundingRate': this.safeNumber(entry, '
|
|
4762
|
+
'fundingRate': this.safeNumber(entry, 'actual_funding_rate'),
|
|
4787
4763
|
'timestamp': timestamp,
|
|
4788
4764
|
'datetime': this.iso8601(timestamp),
|
|
4789
4765
|
});
|
|
@@ -5915,7 +5891,7 @@ export default class coinex extends Exchange {
|
|
|
5915
5891
|
const code = this.safeString(response, 'code');
|
|
5916
5892
|
const data = this.safeValue(response, 'data');
|
|
5917
5893
|
const message = this.safeString(response, 'message');
|
|
5918
|
-
if ((code !== '0') || ((message !== 'Success') && (message !== 'Succeeded') && (message !== '
|
|
5894
|
+
if ((code !== '0') || ((message !== 'Success') && (message !== 'Succeeded') && (message.toLowerCase() !== 'ok') && !data)) {
|
|
5919
5895
|
const feedback = this.id + ' ' + message;
|
|
5920
5896
|
this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
|
|
5921
5897
|
this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
|
package/js/src/phemex.d.ts
CHANGED
|
@@ -61,6 +61,7 @@ export default class phemex extends Exchange {
|
|
|
61
61
|
fetchPositions(symbols?: Strings, params?: {}): Promise<import("./base/types.js").Position[]>;
|
|
62
62
|
parsePosition(position: any, market?: Market): import("./base/types.js").Position;
|
|
63
63
|
fetchFundingHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingHistory[]>;
|
|
64
|
+
parseFundingFeeToPrecision(value: any, market?: Market, currencyCode?: Str): any;
|
|
64
65
|
fetchFundingRate(symbol: string, params?: {}): Promise<{
|
|
65
66
|
info: any;
|
|
66
67
|
symbol: string;
|