ccxt 4.1.69 → 4.1.70
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 +391 -66
- package/dist/ccxt.browser.min.js +2 -2
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/coinex.js +388 -63
- package/dist/cjs/src/pro/binance.js +2 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/coinex.d.ts +4 -1
- package/js/src/coinex.js +388 -63
- package/js/src/pro/binance.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,13 +211,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
211
211
|
|
|
212
212
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
213
213
|
|
|
214
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
215
|
-
* unpkg: https://unpkg.com/ccxt@4.1.
|
|
214
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.1.70/dist/ccxt.browser.js
|
|
215
|
+
* unpkg: https://unpkg.com/ccxt@4.1.70/dist/ccxt.browser.js
|
|
216
216
|
|
|
217
217
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
218
218
|
|
|
219
219
|
```HTML
|
|
220
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.
|
|
220
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.1.70/dist/ccxt.browser.js"></script>
|
|
221
221
|
```
|
|
222
222
|
|
|
223
223
|
Creates a global `ccxt` object:
|
package/dist/ccxt.browser.js
CHANGED
|
@@ -91132,8 +91132,10 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
91132
91132
|
'borrowIsolatedMargin': true,
|
|
91133
91133
|
'cancelAllOrders': true,
|
|
91134
91134
|
'cancelOrder': true,
|
|
91135
|
+
'cancelOrders': true,
|
|
91135
91136
|
'createDepositAddress': true,
|
|
91136
91137
|
'createOrder': true,
|
|
91138
|
+
'createOrders': true,
|
|
91137
91139
|
'createReduceOnlyOrder': true,
|
|
91138
91140
|
'editOrder': true,
|
|
91139
91141
|
'fetchBalance': true,
|
|
@@ -92624,6 +92626,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92624
92626
|
}
|
|
92625
92627
|
parseOrderStatus(status) {
|
|
92626
92628
|
const statuses = {
|
|
92629
|
+
'rejected': 'rejected',
|
|
92630
|
+
'open': 'open',
|
|
92627
92631
|
'not_deal': 'open',
|
|
92628
92632
|
'part_deal': 'open',
|
|
92629
92633
|
'done': 'closed',
|
|
@@ -92657,7 +92661,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92657
92661
|
// "client_id": "",
|
|
92658
92662
|
// }
|
|
92659
92663
|
//
|
|
92660
|
-
// Spot and Margin createOrder, cancelOrder, fetchOrder
|
|
92664
|
+
// Spot and Margin createOrder, createOrders, cancelOrder, cancelOrders, fetchOrder
|
|
92661
92665
|
//
|
|
92662
92666
|
// {
|
|
92663
92667
|
// "amount":"1.5",
|
|
@@ -92856,13 +92860,50 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92856
92860
|
// "user_id": 3620173
|
|
92857
92861
|
// }
|
|
92858
92862
|
//
|
|
92863
|
+
// swap: cancelOrders
|
|
92864
|
+
//
|
|
92865
|
+
// {
|
|
92866
|
+
// "amount": "0.0005",
|
|
92867
|
+
// "client_id": "x-167673045-b0cee0c584718b65",
|
|
92868
|
+
// "create_time": 1701233683.294231,
|
|
92869
|
+
// "deal_asset_fee": "0.00000000000000000000",
|
|
92870
|
+
// "deal_fee": "0.00000000000000000000",
|
|
92871
|
+
// "deal_profit": "0.00000000000000000000",
|
|
92872
|
+
// "deal_stock": "0.00000000000000000000",
|
|
92873
|
+
// "effect_type": 1,
|
|
92874
|
+
// "fee_asset": "",
|
|
92875
|
+
// "fee_discount": "0.00000000000000000000",
|
|
92876
|
+
// "last_deal_amount": "0.00000000000000000000",
|
|
92877
|
+
// "last_deal_id": 0,
|
|
92878
|
+
// "last_deal_price": "0.00000000000000000000",
|
|
92879
|
+
// "last_deal_role": 0,
|
|
92880
|
+
// "last_deal_time": 0,
|
|
92881
|
+
// "last_deal_type": 0,
|
|
92882
|
+
// "left": "0.0005",
|
|
92883
|
+
// "leverage": "3",
|
|
92884
|
+
// "maker_fee": "0.00030",
|
|
92885
|
+
// "market": "BTCUSDT",
|
|
92886
|
+
// "option": 0,
|
|
92887
|
+
// "order_id": 115940476323,
|
|
92888
|
+
// "position_id": 0,
|
|
92889
|
+
// "position_type": 2,
|
|
92890
|
+
// "price": "25000.00",
|
|
92891
|
+
// "side": 2,
|
|
92892
|
+
// "source": "api.v1",
|
|
92893
|
+
// "stop_id": 0,
|
|
92894
|
+
// "stop_loss_price": "0.00000000000000000000",
|
|
92895
|
+
// "stop_loss_type": 0,
|
|
92896
|
+
// "take_profit_price": "0.00000000000000000000",
|
|
92897
|
+
// "take_profit_type": 0,
|
|
92898
|
+
// "taker_fee": "0.00050",
|
|
92899
|
+
// "target": 0,
|
|
92900
|
+
// "type": 1,
|
|
92901
|
+
// "update_time": 1701233721.718884,
|
|
92902
|
+
// "user_id": 3620173
|
|
92903
|
+
// }
|
|
92904
|
+
//
|
|
92905
|
+
const rawStatus = this.safeString(order, 'status');
|
|
92859
92906
|
const timestamp = this.safeTimestamp(order, 'create_time');
|
|
92860
|
-
const priceString = this.safeString(order, 'price');
|
|
92861
|
-
const costString = this.safeString(order, 'deal_money');
|
|
92862
|
-
const amountString = this.safeString(order, 'amount');
|
|
92863
|
-
const filledString = this.safeString(order, 'deal_amount');
|
|
92864
|
-
const averageString = this.safeString(order, 'avg_price');
|
|
92865
|
-
const remainingString = this.safeString(order, 'left');
|
|
92866
92907
|
const marketId = this.safeString(order, 'market');
|
|
92867
92908
|
const defaultType = this.safeString(this.options, 'defaultType');
|
|
92868
92909
|
const orderType = ('source' in order) ? 'swap' : defaultType;
|
|
@@ -92872,7 +92913,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92872
92913
|
if (feeCurrency === undefined) {
|
|
92873
92914
|
feeCurrency = market['quote'];
|
|
92874
92915
|
}
|
|
92875
|
-
const status = this.parseOrderStatus(this.safeString(order, 'status'));
|
|
92876
92916
|
const rawSide = this.safeInteger(order, 'side');
|
|
92877
92917
|
let side = undefined;
|
|
92878
92918
|
if (rawSide === 1) {
|
|
@@ -92908,21 +92948,23 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92908
92948
|
'datetime': this.iso8601(timestamp),
|
|
92909
92949
|
'timestamp': timestamp,
|
|
92910
92950
|
'lastTradeTimestamp': this.safeTimestamp(order, 'update_time'),
|
|
92911
|
-
'status':
|
|
92951
|
+
'status': this.parseOrderStatus(rawStatus),
|
|
92912
92952
|
'symbol': market['symbol'],
|
|
92913
92953
|
'type': type,
|
|
92914
92954
|
'timeInForce': undefined,
|
|
92915
92955
|
'postOnly': undefined,
|
|
92916
92956
|
'reduceOnly': undefined,
|
|
92917
92957
|
'side': side,
|
|
92918
|
-
'price':
|
|
92958
|
+
'price': this.safeString(order, 'price'),
|
|
92919
92959
|
'stopPrice': this.safeString(order, 'stop_price'),
|
|
92920
92960
|
'triggerPrice': this.safeString(order, 'stop_price'),
|
|
92921
|
-
'
|
|
92922
|
-
'
|
|
92923
|
-
'
|
|
92924
|
-
'
|
|
92925
|
-
'
|
|
92961
|
+
'takeProfitPrice': this.safeNumber(order, 'take_profit_price'),
|
|
92962
|
+
'stopLossPrice': this.safeNumber(order, 'stop_loss_price'),
|
|
92963
|
+
'cost': this.safeString(order, 'deal_money'),
|
|
92964
|
+
'average': this.safeString(order, 'avg_price'),
|
|
92965
|
+
'amount': this.safeString(order, 'amount'),
|
|
92966
|
+
'filled': this.safeString(order, 'deal_amount'),
|
|
92967
|
+
'remaining': this.safeString(order, 'left'),
|
|
92926
92968
|
'trades': undefined,
|
|
92927
92969
|
'fee': {
|
|
92928
92970
|
'currency': feeCurrency,
|
|
@@ -92931,34 +92973,7 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92931
92973
|
'info': order,
|
|
92932
92974
|
}, market);
|
|
92933
92975
|
}
|
|
92934
|
-
|
|
92935
|
-
/**
|
|
92936
|
-
* @method
|
|
92937
|
-
* @name coinex#createOrder
|
|
92938
|
-
* @description create a trade order
|
|
92939
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
|
|
92940
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
|
|
92941
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
|
92942
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
|
|
92943
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
|
|
92944
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
|
|
92945
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
92946
|
-
* @param {string} type 'market' or 'limit'
|
|
92947
|
-
* @param {string} side 'buy' or 'sell'
|
|
92948
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
92949
|
-
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
92950
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
92951
|
-
* @param {float} triggerPrice price at which to triger stop orders
|
|
92952
|
-
* @param {float} stopPrice price at which to triger stop orders
|
|
92953
|
-
* @param {float} stopLossPrice price at which to trigger stop-loss orders
|
|
92954
|
-
* @param {float} takeProfitPrice price at which to trigger take-profit orders
|
|
92955
|
-
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", "PO"
|
|
92956
|
-
* @param {bool} params.postOnly
|
|
92957
|
-
* @param {bool} params.reduceOnly
|
|
92958
|
-
* @param {bool} [params.position_id] *required for reduce only orders* the position id to reduce
|
|
92959
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
92960
|
-
*/
|
|
92961
|
-
await this.loadMarkets();
|
|
92976
|
+
createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
|
|
92962
92977
|
const market = this.market(symbol);
|
|
92963
92978
|
const swap = market['swap'];
|
|
92964
92979
|
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
@@ -92972,14 +92987,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92972
92987
|
const timeInForceRaw = this.safeString(params, 'timeInForce'); // Spot: IOC, FOK, PO, GTC, ... NORMAL (default), MAKER_ONLY
|
|
92973
92988
|
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
92974
92989
|
if (reduceOnly) {
|
|
92975
|
-
if (market['
|
|
92990
|
+
if (!market['swap']) {
|
|
92976
92991
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only');
|
|
92977
92992
|
}
|
|
92978
92993
|
if (positionId === undefined) {
|
|
92979
92994
|
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders');
|
|
92980
92995
|
}
|
|
92981
92996
|
}
|
|
92982
|
-
let method = undefined;
|
|
92983
92997
|
const request = {
|
|
92984
92998
|
'market': market['id'],
|
|
92985
92999
|
};
|
|
@@ -92999,16 +93013,13 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
92999
93013
|
}
|
|
93000
93014
|
request['position_id'] = positionId;
|
|
93001
93015
|
if (stopLossPrice) {
|
|
93002
|
-
method = 'perpetualPrivatePostPositionStopLoss';
|
|
93003
93016
|
request['stop_loss_price'] = this.priceToPrecision(symbol, stopLossPrice);
|
|
93004
93017
|
}
|
|
93005
93018
|
else if (takeProfitPrice) {
|
|
93006
|
-
method = 'perpetualPrivatePostPositionTakeProfit';
|
|
93007
93019
|
request['take_profit_price'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
93008
93020
|
}
|
|
93009
93021
|
}
|
|
93010
93022
|
else {
|
|
93011
|
-
method = 'perpetualPrivatePostOrderPut' + this.capitalize(type);
|
|
93012
93023
|
const requestSide = (side === 'buy') ? 2 : 1;
|
|
93013
93024
|
if (stopPrice !== undefined) {
|
|
93014
93025
|
request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
|
|
@@ -93016,12 +93027,8 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93016
93027
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
93017
93028
|
request['side'] = requestSide;
|
|
93018
93029
|
if (type === 'limit') {
|
|
93019
|
-
method = 'perpetualPrivatePostOrderPutStopLimit';
|
|
93020
93030
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
93021
93031
|
}
|
|
93022
|
-
else if (type === 'market') {
|
|
93023
|
-
method = 'perpetualPrivatePostOrderPutStopMarket';
|
|
93024
|
-
}
|
|
93025
93032
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
93026
93033
|
}
|
|
93027
93034
|
let timeInForce = undefined;
|
|
@@ -93044,7 +93051,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93044
93051
|
}
|
|
93045
93052
|
if (type === 'limit' && stopPrice === undefined) {
|
|
93046
93053
|
if (reduceOnly) {
|
|
93047
|
-
method = 'perpetualPrivatePostOrderCloseLimit';
|
|
93048
93054
|
request['position_id'] = positionId;
|
|
93049
93055
|
}
|
|
93050
93056
|
else {
|
|
@@ -93055,7 +93061,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93055
93061
|
}
|
|
93056
93062
|
else if (type === 'market' && stopPrice === undefined) {
|
|
93057
93063
|
if (reduceOnly) {
|
|
93058
|
-
method = 'perpetualPrivatePostOrderCloseMarket';
|
|
93059
93064
|
request['position_id'] = positionId;
|
|
93060
93065
|
}
|
|
93061
93066
|
else {
|
|
@@ -93066,7 +93071,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93066
93071
|
}
|
|
93067
93072
|
}
|
|
93068
93073
|
else {
|
|
93069
|
-
method = 'privatePostOrder' + this.capitalize(type);
|
|
93070
93074
|
request['type'] = side;
|
|
93071
93075
|
if ((type === 'market') && (side === 'buy')) {
|
|
93072
93076
|
if (this.options['createMarketBuyOrderRequiresPrice']) {
|
|
@@ -93093,12 +93097,6 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93093
93097
|
}
|
|
93094
93098
|
if (stopPrice !== undefined) {
|
|
93095
93099
|
request['stop_price'] = this.priceToPrecision(symbol, stopPrice);
|
|
93096
|
-
if (type === 'limit') {
|
|
93097
|
-
method = 'privatePostOrderStopLimit';
|
|
93098
|
-
}
|
|
93099
|
-
else if (type === 'market') {
|
|
93100
|
-
method = 'privatePostOrderStopMarket';
|
|
93101
|
-
}
|
|
93102
93100
|
}
|
|
93103
93101
|
if ((type !== 'market') || (stopPrice !== undefined)) {
|
|
93104
93102
|
// following options cannot be applied to vanilla market orders (but can be applied to stop-market orders)
|
|
@@ -93126,7 +93124,100 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93126
93124
|
request['account_id'] = accountId;
|
|
93127
93125
|
}
|
|
93128
93126
|
params = this.omit(params, ['reduceOnly', 'positionId', 'timeInForce', 'postOnly', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
93129
|
-
|
|
93127
|
+
return this.extend(request, params);
|
|
93128
|
+
}
|
|
93129
|
+
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
93130
|
+
/**
|
|
93131
|
+
* @method
|
|
93132
|
+
* @name coinex#createOrder
|
|
93133
|
+
* @description create a trade order
|
|
93134
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
|
|
93135
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
|
|
93136
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
|
93137
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
|
|
93138
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
|
|
93139
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
|
|
93140
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
93141
|
+
* @param {string} type 'market' or 'limit'
|
|
93142
|
+
* @param {string} side 'buy' or 'sell'
|
|
93143
|
+
* @param {float} amount how much you want to trade in units of the base currency
|
|
93144
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
93145
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
93146
|
+
* @param {float} [params.triggerPrice] price to trigger stop orders
|
|
93147
|
+
* @param {float} [params.stopLossPrice] price to trigger stop loss orders
|
|
93148
|
+
* @param {float} [params.takeProfitPrice] price to trigger take profit orders
|
|
93149
|
+
* @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', 'PO'
|
|
93150
|
+
* @param {boolean} [params.postOnly] set to true if you wish to make a post only order
|
|
93151
|
+
* @param {boolean} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
|
|
93152
|
+
* @param {int} [params.position_id] *required for reduce only orders* the position id to reduce
|
|
93153
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
93154
|
+
*/
|
|
93155
|
+
await this.loadMarkets();
|
|
93156
|
+
const market = this.market(symbol);
|
|
93157
|
+
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
93158
|
+
const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
|
|
93159
|
+
const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
|
|
93160
|
+
const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
|
|
93161
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
93162
|
+
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
93163
|
+
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
93164
|
+
const isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
93165
|
+
const request = this.createOrderRequest(symbol, type, side, amount, price, params);
|
|
93166
|
+
let response = undefined;
|
|
93167
|
+
if (market['spot']) {
|
|
93168
|
+
if (isTriggerOrder) {
|
|
93169
|
+
if (type === 'limit') {
|
|
93170
|
+
response = await this.privatePostOrderStopLimit(request);
|
|
93171
|
+
}
|
|
93172
|
+
else {
|
|
93173
|
+
response = await this.privatePostOrderStopMarket(request);
|
|
93174
|
+
}
|
|
93175
|
+
}
|
|
93176
|
+
else {
|
|
93177
|
+
if (type === 'limit') {
|
|
93178
|
+
response = await this.privatePostOrderLimit(request);
|
|
93179
|
+
}
|
|
93180
|
+
else {
|
|
93181
|
+
response = await this.privatePostOrderMarket(request);
|
|
93182
|
+
}
|
|
93183
|
+
}
|
|
93184
|
+
}
|
|
93185
|
+
else {
|
|
93186
|
+
if (isTriggerOrder) {
|
|
93187
|
+
if (type === 'limit') {
|
|
93188
|
+
response = await this.perpetualPrivatePostOrderPutStopLimit(request);
|
|
93189
|
+
}
|
|
93190
|
+
else {
|
|
93191
|
+
response = await this.perpetualPrivatePostOrderPutStopMarket(request);
|
|
93192
|
+
}
|
|
93193
|
+
}
|
|
93194
|
+
else if (isStopLossOrTakeProfitTrigger) {
|
|
93195
|
+
if (isStopLossTriggerOrder) {
|
|
93196
|
+
response = await this.perpetualPrivatePostPositionStopLoss(request);
|
|
93197
|
+
}
|
|
93198
|
+
else if (isTakeProfitTriggerOrder) {
|
|
93199
|
+
response = await this.perpetualPrivatePostPositionTakeProfit(request);
|
|
93200
|
+
}
|
|
93201
|
+
}
|
|
93202
|
+
else {
|
|
93203
|
+
if (reduceOnly) {
|
|
93204
|
+
if (type === 'limit') {
|
|
93205
|
+
response = await this.perpetualPrivatePostOrderCloseLimit(request);
|
|
93206
|
+
}
|
|
93207
|
+
else {
|
|
93208
|
+
response = await this.perpetualPrivatePostOrderCloseMarket(request);
|
|
93209
|
+
}
|
|
93210
|
+
}
|
|
93211
|
+
else {
|
|
93212
|
+
if (type === 'limit') {
|
|
93213
|
+
response = await this.perpetualPrivatePostOrderPutLimit(request);
|
|
93214
|
+
}
|
|
93215
|
+
else {
|
|
93216
|
+
response = await this.perpetualPrivatePostOrderPutMarket(request);
|
|
93217
|
+
}
|
|
93218
|
+
}
|
|
93219
|
+
}
|
|
93220
|
+
}
|
|
93130
93221
|
//
|
|
93131
93222
|
// Spot and Margin
|
|
93132
93223
|
//
|
|
@@ -93204,9 +93295,243 @@ class coinex extends _abstract_coinex_js__WEBPACK_IMPORTED_MODULE_0__/* ["defaul
|
|
|
93204
93295
|
//
|
|
93205
93296
|
// {"code":0,"data":{"status":"success"},"message":"OK"}
|
|
93206
93297
|
//
|
|
93207
|
-
const data = this.safeValue(response, 'data');
|
|
93298
|
+
const data = this.safeValue(response, 'data', {});
|
|
93208
93299
|
return this.parseOrder(data, market);
|
|
93209
93300
|
}
|
|
93301
|
+
async createOrders(orders, params = {}) {
|
|
93302
|
+
/**
|
|
93303
|
+
* @method
|
|
93304
|
+
* @name coinex#createOrders
|
|
93305
|
+
* @description create a list of trade orders (all orders should be of the same symbol)
|
|
93306
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade002_batch_limit_orders
|
|
93307
|
+
* @param {array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
|
|
93308
|
+
* @param {object} [params] extra parameters specific to the api endpoint
|
|
93309
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
93310
|
+
*/
|
|
93311
|
+
await this.loadMarkets();
|
|
93312
|
+
const ordersRequests = [];
|
|
93313
|
+
let symbol = undefined;
|
|
93314
|
+
for (let i = 0; i < orders.length; i++) {
|
|
93315
|
+
const rawOrder = orders[i];
|
|
93316
|
+
const marketId = this.safeString(rawOrder, 'symbol');
|
|
93317
|
+
if (symbol === undefined) {
|
|
93318
|
+
symbol = marketId;
|
|
93319
|
+
}
|
|
93320
|
+
else {
|
|
93321
|
+
if (symbol !== marketId) {
|
|
93322
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.BadRequest(this.id + ' createOrders() requires all orders to have the same symbol');
|
|
93323
|
+
}
|
|
93324
|
+
}
|
|
93325
|
+
const type = this.safeString(rawOrder, 'type');
|
|
93326
|
+
const side = this.safeString(rawOrder, 'side');
|
|
93327
|
+
const amount = this.safeValue(rawOrder, 'amount');
|
|
93328
|
+
const price = this.safeValue(rawOrder, 'price');
|
|
93329
|
+
const orderParams = this.safeValue(rawOrder, 'params', {});
|
|
93330
|
+
if (type !== 'limit') {
|
|
93331
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + type + ' orders, only limit orders are accepted');
|
|
93332
|
+
}
|
|
93333
|
+
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
93334
|
+
ordersRequests.push(orderRequest);
|
|
93335
|
+
}
|
|
93336
|
+
const market = this.market(symbol);
|
|
93337
|
+
if (!market['spot']) {
|
|
93338
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.NotSupported(this.id + ' createOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted');
|
|
93339
|
+
}
|
|
93340
|
+
const request = {
|
|
93341
|
+
'market': market['id'],
|
|
93342
|
+
'batch_orders': this.json(ordersRequests),
|
|
93343
|
+
};
|
|
93344
|
+
const response = await this.privatePostOrderLimitBatch(request);
|
|
93345
|
+
//
|
|
93346
|
+
// {
|
|
93347
|
+
// "code": 0,
|
|
93348
|
+
// "data": [
|
|
93349
|
+
// {
|
|
93350
|
+
// "code": 0,
|
|
93351
|
+
// "data": {
|
|
93352
|
+
// "amount": "0.0005",
|
|
93353
|
+
// "asset_fee": "0",
|
|
93354
|
+
// "avg_price": "0.00",
|
|
93355
|
+
// "client_id": "x-167673045-d34bfb41242d8fd1",
|
|
93356
|
+
// "create_time": 1701229157,
|
|
93357
|
+
// "deal_amount": "0",
|
|
93358
|
+
// "deal_fee": "0",
|
|
93359
|
+
// "deal_money": "0",
|
|
93360
|
+
// "fee_asset": null,
|
|
93361
|
+
// "fee_discount": "1",
|
|
93362
|
+
// "finished_time": null,
|
|
93363
|
+
// "id": 107745856676,
|
|
93364
|
+
// "left": "0.0005",
|
|
93365
|
+
// "maker_fee_rate": "0.002",
|
|
93366
|
+
// "market": "BTCUSDT",
|
|
93367
|
+
// "money_fee": "0",
|
|
93368
|
+
// "order_type": "limit",
|
|
93369
|
+
// "price": "23000",
|
|
93370
|
+
// "source_id": "",
|
|
93371
|
+
// "status": "not_deal",
|
|
93372
|
+
// "stock_fee": "0",
|
|
93373
|
+
// "taker_fee_rate": "0.002",
|
|
93374
|
+
// "type": "buy"
|
|
93375
|
+
// },
|
|
93376
|
+
// "message": "OK"
|
|
93377
|
+
// },
|
|
93378
|
+
// ],
|
|
93379
|
+
// "message": "Success"
|
|
93380
|
+
// }
|
|
93381
|
+
//
|
|
93382
|
+
const data = this.safeValue(response, 'data', []);
|
|
93383
|
+
const results = [];
|
|
93384
|
+
for (let i = 0; i < data.length; i++) {
|
|
93385
|
+
const entry = data[i];
|
|
93386
|
+
let status = undefined;
|
|
93387
|
+
const code = this.safeInteger(entry, 'code');
|
|
93388
|
+
if (code !== undefined) {
|
|
93389
|
+
if (code !== 0) {
|
|
93390
|
+
status = 'rejected';
|
|
93391
|
+
}
|
|
93392
|
+
else {
|
|
93393
|
+
status = 'open';
|
|
93394
|
+
}
|
|
93395
|
+
}
|
|
93396
|
+
const item = this.safeValue(entry, 'data', {});
|
|
93397
|
+
item['status'] = status;
|
|
93398
|
+
const order = this.parseOrder(item, market);
|
|
93399
|
+
results.push(order);
|
|
93400
|
+
}
|
|
93401
|
+
return results;
|
|
93402
|
+
}
|
|
93403
|
+
async cancelOrders(ids, symbol = undefined, params = {}) {
|
|
93404
|
+
/**
|
|
93405
|
+
* @method
|
|
93406
|
+
* @name coinex#cancelOrders
|
|
93407
|
+
* @description cancel multiple orders
|
|
93408
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order
|
|
93409
|
+
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021-0_cancel_order_batch
|
|
93410
|
+
* @param {string[]} ids order ids
|
|
93411
|
+
* @param {string} symbol unified market symbol
|
|
93412
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
93413
|
+
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
93414
|
+
*/
|
|
93415
|
+
if (symbol === undefined) {
|
|
93416
|
+
throw new _base_errors_js__WEBPACK_IMPORTED_MODULE_2__.ArgumentsRequired(this.id + ' cancelOrders() requires a symbol argument');
|
|
93417
|
+
}
|
|
93418
|
+
await this.loadMarkets();
|
|
93419
|
+
const market = this.market(symbol);
|
|
93420
|
+
const request = {
|
|
93421
|
+
'market': market['id'],
|
|
93422
|
+
};
|
|
93423
|
+
const idsString = ids.join(',');
|
|
93424
|
+
let response = undefined;
|
|
93425
|
+
if (market['spot']) {
|
|
93426
|
+
request['batch_ids'] = idsString;
|
|
93427
|
+
response = await this.privateDeleteOrderPendingBatch(this.extend(request, params));
|
|
93428
|
+
}
|
|
93429
|
+
else {
|
|
93430
|
+
request['order_ids'] = idsString;
|
|
93431
|
+
response = await this.perpetualPrivatePostOrderCancelBatch(this.extend(request, params));
|
|
93432
|
+
}
|
|
93433
|
+
//
|
|
93434
|
+
// spot
|
|
93435
|
+
//
|
|
93436
|
+
// {
|
|
93437
|
+
// "code": 0,
|
|
93438
|
+
// "data": [
|
|
93439
|
+
// {
|
|
93440
|
+
// "code": 0,
|
|
93441
|
+
// "data": {
|
|
93442
|
+
// "account_id": 0,
|
|
93443
|
+
// "amount": "0.0005",
|
|
93444
|
+
// "asset_fee": "0",
|
|
93445
|
+
// "avg_price": "0.00",
|
|
93446
|
+
// "client_id": "x-167673045-d4e03c38f4d19b4e",
|
|
93447
|
+
// "create_time": 1701229157,
|
|
93448
|
+
// "deal_amount": "0",
|
|
93449
|
+
// "deal_fee": "0",
|
|
93450
|
+
// "deal_money": "0",
|
|
93451
|
+
// "fee_asset": null,
|
|
93452
|
+
// "fee_discount": "1",
|
|
93453
|
+
// "finished_time": 0,
|
|
93454
|
+
// "id": 107745856682,
|
|
93455
|
+
// "left": "0",
|
|
93456
|
+
// "maker_fee_rate": "0.002",
|
|
93457
|
+
// "market": "BTCUSDT",
|
|
93458
|
+
// "money_fee": "0",
|
|
93459
|
+
// "order_type": "limit",
|
|
93460
|
+
// "price": "22000",
|
|
93461
|
+
// "status": "not_deal",
|
|
93462
|
+
// "stock_fee": "0",
|
|
93463
|
+
// "taker_fee_rate": "0.002",
|
|
93464
|
+
// "type": "buy"
|
|
93465
|
+
// },
|
|
93466
|
+
// "message": ""
|
|
93467
|
+
// },
|
|
93468
|
+
// ],
|
|
93469
|
+
// "message": "Success"
|
|
93470
|
+
// }
|
|
93471
|
+
//
|
|
93472
|
+
// swap
|
|
93473
|
+
//
|
|
93474
|
+
// {
|
|
93475
|
+
// "code": 0,
|
|
93476
|
+
// "data": [
|
|
93477
|
+
// {
|
|
93478
|
+
// "code": 0,
|
|
93479
|
+
// "message": "",
|
|
93480
|
+
// "order": {
|
|
93481
|
+
// "amount": "0.0005",
|
|
93482
|
+
// "client_id": "x-167673045-b0cee0c584718b65",
|
|
93483
|
+
// "create_time": 1701233683.294231,
|
|
93484
|
+
// "deal_asset_fee": "0.00000000000000000000",
|
|
93485
|
+
// "deal_fee": "0.00000000000000000000",
|
|
93486
|
+
// "deal_profit": "0.00000000000000000000",
|
|
93487
|
+
// "deal_stock": "0.00000000000000000000",
|
|
93488
|
+
// "effect_type": 1,
|
|
93489
|
+
// "fee_asset": "",
|
|
93490
|
+
// "fee_discount": "0.00000000000000000000",
|
|
93491
|
+
// "last_deal_amount": "0.00000000000000000000",
|
|
93492
|
+
// "last_deal_id": 0,
|
|
93493
|
+
// "last_deal_price": "0.00000000000000000000",
|
|
93494
|
+
// "last_deal_role": 0,
|
|
93495
|
+
// "last_deal_time": 0,
|
|
93496
|
+
// "last_deal_type": 0,
|
|
93497
|
+
// "left": "0.0005",
|
|
93498
|
+
// "leverage": "3",
|
|
93499
|
+
// "maker_fee": "0.00030",
|
|
93500
|
+
// "market": "BTCUSDT",
|
|
93501
|
+
// "option": 0,
|
|
93502
|
+
// "order_id": 115940476323,
|
|
93503
|
+
// "position_id": 0,
|
|
93504
|
+
// "position_type": 2,
|
|
93505
|
+
// "price": "25000.00",
|
|
93506
|
+
// "side": 2,
|
|
93507
|
+
// "source": "api.v1",
|
|
93508
|
+
// "stop_id": 0,
|
|
93509
|
+
// "stop_loss_price": "0.00000000000000000000",
|
|
93510
|
+
// "stop_loss_type": 0,
|
|
93511
|
+
// "take_profit_price": "0.00000000000000000000",
|
|
93512
|
+
// "take_profit_type": 0,
|
|
93513
|
+
// "taker_fee": "0.00050",
|
|
93514
|
+
// "target": 0,
|
|
93515
|
+
// "type": 1,
|
|
93516
|
+
// "update_time": 1701233721.718884,
|
|
93517
|
+
// "user_id": 3620173
|
|
93518
|
+
// }
|
|
93519
|
+
// },
|
|
93520
|
+
// ],
|
|
93521
|
+
// "message": "OK"
|
|
93522
|
+
// }
|
|
93523
|
+
//
|
|
93524
|
+
const data = this.safeValue(response, 'data', []);
|
|
93525
|
+
const results = [];
|
|
93526
|
+
for (let i = 0; i < data.length; i++) {
|
|
93527
|
+
const entry = data[i];
|
|
93528
|
+
const dataRequest = market['spot'] ? 'data' : 'order';
|
|
93529
|
+
const item = this.safeValue(entry, dataRequest, {});
|
|
93530
|
+
const order = this.parseOrder(item, market);
|
|
93531
|
+
results.push(order);
|
|
93532
|
+
}
|
|
93533
|
+
return results;
|
|
93534
|
+
}
|
|
93210
93535
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
93211
93536
|
/**
|
|
93212
93537
|
* @method
|
|
@@ -204154,8 +204479,8 @@ class binance extends _binance_js__WEBPACK_IMPORTED_MODULE_0__/* ["default"] */
|
|
|
204154
204479
|
},
|
|
204155
204480
|
'api': {
|
|
204156
204481
|
'ws': {
|
|
204157
|
-
'spot': 'wss://stream.binance.com
|
|
204158
|
-
'margin': 'wss://stream.binance.com
|
|
204482
|
+
'spot': 'wss://stream.binance.com/ws',
|
|
204483
|
+
'margin': 'wss://stream.binance.com/ws',
|
|
204159
204484
|
'future': 'wss://fstream.binance.com/ws',
|
|
204160
204485
|
'delivery': 'wss://dstream.binance.com/ws',
|
|
204161
204486
|
'ws': 'wss://ws-api.binance.com:443/ws-api/v3',
|
|
@@ -287985,7 +288310,7 @@ SOFTWARE.
|
|
|
287985
288310
|
|
|
287986
288311
|
//-----------------------------------------------------------------------------
|
|
287987
288312
|
// this is updated by vss.js when building
|
|
287988
|
-
const version = '4.1.
|
|
288313
|
+
const version = '4.1.70';
|
|
287989
288314
|
_src_base_Exchange_js__WEBPACK_IMPORTED_MODULE_0__/* .Exchange */ .e.ccxtVersion = version;
|
|
287990
288315
|
//-----------------------------------------------------------------------------
|
|
287991
288316
|
|