ccxt 4.1.10 → 4.1.12
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/CONTRIBUTING.md +2 -0
- package/README.md +3 -3
- package/build.sh +3 -1
- package/dist/ccxt.browser.js +324 -129
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +30 -2
- package/dist/cjs/src/binance.js +100 -46
- package/dist/cjs/src/bingx.js +15 -9
- package/dist/cjs/src/bitget.js +11 -4
- package/dist/cjs/src/bitmart.js +2 -2
- package/dist/cjs/src/bybit.js +14 -8
- package/dist/cjs/src/coinex.js +3 -3
- package/dist/cjs/src/coinspot.js +103 -8
- package/dist/cjs/src/cryptocom.js +1 -1
- package/dist/cjs/src/delta.js +4 -4
- package/dist/cjs/src/deribit.js +1 -1
- package/dist/cjs/src/huobi.js +8 -10
- package/dist/cjs/src/okx.js +4 -3
- package/dist/cjs/src/poloniex.js +1 -0
- package/dist/cjs/src/pro/binance.js +3 -9
- package/dist/cjs/src/pro/phemex.js +2 -2
- package/dist/cjs/src/whitebit.js +15 -11
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +3 -0
- package/js/src/abstract/binancecoinm.d.ts +3 -0
- package/js/src/abstract/binanceus.d.ts +3 -0
- package/js/src/abstract/binanceusdm.d.ts +3 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/base/Exchange.d.ts +7 -6
- package/js/src/base/Exchange.js +30 -2
- package/js/src/base/types.d.ts +10 -0
- package/js/src/binance.d.ts +5 -13
- package/js/src/binance.js +100 -46
- package/js/src/bingx.d.ts +2 -16
- package/js/src/bingx.js +15 -9
- package/js/src/bitget.d.ts +2 -16
- package/js/src/bitget.js +11 -4
- package/js/src/bitmart.d.ts +2 -16
- package/js/src/bitmart.js +2 -2
- package/js/src/bybit.d.ts +8 -22
- package/js/src/bybit.js +14 -8
- package/js/src/coinex.js +3 -3
- package/js/src/coinspot.d.ts +1 -0
- package/js/src/coinspot.js +103 -8
- package/js/src/cryptocom.d.ts +1 -1
- package/js/src/cryptocom.js +1 -1
- package/js/src/delta.d.ts +4 -74
- package/js/src/delta.js +4 -4
- package/js/src/deribit.js +1 -1
- package/js/src/gate.d.ts +2 -2
- package/js/src/huobi.d.ts +4 -13
- package/js/src/huobi.js +8 -10
- package/js/src/mexc.d.ts +4 -4
- package/js/src/okx.d.ts +3 -21
- package/js/src/okx.js +4 -3
- package/js/src/poloniex.js +1 -0
- package/js/src/pro/binance.js +3 -9
- package/js/src/pro/phemex.js +2 -2
- package/js/src/whitebit.js +15 -11
- package/package.json +2 -2
package/js/src/base/Exchange.js
CHANGED
|
@@ -2319,7 +2319,7 @@ export default class Exchange {
|
|
|
2319
2319
|
}
|
|
2320
2320
|
return result;
|
|
2321
2321
|
}
|
|
2322
|
-
marketSymbols(symbols, type = undefined, allowEmpty = true) {
|
|
2322
|
+
marketSymbols(symbols, type = undefined, allowEmpty = true, sameTypeOnly = false, sameSubTypeOnly = false) {
|
|
2323
2323
|
if (symbols === undefined) {
|
|
2324
2324
|
if (!allowEmpty) {
|
|
2325
2325
|
throw new ArgumentsRequired(this.id + ' empty list of symbols is not supported');
|
|
@@ -2334,10 +2334,26 @@ export default class Exchange {
|
|
|
2334
2334
|
return symbols;
|
|
2335
2335
|
}
|
|
2336
2336
|
const result = [];
|
|
2337
|
+
let marketType = undefined;
|
|
2338
|
+
let isLinearSubType = undefined;
|
|
2337
2339
|
for (let i = 0; i < symbols.length; i++) {
|
|
2338
2340
|
const market = this.market(symbols[i]);
|
|
2341
|
+
if (sameTypeOnly && (marketType !== undefined)) {
|
|
2342
|
+
if (market['type'] !== marketType) {
|
|
2343
|
+
throw new BadRequest(this.id + ' symbols must be of the same type, either ' + marketType + ' or ' + market['type'] + '.');
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
if (sameSubTypeOnly && (isLinearSubType !== undefined)) {
|
|
2347
|
+
if (market['linear'] !== isLinearSubType) {
|
|
2348
|
+
throw new BadRequest(this.id + ' symbols must be of the same subType, either linear or inverse.');
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2339
2351
|
if (type !== undefined && market['type'] !== type) {
|
|
2340
|
-
throw new BadRequest(this.id + ' symbols must be of same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
|
|
2352
|
+
throw new BadRequest(this.id + ' symbols must be of the same type ' + type + '. If the type is incorrect you can change it in options or the params of the request');
|
|
2353
|
+
}
|
|
2354
|
+
marketType = market['type'];
|
|
2355
|
+
if (!market['spot']) {
|
|
2356
|
+
isLinearSubType = market['linear'];
|
|
2341
2357
|
}
|
|
2342
2358
|
const symbol = this.safeString(market, 'symbol', symbols[i]);
|
|
2343
2359
|
result.push(symbol);
|
|
@@ -4366,5 +4382,17 @@ export default class Exchange {
|
|
|
4366
4382
|
}
|
|
4367
4383
|
return [request, params];
|
|
4368
4384
|
}
|
|
4385
|
+
safeOpenInterest(interest, market = undefined) {
|
|
4386
|
+
return this.extend(interest, {
|
|
4387
|
+
'symbol': this.safeString(market, 'symbol'),
|
|
4388
|
+
'baseVolume': this.safeNumber(interest, 'baseVolume'),
|
|
4389
|
+
'quoteVolume': this.safeNumber(interest, 'quoteVolume'),
|
|
4390
|
+
'openInterestAmount': this.safeNumber(interest, 'openInterestAmount'),
|
|
4391
|
+
'openInterestValue': this.safeNumber(interest, 'openInterestValue'),
|
|
4392
|
+
'timestamp': this.safeInteger(interest, 'timestamp'),
|
|
4393
|
+
'datetime': this.safeString(interest, 'datetime'),
|
|
4394
|
+
'info': this.safeValue(interest, 'info'),
|
|
4395
|
+
});
|
|
4396
|
+
}
|
|
4369
4397
|
}
|
|
4370
4398
|
export { Exchange, };
|
package/js/src/base/types.d.ts
CHANGED
|
@@ -208,6 +208,16 @@ export interface FundingRateHistory {
|
|
|
208
208
|
timestamp?: number;
|
|
209
209
|
datetime?: string;
|
|
210
210
|
}
|
|
211
|
+
export interface OpenInterest {
|
|
212
|
+
symbol: string;
|
|
213
|
+
openInterestAmount?: number;
|
|
214
|
+
openInterestValue?: number;
|
|
215
|
+
baseVolume?: number;
|
|
216
|
+
quoteVolume?: number;
|
|
217
|
+
timestamp?: number;
|
|
218
|
+
datetime?: string;
|
|
219
|
+
info: any;
|
|
220
|
+
}
|
|
211
221
|
/** [ timestamp, open, high, low, close, volume ] */
|
|
212
222
|
export declare type OHLCV = [number, number, number, number, number, number];
|
|
213
223
|
/** [ timestamp, open, high, low, close, volume, count ] */
|
package/js/src/binance.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/binance.js';
|
|
2
|
-
import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory } from './base/types.js';
|
|
2
|
+
import { Market, Int, OrderSide, Balances, OrderType, Trade, OHLCV, Order, FundingRateHistory, OpenInterest } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class binance
|
|
5
5
|
* @extends Exchange
|
|
@@ -71,6 +71,7 @@ export default class binance extends Exchange {
|
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
73
|
info: any;
|
|
74
|
+
created: number;
|
|
74
75
|
};
|
|
75
76
|
parseBalanceHelper(entry: any): import("./base/types.js").Balance;
|
|
76
77
|
parseBalance(response: any, type?: any, marginMode?: any): Balances;
|
|
@@ -493,16 +494,7 @@ export default class binance extends Exchange {
|
|
|
493
494
|
datetime: any;
|
|
494
495
|
info: any;
|
|
495
496
|
};
|
|
496
|
-
fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<
|
|
497
|
-
fetchOpenInterest(symbol: string, params?: {}): Promise<
|
|
498
|
-
parseOpenInterest(interest: any, market?: any):
|
|
499
|
-
symbol: any;
|
|
500
|
-
baseVolume: number;
|
|
501
|
-
quoteVolume: number;
|
|
502
|
-
openInterestAmount: number;
|
|
503
|
-
openInterestValue: number;
|
|
504
|
-
timestamp: number;
|
|
505
|
-
datetime: string;
|
|
506
|
-
info: any;
|
|
507
|
-
};
|
|
497
|
+
fetchOpenInterestHistory(symbol: string, timeframe?: string, since?: Int, limit?: Int, params?: {}): Promise<OpenInterest[]>;
|
|
498
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<OpenInterest>;
|
|
499
|
+
parseOpenInterest(interest: any, market?: any): OpenInterest;
|
|
508
500
|
}
|
package/js/src/binance.js
CHANGED
|
@@ -25,7 +25,7 @@ export default class binance extends Exchange {
|
|
|
25
25
|
'rateLimit': 50,
|
|
26
26
|
'certified': true,
|
|
27
27
|
'pro': true,
|
|
28
|
-
// new
|
|
28
|
+
// new metainfo2 interface
|
|
29
29
|
'has': {
|
|
30
30
|
'CORS': undefined,
|
|
31
31
|
'spot': true,
|
|
@@ -252,6 +252,7 @@ export default class binance extends Exchange {
|
|
|
252
252
|
'loan/vip/loanable/data': 40,
|
|
253
253
|
'loan/vip/collateral/data': 40,
|
|
254
254
|
'loan/vip/request/data': 2.6668,
|
|
255
|
+
'loan/vip/request/interestRate': 2.6668,
|
|
255
256
|
'loan/income': 40.002,
|
|
256
257
|
'loan/ongoing/orders': 40,
|
|
257
258
|
'loan/ltv/adjustment/history': 40,
|
|
@@ -766,10 +767,12 @@ export default class binance extends Exchange {
|
|
|
766
767
|
'adlQuantile': 5,
|
|
767
768
|
'pmAccountInfo': 5,
|
|
768
769
|
'orderAmendment': 1,
|
|
769
|
-
'
|
|
770
|
-
'
|
|
771
|
-
'
|
|
772
|
-
'
|
|
770
|
+
'income/asyn': 1000,
|
|
771
|
+
'income/asyn/id': 10,
|
|
772
|
+
'order/asyn': 1000,
|
|
773
|
+
'order/asyn/id': 10,
|
|
774
|
+
'trade/asyn': 1000,
|
|
775
|
+
'trade/asyn/id': 10,
|
|
773
776
|
},
|
|
774
777
|
'post': {
|
|
775
778
|
'batchOrders': 5,
|
|
@@ -1807,14 +1810,16 @@ export default class binance extends Exchange {
|
|
|
1807
1810
|
const query = this.omit(params, 'type');
|
|
1808
1811
|
let subType = undefined;
|
|
1809
1812
|
[subType, params] = this.handleSubTypeAndParams('fetchTime', undefined, params);
|
|
1810
|
-
let
|
|
1813
|
+
let response = undefined;
|
|
1811
1814
|
if (this.isLinear(type, subType)) {
|
|
1812
|
-
|
|
1815
|
+
response = await this.fapiPublicGetTime(query);
|
|
1813
1816
|
}
|
|
1814
1817
|
else if (this.isInverse(type, subType)) {
|
|
1815
|
-
|
|
1818
|
+
response = await this.dapiPublicGetTime(query);
|
|
1819
|
+
}
|
|
1820
|
+
else {
|
|
1821
|
+
response = await this.publicGetTime(query);
|
|
1816
1822
|
}
|
|
1817
|
-
const response = await this[method](query);
|
|
1818
1823
|
return this.safeInteger(response, 'serverTime');
|
|
1819
1824
|
}
|
|
1820
1825
|
async fetchCurrencies(params = {}) {
|
|
@@ -2388,6 +2393,7 @@ export default class binance extends Exchange {
|
|
|
2388
2393
|
},
|
|
2389
2394
|
},
|
|
2390
2395
|
'info': market,
|
|
2396
|
+
'created': this.safeInteger(market, 'onboardDate'), // present in inverse & linear apis
|
|
2391
2397
|
};
|
|
2392
2398
|
if ('PRICE_FILTER' in filtersByType) {
|
|
2393
2399
|
const filter = this.safeValue(filtersByType, 'PRICE_FILTER', {});
|
|
@@ -2715,7 +2721,7 @@ export default class binance extends Exchange {
|
|
|
2715
2721
|
// "unrealizedProfit":"0.00000000",
|
|
2716
2722
|
// "positionInitialMargin":"0",
|
|
2717
2723
|
// "openOrderInitialMargin":"0",
|
|
2718
|
-
// "leverage":"
|
|
2724
|
+
// "leverage":"21",
|
|
2719
2725
|
// "isolated":false,
|
|
2720
2726
|
// "entryPrice":"0.00000",
|
|
2721
2727
|
// "maxNotional":"5000000",
|
|
@@ -2799,17 +2805,19 @@ export default class binance extends Exchange {
|
|
|
2799
2805
|
if (limit !== undefined) {
|
|
2800
2806
|
request['limit'] = limit; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
|
|
2801
2807
|
}
|
|
2802
|
-
let
|
|
2808
|
+
let response = undefined;
|
|
2803
2809
|
if (market['option']) {
|
|
2804
|
-
|
|
2810
|
+
response = await this.eapiPublicGetDepth(this.extend(request, params));
|
|
2805
2811
|
}
|
|
2806
2812
|
else if (market['linear']) {
|
|
2807
|
-
|
|
2813
|
+
response = await this.fapiPublicGetDepth(this.extend(request, params));
|
|
2808
2814
|
}
|
|
2809
2815
|
else if (market['inverse']) {
|
|
2810
|
-
|
|
2816
|
+
response = await this.dapiPublicGetDepth(this.extend(request, params));
|
|
2817
|
+
}
|
|
2818
|
+
else {
|
|
2819
|
+
response = await this.publicGetDepth(this.extend(request, params));
|
|
2811
2820
|
}
|
|
2812
|
-
const response = await this[method](this.extend(request, params));
|
|
2813
2821
|
//
|
|
2814
2822
|
// future
|
|
2815
2823
|
//
|
|
@@ -3043,17 +3051,19 @@ export default class binance extends Exchange {
|
|
|
3043
3051
|
const request = {
|
|
3044
3052
|
'symbol': market['id'],
|
|
3045
3053
|
};
|
|
3046
|
-
let
|
|
3054
|
+
let response = undefined;
|
|
3047
3055
|
if (market['option']) {
|
|
3048
|
-
|
|
3056
|
+
response = await this.eapiPublicGetTicker(this.extend(request, params));
|
|
3049
3057
|
}
|
|
3050
3058
|
else if (market['linear']) {
|
|
3051
|
-
|
|
3059
|
+
response = await this.fapiPublicGetTicker24hr(this.extend(request, params));
|
|
3052
3060
|
}
|
|
3053
3061
|
else if (market['inverse']) {
|
|
3054
|
-
|
|
3062
|
+
response = await this.dapiPublicGetTicker24hr(this.extend(request, params));
|
|
3063
|
+
}
|
|
3064
|
+
else {
|
|
3065
|
+
response = await this.publicGetTicker24hr(this.extend(request, params));
|
|
3055
3066
|
}
|
|
3056
|
-
const response = await this[method](this.extend(request, params));
|
|
3057
3067
|
if (Array.isArray(response)) {
|
|
3058
3068
|
const firstTicker = this.safeValue(response, 0, {});
|
|
3059
3069
|
return this.parseTicker(firstTicker, market);
|
|
@@ -3083,17 +3093,16 @@ export default class binance extends Exchange {
|
|
|
3083
3093
|
let subType = undefined;
|
|
3084
3094
|
[subType, params] = this.handleSubTypeAndParams('fetchBidsAsks', market, params);
|
|
3085
3095
|
[type, params] = this.handleMarketTypeAndParams('fetchBidsAsks', market, params);
|
|
3086
|
-
let
|
|
3096
|
+
let response = undefined;
|
|
3087
3097
|
if (this.isLinear(type, subType)) {
|
|
3088
|
-
|
|
3098
|
+
response = await this.fapiPublicGetTickerBookTicker(params);
|
|
3089
3099
|
}
|
|
3090
3100
|
else if (this.isInverse(type, subType)) {
|
|
3091
|
-
|
|
3101
|
+
response = await this.dapiPublicGetTickerBookTicker(params);
|
|
3092
3102
|
}
|
|
3093
3103
|
else {
|
|
3094
|
-
|
|
3104
|
+
response = await this.publicGetTickerBookTicker(params);
|
|
3095
3105
|
}
|
|
3096
|
-
const response = await this[method](params);
|
|
3097
3106
|
return this.parseTickers(response, symbols);
|
|
3098
3107
|
}
|
|
3099
3108
|
async fetchLastPrices(symbols = undefined, params = {}) {
|
|
@@ -3115,9 +3124,9 @@ export default class binance extends Exchange {
|
|
|
3115
3124
|
let subType = undefined;
|
|
3116
3125
|
[subType, params] = this.handleSubTypeAndParams('fetchLastPrices', market, params);
|
|
3117
3126
|
[type, params] = this.handleMarketTypeAndParams('fetchLastPrices', market, params);
|
|
3118
|
-
let
|
|
3127
|
+
let response = undefined;
|
|
3119
3128
|
if (this.isLinear(type, subType)) {
|
|
3120
|
-
|
|
3129
|
+
response = await this.fapiPublicGetTickerPrice(params);
|
|
3121
3130
|
//
|
|
3122
3131
|
// [
|
|
3123
3132
|
// {
|
|
@@ -3130,7 +3139,7 @@ export default class binance extends Exchange {
|
|
|
3130
3139
|
//
|
|
3131
3140
|
}
|
|
3132
3141
|
else if (this.isInverse(type, subType)) {
|
|
3133
|
-
|
|
3142
|
+
response = await this.dapiPublicGetTickerPrice(params);
|
|
3134
3143
|
//
|
|
3135
3144
|
// [
|
|
3136
3145
|
// {
|
|
@@ -3143,7 +3152,7 @@ export default class binance extends Exchange {
|
|
|
3143
3152
|
//
|
|
3144
3153
|
}
|
|
3145
3154
|
else if (type === 'spot') {
|
|
3146
|
-
|
|
3155
|
+
response = await this.publicGetTickerPrice(params);
|
|
3147
3156
|
//
|
|
3148
3157
|
// [
|
|
3149
3158
|
// {
|
|
@@ -3157,7 +3166,6 @@ export default class binance extends Exchange {
|
|
|
3157
3166
|
else {
|
|
3158
3167
|
throw new NotSupported(this.id + ' fetchLastPrices() does not support ' + type + ' markets yet');
|
|
3159
3168
|
}
|
|
3160
|
-
const response = await this[method](params);
|
|
3161
3169
|
return this.parseLastPrices(response, symbols);
|
|
3162
3170
|
}
|
|
3163
3171
|
parseLastPrice(info, market = undefined) {
|
|
@@ -3217,6 +3225,7 @@ export default class binance extends Exchange {
|
|
|
3217
3225
|
await this.loadMarkets();
|
|
3218
3226
|
let type = undefined;
|
|
3219
3227
|
let market = undefined;
|
|
3228
|
+
symbols = this.marketSymbols(symbols, undefined, true, true, true);
|
|
3220
3229
|
if (symbols !== undefined) {
|
|
3221
3230
|
const first = this.safeString(symbols, 0);
|
|
3222
3231
|
market = this.market(first);
|
|
@@ -6476,10 +6485,20 @@ export default class binance extends Exchange {
|
|
|
6476
6485
|
}
|
|
6477
6486
|
parseTradingFee(fee, market = undefined) {
|
|
6478
6487
|
//
|
|
6488
|
+
// spot
|
|
6489
|
+
// [
|
|
6490
|
+
// {
|
|
6491
|
+
// "symbol": "BTCUSDT",
|
|
6492
|
+
// "makerCommission": "0.001",
|
|
6493
|
+
// "takerCommission": "0.001"
|
|
6494
|
+
// }
|
|
6495
|
+
// ]
|
|
6496
|
+
//
|
|
6497
|
+
// swap
|
|
6479
6498
|
// {
|
|
6480
|
-
// "symbol": "
|
|
6481
|
-
// "
|
|
6482
|
-
// "
|
|
6499
|
+
// "symbol": "BTCUSD_PERP",
|
|
6500
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6501
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6483
6502
|
// }
|
|
6484
6503
|
//
|
|
6485
6504
|
const marketId = this.safeString(fee, 'symbol');
|
|
@@ -6487,8 +6506,8 @@ export default class binance extends Exchange {
|
|
|
6487
6506
|
return {
|
|
6488
6507
|
'info': fee,
|
|
6489
6508
|
'symbol': symbol,
|
|
6490
|
-
'maker': this.
|
|
6491
|
-
'taker': this.
|
|
6509
|
+
'maker': this.safeNumber2(fee, 'makerCommission', 'makerCommissionRate'),
|
|
6510
|
+
'taker': this.safeNumber2(fee, 'takerCommission', 'takerCommissionRate'),
|
|
6492
6511
|
};
|
|
6493
6512
|
}
|
|
6494
6513
|
async fetchTradingFee(symbol, params = {}) {
|
|
@@ -6497,17 +6516,37 @@ export default class binance extends Exchange {
|
|
|
6497
6516
|
* @name binance#fetchTradingFee
|
|
6498
6517
|
* @description fetch the trading fees for a market
|
|
6499
6518
|
* @see https://binance-docs.github.io/apidocs/spot/en/#trade-fee-user_data
|
|
6519
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#user-commission-rate-user_data
|
|
6520
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#user-commission-rate-user_data
|
|
6500
6521
|
* @param {string} symbol unified market symbol
|
|
6501
6522
|
* @param {object} [params] extra parameters specific to the binance api endpoint
|
|
6502
6523
|
* @returns {object} a [fee structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#fee-structure}
|
|
6503
6524
|
*/
|
|
6504
6525
|
await this.loadMarkets();
|
|
6505
6526
|
const market = this.market(symbol);
|
|
6527
|
+
const defaultType = this.safeString2(this.options, 'fetchTradingFee', 'defaultType', 'linear');
|
|
6528
|
+
const type = this.safeString(params, 'type', defaultType);
|
|
6529
|
+
params = this.omit(params, 'type');
|
|
6530
|
+
let subType = undefined;
|
|
6531
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFee', market, params);
|
|
6532
|
+
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6533
|
+
const isLinear = this.isLinear(type, subType);
|
|
6534
|
+
const isInverse = this.isInverse(type, subType);
|
|
6506
6535
|
const request = {
|
|
6507
6536
|
'symbol': market['id'],
|
|
6508
6537
|
};
|
|
6509
|
-
|
|
6538
|
+
let response = undefined;
|
|
6539
|
+
if (isSpotOrMargin) {
|
|
6540
|
+
response = await this.sapiGetAssetTradeFee(this.extend(request, params));
|
|
6541
|
+
}
|
|
6542
|
+
else if (isLinear) {
|
|
6543
|
+
response = await this.fapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6544
|
+
}
|
|
6545
|
+
else if (isInverse) {
|
|
6546
|
+
response = await this.dapiPrivateGetCommissionRate(this.extend(request, params));
|
|
6547
|
+
}
|
|
6510
6548
|
//
|
|
6549
|
+
// spot
|
|
6511
6550
|
// [
|
|
6512
6551
|
// {
|
|
6513
6552
|
// "symbol": "BTCUSDT",
|
|
@@ -6516,8 +6555,18 @@ export default class binance extends Exchange {
|
|
|
6516
6555
|
// }
|
|
6517
6556
|
// ]
|
|
6518
6557
|
//
|
|
6519
|
-
|
|
6520
|
-
|
|
6558
|
+
// swap
|
|
6559
|
+
// {
|
|
6560
|
+
// "symbol": "BTCUSD_PERP",
|
|
6561
|
+
// "makerCommissionRate": "0.00015", // 0.015%
|
|
6562
|
+
// "takerCommissionRate": "0.00040" // 0.040%
|
|
6563
|
+
// }
|
|
6564
|
+
//
|
|
6565
|
+
let data = response;
|
|
6566
|
+
if (Array.isArray(data)) {
|
|
6567
|
+
data = this.safeValue(data, 0, {});
|
|
6568
|
+
}
|
|
6569
|
+
return this.parseTradingFee(data);
|
|
6521
6570
|
}
|
|
6522
6571
|
async fetchTradingFees(params = {}) {
|
|
6523
6572
|
/**
|
|
@@ -6532,11 +6581,10 @@ export default class binance extends Exchange {
|
|
|
6532
6581
|
*/
|
|
6533
6582
|
await this.loadMarkets();
|
|
6534
6583
|
let method = undefined;
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
params = this.omit(params, 'type');
|
|
6584
|
+
let type = undefined;
|
|
6585
|
+
[type, params] = this.handleMarketTypeAndParams('fetchTradingFees', undefined, params);
|
|
6538
6586
|
let subType = undefined;
|
|
6539
|
-
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params);
|
|
6587
|
+
[subType, params] = this.handleSubTypeAndParams('fetchTradingFees', undefined, params, 'linear');
|
|
6540
6588
|
const isSpotOrMargin = (type === 'spot') || (type === 'margin');
|
|
6541
6589
|
const isLinear = this.isLinear(type, subType);
|
|
6542
6590
|
const isInverse = this.isInverse(type, subType);
|
|
@@ -8389,7 +8437,7 @@ export default class binance extends Exchange {
|
|
|
8389
8437
|
throw new AuthenticationError(this.id + ' userDataStream endpoint requires `apiKey` credential');
|
|
8390
8438
|
}
|
|
8391
8439
|
}
|
|
8392
|
-
else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2')) {
|
|
8440
|
+
else if ((api === 'private') || (api === 'eapiPrivate') || (api === 'sapi' && path !== 'system/status') || (api === 'sapiV2') || (api === 'sapiV3') || (api === 'sapiV4') || (api === 'wapi' && path !== 'systemStatus') || (api === 'dapiPrivate') || (api === 'dapiPrivateV2') || (api === 'fapiPrivate') || (api === 'fapiPrivateV2') || (api === 'papi')) {
|
|
8393
8441
|
this.checkRequiredCredentials();
|
|
8394
8442
|
if (method === 'POST' && ((path === 'order') || (path === 'sor/order'))) {
|
|
8395
8443
|
// inject in implicit API calls
|
|
@@ -9144,7 +9192,13 @@ export default class binance extends Exchange {
|
|
|
9144
9192
|
// ]
|
|
9145
9193
|
//
|
|
9146
9194
|
if (market['option']) {
|
|
9147
|
-
|
|
9195
|
+
const result = this.parseOpenInterests(response, market);
|
|
9196
|
+
for (let i = 0; i < result.length; i++) {
|
|
9197
|
+
const item = result[i];
|
|
9198
|
+
if (item['symbol'] === symbol) {
|
|
9199
|
+
return item;
|
|
9200
|
+
}
|
|
9201
|
+
}
|
|
9148
9202
|
}
|
|
9149
9203
|
else {
|
|
9150
9204
|
return this.parseOpenInterest(response, market);
|
|
@@ -9157,7 +9211,7 @@ export default class binance extends Exchange {
|
|
|
9157
9211
|
const value = this.safeNumber2(interest, 'sumOpenInterestValue', 'sumOpenInterestUsd');
|
|
9158
9212
|
// Inverse returns the number of contracts different from the base or quote volume in this case
|
|
9159
9213
|
// compared with https://www.binance.com/en/futures/funding-history/quarterly/4
|
|
9160
|
-
return {
|
|
9214
|
+
return this.safeOpenInterest({
|
|
9161
9215
|
'symbol': this.safeSymbol(id, market, undefined, 'contract'),
|
|
9162
9216
|
'baseVolume': market['inverse'] ? undefined : amount,
|
|
9163
9217
|
'quoteVolume': value,
|
|
@@ -9166,6 +9220,6 @@ export default class binance extends Exchange {
|
|
|
9166
9220
|
'timestamp': timestamp,
|
|
9167
9221
|
'datetime': this.iso8601(timestamp),
|
|
9168
9222
|
'info': interest,
|
|
9169
|
-
};
|
|
9223
|
+
}, market);
|
|
9170
9224
|
}
|
|
9171
9225
|
}
|
package/js/src/bingx.d.ts
CHANGED
|
@@ -103,22 +103,8 @@ export default class bingx extends Exchange {
|
|
|
103
103
|
previousFundingDatetime: any;
|
|
104
104
|
};
|
|
105
105
|
fetchFundingRateHistory(symbol?: string, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
106
|
-
fetchOpenInterest(symbol: string, params?: {}): Promise<
|
|
107
|
-
|
|
108
|
-
openInterestAmount: any;
|
|
109
|
-
openInterestValue: number;
|
|
110
|
-
timestamp: number;
|
|
111
|
-
datetime: string;
|
|
112
|
-
info: any;
|
|
113
|
-
}>;
|
|
114
|
-
parseOpenInterest(interest: any, market?: any): {
|
|
115
|
-
symbol: any;
|
|
116
|
-
openInterestAmount: any;
|
|
117
|
-
openInterestValue: number;
|
|
118
|
-
timestamp: number;
|
|
119
|
-
datetime: string;
|
|
120
|
-
info: any;
|
|
121
|
-
};
|
|
106
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
107
|
+
parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
|
|
122
108
|
fetchTicker(symbol: string, params?: {}): Promise<import("./base/types.js").Ticker>;
|
|
123
109
|
fetchTickers(symbols?: string[], params?: {}): Promise<import("./base/types.js").Dictionary<import("./base/types.js").Ticker>>;
|
|
124
110
|
parseTicker(ticker: any, market?: any): import("./base/types.js").Ticker;
|
package/js/src/bingx.js
CHANGED
|
@@ -176,6 +176,13 @@ export default class bingx extends Exchange {
|
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
},
|
|
179
|
+
'v3': {
|
|
180
|
+
'public': {
|
|
181
|
+
'get': {
|
|
182
|
+
'quote/klines': 1,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
179
186
|
},
|
|
180
187
|
'contract': {
|
|
181
188
|
'v1': {
|
|
@@ -633,12 +640,12 @@ export default class bingx extends Exchange {
|
|
|
633
640
|
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
|
|
634
641
|
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#K-Line%20Data
|
|
635
642
|
* @see https://bingx-api.github.io/docs/#/spot/market-api.html#Candlestick%20chart%20data
|
|
643
|
+
* @see https://bingx-api.github.io/docs/#/swapV2/market-api.html#%20K-Line%20Data
|
|
636
644
|
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
|
|
637
645
|
* @param {string} timeframe the length of time each candle represents
|
|
638
646
|
* @param {int} [since] timestamp in ms of the earliest candle to fetch
|
|
639
647
|
* @param {int} [limit] the maximum amount of candles to fetch
|
|
640
648
|
* @param {object} [params] extra parameters specific to the bingx api endpoint
|
|
641
|
-
* @param {string} [params.price] "mark" or "index" for mark price and index price candles
|
|
642
649
|
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
|
|
643
650
|
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
|
|
644
651
|
* @returns {[[int]]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
@@ -660,20 +667,17 @@ export default class bingx extends Exchange {
|
|
|
660
667
|
if (limit !== undefined) {
|
|
661
668
|
request['limit'] = limit;
|
|
662
669
|
}
|
|
663
|
-
|
|
664
|
-
request['limit'] = 50;
|
|
665
|
-
}
|
|
666
|
-
const until = this.safeInteger2(params, 'until', 'startTime');
|
|
670
|
+
const until = this.safeInteger2(params, 'until', 'endTime');
|
|
667
671
|
if (until !== undefined) {
|
|
668
672
|
params = this.omit(params, ['until']);
|
|
669
|
-
request['
|
|
673
|
+
request['endTime'] = until;
|
|
670
674
|
}
|
|
671
675
|
let response = undefined;
|
|
672
676
|
if (market['spot']) {
|
|
673
677
|
response = await this.spotV1PublicGetMarketKline(this.extend(request, params));
|
|
674
678
|
}
|
|
675
679
|
else {
|
|
676
|
-
response = await this.
|
|
680
|
+
response = await this.swapV3PublicGetQuoteKlines(this.extend(request, params));
|
|
677
681
|
}
|
|
678
682
|
//
|
|
679
683
|
// {
|
|
@@ -1174,14 +1178,16 @@ export default class bingx extends Exchange {
|
|
|
1174
1178
|
const id = this.safeString(interest, 'symbol');
|
|
1175
1179
|
const symbol = this.safeSymbol(id, market, '-', 'swap');
|
|
1176
1180
|
const openInterest = this.safeNumber(interest, 'openInterest');
|
|
1177
|
-
return {
|
|
1181
|
+
return this.safeOpenInterest({
|
|
1178
1182
|
'symbol': symbol,
|
|
1183
|
+
'baseVolume': undefined,
|
|
1184
|
+
'quoteVolume': undefined,
|
|
1179
1185
|
'openInterestAmount': undefined,
|
|
1180
1186
|
'openInterestValue': openInterest,
|
|
1181
1187
|
'timestamp': timestamp,
|
|
1182
1188
|
'datetime': this.iso8601(timestamp),
|
|
1183
1189
|
'info': interest,
|
|
1184
|
-
};
|
|
1190
|
+
}, market);
|
|
1185
1191
|
}
|
|
1186
1192
|
async fetchTicker(symbol, params = {}) {
|
|
1187
1193
|
/**
|
package/js/src/bitget.d.ts
CHANGED
|
@@ -247,14 +247,7 @@ export default class bitget extends Exchange {
|
|
|
247
247
|
setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
|
|
248
248
|
setMarginMode(marginMode: any, symbol?: string, params?: {}): Promise<any>;
|
|
249
249
|
setPositionMode(hedged: any, symbol?: string, params?: {}): Promise<any>;
|
|
250
|
-
fetchOpenInterest(symbol: string, params?: {}): Promise<
|
|
251
|
-
symbol: any;
|
|
252
|
-
openInterestAmount: number;
|
|
253
|
-
openInterestValue: any;
|
|
254
|
-
timestamp: number;
|
|
255
|
-
datetime: string;
|
|
256
|
-
info: any;
|
|
257
|
-
}>;
|
|
250
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
258
251
|
fetchTransfers(code?: string, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
259
252
|
transfer(code: string, amount: any, fromAccount: any, toAccount: any, params?: {}): Promise<{
|
|
260
253
|
info: any;
|
|
@@ -292,14 +285,7 @@ export default class bitget extends Exchange {
|
|
|
292
285
|
};
|
|
293
286
|
fetchDepositWithdrawFees(codes?: string[], params?: {}): Promise<any>;
|
|
294
287
|
parseTransferStatus(status: any): string;
|
|
295
|
-
parseOpenInterest(interest: any, market?: any):
|
|
296
|
-
symbol: any;
|
|
297
|
-
openInterestAmount: number;
|
|
298
|
-
openInterestValue: any;
|
|
299
|
-
timestamp: number;
|
|
300
|
-
datetime: string;
|
|
301
|
-
info: any;
|
|
302
|
-
};
|
|
288
|
+
parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
|
|
303
289
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
304
290
|
sign(path: any, api?: any[], method?: string, params?: {}, headers?: any, body?: any): {
|
|
305
291
|
url: string;
|
package/js/src/bitget.js
CHANGED
|
@@ -1576,7 +1576,7 @@ export default class bitget extends Exchange {
|
|
|
1576
1576
|
}
|
|
1577
1577
|
const currency = this.currency(code);
|
|
1578
1578
|
if (since === undefined) {
|
|
1579
|
-
since = this.milliseconds() -
|
|
1579
|
+
since = this.milliseconds() - 7776000000; // 90 days
|
|
1580
1580
|
}
|
|
1581
1581
|
let request = {
|
|
1582
1582
|
'coin': currency['code'],
|
|
@@ -1732,7 +1732,7 @@ export default class bitget extends Exchange {
|
|
|
1732
1732
|
}
|
|
1733
1733
|
const currency = this.currency(code);
|
|
1734
1734
|
if (since === undefined) {
|
|
1735
|
-
since = this.milliseconds() -
|
|
1735
|
+
since = this.milliseconds() - 7776000000; // 90 days
|
|
1736
1736
|
}
|
|
1737
1737
|
let request = {
|
|
1738
1738
|
'coin': currency['code'],
|
|
@@ -4045,10 +4045,17 @@ export default class bitget extends Exchange {
|
|
|
4045
4045
|
response = await this.privateSpotPostTradeFills(this.extend(request, params));
|
|
4046
4046
|
}
|
|
4047
4047
|
else {
|
|
4048
|
+
const orderId = this.safeString(params, 'orderId'); // when order id is not defined, startTime and endTime are required
|
|
4048
4049
|
if (since !== undefined) {
|
|
4049
4050
|
request['startTime'] = since;
|
|
4050
4051
|
}
|
|
4052
|
+
else if (orderId === undefined) {
|
|
4053
|
+
request['startTime'] = 0;
|
|
4054
|
+
}
|
|
4051
4055
|
[request, params] = this.handleUntilOption('endTime', params, request);
|
|
4056
|
+
if (!('endTime' in request) && (orderId === undefined)) {
|
|
4057
|
+
request['endTime'] = this.milliseconds();
|
|
4058
|
+
}
|
|
4052
4059
|
response = await this.privateMixGetOrderFills(this.extend(request, params));
|
|
4053
4060
|
}
|
|
4054
4061
|
//
|
|
@@ -5176,14 +5183,14 @@ export default class bitget extends Exchange {
|
|
|
5176
5183
|
const id = this.safeString(interest, 'symbol');
|
|
5177
5184
|
const symbol = this.safeSymbol(id, market);
|
|
5178
5185
|
const amount = this.safeNumber(interest, 'amount');
|
|
5179
|
-
return {
|
|
5186
|
+
return this.safeOpenInterest({
|
|
5180
5187
|
'symbol': symbol,
|
|
5181
5188
|
'openInterestAmount': amount,
|
|
5182
5189
|
'openInterestValue': undefined,
|
|
5183
5190
|
'timestamp': timestamp,
|
|
5184
5191
|
'datetime': this.iso8601(timestamp),
|
|
5185
5192
|
'info': interest,
|
|
5186
|
-
};
|
|
5193
|
+
}, market);
|
|
5187
5194
|
}
|
|
5188
5195
|
handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
|
|
5189
5196
|
if (!response) {
|
package/js/src/bitmart.d.ts
CHANGED
|
@@ -212,22 +212,8 @@ export default class bitmart extends Exchange {
|
|
|
212
212
|
datetime: string;
|
|
213
213
|
info: any;
|
|
214
214
|
};
|
|
215
|
-
fetchOpenInterest(symbol: string, params?: {}): Promise<
|
|
216
|
-
|
|
217
|
-
openInterestAmount: number;
|
|
218
|
-
openInterestValue: number;
|
|
219
|
-
timestamp: number;
|
|
220
|
-
datetime: string;
|
|
221
|
-
info: any;
|
|
222
|
-
}>;
|
|
223
|
-
parseOpenInterest(interest: any, market?: any): {
|
|
224
|
-
symbol: any;
|
|
225
|
-
openInterestAmount: number;
|
|
226
|
-
openInterestValue: number;
|
|
227
|
-
timestamp: number;
|
|
228
|
-
datetime: string;
|
|
229
|
-
info: any;
|
|
230
|
-
};
|
|
215
|
+
fetchOpenInterest(symbol: string, params?: {}): Promise<import("./base/types.js").OpenInterest>;
|
|
216
|
+
parseOpenInterest(interest: any, market?: any): import("./base/types.js").OpenInterest;
|
|
231
217
|
setLeverage(leverage: any, symbol?: string, params?: {}): Promise<any>;
|
|
232
218
|
fetchFundingRate(symbol: string, params?: {}): Promise<{
|
|
233
219
|
info: any;
|