ccxt 4.3.10 → 4.3.12
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 +15 -0
- package/dist/cjs/src/bigone.js +22 -22
- package/dist/cjs/src/binance.js +5 -5
- package/dist/cjs/src/bingx.js +2 -2
- package/dist/cjs/src/bitget.js +7 -4
- package/dist/cjs/src/bitmart.js +3 -8
- package/dist/cjs/src/bitmex.js +2 -2
- package/dist/cjs/src/blofin.js +2 -0
- package/dist/cjs/src/bybit.js +81 -71
- package/dist/cjs/src/coinbase.js +8 -8
- package/dist/cjs/src/coinbaseinternational.js +2 -2
- package/dist/cjs/src/coinex.js +513 -449
- package/dist/cjs/src/coinlist.js +12 -12
- package/dist/cjs/src/coinmetro.js +2 -2
- package/dist/cjs/src/cryptocom.js +16 -16
- package/dist/cjs/src/gate.js +2 -2
- package/dist/cjs/src/hitbtc.js +3 -3
- package/dist/cjs/src/htx.js +3 -7
- package/dist/cjs/src/indodax.js +2 -2
- package/dist/cjs/src/kraken.js +3 -1
- package/dist/cjs/src/kucoin.js +4 -4
- package/dist/cjs/src/kucoinfutures.js +6 -6
- package/dist/cjs/src/mexc.js +5 -5
- package/dist/cjs/src/okx.js +6 -6
- package/dist/cjs/src/poloniexfutures.js +4 -4
- package/dist/cjs/src/pro/bitget.js +140 -89
- package/dist/cjs/src/pro/bybit.js +196 -11
- package/dist/cjs/src/pro/coinbase.js +107 -29
- package/dist/cjs/src/pro/mexc.js +21 -1
- package/dist/cjs/src/probit.js +2 -2
- package/dist/cjs/src/whitebit.js +76 -1
- package/dist/cjs/src/woo.js +2 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/blofin.d.ts +2 -0
- package/js/src/base/Exchange.d.ts +10 -6
- package/js/src/base/Exchange.js +15 -0
- package/js/src/base/types.d.ts +17 -2
- package/js/src/bigone.js +22 -22
- package/js/src/binance.d.ts +2 -9
- package/js/src/binance.js +5 -5
- package/js/src/bingx.js +2 -2
- package/js/src/bitget.d.ts +4 -31
- package/js/src/bitget.js +7 -4
- package/js/src/bitmart.d.ts +4 -24
- package/js/src/bitmart.js +3 -8
- package/js/src/bitmex.js +2 -2
- package/js/src/blofin.js +2 -0
- package/js/src/bybit.d.ts +7 -9
- package/js/src/bybit.js +81 -71
- package/js/src/coinbase.js +8 -8
- package/js/src/coinbaseinternational.js +2 -2
- package/js/src/coinex.d.ts +4 -24
- package/js/src/coinex.js +513 -449
- package/js/src/coinlist.js +12 -12
- package/js/src/coinmetro.js +2 -2
- package/js/src/cryptocom.js +16 -16
- package/js/src/digifinex.d.ts +3 -10
- package/js/src/gate.js +2 -2
- package/js/src/hitbtc.js +3 -3
- package/js/src/htx.d.ts +3 -13
- package/js/src/htx.js +3 -7
- package/js/src/indodax.js +2 -2
- package/js/src/kraken.js +3 -1
- package/js/src/kucoin.js +4 -4
- package/js/src/kucoinfutures.js +6 -6
- package/js/src/mexc.js +5 -5
- package/js/src/okx.d.ts +3 -10
- package/js/src/okx.js +6 -6
- package/js/src/poloniexfutures.js +4 -4
- package/js/src/pro/bitget.js +140 -89
- package/js/src/pro/bybit.d.ts +5 -1
- package/js/src/pro/bybit.js +196 -11
- package/js/src/pro/coinbase.d.ts +4 -0
- package/js/src/pro/coinbase.js +107 -29
- package/js/src/pro/mexc.js +21 -1
- package/js/src/probit.js +2 -2
- package/js/src/whitebit.d.ts +1 -0
- package/js/src/whitebit.js +76 -1
- package/js/src/woo.js +2 -2
- package/package.json +6 -5
- package/dist/cjs/src/flowbtc.js +0 -35
package/dist/cjs/src/coinex.js
CHANGED
|
@@ -1715,121 +1715,6 @@ class coinex extends coinex$1 {
|
|
|
1715
1715
|
return this.safeString(statuses, status, status);
|
|
1716
1716
|
}
|
|
1717
1717
|
parseOrder(order, market = undefined) {
|
|
1718
|
-
//
|
|
1719
|
-
// fetchOrder
|
|
1720
|
-
//
|
|
1721
|
-
// {
|
|
1722
|
-
// "amount": "0.1",
|
|
1723
|
-
// "asset_fee": "0.22736197736197736197",
|
|
1724
|
-
// "avg_price": "196.85000000000000000000",
|
|
1725
|
-
// "create_time": 1537270135,
|
|
1726
|
-
// "deal_amount": "0.1",
|
|
1727
|
-
// "deal_fee": "0",
|
|
1728
|
-
// "deal_money": "19.685",
|
|
1729
|
-
// "fee_asset": "CET",
|
|
1730
|
-
// "fee_discount": "0.5",
|
|
1731
|
-
// "id": 1788259447,
|
|
1732
|
-
// "left": "0",
|
|
1733
|
-
// "maker_fee_rate": "0",
|
|
1734
|
-
// "market": "ETHUSDT",
|
|
1735
|
-
// "order_type": "limit",
|
|
1736
|
-
// "price": "170.00000000",
|
|
1737
|
-
// "status": "done",
|
|
1738
|
-
// "taker_fee_rate": "0.0005",
|
|
1739
|
-
// "type": "sell",
|
|
1740
|
-
// "client_id": "",
|
|
1741
|
-
// }
|
|
1742
|
-
//
|
|
1743
|
-
// Spot and Margin cancelOrder, fetchOrder
|
|
1744
|
-
//
|
|
1745
|
-
// {
|
|
1746
|
-
// "amount":"1.5",
|
|
1747
|
-
// "asset_fee":"0",
|
|
1748
|
-
// "avg_price":"0.14208538",
|
|
1749
|
-
// "client_id":"",
|
|
1750
|
-
// "create_time":1650993819,
|
|
1751
|
-
// "deal_amount":"10.55703267",
|
|
1752
|
-
// "deal_fee":"0.0029999999971787292",
|
|
1753
|
-
// "deal_money":"1.4999999985893646",
|
|
1754
|
-
// "fee_asset":null,
|
|
1755
|
-
// "fee_discount":"1",
|
|
1756
|
-
// "finished_time":null,
|
|
1757
|
-
// "id":74556296907,
|
|
1758
|
-
// "left":"0.0000000014106354",
|
|
1759
|
-
// "maker_fee_rate":"0",
|
|
1760
|
-
// "market":"DOGEUSDT",
|
|
1761
|
-
// "money_fee":"0.0029999999971787292",
|
|
1762
|
-
// "order_type":"market",
|
|
1763
|
-
// "price":"0",
|
|
1764
|
-
// "status":"done",
|
|
1765
|
-
// "stock_fee":"0",
|
|
1766
|
-
// "taker_fee_rate":"0.002",
|
|
1767
|
-
// "type":"buy"
|
|
1768
|
-
// "client_id": "",
|
|
1769
|
-
// }
|
|
1770
|
-
//
|
|
1771
|
-
// Swap cancelOrder, fetchOrder
|
|
1772
|
-
//
|
|
1773
|
-
// {
|
|
1774
|
-
// "amount": "0.0005",
|
|
1775
|
-
// "client_id": "",
|
|
1776
|
-
// "create_time": 1651004578.618224,
|
|
1777
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
1778
|
-
// "deal_fee": "0.00000000000000000000",
|
|
1779
|
-
// "deal_profit": "0.00000000000000000000",
|
|
1780
|
-
// "deal_stock": "0.00000000000000000000",
|
|
1781
|
-
// "effect_type": 1,
|
|
1782
|
-
// "fee_asset": "",
|
|
1783
|
-
// "fee_discount": "0.00000000000000000000",
|
|
1784
|
-
// "last_deal_amount": "0.00000000000000000000",
|
|
1785
|
-
// "last_deal_id": 0,
|
|
1786
|
-
// "last_deal_price": "0.00000000000000000000",
|
|
1787
|
-
// "last_deal_role": 0,
|
|
1788
|
-
// "last_deal_time": 0,
|
|
1789
|
-
// "last_deal_type": 0,
|
|
1790
|
-
// "left": "0.0005",
|
|
1791
|
-
// "leverage": "3",
|
|
1792
|
-
// "maker_fee": "0.00030",
|
|
1793
|
-
// "market": "BTCUSDT",
|
|
1794
|
-
// "order_id": 18221659097,
|
|
1795
|
-
// "position_id": 0,
|
|
1796
|
-
// "position_type": 1,
|
|
1797
|
-
// "price": "30000.00",
|
|
1798
|
-
// "side": 2,
|
|
1799
|
-
// "source": "api.v1",
|
|
1800
|
-
// "stop_id": 0,
|
|
1801
|
-
// "taker_fee": "0.00050",
|
|
1802
|
-
// "target": 0,
|
|
1803
|
-
// "type": 1,
|
|
1804
|
-
// "update_time": 1651004578.618224,
|
|
1805
|
-
// "user_id": 3620173
|
|
1806
|
-
// }
|
|
1807
|
-
//
|
|
1808
|
-
// Swap Stop cancelOrder, fetchOrder
|
|
1809
|
-
//
|
|
1810
|
-
// {
|
|
1811
|
-
// "amount": "0.0005",
|
|
1812
|
-
// "client_id": "",
|
|
1813
|
-
// "create_time": 1651034023.008771,
|
|
1814
|
-
// "effect_type": 1,
|
|
1815
|
-
// "fee_asset": "",
|
|
1816
|
-
// "fee_discount": "0.00000000000000000000",
|
|
1817
|
-
// "maker_fee": "0.00030",
|
|
1818
|
-
// "market": "BTCUSDT",
|
|
1819
|
-
// "order_id": 18256915101,
|
|
1820
|
-
// "price": "31000.00",
|
|
1821
|
-
// "side": 2,
|
|
1822
|
-
// "source": "api.v1",
|
|
1823
|
-
// "state": 1,
|
|
1824
|
-
// "stop_price": "31500.00",
|
|
1825
|
-
// "stop_type": 1,
|
|
1826
|
-
// "taker_fee": "0.00050",
|
|
1827
|
-
// "target": 0,
|
|
1828
|
-
// "type": 1,
|
|
1829
|
-
// "update_time": 1651034397.193624,
|
|
1830
|
-
// "user_id": 3620173
|
|
1831
|
-
// }
|
|
1832
|
-
//
|
|
1833
1718
|
//
|
|
1834
1719
|
// Spot and Margin fetchOpenOrders, fetchClosedOrders
|
|
1835
1720
|
//
|
|
@@ -1935,7 +1820,7 @@ class coinex extends coinex$1 {
|
|
|
1935
1820
|
// "user_id": 3620173
|
|
1936
1821
|
// }
|
|
1937
1822
|
//
|
|
1938
|
-
// Spot and Margin createOrder, createOrders, cancelOrders v2
|
|
1823
|
+
// Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder v2
|
|
1939
1824
|
//
|
|
1940
1825
|
// {
|
|
1941
1826
|
// "amount": "0.0001",
|
|
@@ -1961,13 +1846,13 @@ class coinex extends coinex$1 {
|
|
|
1961
1846
|
// "updated_at": 1714114386250
|
|
1962
1847
|
// }
|
|
1963
1848
|
//
|
|
1964
|
-
// Spot, Margin and Swap trigger createOrder, createOrders v2
|
|
1849
|
+
// Spot, Margin and Swap trigger createOrder, createOrders, editOrder v2
|
|
1965
1850
|
//
|
|
1966
1851
|
// {
|
|
1967
1852
|
// "stop_id": 117180138153
|
|
1968
1853
|
// }
|
|
1969
1854
|
//
|
|
1970
|
-
// Swap createOrder, createOrders, cancelOrders v2
|
|
1855
|
+
// Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder v2
|
|
1971
1856
|
//
|
|
1972
1857
|
// {
|
|
1973
1858
|
// "amount": "0.0001",
|
|
@@ -2027,7 +1912,7 @@ class coinex extends coinex$1 {
|
|
|
2027
1912
|
// "updated_at": 1714119054559
|
|
2028
1913
|
// }
|
|
2029
1914
|
//
|
|
2030
|
-
// Swap and Spot stop cancelOrders v2
|
|
1915
|
+
// Swap and Spot stop cancelOrders, cancelOrder v2
|
|
2031
1916
|
//
|
|
2032
1917
|
// {
|
|
2033
1918
|
// "amount": "0.0001",
|
|
@@ -2045,6 +1930,59 @@ class coinex extends coinex$1 {
|
|
|
2045
1930
|
// "updated_at": 1714187974363
|
|
2046
1931
|
// }
|
|
2047
1932
|
//
|
|
1933
|
+
// Swap fetchOrder v2
|
|
1934
|
+
//
|
|
1935
|
+
// {
|
|
1936
|
+
// "amount": "0.0001",
|
|
1937
|
+
// "client_id": "x-167673045-da5f31dcd478a829",
|
|
1938
|
+
// "created_at": 1714460987164,
|
|
1939
|
+
// "fee": "0",
|
|
1940
|
+
// "fee_ccy": "USDT",
|
|
1941
|
+
// "filled_amount": "0",
|
|
1942
|
+
// "filled_value": "0",
|
|
1943
|
+
// "last_filled_amount": "0",
|
|
1944
|
+
// "last_filled_price": "0",
|
|
1945
|
+
// "maker_fee_rate": "0.0003",
|
|
1946
|
+
// "market": "BTCUSDT",
|
|
1947
|
+
// "market_type": "FUTURES",
|
|
1948
|
+
// "order_id": 137319868771,
|
|
1949
|
+
// "price": "61000",
|
|
1950
|
+
// "realized_pnl": "0",
|
|
1951
|
+
// "side": "buy",
|
|
1952
|
+
// "status": "open",
|
|
1953
|
+
// "taker_fee_rate": "0.0005",
|
|
1954
|
+
// "type": "limit",
|
|
1955
|
+
// "unfilled_amount": "0.0001",
|
|
1956
|
+
// "updated_at": 1714460987164
|
|
1957
|
+
// }
|
|
1958
|
+
//
|
|
1959
|
+
// Spot and Margin fetchOrder v2
|
|
1960
|
+
//
|
|
1961
|
+
// {
|
|
1962
|
+
// "amount": "0.0001",
|
|
1963
|
+
// "base_fee": "0",
|
|
1964
|
+
// "ccy": "BTC",
|
|
1965
|
+
// "client_id": "x-167673045-da918d6724e3af81",
|
|
1966
|
+
// "created_at": 1714461638958,
|
|
1967
|
+
// "discount_fee": "0",
|
|
1968
|
+
// "filled_amount": "0",
|
|
1969
|
+
// "filled_value": "0",
|
|
1970
|
+
// "last_fill_amount": "0",
|
|
1971
|
+
// "last_fill_price": "0",
|
|
1972
|
+
// "maker_fee_rate": "0.002",
|
|
1973
|
+
// "market": "BTCUSDT",
|
|
1974
|
+
// "market_type": "SPOT",
|
|
1975
|
+
// "order_id": 117492012985,
|
|
1976
|
+
// "price": "61000",
|
|
1977
|
+
// "quote_fee": "0",
|
|
1978
|
+
// "side": "buy",
|
|
1979
|
+
// "status": "open",
|
|
1980
|
+
// "taker_fee_rate": "0.002",
|
|
1981
|
+
// "type": "limit",
|
|
1982
|
+
// "unfilled_amount": "0.0001",
|
|
1983
|
+
// "updated_at": 1714461638958
|
|
1984
|
+
// }
|
|
1985
|
+
//
|
|
2048
1986
|
const rawStatus = this.safeString(order, 'status');
|
|
2049
1987
|
let timestamp = this.safeTimestamp(order, 'create_time');
|
|
2050
1988
|
if (timestamp === undefined) {
|
|
@@ -2731,7 +2669,7 @@ class coinex extends coinex$1 {
|
|
|
2731
2669
|
* @param {string[]} ids order ids
|
|
2732
2670
|
* @param {string} symbol unified market symbol
|
|
2733
2671
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2734
|
-
* @param {boolean} [params.
|
|
2672
|
+
* @param {boolean} [params.trigger] set to true for canceling stop orders
|
|
2735
2673
|
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2736
2674
|
*/
|
|
2737
2675
|
if (symbol === undefined) {
|
|
@@ -2905,9 +2843,12 @@ class coinex extends coinex$1 {
|
|
|
2905
2843
|
async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
|
|
2906
2844
|
/**
|
|
2907
2845
|
* @method
|
|
2908
|
-
* @name
|
|
2846
|
+
* @name coinex#editOrder
|
|
2909
2847
|
* @description edit a trade order
|
|
2910
|
-
* @see https://
|
|
2848
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/edit-order
|
|
2849
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
|
|
2850
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/edit-order
|
|
2851
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
|
|
2911
2852
|
* @param {string} id order id
|
|
2912
2853
|
* @param {string} symbol unified symbol of the market to create an order in
|
|
2913
2854
|
* @param {string} type 'market' or 'limit'
|
|
@@ -2915,6 +2856,7 @@ class coinex extends coinex$1 {
|
|
|
2915
2856
|
* @param {float} amount how much of the currency you want to trade in units of the base currency
|
|
2916
2857
|
* @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
|
2917
2858
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2859
|
+
* @param {float} [params.triggerPrice] the price to trigger stop orders
|
|
2918
2860
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2919
2861
|
*/
|
|
2920
2862
|
if (symbol === undefined) {
|
|
@@ -2922,12 +2864,8 @@ class coinex extends coinex$1 {
|
|
|
2922
2864
|
}
|
|
2923
2865
|
await this.loadMarkets();
|
|
2924
2866
|
const market = this.market(symbol);
|
|
2925
|
-
if (!market['spot']) {
|
|
2926
|
-
throw new errors.NotSupported(this.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted');
|
|
2927
|
-
}
|
|
2928
2867
|
const request = {
|
|
2929
2868
|
'market': market['id'],
|
|
2930
|
-
'id': parseInt(id),
|
|
2931
2869
|
};
|
|
2932
2870
|
if (amount !== undefined) {
|
|
2933
2871
|
request['amount'] = this.amountToPrecision(symbol, amount);
|
|
@@ -2935,38 +2873,118 @@ class coinex extends coinex$1 {
|
|
|
2935
2873
|
if (price !== undefined) {
|
|
2936
2874
|
request['price'] = this.priceToPrecision(symbol, price);
|
|
2937
2875
|
}
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2876
|
+
let response = undefined;
|
|
2877
|
+
const triggerPrice = this.safeStringN(params, ['stopPrice', 'triggerPrice', 'trigger_price']);
|
|
2878
|
+
params = this.omit(params, ['stopPrice', 'triggerPrice']);
|
|
2879
|
+
const isTriggerOrder = triggerPrice !== undefined;
|
|
2880
|
+
if (isTriggerOrder) {
|
|
2881
|
+
request['trigger_price'] = this.priceToPrecision(symbol, triggerPrice);
|
|
2882
|
+
request['stop_id'] = this.parseToNumeric(id);
|
|
2883
|
+
}
|
|
2884
|
+
else {
|
|
2885
|
+
request['order_id'] = this.parseToNumeric(id);
|
|
2886
|
+
}
|
|
2887
|
+
let marginMode = undefined;
|
|
2888
|
+
[marginMode, params] = this.handleMarginModeAndParams('editOrder', params);
|
|
2889
|
+
if (market['spot']) {
|
|
2890
|
+
if (marginMode !== undefined) {
|
|
2891
|
+
request['market_type'] = 'MARGIN';
|
|
2892
|
+
}
|
|
2893
|
+
else {
|
|
2894
|
+
request['market_type'] = 'SPOT';
|
|
2895
|
+
}
|
|
2896
|
+
if (isTriggerOrder) {
|
|
2897
|
+
response = await this.v2PrivatePostSpotModifyStopOrder(this.extend(request, params));
|
|
2898
|
+
//
|
|
2899
|
+
// {
|
|
2900
|
+
// "code": 0,
|
|
2901
|
+
// "data": {
|
|
2902
|
+
// "stop_id": 117337235167
|
|
2903
|
+
// },
|
|
2904
|
+
// "message": "OK"
|
|
2905
|
+
// }
|
|
2906
|
+
//
|
|
2907
|
+
}
|
|
2908
|
+
else {
|
|
2909
|
+
response = await this.v2PrivatePostSpotModifyOrder(this.extend(request, params));
|
|
2910
|
+
//
|
|
2911
|
+
// {
|
|
2912
|
+
// "code": 0,
|
|
2913
|
+
// "data": {
|
|
2914
|
+
// "amount": "0.0001",
|
|
2915
|
+
// "base_fee": "0",
|
|
2916
|
+
// "ccy": "BTC",
|
|
2917
|
+
// "client_id": "x-167673045-87eb2bebf42882d8",
|
|
2918
|
+
// "created_at": 1714290302047,
|
|
2919
|
+
// "discount_fee": "0",
|
|
2920
|
+
// "filled_amount": "0",
|
|
2921
|
+
// "filled_value": "0",
|
|
2922
|
+
// "last_fill_amount": "0",
|
|
2923
|
+
// "last_fill_price": "0",
|
|
2924
|
+
// "maker_fee_rate": "0.002",
|
|
2925
|
+
// "market": "BTCUSDT",
|
|
2926
|
+
// "market_type": "SPOT",
|
|
2927
|
+
// "order_id": 117336922195,
|
|
2928
|
+
// "price": "61000",
|
|
2929
|
+
// "quote_fee": "0",
|
|
2930
|
+
// "side": "buy",
|
|
2931
|
+
// "status": "open",
|
|
2932
|
+
// "taker_fee_rate": "0.002",
|
|
2933
|
+
// "type": "limit",
|
|
2934
|
+
// "unfilled_amount": "0.0001",
|
|
2935
|
+
// "updated_at": 1714290191141
|
|
2936
|
+
// },
|
|
2937
|
+
// "message": "OK"
|
|
2938
|
+
// }
|
|
2939
|
+
//
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
else {
|
|
2943
|
+
request['market_type'] = 'FUTURES';
|
|
2944
|
+
if (isTriggerOrder) {
|
|
2945
|
+
response = await this.v2PrivatePostFuturesModifyStopOrder(this.extend(request, params));
|
|
2946
|
+
//
|
|
2947
|
+
// {
|
|
2948
|
+
// "code": 0,
|
|
2949
|
+
// "data": {
|
|
2950
|
+
// "stop_id": 137091875605
|
|
2951
|
+
// },
|
|
2952
|
+
// "message": "OK"
|
|
2953
|
+
// }
|
|
2954
|
+
//
|
|
2955
|
+
}
|
|
2956
|
+
else {
|
|
2957
|
+
response = await this.v2PrivatePostFuturesModifyOrder(this.extend(request, params));
|
|
2958
|
+
//
|
|
2959
|
+
// {
|
|
2960
|
+
// "code": 0,
|
|
2961
|
+
// "data": {
|
|
2962
|
+
// "amount": "0.0001",
|
|
2963
|
+
// "client_id": "x-167673045-3f2d09191462b207",
|
|
2964
|
+
// "created_at": 1714290927630,
|
|
2965
|
+
// "fee": "0",
|
|
2966
|
+
// "fee_ccy": "USDT",
|
|
2967
|
+
// "filled_amount": "0",
|
|
2968
|
+
// "filled_value": "0",
|
|
2969
|
+
// "last_filled_amount": "0",
|
|
2970
|
+
// "last_filled_price": "0",
|
|
2971
|
+
// "maker_fee_rate": "0.0003",
|
|
2972
|
+
// "market": "BTCUSDT",
|
|
2973
|
+
// "market_type": "FUTURES",
|
|
2974
|
+
// "order_id": 137091566717,
|
|
2975
|
+
// "price": "61000",
|
|
2976
|
+
// "realized_pnl": "0",
|
|
2977
|
+
// "side": "buy",
|
|
2978
|
+
// "taker_fee_rate": "0.0005",
|
|
2979
|
+
// "type": "limit",
|
|
2980
|
+
// "unfilled_amount": "0.0001",
|
|
2981
|
+
// "updated_at": 1714290927630
|
|
2982
|
+
// },
|
|
2983
|
+
// "message": "OK"
|
|
2984
|
+
// }
|
|
2985
|
+
//
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2970
2988
|
const data = this.safeDict(response, 'data', {});
|
|
2971
2989
|
return this.parseOrder(data, market);
|
|
2972
2990
|
}
|
|
@@ -2975,189 +2993,303 @@ class coinex extends coinex$1 {
|
|
|
2975
2993
|
* @method
|
|
2976
2994
|
* @name coinex#cancelOrder
|
|
2977
2995
|
* @description cancels an open order
|
|
2978
|
-
* @see https://
|
|
2979
|
-
* @see https://
|
|
2980
|
-
* @see https://
|
|
2981
|
-
* @see https://
|
|
2982
|
-
* @see https://
|
|
2983
|
-
* @see https://
|
|
2984
|
-
* @see https://
|
|
2985
|
-
* @see https://
|
|
2996
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-order
|
|
2997
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
|
|
2998
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
|
|
2999
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
|
|
3000
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-order
|
|
3001
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
|
|
3002
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
|
|
3003
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
|
|
2986
3004
|
* @param {string} id order id
|
|
2987
3005
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
2988
3006
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2989
3007
|
* @param {string} [params.clientOrderId] client order id, defaults to id if not passed
|
|
2990
|
-
* @param {boolean} [params.
|
|
2991
|
-
* @returns {object}
|
|
3008
|
+
* @param {boolean} [params.trigger] set to true for canceling a trigger order
|
|
3009
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
2992
3010
|
*/
|
|
2993
3011
|
if (symbol === undefined) {
|
|
2994
3012
|
throw new errors.ArgumentsRequired(this.id + ' cancelOrder() requires a symbol argument');
|
|
2995
3013
|
}
|
|
2996
3014
|
await this.loadMarkets();
|
|
2997
3015
|
const market = this.market(symbol);
|
|
2998
|
-
const
|
|
3016
|
+
const isTriggerOrder = this.safeBool2(params, 'stop', 'trigger');
|
|
2999
3017
|
const swap = market['swap'];
|
|
3000
3018
|
const request = {
|
|
3001
3019
|
'market': market['id'],
|
|
3002
3020
|
};
|
|
3003
|
-
const accountId = this.safeInteger(params, 'account_id');
|
|
3004
3021
|
let marginMode = undefined;
|
|
3005
3022
|
[marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3023
|
+
if (swap) {
|
|
3024
|
+
request['market_type'] = 'FUTURES';
|
|
3025
|
+
}
|
|
3026
|
+
else {
|
|
3027
|
+
if (marginMode !== undefined) {
|
|
3028
|
+
request['market_type'] = 'MARGIN';
|
|
3029
|
+
}
|
|
3030
|
+
else {
|
|
3031
|
+
request['market_type'] = 'SPOT';
|
|
3010
3032
|
}
|
|
3011
|
-
request['account_id'] = accountId;
|
|
3012
3033
|
}
|
|
3013
|
-
const
|
|
3034
|
+
const clientOrderId = this.safeString2(params, 'client_id', 'clientOrderId');
|
|
3035
|
+
params = this.omit(params, ['stop', 'trigger', 'clientOrderId']);
|
|
3014
3036
|
let response = undefined;
|
|
3015
3037
|
if (clientOrderId !== undefined) {
|
|
3016
3038
|
request['client_id'] = clientOrderId;
|
|
3017
|
-
if (
|
|
3039
|
+
if (isTriggerOrder) {
|
|
3018
3040
|
if (swap) {
|
|
3019
|
-
response = await this.
|
|
3041
|
+
response = await this.v2PrivatePostFuturesCancelStopOrderByClientId(this.extend(request, params));
|
|
3042
|
+
// {
|
|
3043
|
+
// "code": 0,
|
|
3044
|
+
// "data": [
|
|
3045
|
+
// {
|
|
3046
|
+
// "code": 0,
|
|
3047
|
+
// "data": {
|
|
3048
|
+
// "amount": "0.0001",
|
|
3049
|
+
// "client_id": "client01",
|
|
3050
|
+
// "created_at": 1714368624473,
|
|
3051
|
+
// "market": "BTCUSDT",
|
|
3052
|
+
// "market_type": "FUTURES",
|
|
3053
|
+
// "price": "61000",
|
|
3054
|
+
// "side": "buy",
|
|
3055
|
+
// "stop_id": 137175823891,
|
|
3056
|
+
// "trigger_direction": "higher",
|
|
3057
|
+
// "trigger_price": "61500",
|
|
3058
|
+
// "trigger_price_type": "latest_price",
|
|
3059
|
+
// "type": "limit",
|
|
3060
|
+
// "updated_at": 1714368661444
|
|
3061
|
+
// },
|
|
3062
|
+
// "message": ""
|
|
3063
|
+
// }
|
|
3064
|
+
// ],
|
|
3065
|
+
// "message": "OK"
|
|
3066
|
+
// }
|
|
3020
3067
|
}
|
|
3021
3068
|
else {
|
|
3022
|
-
response = await this.
|
|
3069
|
+
response = await this.v2PrivatePostSpotCancelStopOrderByClientId(this.extend(request, params));
|
|
3070
|
+
// {
|
|
3071
|
+
// "code" :0,
|
|
3072
|
+
// "data": [
|
|
3073
|
+
// {
|
|
3074
|
+
// "code": 0,
|
|
3075
|
+
// "data": {
|
|
3076
|
+
// "amount": "0.0001",
|
|
3077
|
+
// "ccy": "BTC",
|
|
3078
|
+
// "client_id": "client01",
|
|
3079
|
+
// "created_at": 1714366950279,
|
|
3080
|
+
// "market": "BTCUSDT",
|
|
3081
|
+
// "market_type": "SPOT",
|
|
3082
|
+
// "price": "61000",
|
|
3083
|
+
// "side": "buy",
|
|
3084
|
+
// "stop_id": 117402512706,
|
|
3085
|
+
// "trigger_direction": "higher",
|
|
3086
|
+
// "trigger_price": "61500",
|
|
3087
|
+
// "trigger_price_type": "mark_price",
|
|
3088
|
+
// "type": "limit",
|
|
3089
|
+
// "updated_at": 1714366950279
|
|
3090
|
+
// },
|
|
3091
|
+
// "message": "OK"
|
|
3092
|
+
// }
|
|
3093
|
+
// ],
|
|
3094
|
+
// "message": "OK"
|
|
3095
|
+
// }
|
|
3023
3096
|
}
|
|
3024
3097
|
}
|
|
3025
3098
|
else {
|
|
3026
3099
|
if (swap) {
|
|
3027
|
-
response = await this.
|
|
3100
|
+
response = await this.v2PrivatePostFuturesCancelOrderByClientId(this.extend(request, params));
|
|
3101
|
+
// {
|
|
3102
|
+
// "code": 0,
|
|
3103
|
+
// "data": [
|
|
3104
|
+
// {
|
|
3105
|
+
// "code": 0,
|
|
3106
|
+
// "data": {
|
|
3107
|
+
// "amount": "0.0001",
|
|
3108
|
+
// "client_id": "x-167673045-bf60e24bb437a3df",
|
|
3109
|
+
// "created_at": 1714368416437,
|
|
3110
|
+
// "fee": "0",
|
|
3111
|
+
// "fee_ccy": "USDT",
|
|
3112
|
+
// "filled_amount": "0",
|
|
3113
|
+
// "filled_value": "0",
|
|
3114
|
+
// "last_filled_amount": "0",
|
|
3115
|
+
// "last_filled_price": "0",
|
|
3116
|
+
// "maker_fee_rate": "0.0003",
|
|
3117
|
+
// "market": "BTCUSDT",
|
|
3118
|
+
// "market_type": "FUTURES",
|
|
3119
|
+
// "order_id": 137175616437,
|
|
3120
|
+
// "price": "61000",
|
|
3121
|
+
// "realized_pnl": "0",
|
|
3122
|
+
// "side": "buy",
|
|
3123
|
+
// "taker_fee_rate": "0.0005",
|
|
3124
|
+
// "type": "limit",
|
|
3125
|
+
// "unfilled_amount": "0.0001",
|
|
3126
|
+
// "updated_at": 1714368507174
|
|
3127
|
+
// },
|
|
3128
|
+
// "message": ""
|
|
3129
|
+
// }
|
|
3130
|
+
// ],
|
|
3131
|
+
// "message": "OK"
|
|
3132
|
+
// }
|
|
3028
3133
|
}
|
|
3029
3134
|
else {
|
|
3030
|
-
response = await this.
|
|
3135
|
+
response = await this.v2PrivatePostSpotCancelOrderByClientId(this.extend(request, params));
|
|
3136
|
+
// {
|
|
3137
|
+
// "code": 0,
|
|
3138
|
+
// "data": [
|
|
3139
|
+
// {
|
|
3140
|
+
// "code": 0,
|
|
3141
|
+
// "data": {
|
|
3142
|
+
// "amount": "0.0001",
|
|
3143
|
+
// "base_fee": "0",
|
|
3144
|
+
// "ccy": "BTC",
|
|
3145
|
+
// "client_id": "x-167673045-d49eaca5f412afc8",
|
|
3146
|
+
// "created_at": 1714366502807,
|
|
3147
|
+
// "discount_fee": "0",
|
|
3148
|
+
// "filled_amount": "0",
|
|
3149
|
+
// "filled_value": "0",
|
|
3150
|
+
// "last_fill_amount": "0",
|
|
3151
|
+
// "last_fill_price": "0",
|
|
3152
|
+
// "maker_fee_rate": "0.002",
|
|
3153
|
+
// "market": "BTCUSDT",
|
|
3154
|
+
// "market_type": "SPOT",
|
|
3155
|
+
// "order_id": 117402157490,
|
|
3156
|
+
// "price": "61000",
|
|
3157
|
+
// "quote_fee": "0",
|
|
3158
|
+
// "side": "buy",
|
|
3159
|
+
// "taker_fee_rate": "0.002",
|
|
3160
|
+
// "type": "limit",
|
|
3161
|
+
// "unfilled_amount": "0.0001",
|
|
3162
|
+
// "updated_at": 1714366502807
|
|
3163
|
+
// },
|
|
3164
|
+
// "message": "OK"
|
|
3165
|
+
// }
|
|
3166
|
+
// ],
|
|
3167
|
+
// "message": "OK"
|
|
3168
|
+
// }
|
|
3031
3169
|
}
|
|
3032
3170
|
}
|
|
3033
3171
|
}
|
|
3034
3172
|
else {
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
if (stop) {
|
|
3173
|
+
if (isTriggerOrder) {
|
|
3174
|
+
request['stop_id'] = this.parseToNumeric(id);
|
|
3038
3175
|
if (swap) {
|
|
3039
|
-
response = await this.
|
|
3176
|
+
response = await this.v2PrivatePostFuturesCancelStopOrder(this.extend(request, params));
|
|
3177
|
+
// {
|
|
3178
|
+
// "code": 0,
|
|
3179
|
+
// "data": {
|
|
3180
|
+
// "amount": "0.0001",
|
|
3181
|
+
// "ccy": "BTC",
|
|
3182
|
+
// "client_id": "x-167673045-f21ecfd7542abf1f",
|
|
3183
|
+
// "created_at": 1714366177334,
|
|
3184
|
+
// "market": "BTCUSDT",
|
|
3185
|
+
// "market_type": "SPOT",
|
|
3186
|
+
// "price": "61000",
|
|
3187
|
+
// "side": "buy",
|
|
3188
|
+
// "stop_id": 117401897954,
|
|
3189
|
+
// "trigger_direction": "higher",
|
|
3190
|
+
// "trigger_price": "61500",
|
|
3191
|
+
// "trigger_price_type": "mark_price",
|
|
3192
|
+
// "type": "limit",
|
|
3193
|
+
// "updated_at": 1714366177334
|
|
3194
|
+
// },
|
|
3195
|
+
// "message": "OK"
|
|
3196
|
+
// }
|
|
3040
3197
|
}
|
|
3041
3198
|
else {
|
|
3042
|
-
response = await this.
|
|
3199
|
+
response = await this.v2PrivatePostSpotCancelStopOrder(this.extend(request, params));
|
|
3200
|
+
// {
|
|
3201
|
+
// "code": 0,
|
|
3202
|
+
// "data": {
|
|
3203
|
+
// "amount": "0.0001",
|
|
3204
|
+
// "ccy": "BTC",
|
|
3205
|
+
// "client_id": "x-167673045-f21ecfd7542abf1f",
|
|
3206
|
+
// "created_at": 1714366177334,
|
|
3207
|
+
// "market": "BTCUSDT",
|
|
3208
|
+
// "market_type": "SPOT",
|
|
3209
|
+
// "price": "61000",
|
|
3210
|
+
// "side": "buy",
|
|
3211
|
+
// "stop_id": 117401897954,
|
|
3212
|
+
// "trigger_direction": "higher",
|
|
3213
|
+
// "trigger_price": "61500",
|
|
3214
|
+
// "trigger_price_type": "mark_price",
|
|
3215
|
+
// "type": "limit",
|
|
3216
|
+
// "updated_at": 1714366177334
|
|
3217
|
+
// },
|
|
3218
|
+
// "message": "OK"
|
|
3219
|
+
// }
|
|
3043
3220
|
}
|
|
3044
3221
|
}
|
|
3045
3222
|
else {
|
|
3223
|
+
request['order_id'] = this.parseToNumeric(id);
|
|
3046
3224
|
if (swap) {
|
|
3047
|
-
response = await this.
|
|
3225
|
+
response = await this.v2PrivatePostFuturesCancelOrder(this.extend(request, params));
|
|
3226
|
+
// {
|
|
3227
|
+
// "code": 0,
|
|
3228
|
+
// "data": {
|
|
3229
|
+
// "amount": "0.0001",
|
|
3230
|
+
// "client_id": "x-167673045-7f14381c74a98a85",
|
|
3231
|
+
// "created_at": 1714367342024,
|
|
3232
|
+
// "fee": "0",
|
|
3233
|
+
// "fee_ccy": "USDT",
|
|
3234
|
+
// "filled_amount": "0",
|
|
3235
|
+
// "filled_value": "0",
|
|
3236
|
+
// "last_filled_amount": "0",
|
|
3237
|
+
// "last_filled_price": "0",
|
|
3238
|
+
// "maker_fee_rate": "0.0003",
|
|
3239
|
+
// "market": "BTCUSDT",
|
|
3240
|
+
// "market_type": "FUTURES",
|
|
3241
|
+
// "order_id": 137174472136,
|
|
3242
|
+
// "price": "61000",
|
|
3243
|
+
// "realized_pnl": "0",
|
|
3244
|
+
// "side": "buy",
|
|
3245
|
+
// "taker_fee_rate": "0.0005",
|
|
3246
|
+
// "type": "limit",
|
|
3247
|
+
// "unfilled_amount": "0.0001",
|
|
3248
|
+
// "updated_at": 1714367515978
|
|
3249
|
+
// },
|
|
3250
|
+
// "message": "OK"
|
|
3251
|
+
// }
|
|
3048
3252
|
}
|
|
3049
3253
|
else {
|
|
3050
|
-
response = await this.
|
|
3254
|
+
response = await this.v2PrivatePostSpotCancelOrder(this.extend(request, params));
|
|
3255
|
+
// {
|
|
3256
|
+
// "code": 0,
|
|
3257
|
+
// "data": {
|
|
3258
|
+
// "amount": "0.0001",
|
|
3259
|
+
// "base_fee": "0",
|
|
3260
|
+
// "ccy": "BTC",
|
|
3261
|
+
// "client_id": "x-167673045-86fbe37b54a2aea3",
|
|
3262
|
+
// "created_at": 1714365277437,
|
|
3263
|
+
// "discount_fee": "0",
|
|
3264
|
+
// "filled_amount": "0",
|
|
3265
|
+
// "filled_value": "0",
|
|
3266
|
+
// "last_fill_amount": "0",
|
|
3267
|
+
// "last_fill_price": "0",
|
|
3268
|
+
// "maker_fee_rate": "0.002",
|
|
3269
|
+
// "market": "BTCUSDT",
|
|
3270
|
+
// "market_type": "SPOT",
|
|
3271
|
+
// "order_id": 117401168172,
|
|
3272
|
+
// "price": "61000",
|
|
3273
|
+
// "quote_fee": "0",
|
|
3274
|
+
// "side": "buy",
|
|
3275
|
+
// "taker_fee_rate": "0.002",
|
|
3276
|
+
// "type": "limit",
|
|
3277
|
+
// "unfilled_amount": "0.0001",
|
|
3278
|
+
// "updated_at": 1714365277437
|
|
3279
|
+
// },
|
|
3280
|
+
// "message": "OK"
|
|
3281
|
+
// }
|
|
3051
3282
|
}
|
|
3052
3283
|
}
|
|
3053
3284
|
}
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
// "avg_price": "0.00",
|
|
3063
|
-
// "client_id": "",
|
|
3064
|
-
// "create_time": 1650951627,
|
|
3065
|
-
// "deal_amount": "0",
|
|
3066
|
-
// "deal_fee": "0",
|
|
3067
|
-
// "deal_money": "0",
|
|
3068
|
-
// "fee_asset": null,
|
|
3069
|
-
// "fee_discount": "1",
|
|
3070
|
-
// "finished_time": null,
|
|
3071
|
-
// "id": 74510932594,
|
|
3072
|
-
// "left": "0.0005",
|
|
3073
|
-
// "maker_fee_rate": "0.002",
|
|
3074
|
-
// "market": "BTCUSDT",
|
|
3075
|
-
// "money_fee": "0",
|
|
3076
|
-
// "order_type": "limit",
|
|
3077
|
-
// "price": "30000",
|
|
3078
|
-
// "status": "not_deal",
|
|
3079
|
-
// "stock_fee": "0",
|
|
3080
|
-
// "taker_fee_rate": "0.002",
|
|
3081
|
-
// "type": "buy"
|
|
3082
|
-
// },
|
|
3083
|
-
// "message": "Success"
|
|
3084
|
-
// }
|
|
3085
|
-
//
|
|
3086
|
-
// Swap
|
|
3087
|
-
//
|
|
3088
|
-
// {
|
|
3089
|
-
// "code": 0,
|
|
3090
|
-
// "data": {
|
|
3091
|
-
// "amount": "0.0005",
|
|
3092
|
-
// "client_id": "",
|
|
3093
|
-
// "create_time": 1651004578.618224,
|
|
3094
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
3095
|
-
// "deal_fee": "0.00000000000000000000",
|
|
3096
|
-
// "deal_profit": "0.00000000000000000000",
|
|
3097
|
-
// "deal_stock": "0.00000000000000000000",
|
|
3098
|
-
// "effect_type": 1,
|
|
3099
|
-
// "fee_asset": "",
|
|
3100
|
-
// "fee_discount": "0.00000000000000000000",
|
|
3101
|
-
// "last_deal_amount": "0.00000000000000000000",
|
|
3102
|
-
// "last_deal_id": 0,
|
|
3103
|
-
// "last_deal_price": "0.00000000000000000000",
|
|
3104
|
-
// "last_deal_role": 0,
|
|
3105
|
-
// "last_deal_time": 0,
|
|
3106
|
-
// "last_deal_type": 0,
|
|
3107
|
-
// "left": "0.0005",
|
|
3108
|
-
// "leverage": "3",
|
|
3109
|
-
// "maker_fee": "0.00030",
|
|
3110
|
-
// "market": "BTCUSDT",
|
|
3111
|
-
// "order_id": 18221659097,
|
|
3112
|
-
// "position_id": 0,
|
|
3113
|
-
// "position_type": 1,
|
|
3114
|
-
// "price": "30000.00",
|
|
3115
|
-
// "side": 2,
|
|
3116
|
-
// "source": "api.v1",
|
|
3117
|
-
// "stop_id": 0,
|
|
3118
|
-
// "taker_fee": "0.00050",
|
|
3119
|
-
// "target": 0,
|
|
3120
|
-
// "type": 1,
|
|
3121
|
-
// "update_time": 1651004578.618224,
|
|
3122
|
-
// "user_id": 3620173
|
|
3123
|
-
// },
|
|
3124
|
-
// "message": "OK"
|
|
3125
|
-
// }
|
|
3126
|
-
//
|
|
3127
|
-
// Swap Stop
|
|
3128
|
-
//
|
|
3129
|
-
// {
|
|
3130
|
-
// "code": 0,
|
|
3131
|
-
// "data": {
|
|
3132
|
-
// "amount": "0.0005",
|
|
3133
|
-
// "client_id": "",
|
|
3134
|
-
// "create_time": 1651034023.008771,
|
|
3135
|
-
// "effect_type": 1,
|
|
3136
|
-
// "fee_asset": "",
|
|
3137
|
-
// "fee_discount": "0.00000000000000000000",
|
|
3138
|
-
// "maker_fee": "0.00030",
|
|
3139
|
-
// "market": "BTCUSDT",
|
|
3140
|
-
// "order_id": 18256915101,
|
|
3141
|
-
// "price": "31000.00",
|
|
3142
|
-
// "side": 2,
|
|
3143
|
-
// "source": "api.v1",
|
|
3144
|
-
// "state": 1,
|
|
3145
|
-
// "stop_price": "31500.00",
|
|
3146
|
-
// "stop_type": 1,
|
|
3147
|
-
// "taker_fee": "0.00050",
|
|
3148
|
-
// "target": 0,
|
|
3149
|
-
// "type": 1,
|
|
3150
|
-
// "update_time": 1651034397.193624,
|
|
3151
|
-
// "user_id": 3620173
|
|
3152
|
-
// },
|
|
3153
|
-
// "message":"OK"
|
|
3154
|
-
// }
|
|
3155
|
-
//
|
|
3156
|
-
// Spot and Margin Stop
|
|
3157
|
-
//
|
|
3158
|
-
// {"code":0,"data":{},"message":"Success"}
|
|
3159
|
-
//
|
|
3160
|
-
const data = this.safeDict(response, 'data');
|
|
3285
|
+
let data = undefined;
|
|
3286
|
+
if (clientOrderId !== undefined) {
|
|
3287
|
+
const rows = this.safeList(response, 'data', []);
|
|
3288
|
+
data = this.safeDict(rows[0], 'data', {});
|
|
3289
|
+
}
|
|
3290
|
+
else {
|
|
3291
|
+
data = this.safeDict(response, 'data', {});
|
|
3292
|
+
}
|
|
3161
3293
|
return this.parseOrder(data, market);
|
|
3162
3294
|
}
|
|
3163
3295
|
async cancelAllOrders(symbol = undefined, params = {}) {
|
|
@@ -3165,12 +3297,11 @@ class coinex extends coinex$1 {
|
|
|
3165
3297
|
* @method
|
|
3166
3298
|
* @name coinex#cancelAllOrders
|
|
3167
3299
|
* @description cancel all open orders in a market
|
|
3168
|
-
* @see https://
|
|
3169
|
-
* @see https://
|
|
3170
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http024_cancel_stop_all
|
|
3171
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http022_cancel_all
|
|
3300
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
|
|
3301
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
|
|
3172
3302
|
* @param {string} symbol unified market symbol of the market to cancel orders in
|
|
3173
3303
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3304
|
+
* @param {string} [params.marginMode] 'cross' or 'isolated' for canceling spot margin orders
|
|
3174
3305
|
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3175
3306
|
*/
|
|
3176
3307
|
if (symbol === undefined) {
|
|
@@ -3178,43 +3309,31 @@ class coinex extends coinex$1 {
|
|
|
3178
3309
|
}
|
|
3179
3310
|
await this.loadMarkets();
|
|
3180
3311
|
const market = this.market(symbol);
|
|
3181
|
-
const marketId = market['id'];
|
|
3182
|
-
const accountId = this.safeInteger(params, 'account_id', 0);
|
|
3183
3312
|
const request = {
|
|
3184
|
-
'market':
|
|
3185
|
-
// 'account_id': accountId, // SPOT, main account ID: 0, margin account ID: See < Inquire Margin Account Market Info >, future account ID: See < Inquire Future Account Market Info >
|
|
3186
|
-
// 'side': 0, // SWAP, 0: All, 1: Sell, 2: Buy
|
|
3313
|
+
'market': market['id'],
|
|
3187
3314
|
};
|
|
3188
|
-
const swap = market['swap'];
|
|
3189
|
-
const stop = this.safeValue(params, 'stop');
|
|
3190
|
-
params = this.omit(params, ['stop', 'account_id']);
|
|
3191
3315
|
let response = undefined;
|
|
3192
|
-
if (swap) {
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
}
|
|
3316
|
+
if (market['swap']) {
|
|
3317
|
+
request['market_type'] = 'FUTURES';
|
|
3318
|
+
response = await this.v2PrivatePostFuturesCancelAllOrder(this.extend(request, params));
|
|
3319
|
+
//
|
|
3320
|
+
// {"code":0,"data":{},"message":"OK"}
|
|
3321
|
+
//
|
|
3199
3322
|
}
|
|
3200
3323
|
else {
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3324
|
+
let marginMode = undefined;
|
|
3325
|
+
[marginMode, params] = this.handleMarginModeAndParams('fetchOrdersByStatus', params);
|
|
3326
|
+
if (marginMode !== undefined) {
|
|
3327
|
+
request['market_type'] = 'MARGIN';
|
|
3204
3328
|
}
|
|
3205
3329
|
else {
|
|
3206
|
-
|
|
3330
|
+
request['market_type'] = 'SPOT';
|
|
3207
3331
|
}
|
|
3332
|
+
response = await this.v2PrivatePostSpotCancelAllOrder(this.extend(request, params));
|
|
3333
|
+
//
|
|
3334
|
+
// {"code":0,"data":{},"message":"OK"}
|
|
3335
|
+
//
|
|
3208
3336
|
}
|
|
3209
|
-
//
|
|
3210
|
-
// Spot and Margin
|
|
3211
|
-
//
|
|
3212
|
-
// {"code": 0, "data": null, "message": "Success"}
|
|
3213
|
-
//
|
|
3214
|
-
// Swap
|
|
3215
|
-
//
|
|
3216
|
-
// {"code": 0, "data": {"status":"success"}, "message": "OK"}
|
|
3217
|
-
//
|
|
3218
3337
|
return response;
|
|
3219
3338
|
}
|
|
3220
3339
|
async fetchOrder(id, symbol = undefined, params = {}) {
|
|
@@ -3222,9 +3341,8 @@ class coinex extends coinex$1 {
|
|
|
3222
3341
|
* @method
|
|
3223
3342
|
* @name coinex#fetchOrder
|
|
3224
3343
|
* @description fetches information on an order made by the user
|
|
3225
|
-
* @see https://
|
|
3226
|
-
* @see https://
|
|
3227
|
-
* @see https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade007_order_status
|
|
3344
|
+
* @see https://docs.coinex.com/api/v2/spot/order/http/get-order-status
|
|
3345
|
+
* @see https://docs.coinex.com/api/v2/futures/order/http/get-order-status
|
|
3228
3346
|
* @param {string} symbol unified symbol of the market the order was made in
|
|
3229
3347
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3230
3348
|
* @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
@@ -3234,127 +3352,77 @@ class coinex extends coinex$1 {
|
|
|
3234
3352
|
}
|
|
3235
3353
|
await this.loadMarkets();
|
|
3236
3354
|
const market = this.market(symbol);
|
|
3237
|
-
const swap = market['swap'];
|
|
3238
|
-
const stop = this.safeValue(params, 'stop');
|
|
3239
|
-
params = this.omit(params, 'stop');
|
|
3240
3355
|
const request = {
|
|
3241
3356
|
'market': market['id'],
|
|
3242
|
-
|
|
3243
|
-
// 'order_id': id, // SWAP
|
|
3357
|
+
'order_id': this.parseToNumeric(id),
|
|
3244
3358
|
};
|
|
3245
|
-
const idRequest = swap ? 'order_id' : 'id';
|
|
3246
|
-
request[idRequest] = id;
|
|
3247
3359
|
let response = undefined;
|
|
3248
|
-
if (swap) {
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3360
|
+
if (market['swap']) {
|
|
3361
|
+
response = await this.v2PrivateGetFuturesOrderStatus(this.extend(request, params));
|
|
3362
|
+
//
|
|
3363
|
+
// {
|
|
3364
|
+
// "code": 0,
|
|
3365
|
+
// "data": {
|
|
3366
|
+
// "amount": "0.0001",
|
|
3367
|
+
// "client_id": "x-167673045-da5f31dcd478a829",
|
|
3368
|
+
// "created_at": 1714460987164,
|
|
3369
|
+
// "fee": "0",
|
|
3370
|
+
// "fee_ccy": "USDT",
|
|
3371
|
+
// "filled_amount": "0",
|
|
3372
|
+
// "filled_value": "0",
|
|
3373
|
+
// "last_filled_amount": "0",
|
|
3374
|
+
// "last_filled_price": "0",
|
|
3375
|
+
// "maker_fee_rate": "0.0003",
|
|
3376
|
+
// "market": "BTCUSDT",
|
|
3377
|
+
// "market_type": "FUTURES",
|
|
3378
|
+
// "order_id": 137319868771,
|
|
3379
|
+
// "price": "61000",
|
|
3380
|
+
// "realized_pnl": "0",
|
|
3381
|
+
// "side": "buy",
|
|
3382
|
+
// "status": "open",
|
|
3383
|
+
// "taker_fee_rate": "0.0005",
|
|
3384
|
+
// "type": "limit",
|
|
3385
|
+
// "unfilled_amount": "0.0001",
|
|
3386
|
+
// "updated_at": 1714460987164
|
|
3387
|
+
// },
|
|
3388
|
+
// "message": "OK"
|
|
3389
|
+
// }
|
|
3390
|
+
//
|
|
3255
3391
|
}
|
|
3256
3392
|
else {
|
|
3257
|
-
response = await this.
|
|
3393
|
+
response = await this.v2PrivateGetSpotOrderStatus(this.extend(request, params));
|
|
3394
|
+
//
|
|
3395
|
+
// {
|
|
3396
|
+
// "code": 0,
|
|
3397
|
+
// "data": {
|
|
3398
|
+
// "amount": "0.0001",
|
|
3399
|
+
// "base_fee": "0",
|
|
3400
|
+
// "ccy": "BTC",
|
|
3401
|
+
// "client_id": "x-167673045-da918d6724e3af81",
|
|
3402
|
+
// "created_at": 1714461638958,
|
|
3403
|
+
// "discount_fee": "0",
|
|
3404
|
+
// "filled_amount": "0",
|
|
3405
|
+
// "filled_value": "0",
|
|
3406
|
+
// "last_fill_amount": "0",
|
|
3407
|
+
// "last_fill_price": "0",
|
|
3408
|
+
// "maker_fee_rate": "0.002",
|
|
3409
|
+
// "market": "BTCUSDT",
|
|
3410
|
+
// "market_type": "SPOT",
|
|
3411
|
+
// "order_id": 117492012985,
|
|
3412
|
+
// "price": "61000",
|
|
3413
|
+
// "quote_fee": "0",
|
|
3414
|
+
// "side": "buy",
|
|
3415
|
+
// "status": "open",
|
|
3416
|
+
// "taker_fee_rate": "0.002",
|
|
3417
|
+
// "type": "limit",
|
|
3418
|
+
// "unfilled_amount": "0.0001",
|
|
3419
|
+
// "updated_at": 1714461638958
|
|
3420
|
+
// },
|
|
3421
|
+
// "message": "OK"
|
|
3422
|
+
// }
|
|
3423
|
+
//
|
|
3258
3424
|
}
|
|
3259
|
-
|
|
3260
|
-
// Spot
|
|
3261
|
-
//
|
|
3262
|
-
// {
|
|
3263
|
-
// "code": 0,
|
|
3264
|
-
// "data": {
|
|
3265
|
-
// "amount": "0.1",
|
|
3266
|
-
// "asset_fee": "0.22736197736197736197",
|
|
3267
|
-
// "avg_price": "196.85000000000000000000",
|
|
3268
|
-
// "create_time": 1537270135,
|
|
3269
|
-
// "deal_amount": "0.1",
|
|
3270
|
-
// "deal_fee": "0",
|
|
3271
|
-
// "deal_money": "19.685",
|
|
3272
|
-
// "fee_asset": "CET",
|
|
3273
|
-
// "fee_discount": "0.5",
|
|
3274
|
-
// "id": 1788259447,
|
|
3275
|
-
// "left": "0",
|
|
3276
|
-
// "maker_fee_rate": "0",
|
|
3277
|
-
// "market": "ETHUSDT",
|
|
3278
|
-
// "order_type": "limit",
|
|
3279
|
-
// "price": "170.00000000",
|
|
3280
|
-
// "status": "done",
|
|
3281
|
-
// "taker_fee_rate": "0.0005",
|
|
3282
|
-
// "type": "sell",
|
|
3283
|
-
// },
|
|
3284
|
-
// "message": "Ok"
|
|
3285
|
-
// }
|
|
3286
|
-
//
|
|
3287
|
-
// Swap
|
|
3288
|
-
//
|
|
3289
|
-
// {
|
|
3290
|
-
// "code": 0,
|
|
3291
|
-
// "data": {
|
|
3292
|
-
// "amount": "0.0005",
|
|
3293
|
-
// "client_id": "",
|
|
3294
|
-
// "create_time": 1651004578.618224,
|
|
3295
|
-
// "deal_asset_fee": "0.00000000000000000000",
|
|
3296
|
-
// "deal_fee": "0.00000000000000000000",
|
|
3297
|
-
// "deal_profit": "0.00000000000000000000",
|
|
3298
|
-
// "deal_stock": "0.00000000000000000000",
|
|
3299
|
-
// "effect_type": 1,
|
|
3300
|
-
// "fee_asset": "",
|
|
3301
|
-
// "fee_discount": "0.00000000000000000000",
|
|
3302
|
-
// "last_deal_amount": "0.00000000000000000000",
|
|
3303
|
-
// "last_deal_id": 0,
|
|
3304
|
-
// "last_deal_price": "0.00000000000000000000",
|
|
3305
|
-
// "last_deal_role": 0,
|
|
3306
|
-
// "last_deal_time": 0,
|
|
3307
|
-
// "last_deal_type": 0,
|
|
3308
|
-
// "left": "0.0005",
|
|
3309
|
-
// "leverage": "3",
|
|
3310
|
-
// "maker_fee": "0.00030",
|
|
3311
|
-
// "market": "BTCUSDT",
|
|
3312
|
-
// "order_id": 18221659097,
|
|
3313
|
-
// "position_id": 0,
|
|
3314
|
-
// "position_type": 1,
|
|
3315
|
-
// "price": "30000.00",
|
|
3316
|
-
// "side": 2,
|
|
3317
|
-
// "source": "api.v1",
|
|
3318
|
-
// "stop_id": 0,
|
|
3319
|
-
// "taker_fee": "0.00050",
|
|
3320
|
-
// "target": 0,
|
|
3321
|
-
// "type": 1,
|
|
3322
|
-
// "update_time": 1651004578.618224,
|
|
3323
|
-
// "user_id": 3620173
|
|
3324
|
-
// },
|
|
3325
|
-
// "message": "OK"
|
|
3326
|
-
// }
|
|
3327
|
-
//
|
|
3328
|
-
// Swap Stop
|
|
3329
|
-
//
|
|
3330
|
-
// {
|
|
3331
|
-
// "code": 0,
|
|
3332
|
-
// "data": {
|
|
3333
|
-
// "amount": "0.0005",
|
|
3334
|
-
// "client_id": "",
|
|
3335
|
-
// "create_time": 1651034023.008771,
|
|
3336
|
-
// "effect_type": 1,
|
|
3337
|
-
// "fee_asset": "",
|
|
3338
|
-
// "fee_discount": "0.00000000000000000000",
|
|
3339
|
-
// "maker_fee": "0.00030",
|
|
3340
|
-
// "market": "BTCUSDT",
|
|
3341
|
-
// "order_id": 18256915101,
|
|
3342
|
-
// "price": "31000.00",
|
|
3343
|
-
// "side": 2,
|
|
3344
|
-
// "source": "api.v1",
|
|
3345
|
-
// "state": 1,
|
|
3346
|
-
// "stop_price": "31500.00",
|
|
3347
|
-
// "stop_type": 1,
|
|
3348
|
-
// "taker_fee": "0.00050",
|
|
3349
|
-
// "target": 0,
|
|
3350
|
-
// "type": 1,
|
|
3351
|
-
// "update_time": 1651034397.193624,
|
|
3352
|
-
// "user_id": 3620173
|
|
3353
|
-
// },
|
|
3354
|
-
// "message":"OK"
|
|
3355
|
-
// }
|
|
3356
|
-
//
|
|
3357
|
-
const data = this.safeDict(response, 'data');
|
|
3425
|
+
const data = this.safeDict(response, 'data', {});
|
|
3358
3426
|
return this.parseOrder(data, market);
|
|
3359
3427
|
}
|
|
3360
3428
|
async fetchOrdersByStatus(status, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -5511,11 +5579,7 @@ class coinex extends coinex$1 {
|
|
|
5511
5579
|
// }
|
|
5512
5580
|
//
|
|
5513
5581
|
const data = this.safeValue(response, 'data', []);
|
|
5514
|
-
|
|
5515
|
-
for (let i = 0; i < data.length; i++) {
|
|
5516
|
-
rates.push(this.parseIsolatedBorrowRate(data[i]));
|
|
5517
|
-
}
|
|
5518
|
-
return rates;
|
|
5582
|
+
return this.parseIsolatedBorrowRates(data);
|
|
5519
5583
|
}
|
|
5520
5584
|
async fetchBorrowInterest(code = undefined, symbol = undefined, since = undefined, limit = undefined, params = {}) {
|
|
5521
5585
|
await this.loadMarkets();
|