ccxt 4.2.3 → 4.2.4
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 +87 -17
- package/dist/ccxt.browser.min.js +5 -5
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +5 -2
- package/dist/cjs/src/bitmart.js +18 -8
- package/dist/cjs/src/bybit.js +2 -0
- package/dist/cjs/src/coinsph.js +20 -2
- package/dist/cjs/src/htx.js +35 -3
- package/dist/cjs/src/okx.js +5 -0
- package/dist/cjs/src/phemex.js +1 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bitmart.d.ts +1 -0
- package/js/src/base/Exchange.js +5 -2
- package/js/src/bitmart.js +18 -8
- package/js/src/bybit.js +2 -0
- package/js/src/coinsph.js +20 -2
- package/js/src/htx.js +35 -3
- package/js/src/okx.js +5 -0
- package/js/src/phemex.js +1 -1
- package/package.json +1 -1
package/dist/cjs/ccxt.js
CHANGED
|
@@ -169,7 +169,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
169
169
|
|
|
170
170
|
//-----------------------------------------------------------------------------
|
|
171
171
|
// this is updated by vss.js when building
|
|
172
|
-
const version = '4.2.
|
|
172
|
+
const version = '4.2.4';
|
|
173
173
|
Exchange["default"].ccxtVersion = version;
|
|
174
174
|
const exchanges = {
|
|
175
175
|
'ace': ace,
|
|
@@ -757,8 +757,11 @@ class Exchange {
|
|
|
757
757
|
// proxy agents
|
|
758
758
|
const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
|
|
759
759
|
this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
|
|
760
|
-
if (
|
|
761
|
-
|
|
760
|
+
if (isNode) {
|
|
761
|
+
// skip this on the browser
|
|
762
|
+
if (!this.proxyModulesLoaded) {
|
|
763
|
+
await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
|
|
764
|
+
}
|
|
762
765
|
}
|
|
763
766
|
const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
|
|
764
767
|
// user-agent
|
package/dist/cjs/src/bitmart.js
CHANGED
|
@@ -196,6 +196,7 @@ class bitmart extends bitmart$1 {
|
|
|
196
196
|
'contract/private/order-history': 10,
|
|
197
197
|
'contract/private/position': 10,
|
|
198
198
|
'contract/private/get-open-orders': 1.2,
|
|
199
|
+
'contract/private/current-plan-order': 1.2,
|
|
199
200
|
'contract/private/trades': 10,
|
|
200
201
|
},
|
|
201
202
|
'post': {
|
|
@@ -2678,6 +2679,7 @@ class bitmart extends bitmart$1 {
|
|
|
2678
2679
|
* @name bitmart#fetchOpenOrders
|
|
2679
2680
|
* @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
|
|
2680
2681
|
* @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
|
|
2682
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
|
|
2681
2683
|
* @description fetch all unfilled currently open orders
|
|
2682
2684
|
* @param {string} symbol unified market symbol
|
|
2683
2685
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
@@ -2689,6 +2691,7 @@ class bitmart extends bitmart$1 {
|
|
|
2689
2691
|
* @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
|
|
2690
2692
|
* @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
|
|
2691
2693
|
* @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
|
|
2694
|
+
* @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
|
|
2692
2695
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2693
2696
|
*/
|
|
2694
2697
|
await this.loadMarkets();
|
|
@@ -2721,16 +2724,23 @@ class bitmart extends bitmart$1 {
|
|
|
2721
2724
|
response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
|
|
2722
2725
|
}
|
|
2723
2726
|
else if (type === 'swap') {
|
|
2724
|
-
const
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
orderType = 'trailing';
|
|
2727
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger');
|
|
2728
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
2729
|
+
if (isStop) {
|
|
2730
|
+
response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
|
|
2729
2731
|
}
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
+
else {
|
|
2733
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
2734
|
+
let orderType = this.safeString(params, 'orderType');
|
|
2735
|
+
params = this.omit(params, ['orderType', 'trailing']);
|
|
2736
|
+
if (trailing) {
|
|
2737
|
+
orderType = 'trailing';
|
|
2738
|
+
}
|
|
2739
|
+
if (orderType !== undefined) {
|
|
2740
|
+
request['type'] = orderType;
|
|
2741
|
+
}
|
|
2742
|
+
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2732
2743
|
}
|
|
2733
|
-
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2734
2744
|
}
|
|
2735
2745
|
else {
|
|
2736
2746
|
throw new errors.NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
|
package/dist/cjs/src/bybit.js
CHANGED
|
@@ -626,6 +626,8 @@ class bybit extends bybit$1 {
|
|
|
626
626
|
'131215': errors.BadRequest,
|
|
627
627
|
'131216': errors.ExchangeError,
|
|
628
628
|
'131217': errors.ExchangeError,
|
|
629
|
+
'131231': errors.NotSupported,
|
|
630
|
+
'131232': errors.NotSupported,
|
|
629
631
|
'131002': errors.BadRequest,
|
|
630
632
|
'131003': errors.ExchangeError,
|
|
631
633
|
'131004': errors.AuthenticationError,
|
package/dist/cjs/src/coinsph.js
CHANGED
|
@@ -628,7 +628,16 @@ class coinsph extends coinsph$1 {
|
|
|
628
628
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
629
629
|
const options = this.safeValue(this.options, 'fetchTickers', {});
|
|
630
630
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
631
|
-
|
|
631
|
+
let tickers = undefined;
|
|
632
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
633
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
634
|
+
}
|
|
635
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
636
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
637
|
+
}
|
|
638
|
+
else {
|
|
639
|
+
tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
640
|
+
}
|
|
632
641
|
return this.parseTickers(tickers, symbols, params);
|
|
633
642
|
}
|
|
634
643
|
async fetchTicker(symbol, params = {}) {
|
|
@@ -648,7 +657,16 @@ class coinsph extends coinsph$1 {
|
|
|
648
657
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
649
658
|
const options = this.safeValue(this.options, 'fetchTicker', {});
|
|
650
659
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
651
|
-
|
|
660
|
+
let ticker = undefined;
|
|
661
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
662
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
663
|
+
}
|
|
664
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
665
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
669
|
+
}
|
|
652
670
|
return this.parseTicker(ticker, market);
|
|
653
671
|
}
|
|
654
672
|
parseTicker(ticker, market = undefined) {
|
package/dist/cjs/src/htx.js
CHANGED
|
@@ -5014,6 +5014,8 @@ class htx extends htx$1 {
|
|
|
5014
5014
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
5015
5015
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5016
5016
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5017
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5018
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5017
5019
|
* @returns {object} request to be sent to the exchange
|
|
5018
5020
|
*/
|
|
5019
5021
|
const market = this.market(symbol);
|
|
@@ -5037,6 +5039,9 @@ class htx extends htx$1 {
|
|
|
5037
5039
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5038
5040
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5039
5041
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5042
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
|
|
5043
|
+
const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
|
|
5044
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5040
5045
|
const isStop = triggerPrice !== undefined;
|
|
5041
5046
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5042
5047
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -5064,6 +5069,12 @@ class htx extends htx$1 {
|
|
|
5064
5069
|
}
|
|
5065
5070
|
}
|
|
5066
5071
|
}
|
|
5072
|
+
else if (isTrailingPercentOrder) {
|
|
5073
|
+
const trailingPercentString = Precise["default"].stringDiv(trailingPercent, '100');
|
|
5074
|
+
request['callback_rate'] = this.parseToNumeric(trailingPercentString);
|
|
5075
|
+
request['active_price'] = trailingTriggerPrice;
|
|
5076
|
+
request['order_price_type'] = this.safeString(params, 'order_price_type', 'formula_price');
|
|
5077
|
+
}
|
|
5067
5078
|
else {
|
|
5068
5079
|
const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
|
|
5069
5080
|
if (clientOrderId !== undefined) {
|
|
@@ -5075,7 +5086,7 @@ class htx extends htx$1 {
|
|
|
5075
5086
|
}
|
|
5076
5087
|
}
|
|
5077
5088
|
if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
|
|
5078
|
-
const leverRate = this.
|
|
5089
|
+
const leverRate = this.safeIntegerN(params, ['leverRate', 'lever_rate', 'leverage'], 1);
|
|
5079
5090
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
|
|
5080
5091
|
const openOrClose = (reduceOnly) ? 'close' : 'open';
|
|
5081
5092
|
const offset = this.safeString(params, 'offset', openOrClose);
|
|
@@ -5084,12 +5095,14 @@ class htx extends htx$1 {
|
|
|
5084
5095
|
request['reduce_only'] = 1;
|
|
5085
5096
|
}
|
|
5086
5097
|
request['lever_rate'] = leverRate;
|
|
5087
|
-
|
|
5098
|
+
if (!isTrailingPercentOrder) {
|
|
5099
|
+
request['order_price_type'] = type;
|
|
5100
|
+
}
|
|
5088
5101
|
}
|
|
5089
5102
|
const broker = this.safeValue(this.options, 'broker', {});
|
|
5090
5103
|
const brokerId = this.safeString(broker, 'id');
|
|
5091
5104
|
request['channel_code'] = brokerId;
|
|
5092
|
-
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
|
|
5105
|
+
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
|
|
5093
5106
|
return this.extend(request, params);
|
|
5094
5107
|
}
|
|
5095
5108
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -5122,6 +5135,8 @@ class htx extends htx$1 {
|
|
|
5122
5135
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
5123
5136
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5124
5137
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
5138
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5139
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5125
5140
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5126
5141
|
*/
|
|
5127
5142
|
await this.loadMarkets();
|
|
@@ -5129,11 +5144,16 @@ class htx extends htx$1 {
|
|
|
5129
5144
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5130
5145
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5131
5146
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5147
|
+
const trailingPercent = this.safeNumber(params, 'trailingPercent');
|
|
5148
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5132
5149
|
const isStop = triggerPrice !== undefined;
|
|
5133
5150
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5134
5151
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
5135
5152
|
let response = undefined;
|
|
5136
5153
|
if (market['spot']) {
|
|
5154
|
+
if (isTrailingPercentOrder) {
|
|
5155
|
+
throw new errors.NotSupported(this.id + ' createOrder() does not support trailing orders for spot markets');
|
|
5156
|
+
}
|
|
5137
5157
|
const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
|
|
5138
5158
|
response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
|
|
5139
5159
|
}
|
|
@@ -5150,6 +5170,9 @@ class htx extends htx$1 {
|
|
|
5150
5170
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5151
5171
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
|
|
5152
5172
|
}
|
|
5173
|
+
else if (isTrailingPercentOrder) {
|
|
5174
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(contractRequest);
|
|
5175
|
+
}
|
|
5153
5176
|
else {
|
|
5154
5177
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
|
|
5155
5178
|
}
|
|
@@ -5161,6 +5184,9 @@ class htx extends htx$1 {
|
|
|
5161
5184
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5162
5185
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
|
|
5163
5186
|
}
|
|
5187
|
+
else if (isTrailingPercentOrder) {
|
|
5188
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(contractRequest);
|
|
5189
|
+
}
|
|
5164
5190
|
else {
|
|
5165
5191
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
|
|
5166
5192
|
}
|
|
@@ -5174,6 +5200,9 @@ class htx extends htx$1 {
|
|
|
5174
5200
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5175
5201
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
|
|
5176
5202
|
}
|
|
5203
|
+
else if (isTrailingPercentOrder) {
|
|
5204
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOrder(contractRequest);
|
|
5205
|
+
}
|
|
5177
5206
|
else {
|
|
5178
5207
|
response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
|
|
5179
5208
|
}
|
|
@@ -5185,6 +5214,9 @@ class htx extends htx$1 {
|
|
|
5185
5214
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5186
5215
|
response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
|
|
5187
5216
|
}
|
|
5217
|
+
else if (isTrailingPercentOrder) {
|
|
5218
|
+
response = await this.contractPrivatePostApiV1ContractTrackOrder(contractRequest);
|
|
5219
|
+
}
|
|
5188
5220
|
else {
|
|
5189
5221
|
response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
|
|
5190
5222
|
}
|
package/dist/cjs/src/okx.js
CHANGED
|
@@ -3903,6 +3903,7 @@ class okx extends okx$1 {
|
|
|
3903
3903
|
* @description fetches information on multiple closed orders made by the user
|
|
3904
3904
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
|
|
3905
3905
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
|
|
3906
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
|
|
3906
3907
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
3907
3908
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
3908
3909
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -3912,6 +3913,7 @@ class okx extends okx$1 {
|
|
|
3912
3913
|
* @param {string} [params.algoId] Algo ID "'433845797218942976'"
|
|
3913
3914
|
* @param {int} [params.until] timestamp in ms to fetch orders for
|
|
3914
3915
|
* @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)
|
|
3916
|
+
* @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
|
|
3915
3917
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3916
3918
|
*/
|
|
3917
3919
|
await this.loadMarkets();
|
|
@@ -3974,6 +3976,9 @@ class okx extends okx$1 {
|
|
|
3974
3976
|
if (method === 'privateGetTradeOrdersAlgoHistory') {
|
|
3975
3977
|
response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
|
|
3976
3978
|
}
|
|
3979
|
+
else if (method === 'privateGetTradeOrdersHistoryArchive') {
|
|
3980
|
+
response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
|
|
3981
|
+
}
|
|
3977
3982
|
else {
|
|
3978
3983
|
response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
|
|
3979
3984
|
}
|
package/dist/cjs/src/phemex.js
CHANGED
|
@@ -1485,7 +1485,7 @@ class phemex extends phemex$1 {
|
|
|
1485
1485
|
if (type === 'spot') {
|
|
1486
1486
|
response = await this.v1GetMdSpotTicker24hrAll(query);
|
|
1487
1487
|
}
|
|
1488
|
-
else if (subType === 'inverse' || market
|
|
1488
|
+
else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
|
|
1489
1489
|
response = await this.v1GetMdTicker24hrAll(query);
|
|
1490
1490
|
}
|
|
1491
1491
|
else {
|
package/js/ccxt.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
|
|
|
4
4
|
import * as errors from './src/base/errors.js';
|
|
5
5
|
import type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } from './src/base/types.js';
|
|
6
6
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
7
|
-
declare const version = "4.2.
|
|
7
|
+
declare const version = "4.2.3";
|
|
8
8
|
import ace from './src/ace.js';
|
|
9
9
|
import alpaca from './src/alpaca.js';
|
|
10
10
|
import ascendex from './src/ascendex.js';
|
package/js/ccxt.js
CHANGED
|
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
|
|
|
38
38
|
import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending, NoChange } from './src/base/errors.js';
|
|
39
39
|
//-----------------------------------------------------------------------------
|
|
40
40
|
// this is updated by vss.js when building
|
|
41
|
-
const version = '4.2.
|
|
41
|
+
const version = '4.2.4';
|
|
42
42
|
Exchange.ccxtVersion = version;
|
|
43
43
|
//-----------------------------------------------------------------------------
|
|
44
44
|
import ace from './src/ace.js';
|
|
@@ -58,6 +58,7 @@ interface Exchange {
|
|
|
58
58
|
privateGetContractPrivateOrderHistory(params?: {}): Promise<implicitReturnType>;
|
|
59
59
|
privateGetContractPrivatePosition(params?: {}): Promise<implicitReturnType>;
|
|
60
60
|
privateGetContractPrivateGetOpenOrders(params?: {}): Promise<implicitReturnType>;
|
|
61
|
+
privateGetContractPrivateCurrentPlanOrder(params?: {}): Promise<implicitReturnType>;
|
|
61
62
|
privateGetContractPrivateTrades(params?: {}): Promise<implicitReturnType>;
|
|
62
63
|
privatePostAccountSubAccountMainV1SubToMain(params?: {}): Promise<implicitReturnType>;
|
|
63
64
|
privatePostAccountSubAccountSubV1SubToMain(params?: {}): Promise<implicitReturnType>;
|
package/js/src/base/Exchange.js
CHANGED
|
@@ -751,8 +751,11 @@ export default class Exchange {
|
|
|
751
751
|
// proxy agents
|
|
752
752
|
const [httpProxy, httpsProxy, socksProxy] = this.checkProxySettings(url, method, headers, body);
|
|
753
753
|
this.checkConflictingProxies(httpProxy || httpsProxy || socksProxy, proxyUrl);
|
|
754
|
-
if (
|
|
755
|
-
|
|
754
|
+
if (isNode) {
|
|
755
|
+
// skip this on the browser
|
|
756
|
+
if (!this.proxyModulesLoaded) {
|
|
757
|
+
await this.loadProxyModules(); // this is needed in JS, independently whether proxy properties were set or not, we have to load them because of necessity in WS, which would happen beyond 'fetch' method (WS/etc)
|
|
758
|
+
}
|
|
756
759
|
}
|
|
757
760
|
const chosenAgent = this.setProxyAgents(httpProxy, httpsProxy, socksProxy);
|
|
758
761
|
// user-agent
|
package/js/src/bitmart.js
CHANGED
|
@@ -199,6 +199,7 @@ export default class bitmart extends Exchange {
|
|
|
199
199
|
'contract/private/order-history': 10,
|
|
200
200
|
'contract/private/position': 10,
|
|
201
201
|
'contract/private/get-open-orders': 1.2,
|
|
202
|
+
'contract/private/current-plan-order': 1.2,
|
|
202
203
|
'contract/private/trades': 10,
|
|
203
204
|
},
|
|
204
205
|
'post': {
|
|
@@ -2681,6 +2682,7 @@ export default class bitmart extends Exchange {
|
|
|
2681
2682
|
* @name bitmart#fetchOpenOrders
|
|
2682
2683
|
* @see https://developer-pro.bitmart.com/en/spot/#current-open-orders-v4-signed
|
|
2683
2684
|
* @see https://developer-pro.bitmart.com/en/futures/#get-all-open-orders-keyed
|
|
2685
|
+
* @see https://developer-pro.bitmart.com/en/futures/#get-all-current-plan-orders-keyed
|
|
2684
2686
|
* @description fetch all unfilled currently open orders
|
|
2685
2687
|
* @param {string} symbol unified market symbol
|
|
2686
2688
|
* @param {int} [since] the earliest time in ms to fetch open orders for
|
|
@@ -2692,6 +2694,7 @@ export default class bitmart extends Exchange {
|
|
|
2692
2694
|
* @param {string} [params.order_state] *swap* the order state, 'all' or 'partially_filled', default is 'all'
|
|
2693
2695
|
* @param {string} [params.orderType] *swap only* 'limit', 'market', or 'trailing'
|
|
2694
2696
|
* @param {boolean} [params.trailing] *swap only* set to true if you want to fetch trailing orders
|
|
2697
|
+
* @param {boolean} [params.trigger] *swap only* set to true if you want to fetch trigger orders
|
|
2695
2698
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2696
2699
|
*/
|
|
2697
2700
|
await this.loadMarkets();
|
|
@@ -2724,16 +2727,23 @@ export default class bitmart extends Exchange {
|
|
|
2724
2727
|
response = await this.privatePostSpotV4QueryOpenOrders(this.extend(request, params));
|
|
2725
2728
|
}
|
|
2726
2729
|
else if (type === 'swap') {
|
|
2727
|
-
const
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
orderType = 'trailing';
|
|
2730
|
+
const isStop = this.safeValue2(params, 'stop', 'trigger');
|
|
2731
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
2732
|
+
if (isStop) {
|
|
2733
|
+
response = await this.privateGetContractPrivateCurrentPlanOrder(this.extend(request, params));
|
|
2732
2734
|
}
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
+
else {
|
|
2736
|
+
const trailing = this.safeValue(params, 'trailing', false);
|
|
2737
|
+
let orderType = this.safeString(params, 'orderType');
|
|
2738
|
+
params = this.omit(params, ['orderType', 'trailing']);
|
|
2739
|
+
if (trailing) {
|
|
2740
|
+
orderType = 'trailing';
|
|
2741
|
+
}
|
|
2742
|
+
if (orderType !== undefined) {
|
|
2743
|
+
request['type'] = orderType;
|
|
2744
|
+
}
|
|
2745
|
+
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2735
2746
|
}
|
|
2736
|
-
response = await this.privateGetContractPrivateGetOpenOrders(this.extend(request, params));
|
|
2737
2747
|
}
|
|
2738
2748
|
else {
|
|
2739
2749
|
throw new NotSupported(this.id + ' fetchOpenOrders() does not support ' + type + ' orders, only spot and swap orders are accepted');
|
package/js/src/bybit.js
CHANGED
|
@@ -629,6 +629,8 @@ export default class bybit extends Exchange {
|
|
|
629
629
|
'131215': BadRequest,
|
|
630
630
|
'131216': ExchangeError,
|
|
631
631
|
'131217': ExchangeError,
|
|
632
|
+
'131231': NotSupported,
|
|
633
|
+
'131232': NotSupported,
|
|
632
634
|
'131002': BadRequest,
|
|
633
635
|
'131003': ExchangeError,
|
|
634
636
|
'131004': AuthenticationError,
|
package/js/src/coinsph.js
CHANGED
|
@@ -631,7 +631,16 @@ export default class coinsph extends Exchange {
|
|
|
631
631
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
632
632
|
const options = this.safeValue(this.options, 'fetchTickers', {});
|
|
633
633
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
634
|
-
|
|
634
|
+
let tickers = undefined;
|
|
635
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
636
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
637
|
+
}
|
|
638
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
639
|
+
tickers = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
640
|
+
}
|
|
641
|
+
else {
|
|
642
|
+
tickers = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
643
|
+
}
|
|
635
644
|
return this.parseTickers(tickers, symbols, params);
|
|
636
645
|
}
|
|
637
646
|
async fetchTicker(symbol, params = {}) {
|
|
@@ -651,7 +660,16 @@ export default class coinsph extends Exchange {
|
|
|
651
660
|
const defaultMethod = 'publicGetOpenapiQuoteV1Ticker24hr';
|
|
652
661
|
const options = this.safeValue(this.options, 'fetchTicker', {});
|
|
653
662
|
const method = this.safeString(options, 'method', defaultMethod);
|
|
654
|
-
|
|
663
|
+
let ticker = undefined;
|
|
664
|
+
if (method === 'publicGetOpenapiQuoteV1TickerPrice') {
|
|
665
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerPrice(this.extend(request, params));
|
|
666
|
+
}
|
|
667
|
+
else if (method === 'publicGetOpenapiQuoteV1TickerBookTicker') {
|
|
668
|
+
ticker = await this.publicGetOpenapiQuoteV1TickerBookTicker(this.extend(request, params));
|
|
669
|
+
}
|
|
670
|
+
else {
|
|
671
|
+
ticker = await this.publicGetOpenapiQuoteV1Ticker24hr(this.extend(request, params));
|
|
672
|
+
}
|
|
655
673
|
return this.parseTicker(ticker, market);
|
|
656
674
|
}
|
|
657
675
|
parseTicker(ticker, market = undefined) {
|
package/js/src/htx.js
CHANGED
|
@@ -5017,6 +5017,8 @@ export default class htx extends Exchange {
|
|
|
5017
5017
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
5018
5018
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
5019
5019
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5020
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5021
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5020
5022
|
* @returns {object} request to be sent to the exchange
|
|
5021
5023
|
*/
|
|
5022
5024
|
const market = this.market(symbol);
|
|
@@ -5040,6 +5042,9 @@ export default class htx extends Exchange {
|
|
|
5040
5042
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5041
5043
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5042
5044
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5045
|
+
const trailingPercent = this.safeString2(params, 'trailingPercent', 'callback_rate');
|
|
5046
|
+
const trailingTriggerPrice = this.safeNumber(params, 'trailingTriggerPrice', price);
|
|
5047
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5043
5048
|
const isStop = triggerPrice !== undefined;
|
|
5044
5049
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5045
5050
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -5067,6 +5072,12 @@ export default class htx extends Exchange {
|
|
|
5067
5072
|
}
|
|
5068
5073
|
}
|
|
5069
5074
|
}
|
|
5075
|
+
else if (isTrailingPercentOrder) {
|
|
5076
|
+
const trailingPercentString = Precise.stringDiv(trailingPercent, '100');
|
|
5077
|
+
request['callback_rate'] = this.parseToNumeric(trailingPercentString);
|
|
5078
|
+
request['active_price'] = trailingTriggerPrice;
|
|
5079
|
+
request['order_price_type'] = this.safeString(params, 'order_price_type', 'formula_price');
|
|
5080
|
+
}
|
|
5070
5081
|
else {
|
|
5071
5082
|
const clientOrderId = this.safeInteger2(params, 'client_order_id', 'clientOrderId');
|
|
5072
5083
|
if (clientOrderId !== undefined) {
|
|
@@ -5078,7 +5089,7 @@ export default class htx extends Exchange {
|
|
|
5078
5089
|
}
|
|
5079
5090
|
}
|
|
5080
5091
|
if (!isStopLossTriggerOrder && !isTakeProfitTriggerOrder) {
|
|
5081
|
-
const leverRate = this.
|
|
5092
|
+
const leverRate = this.safeIntegerN(params, ['leverRate', 'lever_rate', 'leverage'], 1);
|
|
5082
5093
|
const reduceOnly = this.safeValue2(params, 'reduceOnly', 'reduce_only', false);
|
|
5083
5094
|
const openOrClose = (reduceOnly) ? 'close' : 'open';
|
|
5084
5095
|
const offset = this.safeString(params, 'offset', openOrClose);
|
|
@@ -5087,12 +5098,14 @@ export default class htx extends Exchange {
|
|
|
5087
5098
|
request['reduce_only'] = 1;
|
|
5088
5099
|
}
|
|
5089
5100
|
request['lever_rate'] = leverRate;
|
|
5090
|
-
|
|
5101
|
+
if (!isTrailingPercentOrder) {
|
|
5102
|
+
request['order_price_type'] = type;
|
|
5103
|
+
}
|
|
5091
5104
|
}
|
|
5092
5105
|
const broker = this.safeValue(this.options, 'broker', {});
|
|
5093
5106
|
const brokerId = this.safeString(broker, 'id');
|
|
5094
5107
|
request['channel_code'] = brokerId;
|
|
5095
|
-
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce']);
|
|
5108
|
+
params = this.omit(params, ['reduceOnly', 'stopPrice', 'stopLossPrice', 'takeProfitPrice', 'triggerType', 'leverRate', 'timeInForce', 'leverage', 'trailingPercent', 'trailingTriggerPrice']);
|
|
5096
5109
|
return this.extend(request, params);
|
|
5097
5110
|
}
|
|
5098
5111
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -5125,6 +5138,8 @@ export default class htx extends Exchange {
|
|
|
5125
5138
|
* @param {int} [params.leverRate] *contract only* required for all contract orders except tpsl, leverage greater than 20x requires prior approval of high-leverage agreement
|
|
5126
5139
|
* @param {string} [params.timeInForce] supports 'IOC' and 'FOK'
|
|
5127
5140
|
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
|
|
5141
|
+
* @param {float} [params.trailingPercent] *contract only* the percent to trail away from the current market price
|
|
5142
|
+
* @param {float} [params.trailingTriggerPrice] *contract only* the price to trigger a trailing order, default uses the price argument
|
|
5128
5143
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
5129
5144
|
*/
|
|
5130
5145
|
await this.loadMarkets();
|
|
@@ -5132,11 +5147,16 @@ export default class htx extends Exchange {
|
|
|
5132
5147
|
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'trigger_price');
|
|
5133
5148
|
const stopLossTriggerPrice = this.safeNumber2(params, 'stopLossPrice', 'sl_trigger_price');
|
|
5134
5149
|
const takeProfitTriggerPrice = this.safeNumber2(params, 'takeProfitPrice', 'tp_trigger_price');
|
|
5150
|
+
const trailingPercent = this.safeNumber(params, 'trailingPercent');
|
|
5151
|
+
const isTrailingPercentOrder = trailingPercent !== undefined;
|
|
5135
5152
|
const isStop = triggerPrice !== undefined;
|
|
5136
5153
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
5137
5154
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
5138
5155
|
let response = undefined;
|
|
5139
5156
|
if (market['spot']) {
|
|
5157
|
+
if (isTrailingPercentOrder) {
|
|
5158
|
+
throw new NotSupported(this.id + ' createOrder() does not support trailing orders for spot markets');
|
|
5159
|
+
}
|
|
5140
5160
|
const spotRequest = await this.createSpotOrderRequest(symbol, type, side, amount, price, params);
|
|
5141
5161
|
response = await this.spotPrivatePostV1OrderOrdersPlace(spotRequest);
|
|
5142
5162
|
}
|
|
@@ -5153,6 +5173,9 @@ export default class htx extends Exchange {
|
|
|
5153
5173
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5154
5174
|
response = await this.contractPrivatePostLinearSwapApiV1SwapTpslOrder(contractRequest);
|
|
5155
5175
|
}
|
|
5176
|
+
else if (isTrailingPercentOrder) {
|
|
5177
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapTrackOrder(contractRequest);
|
|
5178
|
+
}
|
|
5156
5179
|
else {
|
|
5157
5180
|
response = await this.contractPrivatePostLinearSwapApiV1SwapOrder(contractRequest);
|
|
5158
5181
|
}
|
|
@@ -5164,6 +5187,9 @@ export default class htx extends Exchange {
|
|
|
5164
5187
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5165
5188
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTpslOrder(contractRequest);
|
|
5166
5189
|
}
|
|
5190
|
+
else if (isTrailingPercentOrder) {
|
|
5191
|
+
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossTrackOrder(contractRequest);
|
|
5192
|
+
}
|
|
5167
5193
|
else {
|
|
5168
5194
|
response = await this.contractPrivatePostLinearSwapApiV1SwapCrossOrder(contractRequest);
|
|
5169
5195
|
}
|
|
@@ -5177,6 +5203,9 @@ export default class htx extends Exchange {
|
|
|
5177
5203
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5178
5204
|
response = await this.contractPrivatePostSwapApiV1SwapTpslOrder(contractRequest);
|
|
5179
5205
|
}
|
|
5206
|
+
else if (isTrailingPercentOrder) {
|
|
5207
|
+
response = await this.contractPrivatePostSwapApiV1SwapTrackOrder(contractRequest);
|
|
5208
|
+
}
|
|
5180
5209
|
else {
|
|
5181
5210
|
response = await this.contractPrivatePostSwapApiV1SwapOrder(contractRequest);
|
|
5182
5211
|
}
|
|
@@ -5188,6 +5217,9 @@ export default class htx extends Exchange {
|
|
|
5188
5217
|
else if (isStopLossTriggerOrder || isTakeProfitTriggerOrder) {
|
|
5189
5218
|
response = await this.contractPrivatePostApiV1ContractTpslOrder(contractRequest);
|
|
5190
5219
|
}
|
|
5220
|
+
else if (isTrailingPercentOrder) {
|
|
5221
|
+
response = await this.contractPrivatePostApiV1ContractTrackOrder(contractRequest);
|
|
5222
|
+
}
|
|
5191
5223
|
else {
|
|
5192
5224
|
response = await this.contractPrivatePostApiV1ContractOrder(contractRequest);
|
|
5193
5225
|
}
|
package/js/src/okx.js
CHANGED
|
@@ -3906,6 +3906,7 @@ export default class okx extends Exchange {
|
|
|
3906
3906
|
* @description fetches information on multiple closed orders made by the user
|
|
3907
3907
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-7-days
|
|
3908
3908
|
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-get-algo-order-history
|
|
3909
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-history-last-3-months
|
|
3909
3910
|
* @param {string} symbol unified market symbol of the market orders were made in
|
|
3910
3911
|
* @param {int} [since] the earliest time in ms to fetch orders for
|
|
3911
3912
|
* @param {int} [limit] the maximum number of order structures to retrieve
|
|
@@ -3915,6 +3916,7 @@ export default class okx extends Exchange {
|
|
|
3915
3916
|
* @param {string} [params.algoId] Algo ID "'433845797218942976'"
|
|
3916
3917
|
* @param {int} [params.until] timestamp in ms to fetch orders for
|
|
3917
3918
|
* @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)
|
|
3919
|
+
* @param {string} [params.method] method to be used, either 'privateGetTradeOrdersHistory', 'privateGetTradeOrdersHistoryArchive' or 'privateGetTradeOrdersAlgoHistory' default is 'privateGetTradeOrdersHistory'
|
|
3918
3920
|
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3919
3921
|
*/
|
|
3920
3922
|
await this.loadMarkets();
|
|
@@ -3977,6 +3979,9 @@ export default class okx extends Exchange {
|
|
|
3977
3979
|
if (method === 'privateGetTradeOrdersAlgoHistory') {
|
|
3978
3980
|
response = await this.privateGetTradeOrdersAlgoHistory(this.extend(request, send));
|
|
3979
3981
|
}
|
|
3982
|
+
else if (method === 'privateGetTradeOrdersHistoryArchive') {
|
|
3983
|
+
response = await this.privateGetTradeOrdersHistoryArchive(this.extend(request, send));
|
|
3984
|
+
}
|
|
3980
3985
|
else {
|
|
3981
3986
|
response = await this.privateGetTradeOrdersHistory(this.extend(request, send));
|
|
3982
3987
|
}
|
package/js/src/phemex.js
CHANGED
|
@@ -1488,7 +1488,7 @@ export default class phemex extends Exchange {
|
|
|
1488
1488
|
if (type === 'spot') {
|
|
1489
1489
|
response = await this.v1GetMdSpotTicker24hrAll(query);
|
|
1490
1490
|
}
|
|
1491
|
-
else if (subType === 'inverse' || market
|
|
1491
|
+
else if (subType === 'inverse' || this.safeString(market, 'settle') === 'USD') {
|
|
1492
1492
|
response = await this.v1GetMdTicker24hrAll(query);
|
|
1493
1493
|
}
|
|
1494
1494
|
else {
|
package/package.json
CHANGED