ccxt 4.1.70 → 4.1.72
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/ccxt.browser.js +400 -159
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +26 -0
- package/dist/cjs/src/binance.js +1 -0
- package/dist/cjs/src/bingx.js +21 -4
- package/dist/cjs/src/coinbase.js +3 -0
- package/dist/cjs/src/coinex.js +26 -8
- package/dist/cjs/src/gate.js +305 -135
- package/dist/cjs/src/mexc.js +4 -4
- package/dist/cjs/src/pro/binance.js +14 -8
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/coinbase.d.ts +3 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +26 -0
- package/js/src/binance.js +1 -0
- package/js/src/bingx.js +21 -4
- package/js/src/coinbase.js +3 -0
- package/js/src/coinex.d.ts +1 -0
- package/js/src/coinex.js +26 -8
- package/js/src/gate.js +305 -135
- package/js/src/mexc.js +4 -4
- package/js/src/pro/binance.js +14 -8
- package/package.json +2 -1
- package/rollup.config.js +13 -0
- package/skip-tests.json +3 -1
package/js/src/gate.js
CHANGED
|
@@ -2238,11 +2238,16 @@ export default class gate extends Exchange {
|
|
|
2238
2238
|
if (limit !== undefined) {
|
|
2239
2239
|
request['limit'] = limit;
|
|
2240
2240
|
}
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
}
|
|
2245
|
-
|
|
2241
|
+
let response = undefined;
|
|
2242
|
+
if (type === 'swap') {
|
|
2243
|
+
response = await this.privateFuturesGetSettleAccountBook(this.extend(request, requestParams));
|
|
2244
|
+
}
|
|
2245
|
+
else if (type === 'future') {
|
|
2246
|
+
response = await this.privateDeliveryGetSettleAccountBook(this.extend(request, requestParams));
|
|
2247
|
+
}
|
|
2248
|
+
else {
|
|
2249
|
+
throw new NotSupported(this.id + ' fetchFundingHistory() only support swap & future market type');
|
|
2250
|
+
}
|
|
2246
2251
|
//
|
|
2247
2252
|
// [
|
|
2248
2253
|
// {
|
|
@@ -2315,18 +2320,26 @@ export default class gate extends Exchange {
|
|
|
2315
2320
|
// };
|
|
2316
2321
|
//
|
|
2317
2322
|
const [request, query] = this.prepareRequest(market, market['type'], params);
|
|
2318
|
-
const method = this.getSupportedMapping(market['type'], {
|
|
2319
|
-
'spot': 'publicSpotGetOrderBook',
|
|
2320
|
-
'margin': 'publicSpotGetOrderBook',
|
|
2321
|
-
'swap': 'publicFuturesGetSettleOrderBook',
|
|
2322
|
-
'future': 'publicDeliveryGetSettleOrderBook',
|
|
2323
|
-
'option': 'publicOptionsGetOrderBook',
|
|
2324
|
-
});
|
|
2325
2323
|
if (limit !== undefined) {
|
|
2326
2324
|
request['limit'] = limit; // default 10, max 100
|
|
2327
2325
|
}
|
|
2328
2326
|
request['with_id'] = true;
|
|
2329
|
-
|
|
2327
|
+
let response = undefined;
|
|
2328
|
+
if (market['spot'] || market['margin']) {
|
|
2329
|
+
response = await this.publicSpotGetOrderBook(this.extend(request, query));
|
|
2330
|
+
}
|
|
2331
|
+
else if (market['swap']) {
|
|
2332
|
+
response = await this.publicFuturesGetSettleOrderBook(this.extend(request, query));
|
|
2333
|
+
}
|
|
2334
|
+
else if (market['future']) {
|
|
2335
|
+
response = await this.publicDeliveryGetSettleOrderBook(this.extend(request, query));
|
|
2336
|
+
}
|
|
2337
|
+
else if (market['option']) {
|
|
2338
|
+
response = await this.publicOptionsGetOrderBook(this.extend(request, query));
|
|
2339
|
+
}
|
|
2340
|
+
else {
|
|
2341
|
+
throw new NotSupported(this.id + ' fetchOrderBook() not support this market type');
|
|
2342
|
+
}
|
|
2330
2343
|
//
|
|
2331
2344
|
// spot
|
|
2332
2345
|
//
|
|
@@ -2418,19 +2431,25 @@ export default class gate extends Exchange {
|
|
|
2418
2431
|
await this.loadMarkets();
|
|
2419
2432
|
const market = this.market(symbol);
|
|
2420
2433
|
const [request, query] = this.prepareRequest(market, undefined, params);
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
}
|
|
2428
|
-
if (market['
|
|
2434
|
+
let response = undefined;
|
|
2435
|
+
if (market['spot'] || market['margin']) {
|
|
2436
|
+
response = await this.publicSpotGetTickers(this.extend(request, query));
|
|
2437
|
+
}
|
|
2438
|
+
else if (market['swap']) {
|
|
2439
|
+
response = await this.publicFuturesGetSettleTickers(this.extend(request, query));
|
|
2440
|
+
}
|
|
2441
|
+
else if (market['future']) {
|
|
2442
|
+
response = await this.publicDeliveryGetSettleTickers(this.extend(request, query));
|
|
2443
|
+
}
|
|
2444
|
+
else if (market['option']) {
|
|
2429
2445
|
const marketId = market['id'];
|
|
2430
2446
|
const optionParts = marketId.split('-');
|
|
2431
2447
|
request['underlying'] = this.safeString(optionParts, 0);
|
|
2448
|
+
response = await this.publicOptionsGetTickers(this.extend(request, query));
|
|
2449
|
+
}
|
|
2450
|
+
else {
|
|
2451
|
+
throw new NotSupported(this.id + ' fetchTicker() not support this market type');
|
|
2432
2452
|
}
|
|
2433
|
-
const response = await this[method](this.extend(request, query));
|
|
2434
2453
|
let ticker = undefined;
|
|
2435
2454
|
if (market['option']) {
|
|
2436
2455
|
for (let i = 0; i < response.length; i++) {
|
|
@@ -2580,20 +2599,26 @@ export default class gate extends Exchange {
|
|
|
2580
2599
|
}
|
|
2581
2600
|
const [type, query] = this.handleMarketTypeAndParams('fetchTickers', market, params);
|
|
2582
2601
|
const [request, requestParams] = this.prepareRequest(undefined, type, query);
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
}
|
|
2590
|
-
if (type === '
|
|
2602
|
+
let response = undefined;
|
|
2603
|
+
if (type === 'spot' || type === 'margin') {
|
|
2604
|
+
response = await this.publicSpotGetTickers(this.extend(request, requestParams));
|
|
2605
|
+
}
|
|
2606
|
+
else if (type === 'swap') {
|
|
2607
|
+
response = await this.publicFuturesGetSettleTickers(this.extend(request, requestParams));
|
|
2608
|
+
}
|
|
2609
|
+
else if (type === 'future') {
|
|
2610
|
+
response = await this.publicDeliveryGetSettleTickers(this.extend(request, requestParams));
|
|
2611
|
+
}
|
|
2612
|
+
else if (type === 'option') {
|
|
2591
2613
|
this.checkRequiredArgument('fetchTickers', symbols, 'symbols');
|
|
2592
2614
|
const marketId = market['id'];
|
|
2593
2615
|
const optionParts = marketId.split('-');
|
|
2594
2616
|
request['underlying'] = this.safeString(optionParts, 0);
|
|
2617
|
+
response = await this.publicOptionsGetTickers(this.extend(request, requestParams));
|
|
2618
|
+
}
|
|
2619
|
+
else {
|
|
2620
|
+
throw new NotSupported(this.id + ' fetchTickers() not support this market type');
|
|
2595
2621
|
}
|
|
2596
|
-
const response = await this[method](this.extend(request, requestParams));
|
|
2597
2622
|
return this.parseTickers(response, symbols);
|
|
2598
2623
|
}
|
|
2599
2624
|
parseBalanceHelper(entry) {
|
|
@@ -2624,18 +2649,36 @@ export default class gate extends Exchange {
|
|
|
2624
2649
|
const market = this.market(symbol);
|
|
2625
2650
|
request['currency_pair'] = market['id'];
|
|
2626
2651
|
}
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
'
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2652
|
+
let response = undefined;
|
|
2653
|
+
if (type === 'spot') {
|
|
2654
|
+
if (marginMode === 'spot') {
|
|
2655
|
+
response = await this.privateSpotGetAccounts(this.extend(request, requestQuery));
|
|
2656
|
+
}
|
|
2657
|
+
else if (marginMode === 'margin') {
|
|
2658
|
+
response = await this.privateMarginGetAccounts(this.extend(request, requestQuery));
|
|
2659
|
+
}
|
|
2660
|
+
else if (marginMode === 'cross_margin') {
|
|
2661
|
+
response = await this.privateMarginGetCrossAccounts(this.extend(request, requestQuery));
|
|
2662
|
+
}
|
|
2663
|
+
else {
|
|
2664
|
+
throw new NotSupported(this.id + ' fetchBalance() not support this marginMode');
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
else if (type === 'funding') {
|
|
2668
|
+
response = await this.privateMarginGetFundingAccounts(this.extend(request, requestQuery));
|
|
2669
|
+
}
|
|
2670
|
+
else if (type === 'swap') {
|
|
2671
|
+
response = await this.privateFuturesGetSettleAccounts(this.extend(request, requestQuery));
|
|
2672
|
+
}
|
|
2673
|
+
else if (type === 'future') {
|
|
2674
|
+
response = await this.privateDeliveryGetSettleAccounts(this.extend(request, requestQuery));
|
|
2675
|
+
}
|
|
2676
|
+
else if (type === 'option') {
|
|
2677
|
+
response = await this.privateOptionsGetAccounts(this.extend(request, requestQuery));
|
|
2678
|
+
}
|
|
2679
|
+
else {
|
|
2680
|
+
throw new NotSupported(this.id + ' fetchBalance() not support this market type');
|
|
2681
|
+
}
|
|
2639
2682
|
const contract = ((type === 'swap') || (type === 'future') || (type === 'option'));
|
|
2640
2683
|
if (contract) {
|
|
2641
2684
|
response = [response];
|
|
@@ -2855,23 +2898,7 @@ export default class gate extends Exchange {
|
|
|
2855
2898
|
let request = {};
|
|
2856
2899
|
[request, params] = this.prepareRequest(market, undefined, params);
|
|
2857
2900
|
request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
2858
|
-
let method = 'publicSpotGetCandlesticks';
|
|
2859
2901
|
let maxLimit = 1000;
|
|
2860
|
-
if (market['contract']) {
|
|
2861
|
-
maxLimit = 1999;
|
|
2862
|
-
if (market['future']) {
|
|
2863
|
-
method = 'publicDeliveryGetSettleCandlesticks';
|
|
2864
|
-
}
|
|
2865
|
-
else if (market['swap']) {
|
|
2866
|
-
method = 'publicFuturesGetSettleCandlesticks';
|
|
2867
|
-
}
|
|
2868
|
-
const isMark = (price === 'mark');
|
|
2869
|
-
const isIndex = (price === 'index');
|
|
2870
|
-
if (isMark || isIndex) {
|
|
2871
|
-
request['contract'] = price + '_' + market['id'];
|
|
2872
|
-
params = this.omit(params, 'price');
|
|
2873
|
-
}
|
|
2874
|
-
}
|
|
2875
2902
|
limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
|
|
2876
2903
|
let until = this.safeInteger(params, 'until');
|
|
2877
2904
|
if (until !== undefined) {
|
|
@@ -2898,7 +2925,25 @@ export default class gate extends Exchange {
|
|
|
2898
2925
|
}
|
|
2899
2926
|
request['limit'] = limit;
|
|
2900
2927
|
}
|
|
2901
|
-
|
|
2928
|
+
let response = undefined;
|
|
2929
|
+
if (market['contract']) {
|
|
2930
|
+
maxLimit = 1999;
|
|
2931
|
+
const isMark = (price === 'mark');
|
|
2932
|
+
const isIndex = (price === 'index');
|
|
2933
|
+
if (isMark || isIndex) {
|
|
2934
|
+
request['contract'] = price + '_' + market['id'];
|
|
2935
|
+
params = this.omit(params, 'price');
|
|
2936
|
+
}
|
|
2937
|
+
if (market['future']) {
|
|
2938
|
+
response = await this.publicDeliveryGetSettleCandlesticks(this.extend(request, params));
|
|
2939
|
+
}
|
|
2940
|
+
else if (market['swap']) {
|
|
2941
|
+
response = await this.publicFuturesGetSettleCandlesticks(this.extend(request, params));
|
|
2942
|
+
}
|
|
2943
|
+
}
|
|
2944
|
+
else {
|
|
2945
|
+
response = await this.publicSpotGetCandlesticks(this.extend(request, params));
|
|
2946
|
+
}
|
|
2902
2947
|
return this.parseOHLCVs(response, market, timeframe, since, limit);
|
|
2903
2948
|
}
|
|
2904
2949
|
async fetchOptionOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
|
|
@@ -2935,8 +2980,7 @@ export default class gate extends Exchange {
|
|
|
2935
2980
|
if (limit !== undefined) {
|
|
2936
2981
|
request['limit'] = limit;
|
|
2937
2982
|
}
|
|
2938
|
-
const
|
|
2939
|
-
const response = await this[method](this.extend(request, query));
|
|
2983
|
+
const response = await this.publicFuturesGetSettleFundingRate(this.extend(request, query));
|
|
2940
2984
|
//
|
|
2941
2985
|
// {
|
|
2942
2986
|
// "r": "0.00063521",
|
|
@@ -3051,13 +3095,6 @@ export default class gate extends Exchange {
|
|
|
3051
3095
|
// };
|
|
3052
3096
|
//
|
|
3053
3097
|
const [request, query] = this.prepareRequest(market, undefined, params);
|
|
3054
|
-
const method = this.getSupportedMapping(market['type'], {
|
|
3055
|
-
'spot': 'publicSpotGetTrades',
|
|
3056
|
-
'margin': 'publicSpotGetTrades',
|
|
3057
|
-
'swap': 'publicFuturesGetSettleTrades',
|
|
3058
|
-
'future': 'publicDeliveryGetSettleTrades',
|
|
3059
|
-
'option': 'publicOptionsGetTrades',
|
|
3060
|
-
});
|
|
3061
3098
|
const until = this.safeInteger2(params, 'to', 'until');
|
|
3062
3099
|
if (until !== undefined) {
|
|
3063
3100
|
params = this.omit(params, ['until']);
|
|
@@ -3069,7 +3106,22 @@ export default class gate extends Exchange {
|
|
|
3069
3106
|
if (since !== undefined && (market['contract'])) {
|
|
3070
3107
|
request['from'] = this.parseToInt(since / 1000);
|
|
3071
3108
|
}
|
|
3072
|
-
|
|
3109
|
+
let response = undefined;
|
|
3110
|
+
if (market['type'] === 'spot' || market['type'] === 'margin') {
|
|
3111
|
+
response = await this.publicSpotGetTrades(this.extend(request, query));
|
|
3112
|
+
}
|
|
3113
|
+
else if (market['swap']) {
|
|
3114
|
+
response = await this.publicFuturesGetSettleTrades(this.extend(request, query));
|
|
3115
|
+
}
|
|
3116
|
+
else if (market['future']) {
|
|
3117
|
+
response = await this.publicDeliveryGetSettleTrades(this.extend(request, query));
|
|
3118
|
+
}
|
|
3119
|
+
else if (market['type'] === 'option') {
|
|
3120
|
+
response = await this.publicOptionsGetTrades(this.extend(request, query));
|
|
3121
|
+
}
|
|
3122
|
+
else {
|
|
3123
|
+
throw new NotSupported(this.id + ' fetchTrades() not support this market type.');
|
|
3124
|
+
}
|
|
3073
3125
|
//
|
|
3074
3126
|
// spot
|
|
3075
3127
|
//
|
|
@@ -3215,14 +3267,22 @@ export default class gate extends Exchange {
|
|
|
3215
3267
|
if (until !== undefined) {
|
|
3216
3268
|
request['to'] = this.parseToInt(until / 1000);
|
|
3217
3269
|
}
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
}
|
|
3225
|
-
|
|
3270
|
+
let response = undefined;
|
|
3271
|
+
if (type === 'spot' || type === 'margin') {
|
|
3272
|
+
response = await this.privateSpotGetMyTrades(this.extend(request, params));
|
|
3273
|
+
}
|
|
3274
|
+
else if (type === 'swap') {
|
|
3275
|
+
response = await this.privateFuturesGetSettleMyTradesTimerange(this.extend(request, params));
|
|
3276
|
+
}
|
|
3277
|
+
else if (type === 'future') {
|
|
3278
|
+
response = await this.privateDeliveryGetSettleMyTrades(this.extend(request, params));
|
|
3279
|
+
}
|
|
3280
|
+
else if (type === 'option') {
|
|
3281
|
+
response = await this.privateOptionsGetMyTrades(this.extend(request, params));
|
|
3282
|
+
}
|
|
3283
|
+
else {
|
|
3284
|
+
throw new NotSupported(this.id + ' fetchMyTrades() not support this market type.');
|
|
3285
|
+
}
|
|
3226
3286
|
//
|
|
3227
3287
|
// spot
|
|
3228
3288
|
//
|
|
@@ -3563,7 +3623,14 @@ export default class gate extends Exchange {
|
|
|
3563
3623
|
'PEND': 'pending',
|
|
3564
3624
|
'REQUEST': 'pending',
|
|
3565
3625
|
'DMOVE': 'pending',
|
|
3566
|
-
'
|
|
3626
|
+
'MANUAL': 'pending',
|
|
3627
|
+
'VERIFY': 'pending',
|
|
3628
|
+
'PROCES': 'pending',
|
|
3629
|
+
'EXTPEND': 'pending',
|
|
3630
|
+
'SPLITPEND': 'pending',
|
|
3631
|
+
'CANCEL': 'canceled',
|
|
3632
|
+
'FAIL': 'failed',
|
|
3633
|
+
'INVALID': 'failed',
|
|
3567
3634
|
'DONE': 'ok',
|
|
3568
3635
|
'BCODE': 'ok', // GateCode withdrawal
|
|
3569
3636
|
};
|
|
@@ -4473,15 +4540,37 @@ export default class gate extends Exchange {
|
|
|
4473
4540
|
const contract = (type === 'swap') || (type === 'future') || (type === 'option');
|
|
4474
4541
|
const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, stop, query);
|
|
4475
4542
|
request['order_id'] = orderId;
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4543
|
+
let response = undefined;
|
|
4544
|
+
if (type === 'spot' || type === 'margin') {
|
|
4545
|
+
if (stop) {
|
|
4546
|
+
response = await this.privateSpotGetPriceOrdersOrderId(this.extend(request, requestParams));
|
|
4547
|
+
}
|
|
4548
|
+
else {
|
|
4549
|
+
response = await this.privateSpotGetOrdersOrderId(this.extend(request, requestParams));
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
else if (type === 'swap') {
|
|
4553
|
+
if (stop) {
|
|
4554
|
+
response = await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4555
|
+
}
|
|
4556
|
+
else {
|
|
4557
|
+
response = await this.privateFuturesGetSettleOrdersOrderId(this.extend(request, requestParams));
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
else if (type === 'future') {
|
|
4561
|
+
if (stop) {
|
|
4562
|
+
response = await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4563
|
+
}
|
|
4564
|
+
else {
|
|
4565
|
+
response = await this.privateDeliveryGetSettleOrdersOrderId(this.extend(request, requestParams));
|
|
4566
|
+
}
|
|
4567
|
+
}
|
|
4568
|
+
else if (type === 'option') {
|
|
4569
|
+
response = await this.privateOptionsGetOrdersOrderId(this.extend(request, requestParams));
|
|
4570
|
+
}
|
|
4571
|
+
else {
|
|
4572
|
+
throw new NotSupported(this.id + ' fetchOrder() not support this market type');
|
|
4573
|
+
}
|
|
4485
4574
|
return this.parseOrder(response, market);
|
|
4486
4575
|
}
|
|
4487
4576
|
async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -4546,19 +4635,41 @@ export default class gate extends Exchange {
|
|
|
4546
4635
|
if (since !== undefined && spot) {
|
|
4547
4636
|
request['from'] = this.parseToInt(since / 1000);
|
|
4548
4637
|
}
|
|
4549
|
-
let methodTail = stop ? 'PriceOrders' : 'Orders';
|
|
4550
4638
|
const openSpotOrders = spot && (status === 'open') && !stop;
|
|
4551
|
-
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
|
-
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4639
|
+
let response = undefined;
|
|
4640
|
+
if (type === 'spot' || type === 'margin') {
|
|
4641
|
+
if (openSpotOrders) {
|
|
4642
|
+
response = await this.privateSpotGetOpenOrders(this.extend(request, requestParams));
|
|
4643
|
+
}
|
|
4644
|
+
else if (stop) {
|
|
4645
|
+
response = await this.privateSpotGetPriceOrders(this.extend(request, requestParams));
|
|
4646
|
+
}
|
|
4647
|
+
else {
|
|
4648
|
+
response = await this.privateSpotGetOrders(this.extend(request, requestParams));
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
else if (type === 'swap') {
|
|
4652
|
+
if (stop) {
|
|
4653
|
+
response = await this.privateFuturesGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4654
|
+
}
|
|
4655
|
+
else {
|
|
4656
|
+
response = await this.privateFuturesGetSettleOrders(this.extend(request, requestParams));
|
|
4657
|
+
}
|
|
4658
|
+
}
|
|
4659
|
+
else if (type === 'future') {
|
|
4660
|
+
if (stop) {
|
|
4661
|
+
response = await this.privateDeliveryGetSettlePriceOrders(this.extend(request, requestParams));
|
|
4662
|
+
}
|
|
4663
|
+
else {
|
|
4664
|
+
response = await this.privateDeliveryGetSettleOrders(this.extend(request, requestParams));
|
|
4665
|
+
}
|
|
4666
|
+
}
|
|
4667
|
+
else if (type === 'option') {
|
|
4668
|
+
response = await this.privateOptionsGetOrders(this.extend(request, requestParams));
|
|
4669
|
+
}
|
|
4670
|
+
else {
|
|
4671
|
+
throw new NotSupported(this.id + ' fetchOrders() not support this market type');
|
|
4672
|
+
}
|
|
4562
4673
|
//
|
|
4563
4674
|
// spot open orders
|
|
4564
4675
|
//
|
|
@@ -4738,15 +4849,37 @@ export default class gate extends Exchange {
|
|
|
4738
4849
|
const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
4739
4850
|
const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
4740
4851
|
request['order_id'] = id;
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4852
|
+
let response = undefined;
|
|
4853
|
+
if (type === 'spot' || type === 'margin') {
|
|
4854
|
+
if (stop) {
|
|
4855
|
+
response = await this.privateSpotDeletePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4856
|
+
}
|
|
4857
|
+
else {
|
|
4858
|
+
response = await this.privateSpotDeleteOrdersOrderId(this.extend(request, requestParams));
|
|
4859
|
+
}
|
|
4860
|
+
}
|
|
4861
|
+
else if (type === 'swap') {
|
|
4862
|
+
if (stop) {
|
|
4863
|
+
response = await this.privateFuturesDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4864
|
+
}
|
|
4865
|
+
else {
|
|
4866
|
+
response = await this.privateFuturesDeleteSettleOrdersOrderId(this.extend(request, requestParams));
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
else if (type === 'future') {
|
|
4870
|
+
if (stop) {
|
|
4871
|
+
response = await this.privateDeliveryDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4872
|
+
}
|
|
4873
|
+
else {
|
|
4874
|
+
response = await this.privateDeliveryDeleteSettleOrdersOrderId(this.extend(request, requestParams));
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
else if (type === 'option') {
|
|
4878
|
+
response = await this.privateOptionsDeleteOrdersOrderId(this.extend(request, requestParams));
|
|
4879
|
+
}
|
|
4880
|
+
else {
|
|
4881
|
+
throw new NotSupported(this.id + ' cancelOrder() not support this market type');
|
|
4882
|
+
}
|
|
4750
4883
|
//
|
|
4751
4884
|
// spot
|
|
4752
4885
|
//
|
|
@@ -4849,15 +4982,37 @@ export default class gate extends Exchange {
|
|
|
4849
4982
|
params = this.omit(params, 'stop');
|
|
4850
4983
|
const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
|
|
4851
4984
|
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, stop, query) : this.prepareRequest(market, type, query);
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4985
|
+
let response = undefined;
|
|
4986
|
+
if (type === 'spot' || type === 'margin') {
|
|
4987
|
+
if (stop) {
|
|
4988
|
+
response = await this.privateSpotDeletePriceOrders(this.extend(request, requestParams));
|
|
4989
|
+
}
|
|
4990
|
+
else {
|
|
4991
|
+
response = await this.privateSpotDeleteOrders(this.extend(request, requestParams));
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
else if (type === 'swap') {
|
|
4995
|
+
if (stop) {
|
|
4996
|
+
response = await this.privateFuturesDeleteSettlePriceOrders(this.extend(request, requestParams));
|
|
4997
|
+
}
|
|
4998
|
+
else {
|
|
4999
|
+
response = await this.privateFuturesDeleteSettleOrders(this.extend(request, requestParams));
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
else if (type === 'future') {
|
|
5003
|
+
if (stop) {
|
|
5004
|
+
response = await this.privateDeliveryDeleteSettlePriceOrders(this.extend(request, requestParams));
|
|
5005
|
+
}
|
|
5006
|
+
else {
|
|
5007
|
+
response = await this.privateDeliveryDeleteSettleOrders(this.extend(request, requestParams));
|
|
5008
|
+
}
|
|
5009
|
+
}
|
|
5010
|
+
else if (type === 'option') {
|
|
5011
|
+
response = await this.privateOptionsDeleteOrders(this.extend(request, requestParams));
|
|
5012
|
+
}
|
|
5013
|
+
else {
|
|
5014
|
+
throw new NotSupported(this.id + ' cancelAllOrders() not support this market type');
|
|
5015
|
+
}
|
|
4861
5016
|
//
|
|
4862
5017
|
// [
|
|
4863
5018
|
// {
|
|
@@ -4987,10 +5142,6 @@ export default class gate extends Exchange {
|
|
|
4987
5142
|
}
|
|
4988
5143
|
await this.loadMarkets();
|
|
4989
5144
|
const market = this.market(symbol);
|
|
4990
|
-
const method = this.getSupportedMapping(market['type'], {
|
|
4991
|
-
'swap': 'privateFuturesPostSettlePositionsContractLeverage',
|
|
4992
|
-
'future': 'privateDeliveryPostSettlePositionsContractLeverage',
|
|
4993
|
-
});
|
|
4994
5145
|
const [request, query] = this.prepareRequest(market, undefined, params);
|
|
4995
5146
|
const defaultMarginMode = this.safeString2(this.options, 'marginMode', 'defaultMarginMode');
|
|
4996
5147
|
const crossLeverageLimit = this.safeString(query, 'cross_leverage_limit');
|
|
@@ -5006,7 +5157,16 @@ export default class gate extends Exchange {
|
|
|
5006
5157
|
else {
|
|
5007
5158
|
request['leverage'] = leverage.toString();
|
|
5008
5159
|
}
|
|
5009
|
-
|
|
5160
|
+
let response = undefined;
|
|
5161
|
+
if (market['swap']) {
|
|
5162
|
+
response = await this.privateFuturesPostSettlePositionsContractLeverage(this.extend(request, query));
|
|
5163
|
+
}
|
|
5164
|
+
else if (market['future']) {
|
|
5165
|
+
response = await this.privateDeliveryPostSettlePositionsContractLeverage(this.extend(request, query));
|
|
5166
|
+
}
|
|
5167
|
+
else {
|
|
5168
|
+
throw new NotSupported(this.id + ' setLeverage() not support this market type');
|
|
5169
|
+
}
|
|
5010
5170
|
//
|
|
5011
5171
|
// {
|
|
5012
5172
|
// "value": "0",
|
|
@@ -5167,10 +5327,10 @@ export default class gate extends Exchange {
|
|
|
5167
5327
|
[request, params] = this.prepareRequest(market, market['type'], params);
|
|
5168
5328
|
const extendedRequest = this.extend(request, params);
|
|
5169
5329
|
let response = undefined;
|
|
5170
|
-
if (market['
|
|
5330
|
+
if (market['swap']) {
|
|
5171
5331
|
response = await this.privateFuturesGetSettlePositionsContract(extendedRequest);
|
|
5172
5332
|
}
|
|
5173
|
-
else if (market['
|
|
5333
|
+
else if (market['future']) {
|
|
5174
5334
|
response = await this.privateDeliveryGetSettlePositionsContract(extendedRequest);
|
|
5175
5335
|
}
|
|
5176
5336
|
else if (market['type'] === 'option') {
|
|
@@ -5350,11 +5510,16 @@ export default class gate extends Exchange {
|
|
|
5350
5510
|
if (type !== 'future' && type !== 'swap') {
|
|
5351
5511
|
throw new BadRequest(this.id + ' fetchLeverageTiers only supports swap and future');
|
|
5352
5512
|
}
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
}
|
|
5357
|
-
|
|
5513
|
+
let response = undefined;
|
|
5514
|
+
if (type === 'swap') {
|
|
5515
|
+
response = await this.publicFuturesGetSettleContracts(this.extend(request, requestParams));
|
|
5516
|
+
}
|
|
5517
|
+
else if (type === 'future') {
|
|
5518
|
+
response = await this.publicDeliveryGetSettleContracts(this.extend(request, requestParams));
|
|
5519
|
+
}
|
|
5520
|
+
else {
|
|
5521
|
+
throw new NotSupported(this.id + ' fetchLeverageTiers() not support this market type');
|
|
5522
|
+
}
|
|
5358
5523
|
//
|
|
5359
5524
|
// Perpetual swap
|
|
5360
5525
|
//
|
|
@@ -5860,11 +6025,16 @@ export default class gate extends Exchange {
|
|
|
5860
6025
|
const market = this.market(symbol);
|
|
5861
6026
|
const [request, query] = this.prepareRequest(market, undefined, params);
|
|
5862
6027
|
request['change'] = this.numberToString(amount);
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
}
|
|
5867
|
-
|
|
6028
|
+
let response = undefined;
|
|
6029
|
+
if (market['swap']) {
|
|
6030
|
+
response = await this.privateFuturesPostSettlePositionsContractMargin(this.extend(request, query));
|
|
6031
|
+
}
|
|
6032
|
+
else if (market['future']) {
|
|
6033
|
+
response = await this.privateDeliveryPostSettlePositionsContractMargin(this.extend(request, query));
|
|
6034
|
+
}
|
|
6035
|
+
else {
|
|
6036
|
+
throw new NotSupported(this.id + ' modifyMarginHelper() not support this market type');
|
|
6037
|
+
}
|
|
5868
6038
|
return this.parseMarginModification(response, market);
|
|
5869
6039
|
}
|
|
5870
6040
|
parseMarginModification(data, market = undefined) {
|
package/js/src/mexc.js
CHANGED
|
@@ -2086,7 +2086,7 @@ export default class mexc extends Exchange {
|
|
|
2086
2086
|
}
|
|
2087
2087
|
createSpotOrderRequest(market, type, side, amount, price = undefined, marginMode = undefined, params = {}) {
|
|
2088
2088
|
const symbol = market['symbol'];
|
|
2089
|
-
const orderSide = (
|
|
2089
|
+
const orderSide = side.toUpperCase();
|
|
2090
2090
|
const request = {
|
|
2091
2091
|
'symbol': market['id'],
|
|
2092
2092
|
'side': orderSide,
|
|
@@ -2105,10 +2105,10 @@ export default class mexc extends Exchange {
|
|
|
2105
2105
|
const amountString = this.numberToString(amount);
|
|
2106
2106
|
const priceString = this.numberToString(price);
|
|
2107
2107
|
const quoteAmount = Precise.stringMul(amountString, priceString);
|
|
2108
|
-
amount =
|
|
2108
|
+
amount = quoteAmount;
|
|
2109
2109
|
}
|
|
2110
2110
|
}
|
|
2111
|
-
request['quoteOrderQty'] = amount;
|
|
2111
|
+
request['quoteOrderQty'] = this.costToPrecision(symbol, amount);
|
|
2112
2112
|
}
|
|
2113
2113
|
else {
|
|
2114
2114
|
request['quantity'] = this.amountToPrecision(symbol, amount);
|
|
@@ -2308,7 +2308,7 @@ export default class mexc extends Exchange {
|
|
|
2308
2308
|
ordersRequests.push(orderRequest);
|
|
2309
2309
|
}
|
|
2310
2310
|
const request = {
|
|
2311
|
-
'batchOrders': ordersRequests,
|
|
2311
|
+
'batchOrders': this.json(ordersRequests),
|
|
2312
2312
|
};
|
|
2313
2313
|
const response = await this.spotPrivatePostBatchOrders(request);
|
|
2314
2314
|
//
|