ccxt 4.1.29 → 4.1.31
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/CHANGELOG.md +186 -0
- package/README.md +3 -3
- package/dist/ccxt.browser.js +474 -135
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ascendex.js +89 -12
- package/dist/cjs/src/base/Exchange.js +6 -0
- package/dist/cjs/src/base/ws/Future.js +6 -2
- package/dist/cjs/src/bitget.js +187 -44
- package/dist/cjs/src/bitopro.js +5 -4
- package/dist/cjs/src/bitrue.js +33 -18
- package/dist/cjs/src/bitvavo.js +43 -7
- package/dist/cjs/src/bybit.js +0 -3
- package/dist/cjs/src/coinex.js +2 -1
- package/dist/cjs/src/gate.js +58 -10
- package/dist/cjs/src/gemini.js +1 -2
- package/dist/cjs/src/hitbtc.js +32 -22
- package/dist/cjs/src/huobi.js +0 -1
- package/dist/cjs/src/huobijp.js +0 -1
- package/dist/cjs/src/krakenfutures.js +1 -1
- package/dist/cjs/src/mexc.js +2 -6
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/phemex.js +3 -0
- package/dist/cjs/src/pro/huobi.js +4 -0
- package/js/ccxt.d.ts +3 -3
- package/js/ccxt.js +1 -1
- package/js/src/ascendex.d.ts +11 -1
- package/js/src/ascendex.js +89 -12
- package/js/src/base/Exchange.d.ts +5 -3
- package/js/src/base/Exchange.js +6 -0
- package/js/src/base/types.d.ts +9 -0
- package/js/src/base/ws/Future.js +6 -2
- package/js/src/binance.d.ts +1 -1
- package/js/src/bitget.d.ts +3 -3
- package/js/src/bitget.js +187 -44
- package/js/src/bitopro.js +5 -4
- package/js/src/bitrue.js +33 -18
- package/js/src/bitvavo.d.ts +13 -13
- package/js/src/bitvavo.js +43 -7
- package/js/src/bybit.js +0 -3
- package/js/src/coinex.d.ts +2 -2
- package/js/src/coinex.js +2 -1
- package/js/src/gate.d.ts +3 -3
- package/js/src/gate.js +58 -10
- package/js/src/gemini.js +1 -2
- package/js/src/hitbtc.js +33 -23
- package/js/src/huobi.d.ts +1 -1
- package/js/src/huobi.js +0 -1
- package/js/src/huobijp.js +0 -1
- package/js/src/krakenfutures.js +1 -1
- package/js/src/kucoinfutures.d.ts +2 -2
- package/js/src/mexc.d.ts +2 -2
- package/js/src/mexc.js +2 -6
- package/js/src/okx.d.ts +2 -2
- package/js/src/okx.js +1 -0
- package/js/src/phemex.d.ts +2 -2
- package/js/src/phemex.js +3 -0
- package/js/src/poloniexfutures.d.ts +2 -2
- package/js/src/pro/huobi.js +4 -0
- package/js/src/woo.d.ts +1 -1
- package/package.json +2 -2
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.1.
|
|
183
|
+
const version = '4.1.31';
|
|
184
184
|
Exchange["default"].ccxtVersion = version;
|
|
185
185
|
const exchanges = {
|
|
186
186
|
'ace': ace,
|
package/dist/cjs/src/ascendex.js
CHANGED
|
@@ -29,7 +29,7 @@ class ascendex extends ascendex$1 {
|
|
|
29
29
|
'spot': true,
|
|
30
30
|
'margin': true,
|
|
31
31
|
'swap': true,
|
|
32
|
-
'future':
|
|
32
|
+
'future': false,
|
|
33
33
|
'option': false,
|
|
34
34
|
'addMargin': true,
|
|
35
35
|
'cancelAllOrders': true,
|
|
@@ -51,7 +51,7 @@ class ascendex extends ascendex$1 {
|
|
|
51
51
|
'fetchDepositsWithdrawals': true,
|
|
52
52
|
'fetchDepositWithdrawFee': 'emulated',
|
|
53
53
|
'fetchDepositWithdrawFees': true,
|
|
54
|
-
'fetchFundingHistory':
|
|
54
|
+
'fetchFundingHistory': true,
|
|
55
55
|
'fetchFundingRate': 'emulated',
|
|
56
56
|
'fetchFundingRateHistory': false,
|
|
57
57
|
'fetchFundingRates': true,
|
|
@@ -265,7 +265,6 @@ class ascendex extends ascendex$1 {
|
|
|
265
265
|
'accountsByType': {
|
|
266
266
|
'spot': 'cash',
|
|
267
267
|
'swap': 'futures',
|
|
268
|
-
'future': 'futures',
|
|
269
268
|
'margin': 'margin',
|
|
270
269
|
},
|
|
271
270
|
'transfer': {
|
|
@@ -2763,22 +2762,21 @@ class ascendex extends ascendex$1 {
|
|
|
2763
2762
|
* @method
|
|
2764
2763
|
* @name ascendex#setLeverage
|
|
2765
2764
|
* @description set the level of leverage for a market
|
|
2765
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-contract-leverage
|
|
2766
2766
|
* @param {float} leverage the rate of leverage
|
|
2767
2767
|
* @param {string} symbol unified market symbol
|
|
2768
2768
|
* @param {object} [params] extra parameters specific to the ascendex api endpoint
|
|
2769
2769
|
* @returns {object} response from the exchange
|
|
2770
2770
|
*/
|
|
2771
|
-
|
|
2772
|
-
throw new errors.ArgumentsRequired(this.id + ' setLeverage() requires a symbol argument');
|
|
2773
|
-
}
|
|
2771
|
+
this.checkRequiredSymbol('setLeverage', symbol);
|
|
2774
2772
|
if ((leverage < 1) || (leverage > 100)) {
|
|
2775
2773
|
throw new errors.BadRequest(this.id + ' leverage should be between 1 and 100');
|
|
2776
2774
|
}
|
|
2777
2775
|
await this.loadMarkets();
|
|
2778
2776
|
await this.loadAccounts();
|
|
2779
2777
|
const market = this.market(symbol);
|
|
2780
|
-
if (market['
|
|
2781
|
-
throw new errors.BadSymbol(this.id + ' setLeverage() supports
|
|
2778
|
+
if (!market['swap']) {
|
|
2779
|
+
throw new errors.BadSymbol(this.id + ' setLeverage() supports swap contracts only');
|
|
2782
2780
|
}
|
|
2783
2781
|
const account = this.safeValue(this.accounts, 0, {});
|
|
2784
2782
|
const accountGroup = this.safeString(account, 'id');
|
|
@@ -2794,11 +2792,13 @@ class ascendex extends ascendex$1 {
|
|
|
2794
2792
|
* @method
|
|
2795
2793
|
* @name ascendex#setMarginMode
|
|
2796
2794
|
* @description set margin mode to 'cross' or 'isolated'
|
|
2795
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#change-margin-type
|
|
2797
2796
|
* @param {string} marginMode 'cross' or 'isolated'
|
|
2798
2797
|
* @param {string} symbol unified market symbol
|
|
2799
2798
|
* @param {object} [params] extra parameters specific to the ascendex api endpoint
|
|
2800
2799
|
* @returns {object} response from the exchange
|
|
2801
2800
|
*/
|
|
2801
|
+
this.checkRequiredSymbol('setMarginMode', symbol);
|
|
2802
2802
|
marginMode = marginMode.toLowerCase();
|
|
2803
2803
|
if (marginMode === 'cross') {
|
|
2804
2804
|
marginMode = 'crossed';
|
|
@@ -2814,10 +2814,10 @@ class ascendex extends ascendex$1 {
|
|
|
2814
2814
|
const request = {
|
|
2815
2815
|
'account-group': accountGroup,
|
|
2816
2816
|
'symbol': market['id'],
|
|
2817
|
-
'
|
|
2817
|
+
'marginType': marginMode,
|
|
2818
2818
|
};
|
|
2819
|
-
if (market['
|
|
2820
|
-
throw new errors.BadSymbol(this.id + ' setMarginMode() supports
|
|
2819
|
+
if (!market['swap']) {
|
|
2820
|
+
throw new errors.BadSymbol(this.id + ' setMarginMode() supports swap contracts only');
|
|
2821
2821
|
}
|
|
2822
2822
|
return await this.v2PrivateAccountGroupPostFuturesMarginType(this.extend(request, params));
|
|
2823
2823
|
}
|
|
@@ -2998,7 +2998,7 @@ class ascendex extends ascendex$1 {
|
|
|
2998
2998
|
const fromId = this.safeString(accountsByType, fromAccount, fromAccount);
|
|
2999
2999
|
const toId = this.safeString(accountsByType, toAccount, toAccount);
|
|
3000
3000
|
if (fromId !== 'cash' && toId !== 'cash') {
|
|
3001
|
-
throw new errors.ExchangeError(this.id + ' transfer() only supports direct balance transfer between spot and
|
|
3001
|
+
throw new errors.ExchangeError(this.id + ' transfer() only supports direct balance transfer between spot and swap, spot and margin');
|
|
3002
3002
|
}
|
|
3003
3003
|
const request = {
|
|
3004
3004
|
'account-group': accountGroup,
|
|
@@ -3047,6 +3047,83 @@ class ascendex extends ascendex$1 {
|
|
|
3047
3047
|
}
|
|
3048
3048
|
return 'failed';
|
|
3049
3049
|
}
|
|
3050
|
+
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3051
|
+
/**
|
|
3052
|
+
* @method
|
|
3053
|
+
* @name ascendex#fetchFundingHistory
|
|
3054
|
+
* @description fetch the history of funding payments paid and received on this account
|
|
3055
|
+
* @see https://ascendex.github.io/ascendex-futures-pro-api-v2/#funding-payment-history
|
|
3056
|
+
* @param {string} [symbol] unified market symbol
|
|
3057
|
+
* @param {int} [since] the earliest time in ms to fetch funding history for
|
|
3058
|
+
* @param {int} [limit] the maximum number of funding history structures to retrieve
|
|
3059
|
+
* @param {object} [params] extra parameters specific to the ascendex api endpoint
|
|
3060
|
+
* @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)
|
|
3061
|
+
* @returns {object} a [funding history structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-history-structure}
|
|
3062
|
+
*/
|
|
3063
|
+
await this.loadMarkets();
|
|
3064
|
+
await this.loadAccounts();
|
|
3065
|
+
let paginate = false;
|
|
3066
|
+
[paginate, params] = this.handleOptionAndParams(params, 'fetchFundingHistory', 'paginate');
|
|
3067
|
+
if (paginate) {
|
|
3068
|
+
return await this.fetchPaginatedCallIncremental('fetchFundingHistory', symbol, since, limit, params, 'page', 25);
|
|
3069
|
+
}
|
|
3070
|
+
const account = this.safeValue(this.accounts, 0, {});
|
|
3071
|
+
const accountGroup = this.safeString(account, 'id');
|
|
3072
|
+
const request = {
|
|
3073
|
+
'account-group': accountGroup,
|
|
3074
|
+
};
|
|
3075
|
+
let market = undefined;
|
|
3076
|
+
if (symbol !== undefined) {
|
|
3077
|
+
market = this.market(symbol);
|
|
3078
|
+
request['symbol'] = market['id'];
|
|
3079
|
+
}
|
|
3080
|
+
if (limit !== undefined) {
|
|
3081
|
+
request['pageSize'] = limit;
|
|
3082
|
+
}
|
|
3083
|
+
const response = await this.v2PrivateAccountGroupGetFuturesFundingPayments(this.extend(request, params));
|
|
3084
|
+
//
|
|
3085
|
+
// {
|
|
3086
|
+
// "code": 0,
|
|
3087
|
+
// "data": {
|
|
3088
|
+
// "data": [
|
|
3089
|
+
// {
|
|
3090
|
+
// "timestamp": 1640476800000,
|
|
3091
|
+
// "symbol": "BTC-PERP",
|
|
3092
|
+
// "paymentInUSDT": "-0.013991178",
|
|
3093
|
+
// "fundingRate": "0.000173497"
|
|
3094
|
+
// },
|
|
3095
|
+
// ],
|
|
3096
|
+
// "page": 1,
|
|
3097
|
+
// "pageSize": 3,
|
|
3098
|
+
// "hasNext": true
|
|
3099
|
+
// }
|
|
3100
|
+
// }
|
|
3101
|
+
//
|
|
3102
|
+
const data = this.safeValue(response, 'data', {});
|
|
3103
|
+
const rows = this.safeValue(data, 'data', []);
|
|
3104
|
+
return this.parseIncomes(rows, market, since, limit);
|
|
3105
|
+
}
|
|
3106
|
+
parseIncome(income, market = undefined) {
|
|
3107
|
+
//
|
|
3108
|
+
// {
|
|
3109
|
+
// "timestamp": 1640476800000,
|
|
3110
|
+
// "symbol": "BTC-PERP",
|
|
3111
|
+
// "paymentInUSDT": "-0.013991178",
|
|
3112
|
+
// "fundingRate": "0.000173497"
|
|
3113
|
+
// }
|
|
3114
|
+
//
|
|
3115
|
+
const marketId = this.safeString(income, 'symbol');
|
|
3116
|
+
const timestamp = this.safeInteger(income, 'timestamp');
|
|
3117
|
+
return {
|
|
3118
|
+
'info': income,
|
|
3119
|
+
'symbol': this.safeSymbol(marketId, market, '-', 'swap'),
|
|
3120
|
+
'code': 'USDT',
|
|
3121
|
+
'timestamp': timestamp,
|
|
3122
|
+
'datetime': this.iso8601(timestamp),
|
|
3123
|
+
'id': undefined,
|
|
3124
|
+
'amount': this.safeNumber(income, 'paymentInUSDT'),
|
|
3125
|
+
};
|
|
3126
|
+
}
|
|
3050
3127
|
sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
|
|
3051
3128
|
const version = api[0];
|
|
3052
3129
|
const access = api[1];
|
|
@@ -78,6 +78,7 @@ class Exchange {
|
|
|
78
78
|
this.last_http_response = undefined;
|
|
79
79
|
this.last_json_response = undefined;
|
|
80
80
|
this.last_response_headers = undefined;
|
|
81
|
+
this.last_request_headers = undefined;
|
|
81
82
|
this.id = undefined;
|
|
82
83
|
this.markets = undefined;
|
|
83
84
|
this.status = undefined;
|
|
@@ -272,6 +273,7 @@ class Exchange {
|
|
|
272
273
|
this.last_http_response = undefined;
|
|
273
274
|
this.last_json_response = undefined;
|
|
274
275
|
this.last_response_headers = undefined;
|
|
276
|
+
this.last_request_headers = undefined;
|
|
275
277
|
// camelCase and snake_notation support
|
|
276
278
|
const unCamelCaseProperties = (obj = this) => {
|
|
277
279
|
if (obj !== null) {
|
|
@@ -2830,6 +2832,7 @@ class Exchange {
|
|
|
2830
2832
|
}
|
|
2831
2833
|
this.lastRestRequestTimestamp = this.milliseconds();
|
|
2832
2834
|
const request = this.sign(path, api, method, params, headers, body);
|
|
2835
|
+
this.last_request_headers = request['headers'];
|
|
2833
2836
|
return await this.fetch(request['url'], request['method'], request['headers'], request['body']);
|
|
2834
2837
|
}
|
|
2835
2838
|
async request(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined, config = {}) {
|
|
@@ -3414,6 +3417,9 @@ class Exchange {
|
|
|
3414
3417
|
async fetchFundingRateHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3415
3418
|
throw new errors.NotSupported(this.id + ' fetchFundingRateHistory() is not supported yet');
|
|
3416
3419
|
}
|
|
3420
|
+
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
3421
|
+
throw new errors.NotSupported(this.id + ' fetchFundingHistory() is not supported yet');
|
|
3422
|
+
}
|
|
3417
3423
|
parseLastPrice(price, market = undefined) {
|
|
3418
3424
|
throw new errors.NotSupported(this.id + ' parseLastPrice() is not supported yet');
|
|
3419
3425
|
}
|
|
@@ -11,11 +11,15 @@ function createFuture() {
|
|
|
11
11
|
});
|
|
12
12
|
p.resolve = function _resolve() {
|
|
13
13
|
// eslint-disable-next-line prefer-rest-params
|
|
14
|
-
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
resolve.apply(this, arguments);
|
|
16
|
+
});
|
|
15
17
|
};
|
|
16
18
|
p.reject = function _reject() {
|
|
17
19
|
// eslint-disable-next-line prefer-rest-params
|
|
18
|
-
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
reject.apply(this, arguments);
|
|
22
|
+
});
|
|
19
23
|
};
|
|
20
24
|
return p;
|
|
21
25
|
}
|
package/dist/cjs/src/bitget.js
CHANGED
|
@@ -25,7 +25,7 @@ class bitget extends bitget$1 {
|
|
|
25
25
|
'has': {
|
|
26
26
|
'CORS': undefined,
|
|
27
27
|
'spot': true,
|
|
28
|
-
'margin':
|
|
28
|
+
'margin': true,
|
|
29
29
|
'swap': true,
|
|
30
30
|
'future': true,
|
|
31
31
|
'option': false,
|
|
@@ -1303,11 +1303,16 @@ class bitget extends bitget$1 {
|
|
|
1303
1303
|
};
|
|
1304
1304
|
}
|
|
1305
1305
|
async fetchMarketsByType(type, params = {}) {
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
}
|
|
1310
|
-
|
|
1306
|
+
let response = undefined;
|
|
1307
|
+
if (type === 'spot') {
|
|
1308
|
+
response = await this.publicSpotGetPublicProducts(params);
|
|
1309
|
+
}
|
|
1310
|
+
else if (type === 'swap') {
|
|
1311
|
+
response = await this.publicMixGetMarketContracts(params);
|
|
1312
|
+
}
|
|
1313
|
+
else {
|
|
1314
|
+
throw new errors.NotSupported(this.id + ' does not support ' + type + ' market');
|
|
1315
|
+
}
|
|
1311
1316
|
//
|
|
1312
1317
|
// spot
|
|
1313
1318
|
//
|
|
@@ -1492,20 +1497,47 @@ class bitget extends bitget$1 {
|
|
|
1492
1497
|
* @name bitget#fetchMarketLeverageTiers
|
|
1493
1498
|
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
|
|
1494
1499
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#get-position-tier
|
|
1500
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-tier-data
|
|
1501
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-tier-data
|
|
1495
1502
|
* @param {string} symbol unified market symbol
|
|
1496
1503
|
* @param {object} [params] extra parameters specific to the bitget api endpoint
|
|
1504
|
+
* @param {string} [params.marginMode] for spot margin 'cross' or 'isolated', default is 'isolated'
|
|
1505
|
+
* @param {string} [params.code] required for cross spot margin
|
|
1497
1506
|
* @returns {object} a [leverage tiers structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#leverage-tiers-structure}
|
|
1498
1507
|
*/
|
|
1499
1508
|
await this.loadMarkets();
|
|
1500
1509
|
const request = {};
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1510
|
+
const market = this.market(symbol);
|
|
1511
|
+
let type = undefined;
|
|
1512
|
+
[type, params] = this.handleMarketTypeAndParams('fetchMarketLeverageTiers', market, params);
|
|
1513
|
+
let response = undefined;
|
|
1514
|
+
let marginMode = undefined;
|
|
1515
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchMarketLeverageTiers', params, 'isolated');
|
|
1516
|
+
if ((type === 'swap') || (type === 'future')) {
|
|
1517
|
+
const marketId = market['id'];
|
|
1518
|
+
const parts = marketId.split('_');
|
|
1519
|
+
const productType = this.safeStringUpper(parts, 1);
|
|
1520
|
+
request['symbol'] = marketId;
|
|
1521
|
+
request['productType'] = productType;
|
|
1522
|
+
response = await this.publicMixGetMarketQueryPositionLever(this.extend(request, params));
|
|
1523
|
+
}
|
|
1524
|
+
else if (marginMode === 'isolated') {
|
|
1525
|
+
request['symbol'] = market['info']['symbolName'];
|
|
1526
|
+
response = await this.publicMarginGetIsolatedPublicTierData(this.extend(request, params));
|
|
1527
|
+
}
|
|
1528
|
+
else if (marginMode === 'cross') {
|
|
1529
|
+
const code = this.safeString(params, 'code');
|
|
1530
|
+
this.checkRequiredArgument('fetchMarketLeverageTiers', code, 'code');
|
|
1531
|
+
params = this.omit(params, 'code');
|
|
1532
|
+
const currency = this.currency(code);
|
|
1533
|
+
request['coin'] = currency['code'];
|
|
1534
|
+
response = await this.publicMarginGetCrossPublicTierData(this.extend(request, params));
|
|
1535
|
+
}
|
|
1536
|
+
else {
|
|
1504
1537
|
throw new errors.BadRequest(this.id + ' fetchMarketLeverageTiers() symbol does not support market ' + symbol);
|
|
1505
1538
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
const response = await this.publicMixGetMarketQueryPositionLever(this.extend(request, params));
|
|
1539
|
+
//
|
|
1540
|
+
// swap and future
|
|
1509
1541
|
//
|
|
1510
1542
|
// {
|
|
1511
1543
|
// "code":"00000",
|
|
@@ -1522,10 +1554,50 @@ class bitget extends bitget$1 {
|
|
|
1522
1554
|
// "requestTime":1627292076687
|
|
1523
1555
|
// }
|
|
1524
1556
|
//
|
|
1525
|
-
|
|
1557
|
+
// isolated
|
|
1558
|
+
//
|
|
1559
|
+
// {
|
|
1560
|
+
// "code": "00000",
|
|
1561
|
+
// "msg": "success",
|
|
1562
|
+
// "requestTime": 1698352496622,
|
|
1563
|
+
// "data": [
|
|
1564
|
+
// {
|
|
1565
|
+
// "tier": "1",
|
|
1566
|
+
// "symbol": "BTCUSDT",
|
|
1567
|
+
// "leverage": "10",
|
|
1568
|
+
// "baseCoin": "BTC",
|
|
1569
|
+
// "quoteCoin": "USDT",
|
|
1570
|
+
// "baseMaxBorrowableAmount": "3",
|
|
1571
|
+
// "quoteMaxBorrowableAmount": "30000",
|
|
1572
|
+
// "maintainMarginRate": "0.05",
|
|
1573
|
+
// "initRate": "0.1111"
|
|
1574
|
+
// },
|
|
1575
|
+
// ]
|
|
1576
|
+
// }
|
|
1577
|
+
//
|
|
1578
|
+
// cross
|
|
1579
|
+
//
|
|
1580
|
+
// {
|
|
1581
|
+
// "code": "00000",
|
|
1582
|
+
// "msg": "success",
|
|
1583
|
+
// "requestTime": 1698352997077,
|
|
1584
|
+
// "data": [
|
|
1585
|
+
// {
|
|
1586
|
+
// "tier": "1",
|
|
1587
|
+
// "leverage": "3",
|
|
1588
|
+
// "coin": "BTC",
|
|
1589
|
+
// "maxBorrowableAmount": "26",
|
|
1590
|
+
// "maintainMarginRate": "0.1"
|
|
1591
|
+
// }
|
|
1592
|
+
// ]
|
|
1593
|
+
// }
|
|
1594
|
+
//
|
|
1595
|
+
const result = this.safeValue(response, 'data', []);
|
|
1526
1596
|
return this.parseMarketLeverageTiers(result, market);
|
|
1527
1597
|
}
|
|
1528
1598
|
parseMarketLeverageTiers(info, market = undefined) {
|
|
1599
|
+
//
|
|
1600
|
+
// swap and future
|
|
1529
1601
|
//
|
|
1530
1602
|
// [
|
|
1531
1603
|
// {
|
|
@@ -1535,22 +1607,57 @@ class bitget extends bitget$1 {
|
|
|
1535
1607
|
// "leverage": 125,
|
|
1536
1608
|
// "keepMarginRate": "0.004"
|
|
1537
1609
|
// }
|
|
1538
|
-
// ]
|
|
1610
|
+
// ]
|
|
1611
|
+
//
|
|
1612
|
+
// isolated
|
|
1613
|
+
//
|
|
1614
|
+
// [
|
|
1615
|
+
// {
|
|
1616
|
+
// "tier": "1",
|
|
1617
|
+
// "symbol": "BTCUSDT",
|
|
1618
|
+
// "leverage": "10",
|
|
1619
|
+
// "baseCoin": "BTC",
|
|
1620
|
+
// "quoteCoin": "USDT",
|
|
1621
|
+
// "baseMaxBorrowableAmount": "3",
|
|
1622
|
+
// "quoteMaxBorrowableAmount": "30000",
|
|
1623
|
+
// "maintainMarginRate": "0.05",
|
|
1624
|
+
// "initRate": "0.1111"
|
|
1625
|
+
// }
|
|
1626
|
+
// ]
|
|
1627
|
+
//
|
|
1628
|
+
// cross
|
|
1629
|
+
//
|
|
1630
|
+
// [
|
|
1631
|
+
// {
|
|
1632
|
+
// "tier": "1",
|
|
1633
|
+
// "leverage": "3",
|
|
1634
|
+
// "coin": "BTC",
|
|
1635
|
+
// "maxBorrowableAmount": "26",
|
|
1636
|
+
// "maintainMarginRate": "0.1"
|
|
1637
|
+
// }
|
|
1638
|
+
// ]
|
|
1539
1639
|
//
|
|
1540
1640
|
const tiers = [];
|
|
1641
|
+
let minNotional = 0;
|
|
1541
1642
|
for (let i = 0; i < info.length; i++) {
|
|
1542
1643
|
const item = info[i];
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1644
|
+
const minimumNotional = this.safeNumber(item, 'startUnit');
|
|
1645
|
+
if (minimumNotional !== undefined) {
|
|
1646
|
+
minNotional = minimumNotional;
|
|
1647
|
+
}
|
|
1648
|
+
const maxNotional = this.safeNumberN(item, ['endUnit', 'maxBorrowableAmount', 'baseMaxBorrowableAmount']);
|
|
1649
|
+
const marginCurrency = this.safeString2(item, 'coin', 'baseCoin');
|
|
1650
|
+
const currencyId = (marginCurrency !== undefined) ? marginCurrency : market['base'];
|
|
1545
1651
|
tiers.push({
|
|
1546
|
-
'tier': this.
|
|
1547
|
-
'currency':
|
|
1652
|
+
'tier': this.safeInteger2(item, 'level', 'tier'),
|
|
1653
|
+
'currency': this.safeCurrencyCode(currencyId),
|
|
1548
1654
|
'minNotional': minNotional,
|
|
1549
1655
|
'maxNotional': maxNotional,
|
|
1550
|
-
'maintenanceMarginRate': this.
|
|
1656
|
+
'maintenanceMarginRate': this.safeNumber2(item, 'keepMarginRate', 'maintainMarginRate'),
|
|
1551
1657
|
'maxLeverage': this.safeNumber(item, 'leverage'),
|
|
1552
1658
|
'info': item,
|
|
1553
1659
|
});
|
|
1660
|
+
minNotional = maxNotional;
|
|
1554
1661
|
}
|
|
1555
1662
|
return tiers;
|
|
1556
1663
|
}
|
|
@@ -3332,12 +3439,16 @@ class bitget extends bitget$1 {
|
|
|
3332
3439
|
* @description create a list of trade orders (all orders should be of the same symbol)
|
|
3333
3440
|
* @see https://bitgetlimited.github.io/apidoc/en/spot/#batch-order
|
|
3334
3441
|
* @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-order
|
|
3442
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-order
|
|
3443
|
+
* @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-order
|
|
3335
3444
|
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
3445
|
+
* @param {object} [params] extra parameters specific to the api endpoint
|
|
3336
3446
|
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
|
|
3337
3447
|
*/
|
|
3338
3448
|
await this.loadMarkets();
|
|
3339
3449
|
const ordersRequests = [];
|
|
3340
3450
|
let symbol = undefined;
|
|
3451
|
+
let marginMode = undefined;
|
|
3341
3452
|
for (let i = 0; i < orders.length; i++) {
|
|
3342
3453
|
const rawOrder = orders[i];
|
|
3343
3454
|
const marketId = this.safeString(rawOrder, 'symbol');
|
|
@@ -3354,23 +3465,44 @@ class bitget extends bitget$1 {
|
|
|
3354
3465
|
const amount = this.safeValue(rawOrder, 'amount');
|
|
3355
3466
|
const price = this.safeValue(rawOrder, 'price');
|
|
3356
3467
|
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
3468
|
+
const marginResult = this.handleMarginModeAndParams('createOrders', params);
|
|
3469
|
+
const currentMarginMode = marginResult[0];
|
|
3470
|
+
if (currentMarginMode !== undefined) {
|
|
3471
|
+
if (marginMode === undefined) {
|
|
3472
|
+
marginMode = currentMarginMode;
|
|
3473
|
+
}
|
|
3474
|
+
else {
|
|
3475
|
+
if (marginMode !== currentMarginMode) {
|
|
3476
|
+
throw new errors.BadRequest(this.id + ' createOrders() requires all orders to have the same margin mode (isolated or cross)');
|
|
3477
|
+
}
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3357
3480
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
3358
3481
|
ordersRequests.push(orderRequest);
|
|
3359
3482
|
}
|
|
3360
3483
|
const market = this.market(symbol);
|
|
3484
|
+
const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
|
|
3361
3485
|
const request = {
|
|
3362
|
-
'symbol':
|
|
3486
|
+
'symbol': symbolRequest,
|
|
3363
3487
|
};
|
|
3364
3488
|
let response = undefined;
|
|
3365
3489
|
if (market['spot']) {
|
|
3366
3490
|
request['orderList'] = ordersRequests;
|
|
3367
|
-
response = await this.privateSpotPostTradeBatchOrders(request);
|
|
3368
3491
|
}
|
|
3369
|
-
|
|
3492
|
+
if ((market['swap']) || (market['future'])) {
|
|
3370
3493
|
request['orderDataList'] = ordersRequests;
|
|
3371
3494
|
request['marginCoin'] = market['settleId'];
|
|
3372
3495
|
response = await this.privateMixPostOrderBatchOrders(request);
|
|
3373
3496
|
}
|
|
3497
|
+
else if (marginMode === 'isolated') {
|
|
3498
|
+
response = await this.privateMarginPostIsolatedOrderBatchPlaceOrder(request);
|
|
3499
|
+
}
|
|
3500
|
+
else if (marginMode === 'cross') {
|
|
3501
|
+
response = await this.privateMarginPostCrossOrderBatchPlaceOrder(request);
|
|
3502
|
+
}
|
|
3503
|
+
else {
|
|
3504
|
+
response = await this.privateSpotPostTradeBatchOrders(request);
|
|
3505
|
+
}
|
|
3374
3506
|
//
|
|
3375
3507
|
// {
|
|
3376
3508
|
// "code": "00000",
|
|
@@ -3438,11 +3570,6 @@ class bitget extends bitget$1 {
|
|
|
3438
3570
|
if (!isStopOrder && !isTriggerOrder) {
|
|
3439
3571
|
throw new errors.InvalidOrder(this.id + ' editOrder() only support plan orders');
|
|
3440
3572
|
}
|
|
3441
|
-
let method = this.getSupportedMapping(marketType, {
|
|
3442
|
-
'spot': 'privateSpotPostPlanModifyPlan',
|
|
3443
|
-
'swap': 'privateMixPostPlanModifyPlan',
|
|
3444
|
-
'future': 'privateMixPostPlanModifyPlan',
|
|
3445
|
-
});
|
|
3446
3573
|
if (triggerPrice !== undefined) {
|
|
3447
3574
|
// default triggerType to market price for unification
|
|
3448
3575
|
const triggerType = this.safeString(params, 'triggerType', 'market_price');
|
|
@@ -3450,6 +3577,8 @@ class bitget extends bitget$1 {
|
|
|
3450
3577
|
request['triggerPrice'] = this.priceToPrecision(symbol, triggerPrice);
|
|
3451
3578
|
request['executePrice'] = this.priceToPrecision(symbol, price);
|
|
3452
3579
|
}
|
|
3580
|
+
const omitted = this.omit(query, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice']);
|
|
3581
|
+
let response = undefined;
|
|
3453
3582
|
if (marketType === 'spot') {
|
|
3454
3583
|
if (isStopOrder) {
|
|
3455
3584
|
throw new errors.InvalidOrder(this.id + ' editOrder() does not support stop orders on spot markets, only swap markets');
|
|
@@ -3469,10 +3598,15 @@ class bitget extends bitget$1 {
|
|
|
3469
3598
|
else {
|
|
3470
3599
|
request['size'] = this.amountToPrecision(symbol, amount);
|
|
3471
3600
|
}
|
|
3601
|
+
response = await this.privateSpotPostPlanModifyPlan(this.extend(request, omitted));
|
|
3472
3602
|
}
|
|
3473
3603
|
else {
|
|
3474
3604
|
request['symbol'] = market['id'];
|
|
3475
3605
|
request['size'] = this.amountToPrecision(symbol, amount);
|
|
3606
|
+
if ((marketType !== 'swap') && (marketType !== 'future')) {
|
|
3607
|
+
throw new errors.NotSupported(this.id + ' editOrder() does not support ' + marketType + ' market');
|
|
3608
|
+
}
|
|
3609
|
+
request['marginCoin'] = market['settleId'];
|
|
3476
3610
|
if (isStopOrder) {
|
|
3477
3611
|
if (!isMarketOrder) {
|
|
3478
3612
|
throw new errors.ExchangeError(this.id + ' editOrder() bitget stopLoss or takeProfit orders must be market orders');
|
|
@@ -3485,12 +3619,12 @@ class bitget extends bitget$1 {
|
|
|
3485
3619
|
request['triggerPrice'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
3486
3620
|
request['planType'] = 'profit_plan';
|
|
3487
3621
|
}
|
|
3488
|
-
|
|
3622
|
+
response = await this.privateMixPostPlanModifyTPSLPlan(this.extend(request, omitted));
|
|
3623
|
+
}
|
|
3624
|
+
else {
|
|
3625
|
+
response = await this.privateMixPostPlanModifyPlan(this.extend(request, omitted));
|
|
3489
3626
|
}
|
|
3490
|
-
request['marginCoin'] = market['settleId'];
|
|
3491
3627
|
}
|
|
3492
|
-
const omitted = this.omit(query, ['stopPrice', 'triggerType', 'stopLossPrice', 'takeProfitPrice']);
|
|
3493
|
-
const response = await this[method](this.extend(request, omitted));
|
|
3494
3628
|
//
|
|
3495
3629
|
// spot
|
|
3496
3630
|
// {
|
|
@@ -3820,16 +3954,20 @@ class bitget extends bitget$1 {
|
|
|
3820
3954
|
await this.loadMarkets();
|
|
3821
3955
|
const market = this.market(symbol);
|
|
3822
3956
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
3823
|
-
const method = this.getSupportedMapping(marketType, {
|
|
3824
|
-
'spot': 'privateSpotPostTradeOrderInfo',
|
|
3825
|
-
'swap': 'privateMixGetOrderDetail',
|
|
3826
|
-
'future': 'privateMixGetOrderDetail',
|
|
3827
|
-
});
|
|
3828
3957
|
const request = {
|
|
3829
3958
|
'symbol': market['id'],
|
|
3830
3959
|
'orderId': id,
|
|
3831
3960
|
};
|
|
3832
|
-
let response =
|
|
3961
|
+
let response = undefined;
|
|
3962
|
+
if (marketType === 'spot') {
|
|
3963
|
+
response = await this.privateSpotPostTradeOrderInfo(this.extend(request, query));
|
|
3964
|
+
}
|
|
3965
|
+
else if ((marketType === 'swap') || (marketType === 'future')) {
|
|
3966
|
+
response = await this.privateMixGetOrderDetail(this.extend(request, query));
|
|
3967
|
+
}
|
|
3968
|
+
else {
|
|
3969
|
+
throw new errors.NotSupported(this.id + ' fetchOrder() does not support ' + marketType + ' market');
|
|
3970
|
+
}
|
|
3833
3971
|
// spot
|
|
3834
3972
|
// {
|
|
3835
3973
|
// code: '00000',
|
|
@@ -4755,16 +4893,20 @@ class bitget extends bitget$1 {
|
|
|
4755
4893
|
await this.loadMarkets();
|
|
4756
4894
|
const market = this.market(symbol);
|
|
4757
4895
|
const [marketType, query] = this.handleMarketTypeAndParams('fetchOrderTrades', market, params);
|
|
4758
|
-
const method = this.getSupportedMapping(marketType, {
|
|
4759
|
-
'spot': 'privateSpotPostTradeFills',
|
|
4760
|
-
'swap': 'privateMixGetOrderFills',
|
|
4761
|
-
'future': 'privateMixGetOrderFills',
|
|
4762
|
-
});
|
|
4763
4896
|
const request = {
|
|
4764
4897
|
'symbol': market['id'],
|
|
4765
4898
|
'orderId': id,
|
|
4766
4899
|
};
|
|
4767
|
-
|
|
4900
|
+
let response = undefined;
|
|
4901
|
+
if (marketType === 'spot') {
|
|
4902
|
+
response = await this.privateSpotPostTradeFills(this.extend(request, query));
|
|
4903
|
+
}
|
|
4904
|
+
else if ((marketType === 'swap') || (marketType === 'future')) {
|
|
4905
|
+
response = await this.privateMixGetOrderFills(this.extend(request, query));
|
|
4906
|
+
}
|
|
4907
|
+
else {
|
|
4908
|
+
throw new errors.NotSupported(this.id + ' fetchOrderTrades() does not support ' + marketType + ' market');
|
|
4909
|
+
}
|
|
4768
4910
|
// spot
|
|
4769
4911
|
//
|
|
4770
4912
|
// swap
|
|
@@ -5228,7 +5370,7 @@ class bitget extends bitget$1 {
|
|
|
5228
5370
|
'previousFundingDatetime': undefined,
|
|
5229
5371
|
};
|
|
5230
5372
|
}
|
|
5231
|
-
async fetchFundingHistory(symbol, since = undefined, limit = undefined, params = {}) {
|
|
5373
|
+
async fetchFundingHistory(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
5232
5374
|
/**
|
|
5233
5375
|
* @method
|
|
5234
5376
|
* @name bitget#fetchFundingHistory
|
|
@@ -5241,6 +5383,7 @@ class bitget extends bitget$1 {
|
|
|
5241
5383
|
* @returns {object[]} a list of [funding history structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#funding-history-structure}
|
|
5242
5384
|
*/
|
|
5243
5385
|
await this.loadMarkets();
|
|
5386
|
+
this.checkRequiredSymbol('fetchFundingHistory', symbol);
|
|
5244
5387
|
const market = this.market(symbol);
|
|
5245
5388
|
if (!market['swap']) {
|
|
5246
5389
|
throw new errors.BadSymbol(this.id + ' fetchFundingHistory() supports swap contracts only');
|
package/dist/cjs/src/bitopro.js
CHANGED
|
@@ -1121,14 +1121,15 @@ class bitopro extends bitopro$1 {
|
|
|
1121
1121
|
const request = {
|
|
1122
1122
|
// 'pair': market['id'], // optional
|
|
1123
1123
|
};
|
|
1124
|
-
|
|
1125
|
-
let method = this.safeString(this.options, 'privateDeleteOrdersPair', 'privateDeleteOrdersAll');
|
|
1124
|
+
let response = undefined;
|
|
1126
1125
|
if (symbol !== undefined) {
|
|
1127
1126
|
const market = this.market(symbol);
|
|
1128
1127
|
request['pair'] = market['id'];
|
|
1129
|
-
|
|
1128
|
+
response = await this.privateDeleteOrdersPair(this.extend(request, params));
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
response = await this.privateDeleteOrdersAll(this.extend(request, params));
|
|
1130
1132
|
}
|
|
1131
|
-
const response = await this[method](this.extend(request, params));
|
|
1132
1133
|
const result = this.safeValue(response, 'data', {});
|
|
1133
1134
|
//
|
|
1134
1135
|
// {
|