ccxt 4.3.8 → 4.3.10
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/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +3 -3
- package/dist/cjs/src/bingx.js +21 -11
- package/dist/cjs/src/bitget.js +1 -1
- package/dist/cjs/src/coinex.js +689 -426
- package/dist/cjs/src/coinmetro.js +31 -31
- package/dist/cjs/src/kucoinfutures.js +159 -11
- package/dist/cjs/src/okx.js +58 -1
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/bingx.d.ts +1 -1
- package/js/src/abstract/coinmetro.d.ts +1 -0
- package/js/src/abstract/kucoinfutures.d.ts +2 -0
- package/js/src/base/Exchange.js +3 -3
- package/js/src/base/types.d.ts +2 -0
- package/js/src/bingx.js +21 -11
- package/js/src/bitget.js +1 -1
- package/js/src/coinex.js +689 -426
- package/js/src/coinmetro.d.ts +1 -1
- package/js/src/coinmetro.js +31 -31
- package/js/src/kucoinfutures.d.ts +3 -1
- package/js/src/kucoinfutures.js +159 -11
- package/js/src/okx.d.ts +4 -0
- package/js/src/okx.js +58 -1
- package/package.json +8 -7
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -1740,7 +1740,7 @@ class coinex extends coinex$1 {
|
|
|
1740
1740
|
// "client_id": "",
|
|
1741
1741
|
// }
|
|
1742
1742
|
//
|
|
1743
|
-
// Spot and Margin
|
|
1743
|
+
// Spot and Margin cancelOrder, fetchOrder
|
|
1744
1744
|
//
|
|
1745
1745
|
// {
|
|
1746
1746
|
// "amount":"1.5",
|
|
@@ -1768,7 +1768,7 @@ class coinex extends coinex$1 {
|
|
|
1768
1768
|
// "client_id": "",
|
|
1769
1769
|
// }
|
|
1770
1770
|
//
|
|
1771
|
-
// Swap
|
|
1771
|
+
// Swap cancelOrder, fetchOrder
|
|
1772
1772
|
//
|
|
1773
1773
|
// {
|
|
1774
1774
|
// "amount": "0.0005",
|
|
@@ -1805,10 +1805,6 @@ class coinex extends coinex$1 {
|
|
|
1805
1805
|
// "user_id": 3620173
|
|
1806
1806
|
// }
|
|
1807
1807
|
//
|
|
1808
|
-
// Stop order createOrder
|
|
1809
|
-
//
|
|
1810
|
-
// {"status":"success"}
|
|
1811
|
-
//
|
|
1812
1808
|
// Swap Stop cancelOrder, fetchOrder
|
|
1813
1809
|
//
|
|
1814
1810
|
// {
|
|
@@ -1939,67 +1935,146 @@ class coinex extends coinex$1 {
|
|
|
1939
1935
|
// "user_id": 3620173
|
|
1940
1936
|
// }
|
|
1941
1937
|
//
|
|
1942
|
-
//
|
|
1938
|
+
// Spot and Margin createOrder, createOrders, cancelOrders v2
|
|
1943
1939
|
//
|
|
1944
1940
|
// {
|
|
1945
|
-
// "amount": "0.
|
|
1946
|
-
// "
|
|
1947
|
-
// "
|
|
1948
|
-
// "
|
|
1949
|
-
// "
|
|
1950
|
-
// "
|
|
1951
|
-
// "
|
|
1952
|
-
// "
|
|
1953
|
-
// "
|
|
1954
|
-
// "
|
|
1955
|
-
// "
|
|
1956
|
-
// "
|
|
1957
|
-
// "
|
|
1958
|
-
// "
|
|
1959
|
-
// "
|
|
1960
|
-
// "
|
|
1961
|
-
// "
|
|
1941
|
+
// "amount": "0.0001",
|
|
1942
|
+
// "base_fee": "0",
|
|
1943
|
+
// "ccy": "BTC",
|
|
1944
|
+
// "client_id": "x-167673045-a0a3c6461459a801",
|
|
1945
|
+
// "created_at": 1714114386250,
|
|
1946
|
+
// "discount_fee": "0",
|
|
1947
|
+
// "filled_amount": "0",
|
|
1948
|
+
// "filled_value": "0",
|
|
1949
|
+
// "last_fill_amount": "0",
|
|
1950
|
+
// "last_fill_price": "0",
|
|
1951
|
+
// "maker_fee_rate": "0.002",
|
|
1952
|
+
// "market": "BTCUSDT",
|
|
1953
|
+
// "market_type": "SPOT",
|
|
1954
|
+
// "order_id": 117178743547,
|
|
1955
|
+
// "price": "61000",
|
|
1956
|
+
// "quote_fee": "0",
|
|
1957
|
+
// "side": "buy",
|
|
1958
|
+
// "taker_fee_rate": "0.002",
|
|
1959
|
+
// "type": "limit",
|
|
1960
|
+
// "unfilled_amount": "0.0001",
|
|
1961
|
+
// "updated_at": 1714114386250
|
|
1962
|
+
// }
|
|
1963
|
+
//
|
|
1964
|
+
// Spot, Margin and Swap trigger createOrder, createOrders v2
|
|
1965
|
+
//
|
|
1966
|
+
// {
|
|
1967
|
+
// "stop_id": 117180138153
|
|
1968
|
+
// }
|
|
1969
|
+
//
|
|
1970
|
+
// Swap createOrder, createOrders, cancelOrders v2
|
|
1971
|
+
//
|
|
1972
|
+
// {
|
|
1973
|
+
// "amount": "0.0001",
|
|
1974
|
+
// "client_id": "x-167673045-1471b81d747080a0",
|
|
1975
|
+
// "created_at": 1714116769986,
|
|
1976
|
+
// "fee": "0",
|
|
1977
|
+
// "fee_ccy": "USDT",
|
|
1978
|
+
// "filled_amount": "0",
|
|
1979
|
+
// "filled_value": "0",
|
|
1980
|
+
// "last_filled_amount": "0",
|
|
1981
|
+
// "last_filled_price": "0",
|
|
1982
|
+
// "maker_fee_rate": "0.0003",
|
|
1983
|
+
// "market": "BTCUSDT",
|
|
1984
|
+
// "market_type": "FUTURES",
|
|
1985
|
+
// "order_id": 136913377780,
|
|
1986
|
+
// "price": "61000.42",
|
|
1987
|
+
// "realized_pnl": "0",
|
|
1988
|
+
// "side": "buy",
|
|
1989
|
+
// "taker_fee_rate": "0.0005",
|
|
1990
|
+
// "type": "limit",
|
|
1991
|
+
// "unfilled_amount": "0.0001",
|
|
1992
|
+
// "updated_at": 1714116769986
|
|
1993
|
+
// }
|
|
1994
|
+
//
|
|
1995
|
+
// Swap stopLossPrice and takeProfitPrice createOrder v2
|
|
1996
|
+
//
|
|
1997
|
+
// {
|
|
1998
|
+
// "adl_level": 1,
|
|
1999
|
+
// "ath_margin_size": "2.14586666",
|
|
2000
|
+
// "ath_position_amount": "0.0001",
|
|
2001
|
+
// "avg_entry_price": "64376",
|
|
2002
|
+
// "bkr_price": "0",
|
|
2003
|
+
// "close_avbl": "0.0001",
|
|
2004
|
+
// "cml_position_value": "6.4376",
|
|
2005
|
+
// "created_at": 1714119054558,
|
|
1962
2006
|
// "leverage": "3",
|
|
1963
|
-
// "
|
|
2007
|
+
// "liq_price": "0",
|
|
2008
|
+
// "maintenance_margin_rate": "0.005",
|
|
2009
|
+
// "maintenance_margin_value": "0.03218632",
|
|
2010
|
+
// "margin_avbl": "2.14586666",
|
|
2011
|
+
// "margin_mode": "cross",
|
|
1964
2012
|
// "market": "BTCUSDT",
|
|
1965
|
-
// "
|
|
1966
|
-
// "
|
|
1967
|
-
// "
|
|
1968
|
-
// "
|
|
1969
|
-
// "
|
|
1970
|
-
// "
|
|
1971
|
-
// "
|
|
1972
|
-
// "
|
|
1973
|
-
// "
|
|
1974
|
-
// "
|
|
1975
|
-
// "
|
|
1976
|
-
// "
|
|
1977
|
-
// "
|
|
1978
|
-
// "
|
|
1979
|
-
// "
|
|
1980
|
-
//
|
|
1981
|
-
//
|
|
2013
|
+
// "market_type": "FUTURES",
|
|
2014
|
+
// "max_position_value": "6.4376",
|
|
2015
|
+
// "open_interest": "0.0001",
|
|
2016
|
+
// "position_id": 303884204,
|
|
2017
|
+
// "position_margin_rate": "3.10624785634397912265",
|
|
2018
|
+
// "realized_pnl": "-0.0032188",
|
|
2019
|
+
// "settle_price": "64376",
|
|
2020
|
+
// "settle_value": "6.4376",
|
|
2021
|
+
// "side": "long",
|
|
2022
|
+
// "stop_loss_price": "62000",
|
|
2023
|
+
// "stop_loss_type": "latest_price",
|
|
2024
|
+
// "take_profit_price": "0",
|
|
2025
|
+
// "take_profit_type": "",
|
|
2026
|
+
// "unrealized_pnl": "0",
|
|
2027
|
+
// "updated_at": 1714119054559
|
|
2028
|
+
// }
|
|
2029
|
+
//
|
|
2030
|
+
// Swap and Spot stop cancelOrders v2
|
|
2031
|
+
//
|
|
2032
|
+
// {
|
|
2033
|
+
// "amount": "0.0001",
|
|
2034
|
+
// "client_id": "x-167673045-a7d7714c6478acf6",
|
|
2035
|
+
// "created_at": 1714187923820,
|
|
2036
|
+
// "market": "BTCUSDT",
|
|
2037
|
+
// "market_type": "FUTURES",
|
|
2038
|
+
// "price": "61000",
|
|
2039
|
+
// "side": "buy",
|
|
2040
|
+
// "stop_id": 136984426097,
|
|
2041
|
+
// "trigger_direction": "higher",
|
|
2042
|
+
// "trigger_price": "62000",
|
|
2043
|
+
// "trigger_price_type": "latest_price",
|
|
2044
|
+
// "type": "limit",
|
|
2045
|
+
// "updated_at": 1714187974363
|
|
1982
2046
|
// }
|
|
1983
2047
|
//
|
|
1984
2048
|
const rawStatus = this.safeString(order, 'status');
|
|
1985
|
-
|
|
2049
|
+
let timestamp = this.safeTimestamp(order, 'create_time');
|
|
2050
|
+
if (timestamp === undefined) {
|
|
2051
|
+
timestamp = this.safeInteger(order, 'created_at');
|
|
2052
|
+
}
|
|
2053
|
+
let update = this.safeTimestamp(order, 'update_time');
|
|
2054
|
+
if (update === undefined) {
|
|
2055
|
+
update = this.safeInteger(order, 'updated_at');
|
|
2056
|
+
}
|
|
1986
2057
|
const marketId = this.safeString(order, 'market');
|
|
1987
2058
|
const defaultType = this.safeString(this.options, 'defaultType');
|
|
1988
2059
|
const orderType = ('source' in order) ? 'swap' : defaultType;
|
|
1989
2060
|
market = this.safeMarket(marketId, market, undefined, orderType);
|
|
1990
|
-
const feeCurrencyId = this.
|
|
2061
|
+
const feeCurrencyId = this.safeString2(order, 'fee_asset', 'fee_ccy');
|
|
1991
2062
|
let feeCurrency = this.safeCurrencyCode(feeCurrencyId);
|
|
1992
2063
|
if (feeCurrency === undefined) {
|
|
1993
2064
|
feeCurrency = market['quote'];
|
|
1994
2065
|
}
|
|
1995
|
-
const
|
|
2066
|
+
const rawIntegerSide = this.safeInteger(order, 'side');
|
|
2067
|
+
const rawStringSide = this.safeString(order, 'side');
|
|
1996
2068
|
let side = undefined;
|
|
1997
|
-
if (
|
|
2069
|
+
if (rawIntegerSide === 1) {
|
|
1998
2070
|
side = 'sell';
|
|
1999
2071
|
}
|
|
2000
|
-
else if (
|
|
2072
|
+
else if (rawIntegerSide === 2) {
|
|
2001
2073
|
side = 'buy';
|
|
2002
2074
|
}
|
|
2075
|
+
else if ((rawStringSide === 'buy') || (rawStringSide === 'sell')) {
|
|
2076
|
+
side = rawStringSide;
|
|
2077
|
+
}
|
|
2003
2078
|
else {
|
|
2004
2079
|
side = this.safeString(order, 'type');
|
|
2005
2080
|
}
|
|
@@ -2007,12 +2082,19 @@ class coinex extends coinex$1 {
|
|
|
2007
2082
|
let type = undefined;
|
|
2008
2083
|
if (rawType === undefined) {
|
|
2009
2084
|
const typeInteger = this.safeInteger(order, 'type');
|
|
2085
|
+
const typeString = this.safeString(order, 'type');
|
|
2010
2086
|
if (typeInteger === 1) {
|
|
2011
2087
|
type = 'limit';
|
|
2012
2088
|
}
|
|
2013
2089
|
else if (typeInteger === 2) {
|
|
2014
2090
|
type = 'market';
|
|
2015
2091
|
}
|
|
2092
|
+
else if ((typeString === 'limit') || (typeString === 'market')) {
|
|
2093
|
+
type = typeString;
|
|
2094
|
+
}
|
|
2095
|
+
else if (typeString === 'maker_only') {
|
|
2096
|
+
type = 'limit';
|
|
2097
|
+
}
|
|
2016
2098
|
}
|
|
2017
2099
|
else {
|
|
2018
2100
|
type = rawType;
|
|
@@ -2022,11 +2104,11 @@ class coinex extends coinex$1 {
|
|
|
2022
2104
|
clientOrderId = undefined;
|
|
2023
2105
|
}
|
|
2024
2106
|
return this.safeOrder({
|
|
2025
|
-
'id': this.
|
|
2107
|
+
'id': this.safeStringN(order, ['id', 'order_id', 'stop_id']),
|
|
2026
2108
|
'clientOrderId': clientOrderId,
|
|
2027
2109
|
'datetime': this.iso8601(timestamp),
|
|
2028
2110
|
'timestamp': timestamp,
|
|
2029
|
-
'lastTradeTimestamp':
|
|
2111
|
+
'lastTradeTimestamp': update,
|
|
2030
2112
|
'status': this.parseOrderStatus(rawStatus),
|
|
2031
2113
|
'symbol': market['symbol'],
|
|
2032
2114
|
'type': type,
|
|
@@ -2035,19 +2117,19 @@ class coinex extends coinex$1 {
|
|
|
2035
2117
|
'reduceOnly': undefined,
|
|
2036
2118
|
'side': side,
|
|
2037
2119
|
'price': this.safeString(order, 'price'),
|
|
2038
|
-
'stopPrice': this.
|
|
2039
|
-
'triggerPrice': this.
|
|
2120
|
+
'stopPrice': this.safeString2(order, 'stop_price', 'trigger_price'),
|
|
2121
|
+
'triggerPrice': this.safeString2(order, 'stop_price', 'trigger_price'),
|
|
2040
2122
|
'takeProfitPrice': this.safeNumber(order, 'take_profit_price'),
|
|
2041
2123
|
'stopLossPrice': this.safeNumber(order, 'stop_loss_price'),
|
|
2042
|
-
'cost': this.
|
|
2043
|
-
'average': this.
|
|
2124
|
+
'cost': this.safeString2(order, 'deal_money', 'filled_value'),
|
|
2125
|
+
'average': this.safeString2(order, 'avg_price', 'avg_entry_price'),
|
|
2044
2126
|
'amount': this.safeString(order, 'amount'),
|
|
2045
|
-
'filled': this.
|
|
2046
|
-
'remaining': this.
|
|
2127
|
+
'filled': this.safeString2(order, 'deal_amount', 'filled_amount'),
|
|
2128
|
+
'remaining': this.safeString2(order, 'left', 'unfilled_amount'),
|
|
2047
2129
|
'trades': undefined,
|
|
2048
2130
|
'fee': {
|
|
2049
2131
|
'currency': feeCurrency,
|
|
2050
|
-
'cost': this.
|
|
2132
|
+
'cost': this.safeStringN(order, ['deal_fee', 'quote_fee', 'fee']),
|
|
2051
2133
|
},
|
|
2052
2134
|
'info': order,
|
|
2053
2135
|
}, market);
|
|
@@ -2058,6 +2140,7 @@ class coinex extends coinex$1 {
|
|
|
2058
2140
|
* @name coinex#createMarketBuyOrderWithCost
|
|
2059
2141
|
* @description create a market buy order by providing the symbol and cost
|
|
2060
2142
|
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade003_market_order
|
|
2143
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/put-order
|
|
2061
2144
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2062
2145
|
* @param {float} cost how much you want to trade in units of the quote currency
|
|
2063
2146
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
@@ -2075,22 +2158,18 @@ class coinex extends coinex$1 {
|
|
|
2075
2158
|
const market = this.market(symbol);
|
|
2076
2159
|
const swap = market['swap'];
|
|
2077
2160
|
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
2078
|
-
const stopPrice = this.
|
|
2079
|
-
const stopLossPrice = this.
|
|
2080
|
-
const takeProfitPrice = this.
|
|
2161
|
+
const stopPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
2162
|
+
const stopLossPrice = this.safeString(params, 'stopLossPrice');
|
|
2163
|
+
const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
|
|
2081
2164
|
const option = this.safeString(params, 'option');
|
|
2082
2165
|
const isMarketOrder = type === 'market';
|
|
2083
|
-
const postOnly = this.isPostOnly(isMarketOrder, option === '
|
|
2084
|
-
const
|
|
2085
|
-
const
|
|
2086
|
-
const reduceOnly = this.safeValue(params, 'reduceOnly');
|
|
2166
|
+
const postOnly = this.isPostOnly(isMarketOrder, option === 'maker_only', params);
|
|
2167
|
+
const timeInForceRaw = this.safeStringUpper(params, 'timeInForce');
|
|
2168
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly');
|
|
2087
2169
|
if (reduceOnly) {
|
|
2088
2170
|
if (!market['swap']) {
|
|
2089
2171
|
throw new errors.InvalidOrder(this.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only');
|
|
2090
2172
|
}
|
|
2091
|
-
if (positionId === undefined) {
|
|
2092
|
-
throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders');
|
|
2093
|
-
}
|
|
2094
2173
|
}
|
|
2095
2174
|
const request = {
|
|
2096
2175
|
'market': market['id'],
|
|
@@ -2103,73 +2182,56 @@ class coinex extends coinex$1 {
|
|
|
2103
2182
|
else {
|
|
2104
2183
|
request['client_id'] = clientOrderId;
|
|
2105
2184
|
}
|
|
2185
|
+
if ((stopLossPrice === undefined) && (takeProfitPrice === undefined)) {
|
|
2186
|
+
if (!reduceOnly) {
|
|
2187
|
+
request['side'] = side;
|
|
2188
|
+
}
|
|
2189
|
+
let requestType = type;
|
|
2190
|
+
if (postOnly) {
|
|
2191
|
+
requestType = 'maker_only';
|
|
2192
|
+
}
|
|
2193
|
+
else if (timeInForceRaw !== undefined) {
|
|
2194
|
+
if (timeInForceRaw === 'IOC') {
|
|
2195
|
+
requestType = 'ioc';
|
|
2196
|
+
}
|
|
2197
|
+
else if (timeInForceRaw === 'FOK') {
|
|
2198
|
+
requestType = 'fok';
|
|
2199
|
+
}
|
|
2200
|
+
}
|
|
2201
|
+
if (!isMarketOrder) {
|
|
2202
|
+
request['price'] = this.priceToPrecision(symbol, price);
|
|
2203
|
+
}
|
|
2204
|
+
request['type'] = requestType;
|
|
2205
|
+
}
|
|
2106
2206
|
if (swap) {
|
|
2207
|
+
request['market_type'] = 'FUTURES';
|
|
2107
2208
|
if (stopLossPrice || takeProfitPrice) {
|
|
2108
|
-
request['stop_type'] = this.safeInteger(params, 'stop_type', 1); // 1: triggered by the latest transaction, 2: mark price, 3: index price
|
|
2109
|
-
if (positionId === undefined) {
|
|
2110
|
-
throw new errors.ArgumentsRequired(this.id + ' createOrder() requires a position_id parameter for stop loss and take profit orders');
|
|
2111
|
-
}
|
|
2112
|
-
request['position_id'] = positionId;
|
|
2113
2209
|
if (stopLossPrice) {
|
|
2114
2210
|
request['stop_loss_price'] = this.priceToPrecision(symbol, stopLossPrice);
|
|
2211
|
+
request['stop_loss_type'] = this.safeString(params, 'stop_type', 'latest_price');
|
|
2115
2212
|
}
|
|
2116
2213
|
else if (takeProfitPrice) {
|
|
2117
2214
|
request['take_profit_price'] = this.priceToPrecision(symbol, takeProfitPrice);
|
|
2215
|
+
request['take_profit_type'] = this.safeString(params, 'stop_type', 'latest_price');
|
|
2118
2216
|
}
|
|
2119
2217
|
}
|
|
2120
2218
|
else {
|
|
2121
|
-
|
|
2219
|
+
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2122
2220
|
if (stopPrice !== undefined) {
|
|
2123
|
-
request['
|
|
2124
|
-
request['
|
|
2125
|
-
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2126
|
-
request['side'] = requestSide;
|
|
2127
|
-
if (type === 'limit') {
|
|
2128
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
2129
|
-
}
|
|
2130
|
-
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2131
|
-
}
|
|
2132
|
-
let timeInForce = undefined;
|
|
2133
|
-
if ((type !== 'market') || (stopPrice !== undefined)) {
|
|
2134
|
-
if (postOnly) {
|
|
2135
|
-
request['option'] = 1;
|
|
2136
|
-
}
|
|
2137
|
-
else if (timeInForceRaw !== undefined) {
|
|
2138
|
-
if (timeInForceRaw === 'IOC') {
|
|
2139
|
-
timeInForce = 2;
|
|
2140
|
-
}
|
|
2141
|
-
else if (timeInForceRaw === 'FOK') {
|
|
2142
|
-
timeInForce = 3;
|
|
2143
|
-
}
|
|
2144
|
-
else {
|
|
2145
|
-
timeInForce = 1;
|
|
2146
|
-
}
|
|
2147
|
-
request['effect_type'] = timeInForce; // exchange takes 'IOC' and 'FOK'
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
if (type === 'limit' && stopPrice === undefined) {
|
|
2151
|
-
if (reduceOnly) {
|
|
2152
|
-
request['position_id'] = positionId;
|
|
2153
|
-
}
|
|
2154
|
-
else {
|
|
2155
|
-
request['side'] = requestSide;
|
|
2156
|
-
}
|
|
2157
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
2158
|
-
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2159
|
-
}
|
|
2160
|
-
else if (type === 'market' && stopPrice === undefined) {
|
|
2161
|
-
if (reduceOnly) {
|
|
2162
|
-
request['position_id'] = positionId;
|
|
2163
|
-
}
|
|
2164
|
-
else {
|
|
2165
|
-
request['side'] = requestSide;
|
|
2166
|
-
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2167
|
-
}
|
|
2221
|
+
request['trigger_price'] = this.priceToPrecision(symbol, stopPrice);
|
|
2222
|
+
request['trigger_price_type'] = this.safeString(params, 'stop_type', 'latest_price');
|
|
2168
2223
|
}
|
|
2169
2224
|
}
|
|
2170
2225
|
}
|
|
2171
2226
|
else {
|
|
2172
|
-
|
|
2227
|
+
let marginMode = undefined;
|
|
2228
|
+
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
2229
|
+
if (marginMode !== undefined) {
|
|
2230
|
+
request['market_type'] = 'MARGIN';
|
|
2231
|
+
}
|
|
2232
|
+
else {
|
|
2233
|
+
request['market_type'] = 'SPOT';
|
|
2234
|
+
}
|
|
2173
2235
|
if ((type === 'market') && (side === 'buy')) {
|
|
2174
2236
|
let createMarketBuyOrderRequiresPrice = true;
|
|
2175
2237
|
[createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
|
|
@@ -2194,39 +2256,11 @@ class coinex extends coinex$1 {
|
|
|
2194
2256
|
else {
|
|
2195
2257
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
2196
2258
|
}
|
|
2197
|
-
if ((type === 'limit') || (type === 'ioc')) {
|
|
2198
|
-
request['price'] = this.priceToPrecision(symbol, price);
|
|
2199
|
-
}
|
|
2200
2259
|
if (stopPrice !== undefined) {
|
|
2201
|
-
request['
|
|
2260
|
+
request['trigger_price'] = this.priceToPrecision(symbol, stopPrice);
|
|
2202
2261
|
}
|
|
2203
|
-
if ((type !== 'market') || (stopPrice !== undefined)) {
|
|
2204
|
-
// following options cannot be applied to vanilla market orders (but can be applied to stop-market orders)
|
|
2205
|
-
if ((timeInForceRaw !== undefined) || postOnly) {
|
|
2206
|
-
if ((postOnly || (timeInForceRaw !== 'IOC')) && ((type === 'limit') && (stopPrice !== undefined))) {
|
|
2207
|
-
throw new errors.InvalidOrder(this.id + ' createOrder() only supports the IOC option for stop-limit orders');
|
|
2208
|
-
}
|
|
2209
|
-
if (postOnly) {
|
|
2210
|
-
request['option'] = 'MAKER_ONLY';
|
|
2211
|
-
}
|
|
2212
|
-
else {
|
|
2213
|
-
if (timeInForceRaw !== undefined) {
|
|
2214
|
-
request['option'] = timeInForceRaw; // exchange takes 'IOC' and 'FOK'
|
|
2215
|
-
}
|
|
2216
|
-
}
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
const accountId = this.safeInteger(params, 'account_id');
|
|
2221
|
-
let marginMode = undefined;
|
|
2222
|
-
[marginMode, params] = this.handleMarginModeAndParams('createOrder', params);
|
|
2223
|
-
if (marginMode !== undefined) {
|
|
2224
|
-
if (accountId === undefined) {
|
|
2225
|
-
throw new errors.BadRequest(this.id + ' createOrder() requires an account_id parameter for margin orders');
|
|
2226
|
-
}
|
|
2227
|
-
request['account_id'] = accountId;
|
|
2228
2262
|
}
|
|
2229
|
-
params = this.omit(params, ['reduceOnly', '
|
|
2263
|
+
params = this.omit(params, ['reduceOnly', 'timeInForce', 'postOnly', 'stopPrice', 'triggerPrice', 'stopLossPrice', 'takeProfitPrice']);
|
|
2230
2264
|
return this.extend(request, params);
|
|
2231
2265
|
}
|
|
2232
2266
|
async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
@@ -2234,17 +2268,13 @@ class coinex extends coinex$1 {
|
|
|
2234
2268
|
* @method
|
|
2235
2269
|
* @name coinex#createOrder
|
|
2236
2270
|
* @description create a trade order
|
|
2237
|
-
* @see https://
|
|
2238
|
-
* @see https://
|
|
2239
|
-
* @see https://
|
|
2240
|
-
* @see https://
|
|
2241
|
-
* @see https://
|
|
2242
|
-
* @see https://
|
|
2243
|
-
* @see https://
|
|
2244
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
|
2245
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
|
|
2246
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
|
|
2247
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
|
|
2271
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/put-order
|
|
2272
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/put-stop-order
|
|
2273
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/put-order
|
|
2274
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/put-stop-order
|
|
2275
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/close-position
|
|
2276
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/set-position-stop-loss
|
|
2277
|
+
* @see https://docs.coinex.com/api/v2/futures/position/http/set-position-take-profit
|
|
2248
2278
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2249
2279
|
* @param {string} type 'market' or 'limit'
|
|
2250
2280
|
* @param {string} side 'buy' or 'sell'
|
|
@@ -2257,15 +2287,14 @@ class coinex extends coinex$1 {
|
|
|
2257
2287
|
* @param {string} [params.timeInForce] 'GTC', 'IOC', 'FOK', 'PO'
|
|
2258
2288
|
* @param {boolean} [params.postOnly] set to true if you wish to make a post only order
|
|
2259
2289
|
* @param {boolean} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
|
|
2260
|
-
* @param {int} [params.position_id] *required for reduce only orders* the position id to reduce
|
|
2261
2290
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2262
2291
|
*/
|
|
2263
2292
|
await this.loadMarkets();
|
|
2264
2293
|
const market = this.market(symbol);
|
|
2265
|
-
const reduceOnly = this.
|
|
2266
|
-
const triggerPrice = this.
|
|
2267
|
-
const stopLossTriggerPrice = this.
|
|
2268
|
-
const takeProfitTriggerPrice = this.
|
|
2294
|
+
const reduceOnly = this.safeBool(params, 'reduceOnly');
|
|
2295
|
+
const triggerPrice = this.safeString2(params, 'stopPrice', 'triggerPrice');
|
|
2296
|
+
const stopLossTriggerPrice = this.safeString(params, 'stopLossPrice');
|
|
2297
|
+
const takeProfitTriggerPrice = this.safeString(params, 'takeProfitPrice');
|
|
2269
2298
|
const isTriggerOrder = triggerPrice !== undefined;
|
|
2270
2299
|
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
2271
2300
|
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
@@ -2274,135 +2303,212 @@ class coinex extends coinex$1 {
|
|
|
2274
2303
|
let response = undefined;
|
|
2275
2304
|
if (market['spot']) {
|
|
2276
2305
|
if (isTriggerOrder) {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2306
|
+
response = await this.v2PrivatePostSpotStopOrder(request);
|
|
2307
|
+
//
|
|
2308
|
+
// {
|
|
2309
|
+
// "code": 0,
|
|
2310
|
+
// "data": {
|
|
2311
|
+
// "stop_id": 117180138153
|
|
2312
|
+
// },
|
|
2313
|
+
// "message": "OK"
|
|
2314
|
+
// }
|
|
2315
|
+
//
|
|
2283
2316
|
}
|
|
2284
2317
|
else {
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2318
|
+
response = await this.v2PrivatePostSpotOrder(request);
|
|
2319
|
+
//
|
|
2320
|
+
// {
|
|
2321
|
+
// "code": 0,
|
|
2322
|
+
// "data": {
|
|
2323
|
+
// "amount": "0.0001",
|
|
2324
|
+
// "base_fee": "0",
|
|
2325
|
+
// "ccy": "BTC",
|
|
2326
|
+
// "client_id": "x-167673045-a0a3c6461459a801",
|
|
2327
|
+
// "created_at": 1714114386250,
|
|
2328
|
+
// "discount_fee": "0",
|
|
2329
|
+
// "filled_amount": "0",
|
|
2330
|
+
// "filled_value": "0",
|
|
2331
|
+
// "last_fill_amount": "0",
|
|
2332
|
+
// "last_fill_price": "0",
|
|
2333
|
+
// "maker_fee_rate": "0.002",
|
|
2334
|
+
// "market": "BTCUSDT",
|
|
2335
|
+
// "market_type": "SPOT",
|
|
2336
|
+
// "order_id": 117178743547,
|
|
2337
|
+
// "price": "61000",
|
|
2338
|
+
// "quote_fee": "0",
|
|
2339
|
+
// "side": "buy",
|
|
2340
|
+
// "taker_fee_rate": "0.002",
|
|
2341
|
+
// "type": "limit",
|
|
2342
|
+
// "unfilled_amount": "0.0001",
|
|
2343
|
+
// "updated_at": 1714114386250
|
|
2344
|
+
// },
|
|
2345
|
+
// "message": "OK"
|
|
2346
|
+
// }
|
|
2347
|
+
//
|
|
2291
2348
|
}
|
|
2292
2349
|
}
|
|
2293
2350
|
else {
|
|
2294
2351
|
if (isTriggerOrder) {
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2352
|
+
response = await this.v2PrivatePostFuturesStopOrder(request);
|
|
2353
|
+
//
|
|
2354
|
+
// {
|
|
2355
|
+
// "code": 0,
|
|
2356
|
+
// "data": {
|
|
2357
|
+
// "stop_id": 136915460994
|
|
2358
|
+
// },
|
|
2359
|
+
// "message": "OK"
|
|
2360
|
+
// }
|
|
2361
|
+
//
|
|
2301
2362
|
}
|
|
2302
2363
|
else if (isStopLossOrTakeProfitTrigger) {
|
|
2303
2364
|
if (isStopLossTriggerOrder) {
|
|
2304
|
-
response = await this.
|
|
2365
|
+
response = await this.v2PrivatePostFuturesSetPositionStopLoss(request);
|
|
2366
|
+
//
|
|
2367
|
+
// {
|
|
2368
|
+
// "code": 0,
|
|
2369
|
+
// "data": {
|
|
2370
|
+
// "adl_level": 1,
|
|
2371
|
+
// "ath_margin_size": "2.14586666",
|
|
2372
|
+
// "ath_position_amount": "0.0001",
|
|
2373
|
+
// "avg_entry_price": "64376",
|
|
2374
|
+
// "bkr_price": "0",
|
|
2375
|
+
// "close_avbl": "0.0001",
|
|
2376
|
+
// "cml_position_value": "6.4376",
|
|
2377
|
+
// "created_at": 1714119054558,
|
|
2378
|
+
// "leverage": "3",
|
|
2379
|
+
// "liq_price": "0",
|
|
2380
|
+
// "maintenance_margin_rate": "0.005",
|
|
2381
|
+
// "maintenance_margin_value": "0.03218632",
|
|
2382
|
+
// "margin_avbl": "2.14586666",
|
|
2383
|
+
// "margin_mode": "cross",
|
|
2384
|
+
// "market": "BTCUSDT",
|
|
2385
|
+
// "market_type": "FUTURES",
|
|
2386
|
+
// "max_position_value": "6.4376",
|
|
2387
|
+
// "open_interest": "0.0001",
|
|
2388
|
+
// "position_id": 303884204,
|
|
2389
|
+
// "position_margin_rate": "3.10624785634397912265",
|
|
2390
|
+
// "realized_pnl": "-0.0032188",
|
|
2391
|
+
// "settle_price": "64376",
|
|
2392
|
+
// "settle_value": "6.4376",
|
|
2393
|
+
// "side": "long",
|
|
2394
|
+
// "stop_loss_price": "62000",
|
|
2395
|
+
// "stop_loss_type": "latest_price",
|
|
2396
|
+
// "take_profit_price": "0",
|
|
2397
|
+
// "take_profit_type": "",
|
|
2398
|
+
// "unrealized_pnl": "0",
|
|
2399
|
+
// "updated_at": 1714119054559
|
|
2400
|
+
// },
|
|
2401
|
+
// "message": "OK"
|
|
2402
|
+
// }
|
|
2403
|
+
//
|
|
2305
2404
|
}
|
|
2306
2405
|
else if (isTakeProfitTriggerOrder) {
|
|
2307
|
-
response = await this.
|
|
2406
|
+
response = await this.v2PrivatePostFuturesSetPositionTakeProfit(request);
|
|
2407
|
+
//
|
|
2408
|
+
// {
|
|
2409
|
+
// "code": 0,
|
|
2410
|
+
// "data": {
|
|
2411
|
+
// "adl_level": 1,
|
|
2412
|
+
// "ath_margin_size": "2.14586666",
|
|
2413
|
+
// "ath_position_amount": "0.0001",
|
|
2414
|
+
// "avg_entry_price": "64376",
|
|
2415
|
+
// "bkr_price": "0",
|
|
2416
|
+
// "close_avbl": "0.0001",
|
|
2417
|
+
// "cml_position_value": "6.4376",
|
|
2418
|
+
// "created_at": 1714119054558,
|
|
2419
|
+
// "leverage": "3",
|
|
2420
|
+
// "liq_price": "0",
|
|
2421
|
+
// "maintenance_margin_rate": "0.005",
|
|
2422
|
+
// "maintenance_margin_value": "0.03218632",
|
|
2423
|
+
// "margin_avbl": "2.14586666",
|
|
2424
|
+
// "margin_mode": "cross",
|
|
2425
|
+
// "market": "BTCUSDT",
|
|
2426
|
+
// "market_type": "FUTURES",
|
|
2427
|
+
// "max_position_value": "6.4376",
|
|
2428
|
+
// "open_interest": "0.0001",
|
|
2429
|
+
// "position_id": 303884204,
|
|
2430
|
+
// "position_margin_rate": "3.10624785634397912265",
|
|
2431
|
+
// "realized_pnl": "-0.0032188",
|
|
2432
|
+
// "settle_price": "64376",
|
|
2433
|
+
// "settle_value": "6.4376",
|
|
2434
|
+
// "side": "long",
|
|
2435
|
+
// "stop_loss_price": "62000",
|
|
2436
|
+
// "stop_loss_type": "latest_price",
|
|
2437
|
+
// "take_profit_price": "70000",
|
|
2438
|
+
// "take_profit_type": "latest_price",
|
|
2439
|
+
// "unrealized_pnl": "0",
|
|
2440
|
+
// "updated_at": 1714119054559
|
|
2441
|
+
// },
|
|
2442
|
+
// "message": "OK"
|
|
2443
|
+
// }
|
|
2444
|
+
//
|
|
2308
2445
|
}
|
|
2309
2446
|
}
|
|
2310
2447
|
else {
|
|
2311
2448
|
if (reduceOnly) {
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2449
|
+
response = await this.v2PrivatePostFuturesClosePosition(request);
|
|
2450
|
+
//
|
|
2451
|
+
// {
|
|
2452
|
+
// "code": 0,
|
|
2453
|
+
// "data": {
|
|
2454
|
+
// "amount": "0.0001",
|
|
2455
|
+
// "client_id": "x-167673045-4f264600c432ac06",
|
|
2456
|
+
// "created_at": 1714119323764,
|
|
2457
|
+
// "fee": "0.003221",
|
|
2458
|
+
// "fee_ccy": "USDT",
|
|
2459
|
+
// "filled_amount": "0.0001",
|
|
2460
|
+
// "filled_value": "6.442017",
|
|
2461
|
+
// "last_filled_amount": "0.0001",
|
|
2462
|
+
// "last_filled_price": "64420.17",
|
|
2463
|
+
// "maker_fee_rate": "0",
|
|
2464
|
+
// "market": "BTCUSDT",
|
|
2465
|
+
// "market_type": "FUTURES",
|
|
2466
|
+
// "order_id": 136915813578,
|
|
2467
|
+
// "price": "0",
|
|
2468
|
+
// "realized_pnl": "0.004417",
|
|
2469
|
+
// "side": "sell",
|
|
2470
|
+
// "taker_fee_rate": "0.0005",
|
|
2471
|
+
// "type": "market",
|
|
2472
|
+
// "unfilled_amount": "0",
|
|
2473
|
+
// "updated_at": 1714119323764
|
|
2474
|
+
// },
|
|
2475
|
+
// "message": "OK"
|
|
2476
|
+
// }
|
|
2477
|
+
//
|
|
2318
2478
|
}
|
|
2319
2479
|
else {
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2480
|
+
response = await this.v2PrivatePostFuturesOrder(request);
|
|
2481
|
+
//
|
|
2482
|
+
// {
|
|
2483
|
+
// "code": 0,
|
|
2484
|
+
// "data": {
|
|
2485
|
+
// "amount": "0.0001",
|
|
2486
|
+
// "client_id": "x-167673045-1471b81d747080a0",
|
|
2487
|
+
// "created_at": 1714116769986,
|
|
2488
|
+
// "fee": "0",
|
|
2489
|
+
// "fee_ccy": "USDT",
|
|
2490
|
+
// "filled_amount": "0",
|
|
2491
|
+
// "filled_value": "0",
|
|
2492
|
+
// "last_filled_amount": "0",
|
|
2493
|
+
// "last_filled_price": "0",
|
|
2494
|
+
// "maker_fee_rate": "0.0003",
|
|
2495
|
+
// "market": "BTCUSDT",
|
|
2496
|
+
// "market_type": "FUTURES",
|
|
2497
|
+
// "order_id": 136913377780,
|
|
2498
|
+
// "price": "61000.42",
|
|
2499
|
+
// "realized_pnl": "0",
|
|
2500
|
+
// "side": "buy",
|
|
2501
|
+
// "taker_fee_rate": "0.0005",
|
|
2502
|
+
// "type": "limit",
|
|
2503
|
+
// "unfilled_amount": "0.0001",
|
|
2504
|
+
// "updated_at": 1714116769986
|
|
2505
|
+
// },
|
|
2506
|
+
// "message": "OK"
|
|
2507
|
+
// }
|
|
2508
|
+
//
|
|
2326
2509
|
}
|
|
2327
2510
|
}
|
|
2328
2511
|
}
|
|
2329
|
-
//
|
|
2330
|
-
// Spot and Margin
|
|
2331
|
-
//
|
|
2332
|
-
// {
|
|
2333
|
-
// "code": 0,
|
|
2334
|
-
// "data": {
|
|
2335
|
-
// "amount": "0.0005",
|
|
2336
|
-
// "asset_fee": "0",
|
|
2337
|
-
// "avg_price": "0.00",
|
|
2338
|
-
// "client_id": "",
|
|
2339
|
-
// "create_time": 1650951627,
|
|
2340
|
-
// "deal_amount": "0",
|
|
2341
|
-
// "deal_fee": "0",
|
|
2342
|
-
// "deal_money": "0",
|
|
2343
|
-
// "fee_asset": null,
|
|
2344
|
-
// "fee_discount": "1",
|
|
2345
|
-
// "finished_time": null,
|
|
2346
|
-
// "id": 74510932594,
|
|
2347
|
-
// "left": "0.0005",
|
|
2348
|
-
// "maker_fee_rate": "0.002",
|
|
2349
|
-
// "market": "BTCUSDT",
|
|
2350
|
-
// "money_fee": "0",
|
|
2351
|
-
// "order_type": "limit",
|
|
2352
|
-
// "price": "30000",
|
|
2353
|
-
// "status": "not_deal",
|
|
2354
|
-
// "stock_fee": "0",
|
|
2355
|
-
// "taker_fee_rate": "0.002",
|
|
2356
|
-
// "type": "buy"
|
|
2357
|
-
// },
|
|
2358
|
-
// "message": "Success"
|
|
2359
|
-
// }
|
|
2360
|
-
//
|
|
2361
|
-
// Swap
|
|
2362
|
-
//
|
|
2363
|
-
// {
|
|
2364
|
-
// "code": 0,
|
|
2365
|
-
// "data": {
|
|
2366
|
-
// "amount": "0.0005",
|
|
2367
|
-
// "client_id": "",
|
|
2368
|
-
// "create_time": 1651004578.618224,
|
|
2369
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
2370
|
-
// "deal_fee": "0.00000000000000000000",
|
|
2371
|
-
// "deal_profit": "0.00000000000000000000",
|
|
2372
|
-
// "deal_stock": "0.00000000000000000000",
|
|
2373
|
-
// "effect_type": 1,
|
|
2374
|
-
// "fee_asset": "",
|
|
2375
|
-
// "fee_discount": "0.00000000000000000000",
|
|
2376
|
-
// "last_deal_amount": "0.00000000000000000000",
|
|
2377
|
-
// "last_deal_id": 0,
|
|
2378
|
-
// "last_deal_price": "0.00000000000000000000",
|
|
2379
|
-
// "last_deal_role": 0,
|
|
2380
|
-
// "last_deal_time": 0,
|
|
2381
|
-
// "last_deal_type": 0,
|
|
2382
|
-
// "left": "0.0005",
|
|
2383
|
-
// "leverage": "3",
|
|
2384
|
-
// "maker_fee": "0.00030",
|
|
2385
|
-
// "market": "BTCUSDT",
|
|
2386
|
-
// "order_id": 18221659097,
|
|
2387
|
-
// "position_id": 0,
|
|
2388
|
-
// "position_type": 1,
|
|
2389
|
-
// "price": "30000.00",
|
|
2390
|
-
// "side": 2,
|
|
2391
|
-
// "source": "api.v1",
|
|
2392
|
-
// "stop_id": 0,
|
|
2393
|
-
// "taker_fee": "0.00050",
|
|
2394
|
-
// "target": 0,
|
|
2395
|
-
// "type": 1,
|
|
2396
|
-
// "update_time": 1651004578.618224,
|
|
2397
|
-
// "user_id": 3620173
|
|
2398
|
-
// },
|
|
2399
|
-
// "message": "OK"
|
|
2400
|
-
// }
|
|
2401
|
-
//
|
|
2402
|
-
// Stop Order
|
|
2403
|
-
//
|
|
2404
|
-
// {"code":0,"data":{"status":"success"},"message":"OK"}
|
|
2405
|
-
//
|
|
2406
2512
|
const data = this.safeDict(response, 'data', {});
|
|
2407
2513
|
return this.parseOrder(data, market);
|
|
2408
2514
|
}
|
|
@@ -2411,7 +2517,10 @@ class coinex extends coinex$1 {
|
|
|
2411
2517
|
* @method
|
|
2412
2518
|
* @name coinex#createOrders
|
|
2413
2519
|
* @description create a list of trade orders (all orders should be of the same symbol)
|
|
2414
|
-
* @see https://
|
|
2520
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/put-multi-order
|
|
2521
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/put-multi-stop-order
|
|
2522
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/put-multi-order
|
|
2523
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/put-multi-stop-order
|
|
2415
2524
|
* @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
|
|
2416
2525
|
* @param {object} [params] extra parameters specific to the api endpoint
|
|
2417
2526
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -2419,6 +2528,9 @@ class coinex extends coinex$1 {
|
|
|
2419
2528
|
await this.loadMarkets();
|
|
2420
2529
|
const ordersRequests = [];
|
|
2421
2530
|
let symbol = undefined;
|
|
2531
|
+
let reduceOnly = false;
|
|
2532
|
+
let isTriggerOrder = false;
|
|
2533
|
+
let isStopLossOrTakeProfitTrigger = false;
|
|
2422
2534
|
for (let i = 0; i < orders.length; i++) {
|
|
2423
2535
|
const rawOrder = orders[i];
|
|
2424
2536
|
const marketId = this.safeString(rawOrder, 'symbol');
|
|
@@ -2438,56 +2550,148 @@ class coinex extends coinex$1 {
|
|
|
2438
2550
|
if (type !== 'limit') {
|
|
2439
2551
|
throw new errors.NotSupported(this.id + ' createOrders() does not support ' + type + ' orders, only limit orders are accepted');
|
|
2440
2552
|
}
|
|
2553
|
+
reduceOnly = this.safeValue(orderParams, 'reduceOnly');
|
|
2554
|
+
const triggerPrice = this.safeNumber2(orderParams, 'stopPrice', 'triggerPrice');
|
|
2555
|
+
const stopLossTriggerPrice = this.safeNumber(orderParams, 'stopLossPrice');
|
|
2556
|
+
const takeProfitTriggerPrice = this.safeNumber(orderParams, 'takeProfitPrice');
|
|
2557
|
+
isTriggerOrder = triggerPrice !== undefined;
|
|
2558
|
+
const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
|
|
2559
|
+
const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
|
|
2560
|
+
isStopLossOrTakeProfitTrigger = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
|
|
2441
2561
|
const orderRequest = this.createOrderRequest(marketId, type, side, amount, price, orderParams);
|
|
2442
2562
|
ordersRequests.push(orderRequest);
|
|
2443
2563
|
}
|
|
2444
2564
|
const market = this.market(symbol);
|
|
2445
|
-
if (!market['spot']) {
|
|
2446
|
-
throw new errors.NotSupported(this.id + ' createOrders() does not support ' + market['type'] + ' orders, only spot orders are accepted');
|
|
2447
|
-
}
|
|
2448
2565
|
const request = {
|
|
2449
2566
|
'market': market['id'],
|
|
2450
|
-
'
|
|
2567
|
+
'orders': ordersRequests,
|
|
2451
2568
|
};
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2569
|
+
let response = undefined;
|
|
2570
|
+
if (market['spot']) {
|
|
2571
|
+
if (isTriggerOrder) {
|
|
2572
|
+
response = await this.v2PrivatePostSpotBatchStopOrder(request);
|
|
2573
|
+
//
|
|
2574
|
+
// {
|
|
2575
|
+
// "code": 0,
|
|
2576
|
+
// "data": [
|
|
2577
|
+
// {
|
|
2578
|
+
// "code": 0,
|
|
2579
|
+
// "data": {
|
|
2580
|
+
// "stop_id": 117186257510
|
|
2581
|
+
// },
|
|
2582
|
+
// "message": "OK"
|
|
2583
|
+
// },
|
|
2584
|
+
// ],
|
|
2585
|
+
// "message": "OK"
|
|
2586
|
+
// }
|
|
2587
|
+
//
|
|
2588
|
+
}
|
|
2589
|
+
else {
|
|
2590
|
+
response = await this.v2PrivatePostSpotBatchOrder(request);
|
|
2591
|
+
//
|
|
2592
|
+
// {
|
|
2593
|
+
// "code": 0,
|
|
2594
|
+
// "data": [
|
|
2595
|
+
// {
|
|
2596
|
+
// "amount": "0.0001",
|
|
2597
|
+
// "base_fee": "0",
|
|
2598
|
+
// "ccy": "BTC",
|
|
2599
|
+
// "client_id": "x-167673045-f3651372049dab0d",
|
|
2600
|
+
// "created_at": 1714121403450,
|
|
2601
|
+
// "discount_fee": "0",
|
|
2602
|
+
// "filled_amount": "0",
|
|
2603
|
+
// "filled_value": "0",
|
|
2604
|
+
// "last_fill_amount": "0",
|
|
2605
|
+
// "last_fill_price": "0",
|
|
2606
|
+
// "maker_fee_rate": "0.002",
|
|
2607
|
+
// "market": "BTCUSDT",
|
|
2608
|
+
// "market_type": "SPOT",
|
|
2609
|
+
// "order_id": 117185362233,
|
|
2610
|
+
// "price": "61000",
|
|
2611
|
+
// "quote_fee": "0",
|
|
2612
|
+
// "side": "buy",
|
|
2613
|
+
// "taker_fee_rate": "0.002",
|
|
2614
|
+
// "type": "limit",
|
|
2615
|
+
// "unfilled_amount": "0.0001",
|
|
2616
|
+
// "updated_at": 1714121403450
|
|
2617
|
+
// },
|
|
2618
|
+
// {
|
|
2619
|
+
// "code": 3109,
|
|
2620
|
+
// "data": null,
|
|
2621
|
+
// "message": "balance not enough"
|
|
2622
|
+
// }
|
|
2623
|
+
// ],
|
|
2624
|
+
// "message": "OK"
|
|
2625
|
+
// }
|
|
2626
|
+
//
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
else {
|
|
2630
|
+
if (isTriggerOrder) {
|
|
2631
|
+
response = await this.v2PrivatePostFuturesBatchStopOrder(request);
|
|
2632
|
+
//
|
|
2633
|
+
// {
|
|
2634
|
+
// "code": 0,
|
|
2635
|
+
// "data": [
|
|
2636
|
+
// {
|
|
2637
|
+
// "code": 0,
|
|
2638
|
+
// "data": {
|
|
2639
|
+
// "stop_id": 136919625994
|
|
2640
|
+
// },
|
|
2641
|
+
// "message": "OK"
|
|
2642
|
+
// },
|
|
2643
|
+
// ],
|
|
2644
|
+
// "message": "OK"
|
|
2645
|
+
// }
|
|
2646
|
+
//
|
|
2647
|
+
}
|
|
2648
|
+
else if (isStopLossOrTakeProfitTrigger) {
|
|
2649
|
+
throw new errors.NotSupported(this.id + ' createOrders() does not support stopLossPrice or takeProfitPrice orders');
|
|
2650
|
+
}
|
|
2651
|
+
else {
|
|
2652
|
+
if (reduceOnly) {
|
|
2653
|
+
throw new errors.NotSupported(this.id + ' createOrders() does not support reduceOnly orders');
|
|
2654
|
+
}
|
|
2655
|
+
else {
|
|
2656
|
+
response = await this.v2PrivatePostFuturesBatchOrder(request);
|
|
2657
|
+
//
|
|
2658
|
+
// {
|
|
2659
|
+
// "code": 0,
|
|
2660
|
+
// "data": [
|
|
2661
|
+
// {
|
|
2662
|
+
// "code": 0,
|
|
2663
|
+
// "data": {
|
|
2664
|
+
// "amount": "0.0001",
|
|
2665
|
+
// "client_id": "x-167673045-2cb7436f3462a654",
|
|
2666
|
+
// "created_at": 1714122832493,
|
|
2667
|
+
// "fee": "0",
|
|
2668
|
+
// "fee_ccy": "USDT",
|
|
2669
|
+
// "filled_amount": "0",
|
|
2670
|
+
// "filled_value": "0",
|
|
2671
|
+
// "last_filled_amount": "0",
|
|
2672
|
+
// "last_filled_price": "0",
|
|
2673
|
+
// "maker_fee_rate": "0.0003",
|
|
2674
|
+
// "market": "BTCUSDT",
|
|
2675
|
+
// "market_type": "FUTURES",
|
|
2676
|
+
// "order_id": 136918835063,
|
|
2677
|
+
// "price": "61000",
|
|
2678
|
+
// "realized_pnl": "0",
|
|
2679
|
+
// "side": "buy",
|
|
2680
|
+
// "taker_fee_rate": "0.0005",
|
|
2681
|
+
// "type": "limit",
|
|
2682
|
+
// "unfilled_amount": "0.0001",
|
|
2683
|
+
// "updated_at": 1714122832493
|
|
2684
|
+
// },
|
|
2685
|
+
// "message": "OK"
|
|
2686
|
+
// },
|
|
2687
|
+
// ],
|
|
2688
|
+
// "message": "OK"
|
|
2689
|
+
// }
|
|
2690
|
+
//
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
const data = this.safeList(response, 'data', []);
|
|
2491
2695
|
const results = [];
|
|
2492
2696
|
for (let i = 0; i < data.length; i++) {
|
|
2493
2697
|
const entry = data[i];
|
|
@@ -2501,9 +2705,16 @@ class coinex extends coinex$1 {
|
|
|
2501
2705
|
status = 'open';
|
|
2502
2706
|
}
|
|
2503
2707
|
}
|
|
2504
|
-
const
|
|
2505
|
-
|
|
2506
|
-
|
|
2708
|
+
const innerData = this.safeDict(entry, 'data', {});
|
|
2709
|
+
let order = undefined;
|
|
2710
|
+
if (market['spot'] && !isTriggerOrder) {
|
|
2711
|
+
entry['status'] = status;
|
|
2712
|
+
order = this.parseOrder(entry, market);
|
|
2713
|
+
}
|
|
2714
|
+
else {
|
|
2715
|
+
innerData['status'] = status;
|
|
2716
|
+
order = this.parseOrder(innerData, market);
|
|
2717
|
+
}
|
|
2507
2718
|
results.push(order);
|
|
2508
2719
|
}
|
|
2509
2720
|
return results;
|
|
@@ -2513,11 +2724,14 @@ class coinex extends coinex$1 {
|
|
|
2513
2724
|
* @method
|
|
2514
2725
|
* @name coinex#cancelOrders
|
|
2515
2726
|
* @description cancel multiple orders
|
|
2516
|
-
* @see https://
|
|
2517
|
-
* @see https://
|
|
2727
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
|
|
2728
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
|
|
2729
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
|
|
2730
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
|
|
2518
2731
|
* @param {string[]} ids order ids
|
|
2519
2732
|
* @param {string} symbol unified market symbol
|
|
2520
2733
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2734
|
+
* @param {boolean} [params.stop] set to true for canceling stop orders
|
|
2521
2735
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2522
2736
|
*/
|
|
2523
2737
|
if (symbol === undefined) {
|
|
@@ -2528,113 +2742,161 @@ class coinex extends coinex$1 {
|
|
|
2528
2742
|
const request = {
|
|
2529
2743
|
'market': market['id'],
|
|
2530
2744
|
};
|
|
2531
|
-
const
|
|
2745
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
2746
|
+
params = this.omit(params, ['stop', 'trigger']);
|
|
2532
2747
|
let response = undefined;
|
|
2748
|
+
if (stop) {
|
|
2749
|
+
request['stop_ids'] = ids;
|
|
2750
|
+
}
|
|
2751
|
+
else {
|
|
2752
|
+
request['order_ids'] = ids;
|
|
2753
|
+
}
|
|
2533
2754
|
if (market['spot']) {
|
|
2534
|
-
|
|
2535
|
-
|
|
2755
|
+
if (stop) {
|
|
2756
|
+
response = await this.v2PrivatePostSpotCancelBatchStopOrder(this.extend(request, params));
|
|
2757
|
+
//
|
|
2758
|
+
// {
|
|
2759
|
+
// "code": 0,
|
|
2760
|
+
// "data": [
|
|
2761
|
+
// {
|
|
2762
|
+
// "code": 0,
|
|
2763
|
+
// "data": {
|
|
2764
|
+
// "amount": "0.0001",
|
|
2765
|
+
// "ccy": "BTC",
|
|
2766
|
+
// "client_id": "x-167673045-8e33d6f4a4bcb022",
|
|
2767
|
+
// "created_at": 1714188827291,
|
|
2768
|
+
// "market": "BTCUSDT",
|
|
2769
|
+
// "market_type": "SPOT",
|
|
2770
|
+
// "price": "61000",
|
|
2771
|
+
// "side": "buy",
|
|
2772
|
+
// "stop_id": 117248845854,
|
|
2773
|
+
// "trigger_direction": "higher",
|
|
2774
|
+
// "trigger_price": "62000",
|
|
2775
|
+
// "trigger_price_type": "mark_price",
|
|
2776
|
+
// "type": "limit",
|
|
2777
|
+
// "updated_at": 1714188827291
|
|
2778
|
+
// },
|
|
2779
|
+
// "message": "OK"
|
|
2780
|
+
// },
|
|
2781
|
+
// ],
|
|
2782
|
+
// "message": "OK"
|
|
2783
|
+
// }
|
|
2784
|
+
//
|
|
2785
|
+
}
|
|
2786
|
+
else {
|
|
2787
|
+
response = await this.v2PrivatePostSpotCancelBatchOrder(this.extend(request, params));
|
|
2788
|
+
//
|
|
2789
|
+
// {
|
|
2790
|
+
// "code": 0,
|
|
2791
|
+
// "data": [
|
|
2792
|
+
// {
|
|
2793
|
+
// "code": 0,
|
|
2794
|
+
// "data": {
|
|
2795
|
+
// "amount": "0.0001",
|
|
2796
|
+
// "base_fee": "0",
|
|
2797
|
+
// "ccy": "BTC",
|
|
2798
|
+
// "client_id": "x-167673045-c1cc78e5b42d8c4e",
|
|
2799
|
+
// "created_at": 1714188449497,
|
|
2800
|
+
// "discount_fee": "0",
|
|
2801
|
+
// "filled_amount": "0",
|
|
2802
|
+
// "filled_value": "0",
|
|
2803
|
+
// "last_fill_amount": "0",
|
|
2804
|
+
// "last_fill_price": "0",
|
|
2805
|
+
// "maker_fee_rate": "0.002",
|
|
2806
|
+
// "market": "BTCUSDT",
|
|
2807
|
+
// "market_type": "SPOT",
|
|
2808
|
+
// "order_id": 117248494358,
|
|
2809
|
+
// "price": "60000",
|
|
2810
|
+
// "quote_fee": "0",
|
|
2811
|
+
// "side": "buy",
|
|
2812
|
+
// "taker_fee_rate": "0.002",
|
|
2813
|
+
// "type": "limit",
|
|
2814
|
+
// "unfilled_amount": "0.0001",
|
|
2815
|
+
// "updated_at": 1714188449497
|
|
2816
|
+
// },
|
|
2817
|
+
// "message": ""
|
|
2818
|
+
// },
|
|
2819
|
+
// ],
|
|
2820
|
+
// "message": "OK"
|
|
2821
|
+
// }
|
|
2822
|
+
//
|
|
2823
|
+
}
|
|
2536
2824
|
}
|
|
2537
2825
|
else {
|
|
2538
|
-
request['
|
|
2539
|
-
|
|
2826
|
+
request['market_type'] = 'FUTURES';
|
|
2827
|
+
if (stop) {
|
|
2828
|
+
response = await this.v2PrivatePostFuturesCancelBatchStopOrder(this.extend(request, params));
|
|
2829
|
+
//
|
|
2830
|
+
// {
|
|
2831
|
+
// "code": 0,
|
|
2832
|
+
// "data": [
|
|
2833
|
+
// {
|
|
2834
|
+
// "code": 0,
|
|
2835
|
+
// "data": {
|
|
2836
|
+
// "amount": "0.0001",
|
|
2837
|
+
// "client_id": "x-167673045-a7d7714c6478acf6",
|
|
2838
|
+
// "created_at": 1714187923820,
|
|
2839
|
+
// "market": "BTCUSDT",
|
|
2840
|
+
// "market_type": "FUTURES",
|
|
2841
|
+
// "price": "61000",
|
|
2842
|
+
// "side": "buy",
|
|
2843
|
+
// "stop_id": 136984426097,
|
|
2844
|
+
// "trigger_direction": "higher",
|
|
2845
|
+
// "trigger_price": "62000",
|
|
2846
|
+
// "trigger_price_type": "latest_price",
|
|
2847
|
+
// "type": "limit",
|
|
2848
|
+
// "updated_at": 1714187974363
|
|
2849
|
+
// },
|
|
2850
|
+
// "message": ""
|
|
2851
|
+
// },
|
|
2852
|
+
// ],
|
|
2853
|
+
// "message": "OK"
|
|
2854
|
+
// }
|
|
2855
|
+
//
|
|
2856
|
+
}
|
|
2857
|
+
else {
|
|
2858
|
+
response = await this.v2PrivatePostFuturesCancelBatchOrder(this.extend(request, params));
|
|
2859
|
+
//
|
|
2860
|
+
// {
|
|
2861
|
+
// "code": 0,
|
|
2862
|
+
// "data": [
|
|
2863
|
+
// {
|
|
2864
|
+
// "code": 0,
|
|
2865
|
+
// "data": {
|
|
2866
|
+
// "amount": "0.0001",
|
|
2867
|
+
// "client_id": "x-167673045-9f80fde284339a72",
|
|
2868
|
+
// "created_at": 1714187491784,
|
|
2869
|
+
// "fee": "0",
|
|
2870
|
+
// "fee_ccy": "USDT",
|
|
2871
|
+
// "filled_amount": "0",
|
|
2872
|
+
// "filled_value": "0",
|
|
2873
|
+
// "last_filled_amount": "0",
|
|
2874
|
+
// "last_filled_price": "0",
|
|
2875
|
+
// "maker_fee_rate": "0.0003",
|
|
2876
|
+
// "market": "BTCUSDT",
|
|
2877
|
+
// "market_type": "FUTURES",
|
|
2878
|
+
// "order_id": 136983851788,
|
|
2879
|
+
// "price": "61000",
|
|
2880
|
+
// "realized_pnl": "0",
|
|
2881
|
+
// "side": "buy",
|
|
2882
|
+
// "taker_fee_rate": "0.0005",
|
|
2883
|
+
// "type": "limit",
|
|
2884
|
+
// "unfilled_amount": "0.0001",
|
|
2885
|
+
// "updated_at": 1714187567079
|
|
2886
|
+
// },
|
|
2887
|
+
// "message": ""
|
|
2888
|
+
// },
|
|
2889
|
+
// ],
|
|
2890
|
+
// "message": "OK"
|
|
2891
|
+
// }
|
|
2892
|
+
//
|
|
2893
|
+
}
|
|
2540
2894
|
}
|
|
2541
|
-
|
|
2542
|
-
// spot
|
|
2543
|
-
//
|
|
2544
|
-
// {
|
|
2545
|
-
// "code": 0,
|
|
2546
|
-
// "data": [
|
|
2547
|
-
// {
|
|
2548
|
-
// "code": 0,
|
|
2549
|
-
// "data": {
|
|
2550
|
-
// "account_id": 0,
|
|
2551
|
-
// "amount": "0.0005",
|
|
2552
|
-
// "asset_fee": "0",
|
|
2553
|
-
// "avg_price": "0.00",
|
|
2554
|
-
// "client_id": "x-167673045-d4e03c38f4d19b4e",
|
|
2555
|
-
// "create_time": 1701229157,
|
|
2556
|
-
// "deal_amount": "0",
|
|
2557
|
-
// "deal_fee": "0",
|
|
2558
|
-
// "deal_money": "0",
|
|
2559
|
-
// "fee_asset": null,
|
|
2560
|
-
// "fee_discount": "1",
|
|
2561
|
-
// "finished_time": 0,
|
|
2562
|
-
// "id": 107745856682,
|
|
2563
|
-
// "left": "0",
|
|
2564
|
-
// "maker_fee_rate": "0.002",
|
|
2565
|
-
// "market": "BTCUSDT",
|
|
2566
|
-
// "money_fee": "0",
|
|
2567
|
-
// "order_type": "limit",
|
|
2568
|
-
// "price": "22000",
|
|
2569
|
-
// "status": "not_deal",
|
|
2570
|
-
// "stock_fee": "0",
|
|
2571
|
-
// "taker_fee_rate": "0.002",
|
|
2572
|
-
// "type": "buy"
|
|
2573
|
-
// },
|
|
2574
|
-
// "message": ""
|
|
2575
|
-
// },
|
|
2576
|
-
// ],
|
|
2577
|
-
// "message": "Success"
|
|
2578
|
-
// }
|
|
2579
|
-
//
|
|
2580
|
-
// swap
|
|
2581
|
-
//
|
|
2582
|
-
// {
|
|
2583
|
-
// "code": 0,
|
|
2584
|
-
// "data": [
|
|
2585
|
-
// {
|
|
2586
|
-
// "code": 0,
|
|
2587
|
-
// "message": "",
|
|
2588
|
-
// "order": {
|
|
2589
|
-
// "amount": "0.0005",
|
|
2590
|
-
// "client_id": "x-167673045-b0cee0c584718b65",
|
|
2591
|
-
// "create_time": 1701233683.294231,
|
|
2592
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
2593
|
-
// "deal_fee": "0.00000000000000000000",
|
|
2594
|
-
// "deal_profit": "0.00000000000000000000",
|
|
2595
|
-
// "deal_stock": "0.00000000000000000000",
|
|
2596
|
-
// "effect_type": 1,
|
|
2597
|
-
// "fee_asset": "",
|
|
2598
|
-
// "fee_discount": "0.00000000000000000000",
|
|
2599
|
-
// "last_deal_amount": "0.00000000000000000000",
|
|
2600
|
-
// "last_deal_id": 0,
|
|
2601
|
-
// "last_deal_price": "0.00000000000000000000",
|
|
2602
|
-
// "last_deal_role": 0,
|
|
2603
|
-
// "last_deal_time": 0,
|
|
2604
|
-
// "last_deal_type": 0,
|
|
2605
|
-
// "left": "0.0005",
|
|
2606
|
-
// "leverage": "3",
|
|
2607
|
-
// "maker_fee": "0.00030",
|
|
2608
|
-
// "market": "BTCUSDT",
|
|
2609
|
-
// "option": 0,
|
|
2610
|
-
// "order_id": 115940476323,
|
|
2611
|
-
// "position_id": 0,
|
|
2612
|
-
// "position_type": 2,
|
|
2613
|
-
// "price": "25000.00",
|
|
2614
|
-
// "side": 2,
|
|
2615
|
-
// "source": "api.v1",
|
|
2616
|
-
// "stop_id": 0,
|
|
2617
|
-
// "stop_loss_price": "0.00000000000000000000",
|
|
2618
|
-
// "stop_loss_type": 0,
|
|
2619
|
-
// "take_profit_price": "0.00000000000000000000",
|
|
2620
|
-
// "take_profit_type": 0,
|
|
2621
|
-
// "taker_fee": "0.00050",
|
|
2622
|
-
// "target": 0,
|
|
2623
|
-
// "type": 1,
|
|
2624
|
-
// "update_time": 1701233721.718884,
|
|
2625
|
-
// "user_id": 3620173
|
|
2626
|
-
// }
|
|
2627
|
-
// },
|
|
2628
|
-
// ],
|
|
2629
|
-
// "message": "OK"
|
|
2630
|
-
// }
|
|
2631
|
-
//
|
|
2632
|
-
const data = this.safeValue(response, 'data', []);
|
|
2895
|
+
const data = this.safeList(response, 'data', []);
|
|
2633
2896
|
const results = [];
|
|
2634
2897
|
for (let i = 0; i < data.length; i++) {
|
|
2635
2898
|
const entry = data[i];
|
|
2636
|
-
const
|
|
2637
|
-
const item = this.safeValue(entry, dataRequest, {});
|
|
2899
|
+
const item = this.safeDict(entry, 'data', {});
|
|
2638
2900
|
const order = this.parseOrder(item, market);
|
|
2639
2901
|
results.push(order);
|
|
2640
2902
|
}
|
|
@@ -5776,7 +6038,11 @@ class coinex extends coinex$1 {
|
|
|
5776
6038
|
query = this.keysort(query);
|
|
5777
6039
|
const urlencoded = this.rawencode(query);
|
|
5778
6040
|
let preparedString = method + '/' + version + '/' + path;
|
|
5779
|
-
if (
|
|
6041
|
+
if (method === 'POST') {
|
|
6042
|
+
body = this.json(query);
|
|
6043
|
+
preparedString += body;
|
|
6044
|
+
}
|
|
6045
|
+
else if (urlencoded) {
|
|
5780
6046
|
preparedString += '?' + urlencoded;
|
|
5781
6047
|
}
|
|
5782
6048
|
preparedString += nonce + this.secret;
|
|
@@ -5786,14 +6052,11 @@ class coinex extends coinex$1 {
|
|
|
5786
6052
|
'X-COINEX-SIGN': signature,
|
|
5787
6053
|
'X-COINEX-TIMESTAMP': nonce,
|
|
5788
6054
|
};
|
|
5789
|
-
if (
|
|
6055
|
+
if (method !== 'POST') {
|
|
5790
6056
|
if (urlencoded) {
|
|
5791
6057
|
url += '?' + urlencoded;
|
|
5792
6058
|
}
|
|
5793
6059
|
}
|
|
5794
|
-
else {
|
|
5795
|
-
body = this.json(query);
|
|
5796
|
-
}
|
|
5797
6060
|
}
|
|
5798
6061
|
}
|
|
5799
6062
|
return { 'url': url, 'method': method, 'body': body, 'headers': headers };
|