ccxt 4.4.34 → 4.4.36
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 +6 -5
- package/dist/ccxt.browser.min.js +3 -3
- package/dist/cjs/ccxt.js +6 -1
- package/dist/cjs/src/abstract/defx.js +9 -0
- package/dist/cjs/src/bingx.js +339 -144
- package/dist/cjs/src/bitfinex2.js +20 -12
- package/dist/cjs/src/bitmex.js +104 -2
- package/dist/cjs/src/bitopro.js +22 -4
- package/dist/cjs/src/bitrue.js +2 -2
- package/dist/cjs/src/bitso.js +2 -1
- package/dist/cjs/src/btcmarkets.js +3 -3
- package/dist/cjs/src/btcturk.js +19 -19
- package/dist/cjs/src/bybit.js +20 -0
- package/dist/cjs/src/defx.js +2048 -0
- package/dist/cjs/src/deribit.js +34 -14
- package/dist/cjs/src/gate.js +158 -41
- package/dist/cjs/src/hashkey.js +1 -1
- package/dist/cjs/src/htx.js +14 -2
- package/dist/cjs/src/hyperliquid.js +73 -11
- package/dist/cjs/src/idex.js +3 -3
- package/dist/cjs/src/kraken.js +110 -102
- package/dist/cjs/src/kucoin.js +1 -1
- package/dist/cjs/src/okx.js +1 -0
- package/dist/cjs/src/onetrading.js +20 -395
- package/dist/cjs/src/pro/bitrue.js +13 -11
- package/dist/cjs/src/pro/defx.js +864 -0
- package/dist/cjs/src/pro/probit.js +58 -66
- package/dist/cjs/src/xt.js +5 -5
- package/js/ccxt.d.ts +8 -2
- package/js/ccxt.js +6 -2
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/bitopro.d.ts +1 -0
- package/js/src/abstract/bitpanda.d.ts +0 -12
- package/js/src/abstract/bitrue.d.ts +3 -3
- package/js/src/abstract/bybit.d.ts +15 -0
- package/js/src/abstract/defx.d.ts +72 -0
- package/js/src/abstract/defx.js +11 -0
- package/js/src/abstract/deribit.d.ts +1 -0
- package/js/src/abstract/gate.d.ts +14 -0
- package/js/src/abstract/gateio.d.ts +14 -0
- package/js/src/abstract/okx.d.ts +1 -0
- package/js/src/abstract/onetrading.d.ts +0 -12
- package/js/src/bingx.d.ts +8 -0
- package/js/src/bingx.js +339 -144
- package/js/src/bitfinex2.js +21 -13
- package/js/src/bitmex.js +104 -2
- package/js/src/bitopro.d.ts +11 -0
- package/js/src/bitopro.js +22 -4
- package/js/src/bitrue.js +2 -2
- package/js/src/bitso.js +2 -1
- package/js/src/btcmarkets.js +3 -3
- package/js/src/btcturk.js +19 -19
- package/js/src/bybit.js +20 -0
- package/js/src/defx.d.ts +349 -0
- package/js/src/defx.js +2049 -0
- package/js/src/deribit.d.ts +2 -0
- package/js/src/deribit.js +34 -14
- package/js/src/gate.d.ts +5 -5
- package/js/src/gate.js +158 -41
- package/js/src/hashkey.js +1 -1
- package/js/src/htx.d.ts +3 -0
- package/js/src/htx.js +14 -2
- package/js/src/hyperliquid.d.ts +10 -0
- package/js/src/hyperliquid.js +75 -13
- package/js/src/idex.js +4 -4
- package/js/src/kraken.d.ts +11 -8
- package/js/src/kraken.js +110 -102
- package/js/src/kucoin.js +1 -1
- package/js/src/okx.js +1 -0
- package/js/src/onetrading.d.ts +15 -67
- package/js/src/onetrading.js +20 -395
- package/js/src/pro/bitrue.js +13 -11
- package/js/src/pro/defx.d.ts +236 -0
- package/js/src/pro/defx.js +865 -0
- package/js/src/pro/probit.d.ts +2 -1
- package/js/src/pro/probit.js +58 -66
- package/js/src/xt.js +5 -5
- package/package.json +2 -1
package/dist/cjs/src/deribit.js
CHANGED
|
@@ -207,6 +207,7 @@ class deribit extends deribit$1 {
|
|
|
207
207
|
'enable_api_key': 1,
|
|
208
208
|
'get_access_log': 1,
|
|
209
209
|
'get_account_summary': 1,
|
|
210
|
+
'get_account_summaries': 1,
|
|
210
211
|
'get_affiliate_program_info': 1,
|
|
211
212
|
'get_email_language': 1,
|
|
212
213
|
'get_new_announcements': 1,
|
|
@@ -939,13 +940,23 @@ class deribit extends deribit$1 {
|
|
|
939
940
|
const result = {
|
|
940
941
|
'info': balance,
|
|
941
942
|
};
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
943
|
+
let summaries = [];
|
|
944
|
+
if ('summaries' in balance) {
|
|
945
|
+
summaries = this.safeList(balance, 'summaries');
|
|
946
|
+
}
|
|
947
|
+
else {
|
|
948
|
+
summaries = [balance];
|
|
949
|
+
}
|
|
950
|
+
for (let i = 0; i < summaries.length; i++) {
|
|
951
|
+
const data = summaries[i];
|
|
952
|
+
const currencyId = this.safeString(data, 'currency');
|
|
953
|
+
const currencyCode = this.safeCurrencyCode(currencyId);
|
|
954
|
+
const account = this.account();
|
|
955
|
+
account['free'] = this.safeString(data, 'available_funds');
|
|
956
|
+
account['used'] = this.safeString(data, 'maintenance_margin');
|
|
957
|
+
account['total'] = this.safeString(data, 'equity');
|
|
958
|
+
result[currencyCode] = account;
|
|
959
|
+
}
|
|
949
960
|
return this.safeBalance(result);
|
|
950
961
|
}
|
|
951
962
|
/**
|
|
@@ -953,17 +964,26 @@ class deribit extends deribit$1 {
|
|
|
953
964
|
* @name deribit#fetchBalance
|
|
954
965
|
* @description query for balance and get the amount of funds available for trading or funds locked in orders
|
|
955
966
|
* @see https://docs.deribit.com/#private-get_account_summary
|
|
967
|
+
* @see https://docs.deribit.com/#private-get_account_summaries
|
|
956
968
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
969
|
+
* @param {string} [params.code] unified currency code of the currency for the balance, if defined 'privateGetGetAccountSummary' will be used, otherwise 'privateGetGetAccountSummaries' will be used
|
|
957
970
|
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
|
|
958
971
|
*/
|
|
959
972
|
async fetchBalance(params = {}) {
|
|
960
973
|
await this.loadMarkets();
|
|
961
|
-
const code = this.
|
|
962
|
-
|
|
963
|
-
const request = {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
974
|
+
const code = this.safeString(params, 'code');
|
|
975
|
+
params = this.omit(params, 'code');
|
|
976
|
+
const request = {};
|
|
977
|
+
if (code !== undefined) {
|
|
978
|
+
request['currency'] = this.currencyId(code);
|
|
979
|
+
}
|
|
980
|
+
let response = undefined;
|
|
981
|
+
if (code === undefined) {
|
|
982
|
+
response = await this.privateGetGetAccountSummaries(params);
|
|
983
|
+
}
|
|
984
|
+
else {
|
|
985
|
+
response = await this.privateGetGetAccountSummary(this.extend(request, params));
|
|
986
|
+
}
|
|
967
987
|
//
|
|
968
988
|
// {
|
|
969
989
|
// "jsonrpc": "2.0",
|
|
@@ -1006,7 +1026,7 @@ class deribit extends deribit$1 {
|
|
|
1006
1026
|
// "testnet": false
|
|
1007
1027
|
// }
|
|
1008
1028
|
//
|
|
1009
|
-
const result = this.
|
|
1029
|
+
const result = this.safeDict(response, 'result', {});
|
|
1010
1030
|
return this.parseBalance(result);
|
|
1011
1031
|
}
|
|
1012
1032
|
/**
|
package/dist/cjs/src/gate.js
CHANGED
|
@@ -221,6 +221,7 @@ class gate extends gate$1 {
|
|
|
221
221
|
'{settle}/contract_stats': 1,
|
|
222
222
|
'{settle}/index_constituents/{index}': 1,
|
|
223
223
|
'{settle}/liq_orders': 1,
|
|
224
|
+
'{settle}/risk_limit_tiers': 1,
|
|
224
225
|
},
|
|
225
226
|
},
|
|
226
227
|
'delivery': {
|
|
@@ -261,7 +262,8 @@ class gate extends gate$1 {
|
|
|
261
262
|
// private endpoints default is 150r/10s per endpoint
|
|
262
263
|
'withdrawals': {
|
|
263
264
|
'post': {
|
|
264
|
-
'withdrawals': 20,
|
|
265
|
+
'withdrawals': 20,
|
|
266
|
+
'push': 1,
|
|
265
267
|
},
|
|
266
268
|
'delete': {
|
|
267
269
|
'withdrawals/{withdrawal_id}': 1,
|
|
@@ -273,6 +275,7 @@ class gate extends gate$1 {
|
|
|
273
275
|
'withdrawals': 1,
|
|
274
276
|
'deposits': 1,
|
|
275
277
|
'sub_account_transfers': 1,
|
|
278
|
+
'order_status': 1,
|
|
276
279
|
'withdraw_status': 1,
|
|
277
280
|
'sub_account_balances': 2.5,
|
|
278
281
|
'sub_account_margin_balances': 2.5,
|
|
@@ -283,6 +286,7 @@ class gate extends gate$1 {
|
|
|
283
286
|
'total_balance': 2.5,
|
|
284
287
|
'small_balance': 1,
|
|
285
288
|
'small_balance_history': 1,
|
|
289
|
+
'push': 1,
|
|
286
290
|
},
|
|
287
291
|
'post': {
|
|
288
292
|
'transfers': 2.5,
|
|
@@ -325,11 +329,14 @@ class gate extends gate$1 {
|
|
|
325
329
|
'risk_units': 20 / 15,
|
|
326
330
|
'unified_mode': 20 / 15,
|
|
327
331
|
'loan_margin_tiers': 20 / 15,
|
|
332
|
+
'leverage/user_currency_config': 20 / 15,
|
|
333
|
+
'leverage/user_currency_setting': 20 / 15,
|
|
328
334
|
},
|
|
329
335
|
'post': {
|
|
330
336
|
'account_mode': 20 / 15,
|
|
331
337
|
'loans': 200 / 15,
|
|
332
338
|
'portfolio_calculator': 20 / 15,
|
|
339
|
+
'leverage/user_currency_setting': 20 / 15,
|
|
333
340
|
},
|
|
334
341
|
'put': {
|
|
335
342
|
'unified_mode': 20 / 15,
|
|
@@ -509,9 +516,13 @@ class gate extends gate$1 {
|
|
|
509
516
|
'orders': 20 / 15,
|
|
510
517
|
'orders/{order_id}': 20 / 15,
|
|
511
518
|
'my_trades': 20 / 15,
|
|
519
|
+
'mmp': 20 / 15,
|
|
512
520
|
},
|
|
513
521
|
'post': {
|
|
514
522
|
'orders': 20 / 15,
|
|
523
|
+
'countdown_cancel_all': 20 / 15,
|
|
524
|
+
'mmp': 20 / 15,
|
|
525
|
+
'mmp/reset': 20 / 15,
|
|
515
526
|
},
|
|
516
527
|
'delete': {
|
|
517
528
|
'orders': 20 / 15,
|
|
@@ -555,6 +566,7 @@ class gate extends gate$1 {
|
|
|
555
566
|
'multi_collateral/currencies': 20 / 15,
|
|
556
567
|
'multi_collateral/ltv': 20 / 15,
|
|
557
568
|
'multi_collateral/fixed_rate': 20 / 15,
|
|
569
|
+
'multi_collateral/current_rate': 20 / 15,
|
|
558
570
|
},
|
|
559
571
|
'post': {
|
|
560
572
|
'collateral/orders': 20 / 15,
|
|
@@ -568,8 +580,10 @@ class gate extends gate$1 {
|
|
|
568
580
|
'account': {
|
|
569
581
|
'get': {
|
|
570
582
|
'detail': 20 / 15,
|
|
583
|
+
'rate_limit': 20 / 15,
|
|
571
584
|
'stp_groups': 20 / 15,
|
|
572
585
|
'stp_groups/{stp_id}/users': 20 / 15,
|
|
586
|
+
'stp_groups/debit_fee': 20 / 15,
|
|
573
587
|
},
|
|
574
588
|
'post': {
|
|
575
589
|
'stp_groups': 20 / 15,
|
|
@@ -690,6 +704,110 @@ class gate extends gate$1 {
|
|
|
690
704
|
},
|
|
691
705
|
},
|
|
692
706
|
},
|
|
707
|
+
'features': {
|
|
708
|
+
'spot': {
|
|
709
|
+
'sandbox': true,
|
|
710
|
+
'createOrder': {
|
|
711
|
+
'marginMode': true,
|
|
712
|
+
'triggerPrice': true,
|
|
713
|
+
'triggerDirection': true,
|
|
714
|
+
'triggerPriceType': undefined,
|
|
715
|
+
'stopLossPrice': true,
|
|
716
|
+
'takeProfitPrice': true,
|
|
717
|
+
'attachedStopLossTakeProfit': undefined,
|
|
718
|
+
'timeInForce': {
|
|
719
|
+
'GTC': true,
|
|
720
|
+
'IOC': true,
|
|
721
|
+
'FOK': true,
|
|
722
|
+
'PO': true,
|
|
723
|
+
'GTD': false,
|
|
724
|
+
},
|
|
725
|
+
'hedged': false,
|
|
726
|
+
'trailing': false,
|
|
727
|
+
// exchange-specific features
|
|
728
|
+
'iceberg': true,
|
|
729
|
+
'selfTradePrevention': true,
|
|
730
|
+
},
|
|
731
|
+
'createOrders': {
|
|
732
|
+
'max': 40, // NOTE! max 10 per symbol
|
|
733
|
+
},
|
|
734
|
+
'fetchMyTrades': {
|
|
735
|
+
'marginMode': true,
|
|
736
|
+
'limit': 1000,
|
|
737
|
+
'daysBack': undefined,
|
|
738
|
+
'untilDays': 30,
|
|
739
|
+
},
|
|
740
|
+
'fetchOrder': {
|
|
741
|
+
'marginMode': false,
|
|
742
|
+
'trigger': true,
|
|
743
|
+
'trailing': false,
|
|
744
|
+
},
|
|
745
|
+
'fetchOpenOrders': {
|
|
746
|
+
'marginMode': true,
|
|
747
|
+
'trigger': true,
|
|
748
|
+
'trailing': false,
|
|
749
|
+
'limit': 100,
|
|
750
|
+
},
|
|
751
|
+
'fetchOrders': undefined,
|
|
752
|
+
'fetchClosedOrders': {
|
|
753
|
+
'marginMode': true,
|
|
754
|
+
'trigger': true,
|
|
755
|
+
'trailing': false,
|
|
756
|
+
'limit': 100,
|
|
757
|
+
'untilDays': 30,
|
|
758
|
+
'daysBackClosed': undefined,
|
|
759
|
+
'daysBackCanceled': undefined,
|
|
760
|
+
},
|
|
761
|
+
'fetchOHLCV': {
|
|
762
|
+
'limit': 1000,
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
'forDerivatives': {
|
|
766
|
+
'extends': 'spot',
|
|
767
|
+
'createOrder': {
|
|
768
|
+
'marginMode': false,
|
|
769
|
+
'triggerPriceType': {
|
|
770
|
+
'last': true,
|
|
771
|
+
'mark': true,
|
|
772
|
+
'index': true,
|
|
773
|
+
},
|
|
774
|
+
},
|
|
775
|
+
'createOrders': {
|
|
776
|
+
'max': 10,
|
|
777
|
+
},
|
|
778
|
+
'fetchMyTrades': {
|
|
779
|
+
'marginMode': false,
|
|
780
|
+
'untilDays': undefined,
|
|
781
|
+
},
|
|
782
|
+
'fetchOpenOrders': {
|
|
783
|
+
'marginMode': false,
|
|
784
|
+
},
|
|
785
|
+
'fetchClosedOrders': {
|
|
786
|
+
'marginMode': false,
|
|
787
|
+
'untilDays': undefined,
|
|
788
|
+
'limit': 1000,
|
|
789
|
+
},
|
|
790
|
+
'fetchOHLCV': {
|
|
791
|
+
'limit': 1999,
|
|
792
|
+
},
|
|
793
|
+
},
|
|
794
|
+
'swap': {
|
|
795
|
+
'linear': {
|
|
796
|
+
'extends': 'forDerivatives',
|
|
797
|
+
},
|
|
798
|
+
'inverse': {
|
|
799
|
+
'extends': 'forDerivatives',
|
|
800
|
+
},
|
|
801
|
+
},
|
|
802
|
+
'future': {
|
|
803
|
+
'linear': {
|
|
804
|
+
'extends': 'forDerivatives',
|
|
805
|
+
},
|
|
806
|
+
'inverse': {
|
|
807
|
+
'extends': 'forDerivatives',
|
|
808
|
+
},
|
|
809
|
+
},
|
|
810
|
+
},
|
|
693
811
|
'precisionMode': number.TICK_SIZE,
|
|
694
812
|
'fees': {
|
|
695
813
|
'trading': {
|
|
@@ -1540,25 +1658,25 @@ class gate extends gate$1 {
|
|
|
1540
1658
|
}
|
|
1541
1659
|
return [request, params];
|
|
1542
1660
|
}
|
|
1543
|
-
spotOrderPrepareRequest(market = undefined,
|
|
1661
|
+
spotOrderPrepareRequest(market = undefined, trigger = false, params = {}) {
|
|
1544
1662
|
/**
|
|
1545
1663
|
* @ignore
|
|
1546
1664
|
* @method
|
|
1547
1665
|
* @name gate#multiOrderSpotPrepareRequest
|
|
1548
1666
|
* @description Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
|
|
1549
1667
|
* @param {object} market CCXT market
|
|
1550
|
-
* @param {bool}
|
|
1668
|
+
* @param {bool} trigger true if for a trigger order
|
|
1551
1669
|
* @param {object} [params] request parameters
|
|
1552
1670
|
* @returns the api request object, and the new params object with non-needed parameters removed
|
|
1553
1671
|
*/
|
|
1554
|
-
const [marginMode, query] = this.getMarginMode(
|
|
1672
|
+
const [marginMode, query] = this.getMarginMode(trigger, params);
|
|
1555
1673
|
const request = {};
|
|
1556
|
-
if (!
|
|
1674
|
+
if (!trigger) {
|
|
1557
1675
|
if (market === undefined) {
|
|
1558
|
-
throw new errors.ArgumentsRequired(this.id + ' spotOrderPrepareRequest() requires a market argument for non-
|
|
1676
|
+
throw new errors.ArgumentsRequired(this.id + ' spotOrderPrepareRequest() requires a market argument for non-trigger orders');
|
|
1559
1677
|
}
|
|
1560
1678
|
request['account'] = marginMode;
|
|
1561
|
-
request['currency_pair'] = market['id']; // Should always be set for non-
|
|
1679
|
+
request['currency_pair'] = market['id']; // Should always be set for non-trigger
|
|
1562
1680
|
}
|
|
1563
1681
|
return [request, query];
|
|
1564
1682
|
}
|
|
@@ -1569,7 +1687,7 @@ class gate extends gate$1 {
|
|
|
1569
1687
|
* @name gate#multiOrderSpotPrepareRequest
|
|
1570
1688
|
* @description Fills request params currency_pair, market and account where applicable for spot order methods like fetchOpenOrders, cancelAllOrders
|
|
1571
1689
|
* @param {object} market CCXT market
|
|
1572
|
-
* @param {bool}
|
|
1690
|
+
* @param {bool} trigger true if for a trigger order
|
|
1573
1691
|
* @param {object} [params] request parameters
|
|
1574
1692
|
* @returns the api request object, and the new params object with non-needed parameters removed
|
|
1575
1693
|
*/
|
|
@@ -1579,7 +1697,7 @@ class gate extends gate$1 {
|
|
|
1579
1697
|
};
|
|
1580
1698
|
if (market !== undefined) {
|
|
1581
1699
|
if (trigger) {
|
|
1582
|
-
// gate spot and margin
|
|
1700
|
+
// gate spot and margin trigger orders use the term market instead of currency_pair, and normal instead of spot. Neither parameter is used when fetching/cancelling a single order. They are used for creating a single trigger order, but createOrder does not call this method
|
|
1583
1701
|
request['market'] = market['id'];
|
|
1584
1702
|
}
|
|
1585
1703
|
else {
|
|
@@ -1588,13 +1706,13 @@ class gate extends gate$1 {
|
|
|
1588
1706
|
}
|
|
1589
1707
|
return [request, query];
|
|
1590
1708
|
}
|
|
1591
|
-
getMarginMode(
|
|
1709
|
+
getMarginMode(trigger, params) {
|
|
1592
1710
|
/**
|
|
1593
1711
|
* @ignore
|
|
1594
1712
|
* @method
|
|
1595
1713
|
* @name gate#getMarginMode
|
|
1596
1714
|
* @description Gets the margin type for this api call
|
|
1597
|
-
* @param {bool}
|
|
1715
|
+
* @param {bool} trigger True if for a trigger order
|
|
1598
1716
|
* @param {object} [params] Request params
|
|
1599
1717
|
* @returns The marginMode and the updated request params with marginMode removed, marginMode value is the value that can be read by the "account" property specified in gates api docs
|
|
1600
1718
|
*/
|
|
@@ -1610,13 +1728,13 @@ class gate extends gate$1 {
|
|
|
1610
1728
|
else if (marginMode === '') {
|
|
1611
1729
|
marginMode = 'spot';
|
|
1612
1730
|
}
|
|
1613
|
-
if (
|
|
1731
|
+
if (trigger) {
|
|
1614
1732
|
if (marginMode === 'spot') {
|
|
1615
|
-
// gate spot
|
|
1733
|
+
// gate spot trigger orders use the term normal instead of spot
|
|
1616
1734
|
marginMode = 'normal';
|
|
1617
1735
|
}
|
|
1618
1736
|
if (marginMode === 'cross_margin') {
|
|
1619
|
-
throw new errors.BadRequest(this.id + ' getMarginMode() does not support
|
|
1737
|
+
throw new errors.BadRequest(this.id + ' getMarginMode() does not support trigger orders for cross margin');
|
|
1620
1738
|
}
|
|
1621
1739
|
}
|
|
1622
1740
|
let isUnifiedAccount = false;
|
|
@@ -3072,7 +3190,7 @@ class gate extends gate$1 {
|
|
|
3072
3190
|
let request = {};
|
|
3073
3191
|
[request, params] = this.prepareRequest(market, undefined, params);
|
|
3074
3192
|
request['interval'] = this.safeString(this.timeframes, timeframe, timeframe);
|
|
3075
|
-
|
|
3193
|
+
const maxLimit = market['contract'] ? 1999 : 1000;
|
|
3076
3194
|
limit = (limit === undefined) ? maxLimit : Math.min(limit, maxLimit);
|
|
3077
3195
|
let until = this.safeInteger(params, 'until');
|
|
3078
3196
|
if (until !== undefined) {
|
|
@@ -3101,7 +3219,6 @@ class gate extends gate$1 {
|
|
|
3101
3219
|
}
|
|
3102
3220
|
let response = undefined;
|
|
3103
3221
|
if (market['contract']) {
|
|
3104
|
-
maxLimit = 1999;
|
|
3105
3222
|
const isMark = (price === 'mark');
|
|
3106
3223
|
const isIndex = (price === 'index');
|
|
3107
3224
|
if (isMark || isIndex) {
|
|
@@ -3445,7 +3562,7 @@ class gate extends gate$1 {
|
|
|
3445
3562
|
}
|
|
3446
3563
|
else {
|
|
3447
3564
|
if (market !== undefined) {
|
|
3448
|
-
request['currency_pair'] = market['id']; // Should always be set for non-
|
|
3565
|
+
request['currency_pair'] = market['id']; // Should always be set for non-trigger
|
|
3449
3566
|
}
|
|
3450
3567
|
[marginMode, params] = this.getMarginMode(false, params);
|
|
3451
3568
|
request['account'] = marginMode;
|
|
@@ -3993,8 +4110,8 @@ class gate extends gate$1 {
|
|
|
3993
4110
|
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
3994
4111
|
const isStopLossOrder = stopLossPrice !== undefined;
|
|
3995
4112
|
const isTakeProfitOrder = takeProfitPrice !== undefined;
|
|
3996
|
-
const
|
|
3997
|
-
const nonTriggerOrder = !
|
|
4113
|
+
const isTpsl = isStopLossOrder || isTakeProfitOrder;
|
|
4114
|
+
const nonTriggerOrder = !isTpsl && (trigger === undefined);
|
|
3998
4115
|
const orderRequest = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
3999
4116
|
let response = undefined;
|
|
4000
4117
|
if (market['spot'] || market['margin']) {
|
|
@@ -4160,7 +4277,7 @@ class gate extends gate$1 {
|
|
|
4160
4277
|
const takeProfitPrice = this.safeValue(params, 'takeProfitPrice');
|
|
4161
4278
|
const isStopLossOrder = stopLossPrice !== undefined;
|
|
4162
4279
|
const isTakeProfitOrder = takeProfitPrice !== undefined;
|
|
4163
|
-
const
|
|
4280
|
+
const isTpsl = isStopLossOrder || isTakeProfitOrder;
|
|
4164
4281
|
if (isStopLossOrder && isTakeProfitOrder) {
|
|
4165
4282
|
throw new errors.ExchangeError(this.id + ' createOrder() stopLossPrice and takeProfitPrice cannot both be defined');
|
|
4166
4283
|
}
|
|
@@ -4207,7 +4324,7 @@ class gate extends gate$1 {
|
|
|
4207
4324
|
}
|
|
4208
4325
|
}
|
|
4209
4326
|
let request = undefined;
|
|
4210
|
-
const nonTriggerOrder = !
|
|
4327
|
+
const nonTriggerOrder = !isTpsl && (trigger === undefined);
|
|
4211
4328
|
if (nonTriggerOrder) {
|
|
4212
4329
|
if (contract) {
|
|
4213
4330
|
// contract order
|
|
@@ -4820,7 +4937,7 @@ class gate extends gate$1 {
|
|
|
4820
4937
|
}
|
|
4821
4938
|
fetchOrderRequest(id, symbol = undefined, params = {}) {
|
|
4822
4939
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
4823
|
-
const
|
|
4940
|
+
const trigger = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
|
|
4824
4941
|
params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
|
|
4825
4942
|
let clientOrderId = this.safeString2(params, 'text', 'clientOrderId');
|
|
4826
4943
|
let orderId = id;
|
|
@@ -4833,7 +4950,7 @@ class gate extends gate$1 {
|
|
|
4833
4950
|
}
|
|
4834
4951
|
const [type, query] = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
4835
4952
|
const contract = (type === 'swap') || (type === 'future') || (type === 'option');
|
|
4836
|
-
const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market,
|
|
4953
|
+
const [request, requestParams] = contract ? this.prepareRequest(market, type, query) : this.spotOrderPrepareRequest(market, trigger, query);
|
|
4837
4954
|
request['order_id'] = orderId.toString();
|
|
4838
4955
|
return [request, requestParams];
|
|
4839
4956
|
}
|
|
@@ -4861,11 +4978,11 @@ class gate extends gate$1 {
|
|
|
4861
4978
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
4862
4979
|
const result = this.handleMarketTypeAndParams('fetchOrder', market, params);
|
|
4863
4980
|
const type = this.safeString(result, 0);
|
|
4864
|
-
const
|
|
4981
|
+
const trigger = this.safeBoolN(params, ['trigger', 'is_stop_order', 'stop'], false);
|
|
4865
4982
|
const [request, requestParams] = this.fetchOrderRequest(id, symbol, params);
|
|
4866
4983
|
let response = undefined;
|
|
4867
4984
|
if (type === 'spot' || type === 'margin') {
|
|
4868
|
-
if (
|
|
4985
|
+
if (trigger) {
|
|
4869
4986
|
response = await this.privateSpotGetPriceOrdersOrderId(this.extend(request, requestParams));
|
|
4870
4987
|
}
|
|
4871
4988
|
else {
|
|
@@ -4873,7 +4990,7 @@ class gate extends gate$1 {
|
|
|
4873
4990
|
}
|
|
4874
4991
|
}
|
|
4875
4992
|
else if (type === 'swap') {
|
|
4876
|
-
if (
|
|
4993
|
+
if (trigger) {
|
|
4877
4994
|
response = await this.privateFuturesGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4878
4995
|
}
|
|
4879
4996
|
else {
|
|
@@ -4881,7 +4998,7 @@ class gate extends gate$1 {
|
|
|
4881
4998
|
}
|
|
4882
4999
|
}
|
|
4883
5000
|
else if (type === 'future') {
|
|
4884
|
-
if (
|
|
5001
|
+
if (trigger) {
|
|
4885
5002
|
response = await this.privateDeliveryGetSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
4886
5003
|
}
|
|
4887
5004
|
else {
|
|
@@ -4906,7 +5023,7 @@ class gate extends gate$1 {
|
|
|
4906
5023
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
4907
5024
|
* @param {int} [limit] the maximum number of open orders structures to retrieve
|
|
4908
5025
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4909
|
-
* @param {bool} [params.
|
|
5026
|
+
* @param {bool} [params.trigger] true for fetching trigger orders
|
|
4910
5027
|
* @param {string} [params.type] spot, margin, swap or future, if not provided this.options['defaultType'] is used
|
|
4911
5028
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for type='margin', if not provided this.options['defaultMarginMode'] is used
|
|
4912
5029
|
* @param {bool} [params.unifiedAccount] set to true for fetching unified account orders
|
|
@@ -4931,7 +5048,7 @@ class gate extends gate$1 {
|
|
|
4931
5048
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
4932
5049
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
4933
5050
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4934
|
-
* @param {bool} [params.
|
|
5051
|
+
* @param {bool} [params.trigger] true for fetching trigger orders
|
|
4935
5052
|
* @param {string} [params.type] spot, swap or future, if not provided this.options['defaultType'] is used
|
|
4936
5053
|
* @param {string} [params.marginMode] 'cross' or 'isolated' - marginMode for margin trading if not provided this.options['defaultMarginMode'] is used
|
|
4937
5054
|
* @param {boolean} [params.historical] *swap only* true for using historical endpoint
|
|
@@ -5133,7 +5250,7 @@ class gate extends gate$1 {
|
|
|
5133
5250
|
// }
|
|
5134
5251
|
// ]
|
|
5135
5252
|
//
|
|
5136
|
-
// spot
|
|
5253
|
+
// spot trigger
|
|
5137
5254
|
//
|
|
5138
5255
|
// [
|
|
5139
5256
|
// {
|
|
@@ -5229,7 +5346,7 @@ class gate extends gate$1 {
|
|
|
5229
5346
|
* @param {string} id Order id
|
|
5230
5347
|
* @param {string} symbol Unified market symbol
|
|
5231
5348
|
* @param {object} [params] Parameters specified by the exchange api
|
|
5232
|
-
* @param {bool} [params.
|
|
5349
|
+
* @param {bool} [params.trigger] True if the order to be cancelled is a trigger order
|
|
5233
5350
|
* @param {bool} [params.unifiedAccount] set to true for canceling unified account orders
|
|
5234
5351
|
* @returns An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5235
5352
|
*/
|
|
@@ -5237,14 +5354,14 @@ class gate extends gate$1 {
|
|
|
5237
5354
|
await this.loadMarkets();
|
|
5238
5355
|
await this.loadUnifiedStatus();
|
|
5239
5356
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5240
|
-
const
|
|
5357
|
+
const trigger = this.safeBoolN(params, ['is_stop_order', 'stop', 'trigger'], false);
|
|
5241
5358
|
params = this.omit(params, ['is_stop_order', 'stop', 'trigger']);
|
|
5242
5359
|
const [type, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
|
|
5243
|
-
const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market,
|
|
5360
|
+
const [request, requestParams] = (type === 'spot' || type === 'margin') ? this.spotOrderPrepareRequest(market, trigger, query) : this.prepareRequest(market, type, query);
|
|
5244
5361
|
request['order_id'] = id;
|
|
5245
5362
|
let response = undefined;
|
|
5246
5363
|
if (type === 'spot' || type === 'margin') {
|
|
5247
|
-
if (
|
|
5364
|
+
if (trigger) {
|
|
5248
5365
|
response = await this.privateSpotDeletePriceOrdersOrderId(this.extend(request, requestParams));
|
|
5249
5366
|
}
|
|
5250
5367
|
else {
|
|
@@ -5252,7 +5369,7 @@ class gate extends gate$1 {
|
|
|
5252
5369
|
}
|
|
5253
5370
|
}
|
|
5254
5371
|
else if (type === 'swap') {
|
|
5255
|
-
if (
|
|
5372
|
+
if (trigger) {
|
|
5256
5373
|
response = await this.privateFuturesDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
5257
5374
|
}
|
|
5258
5375
|
else {
|
|
@@ -5260,7 +5377,7 @@ class gate extends gate$1 {
|
|
|
5260
5377
|
}
|
|
5261
5378
|
}
|
|
5262
5379
|
else if (type === 'future') {
|
|
5263
|
-
if (
|
|
5380
|
+
if (trigger) {
|
|
5264
5381
|
response = await this.privateDeliveryDeleteSettlePriceOrdersOrderId(this.extend(request, requestParams));
|
|
5265
5382
|
}
|
|
5266
5383
|
else {
|
|
@@ -5462,13 +5579,13 @@ class gate extends gate$1 {
|
|
|
5462
5579
|
await this.loadMarkets();
|
|
5463
5580
|
await this.loadUnifiedStatus();
|
|
5464
5581
|
const market = (symbol === undefined) ? undefined : this.market(symbol);
|
|
5465
|
-
const
|
|
5582
|
+
const trigger = this.safeBool2(params, 'stop', 'trigger');
|
|
5466
5583
|
params = this.omit(params, ['stop', 'trigger']);
|
|
5467
5584
|
const [type, query] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
|
|
5468
|
-
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market,
|
|
5585
|
+
const [request, requestParams] = (type === 'spot') ? this.multiOrderSpotPrepareRequest(market, trigger, query) : this.prepareRequest(market, type, query);
|
|
5469
5586
|
let response = undefined;
|
|
5470
5587
|
if (type === 'spot' || type === 'margin') {
|
|
5471
|
-
if (
|
|
5588
|
+
if (trigger) {
|
|
5472
5589
|
response = await this.privateSpotDeletePriceOrders(this.extend(request, requestParams));
|
|
5473
5590
|
}
|
|
5474
5591
|
else {
|
|
@@ -5476,7 +5593,7 @@ class gate extends gate$1 {
|
|
|
5476
5593
|
}
|
|
5477
5594
|
}
|
|
5478
5595
|
else if (type === 'swap') {
|
|
5479
|
-
if (
|
|
5596
|
+
if (trigger) {
|
|
5480
5597
|
response = await this.privateFuturesDeleteSettlePriceOrders(this.extend(request, requestParams));
|
|
5481
5598
|
}
|
|
5482
5599
|
else {
|
|
@@ -5484,7 +5601,7 @@ class gate extends gate$1 {
|
|
|
5484
5601
|
}
|
|
5485
5602
|
}
|
|
5486
5603
|
else if (type === 'future') {
|
|
5487
|
-
if (
|
|
5604
|
+
if (trigger) {
|
|
5488
5605
|
response = await this.privateDeliveryDeleteSettlePriceOrders(this.extend(request, requestParams));
|
|
5489
5606
|
}
|
|
5490
5607
|
else {
|
package/dist/cjs/src/hashkey.js
CHANGED
package/dist/cjs/src/htx.js
CHANGED
|
@@ -5429,8 +5429,8 @@ class htx extends htx$1 {
|
|
|
5429
5429
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
5430
5430
|
}
|
|
5431
5431
|
}
|
|
5432
|
+
const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only', false);
|
|
5432
5433
|
if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
|
|
5433
|
-
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
|
|
5434
5434
|
if (reduceOnly) {
|
|
5435
5435
|
request['reduce_only'] = 1;
|
|
5436
5436
|
}
|
|
@@ -5439,10 +5439,19 @@ class htx extends htx$1 {
|
|
|
5439
5439
|
request['order_price_type'] = type;
|
|
5440
5440
|
}
|
|
5441
5441
|
}
|
|
5442
|
+
const hedged = this.safeBool(params, 'hedged', false);
|
|
5443
|
+
if (hedged) {
|
|
5444
|
+
if (reduceOnly) {
|
|
5445
|
+
request['offset'] = 'close';
|
|
5446
|
+
}
|
|
5447
|
+
else {
|
|
5448
|
+
request['offset'] = 'open';
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5442
5451
|
const broker = this.safeValue(this.options, 'broker', {});
|
|
5443
5452
|
const brokerId = this.safeString(broker, 'id');
|
|
5444
5453
|
request['channel_code'] = brokerId;
|
|
5445
|
-
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
|
|
5454
|
+
params = this.omit(params, ['reduceOnly', 'triggerPrice', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice', 'hedged']);
|
|
5446
5455
|
return this.extend(request, params);
|
|
5447
5456
|
}
|
|
5448
5457
|
/**
|
|
@@ -5456,6 +5465,8 @@ class htx extends htx$1 {
|
|
|
5456
5465
|
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-place-trigger-order // usdt-m swap cross trigger
|
|
5457
5466
|
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-an-order // usdt-m swap isolated
|
|
5458
5467
|
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-place-trigger-order // usdt-m swap isolated trigger
|
|
5468
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#isolated-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
|
5469
|
+
* @see https://huobiapi.github.io/docs/usdt_swap/v1/en/#cross-set-a-take-profit-and-stop-loss-order-for-an-existing-position
|
|
5459
5470
|
* @see https://huobiapi.github.io/docs/dm/v1/en/#place-an-order // coin-m futures
|
|
5460
5471
|
* @see https://huobiapi.github.io/docs/dm/v1/en/#place-trigger-order // coin-m futures contract trigger
|
|
5461
5472
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
@@ -5476,6 +5487,7 @@ class htx extends htx$1 {
|
|
|
5476
5487
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
5477
5488
|
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5478
5489
|
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5490
|
+
* @param {bool} [params.hedged] *contract only* true for hedged mode, false for one way mode, default is false
|
|
5479
5491
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5480
5492
|
*/
|
|
5481
5493
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|