ccxt 4.3.13__py2.py3-none-any.whl → 4.3.14__py2.py3-none-any.whl
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.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/binance.py +99 -3
- ccxt/async_support/bybit.py +99 -99
- ccxt/async_support/coinbase.py +96 -1
- ccxt/async_support/coinex.py +392 -375
- ccxt/async_support/okx.py +1 -1
- ccxt/base/exchange.py +5 -1
- ccxt/binance.py +99 -3
- ccxt/bybit.py +99 -99
- ccxt/coinbase.py +96 -1
- ccxt/coinex.py +392 -375
- ccxt/okx.py +1 -1
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/woo.py +137 -9
- {ccxt-4.3.13.dist-info → ccxt-4.3.14.dist-info}/METADATA +4 -4
- {ccxt-4.3.13.dist-info → ccxt-4.3.14.dist-info}/RECORD +20 -20
- {ccxt-4.3.13.dist-info → ccxt-4.3.14.dist-info}/WHEEL +0 -0
- {ccxt-4.3.13.dist-info → ccxt-4.3.14.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinex.py
CHANGED
@@ -1665,111 +1665,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1665
1665
|
|
1666
1666
|
def parse_order(self, order, market: Market = None) -> Order:
|
1667
1667
|
#
|
1668
|
-
# Spot and Margin
|
1669
|
-
#
|
1670
|
-
# {
|
1671
|
-
# "account_id": 0,
|
1672
|
-
# "amount": "0.0005",
|
1673
|
-
# "asset_fee": "0",
|
1674
|
-
# "avg_price": "0.00",
|
1675
|
-
# "client_id": "",
|
1676
|
-
# "create_time": 1651089247,
|
1677
|
-
# "deal_amount": "0",
|
1678
|
-
# "deal_fee": "0",
|
1679
|
-
# "deal_money": "0",
|
1680
|
-
# "fee_asset": null,
|
1681
|
-
# "fee_discount": "1",
|
1682
|
-
# "finished_time": 0,
|
1683
|
-
# "id": 74660190839,
|
1684
|
-
# "left": "0.0005",
|
1685
|
-
# "maker_fee_rate": "0.002",
|
1686
|
-
# "market": "BTCUSDT",
|
1687
|
-
# "money_fee": "0",
|
1688
|
-
# "order_type": "limit",
|
1689
|
-
# "price": "31000",
|
1690
|
-
# "status": "not_deal",
|
1691
|
-
# "stock_fee": "0",
|
1692
|
-
# "taker_fee_rate": "0.002",
|
1693
|
-
# "type": "buy"
|
1694
|
-
# }
|
1695
|
-
#
|
1696
|
-
# Swap fetchOpenOrders, fetchClosedOrders
|
1697
|
-
#
|
1698
|
-
# {
|
1699
|
-
# "amount": "0.0005",
|
1700
|
-
# "client_id": "",
|
1701
|
-
# "create_time": 1651030414.088431,
|
1702
|
-
# "deal_asset_fee": "0",
|
1703
|
-
# "deal_fee": "0.00960069",
|
1704
|
-
# "deal_profit": "0.009825",
|
1705
|
-
# "deal_stock": "19.20138",
|
1706
|
-
# "effect_type": 0,
|
1707
|
-
# "fee_asset": "",
|
1708
|
-
# "fee_discount": "0",
|
1709
|
-
# "left": "0",
|
1710
|
-
# "leverage": "3",
|
1711
|
-
# "maker_fee": "0",
|
1712
|
-
# "market": "BTCUSDT",
|
1713
|
-
# "order_id": 18253447431,
|
1714
|
-
# "position_id": 0,
|
1715
|
-
# "position_type": 1,
|
1716
|
-
# "price": "0",
|
1717
|
-
# "side": 1,
|
1718
|
-
# "source": "web",
|
1719
|
-
# "stop_id": 0,
|
1720
|
-
# "taker_fee": "0.0005",
|
1721
|
-
# "target": 0,
|
1722
|
-
# "type": 2,
|
1723
|
-
# "update_time": 1651030414.08847,
|
1724
|
-
# "user_id": 3620173
|
1725
|
-
# }
|
1726
|
-
#
|
1727
|
-
# Spot and Margin Stop fetchOpenOrders, fetchClosedOrders
|
1728
|
-
#
|
1729
|
-
# {
|
1730
|
-
# "account_id": 0,
|
1731
|
-
# "amount": "155",
|
1732
|
-
# "client_id": "",
|
1733
|
-
# "create_time": 1651089182,
|
1734
|
-
# "fee_asset": null,
|
1735
|
-
# "fee_discount": "1",
|
1736
|
-
# "maker_fee": "0.002",
|
1737
|
-
# "market": "BTCUSDT",
|
1738
|
-
# "order_id": 74660111965,
|
1739
|
-
# "order_type": "market",
|
1740
|
-
# "price": "0",
|
1741
|
-
# "state": 0,
|
1742
|
-
# "stop_price": "31500",
|
1743
|
-
# "taker_fee": "0.002",
|
1744
|
-
# "type": "buy"
|
1745
|
-
# }
|
1746
|
-
#
|
1747
|
-
# Swap Stop fetchOpenOrders
|
1748
|
-
#
|
1749
|
-
# {
|
1750
|
-
# "amount": "0.0005",
|
1751
|
-
# "client_id": "",
|
1752
|
-
# "create_time": 1651089147.321691,
|
1753
|
-
# "effect_type": 1,
|
1754
|
-
# "fee_asset": "",
|
1755
|
-
# "fee_discount": "0.00000000000000000000",
|
1756
|
-
# "maker_fee": "0.00030",
|
1757
|
-
# "market": "BTCUSDT",
|
1758
|
-
# "order_id": 18332143848,
|
1759
|
-
# "price": "31000.00",
|
1760
|
-
# "side": 2,
|
1761
|
-
# "source": "api.v1",
|
1762
|
-
# "state": 1,
|
1763
|
-
# "stop_price": "31500.00",
|
1764
|
-
# "stop_type": 1,
|
1765
|
-
# "taker_fee": "0.00050",
|
1766
|
-
# "target": 0,
|
1767
|
-
# "type": 1,
|
1768
|
-
# "update_time": 1651089147.321691,
|
1769
|
-
# "user_id": 3620173
|
1770
|
-
# }
|
1771
|
-
#
|
1772
|
-
# Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder v2
|
1668
|
+
# Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders
|
1773
1669
|
#
|
1774
1670
|
# {
|
1775
1671
|
# "amount": "0.0001",
|
@@ -1795,13 +1691,37 @@ class coinex(Exchange, ImplicitAPI):
|
|
1795
1691
|
# "updated_at": 1714114386250
|
1796
1692
|
# }
|
1797
1693
|
#
|
1798
|
-
# Spot
|
1694
|
+
# Spot and Margin fetchClosedOrders
|
1695
|
+
#
|
1696
|
+
# {
|
1697
|
+
# "order_id": 117180532345,
|
1698
|
+
# "market": "BTCUSDT",
|
1699
|
+
# "market_type": "SPOT",
|
1700
|
+
# "side": "sell",
|
1701
|
+
# "type": "market",
|
1702
|
+
# "ccy": "BTC",
|
1703
|
+
# "amount": "0.00015484",
|
1704
|
+
# "price": "0",
|
1705
|
+
# "client_id": "",
|
1706
|
+
# "created_at": 1714116494219,
|
1707
|
+
# "updated_at": 0,
|
1708
|
+
# "base_fee": "0",
|
1709
|
+
# "quote_fee": "0.0199931699632",
|
1710
|
+
# "discount_fee": "0",
|
1711
|
+
# "maker_fee_rate": "0",
|
1712
|
+
# "taker_fee_rate": "0.002",
|
1713
|
+
# "unfilled_amount": "0",
|
1714
|
+
# "filled_amount": "0.00015484",
|
1715
|
+
# "filled_value": "9.9965849816"
|
1716
|
+
# }
|
1717
|
+
#
|
1718
|
+
# Spot, Margin and Swap trigger createOrder, createOrders, editOrder
|
1799
1719
|
#
|
1800
1720
|
# {
|
1801
1721
|
# "stop_id": 117180138153
|
1802
1722
|
# }
|
1803
1723
|
#
|
1804
|
-
# Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder
|
1724
|
+
# Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder, fetchOpenOrders, fetchClosedOrders
|
1805
1725
|
#
|
1806
1726
|
# {
|
1807
1727
|
# "amount": "0.0001",
|
@@ -1826,7 +1746,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1826
1746
|
# "updated_at": 1714116769986
|
1827
1747
|
# }
|
1828
1748
|
#
|
1829
|
-
# Swap stopLossPrice and takeProfitPrice createOrder
|
1749
|
+
# Swap stopLossPrice and takeProfitPrice createOrder
|
1830
1750
|
#
|
1831
1751
|
# {
|
1832
1752
|
# "adl_level": 1,
|
@@ -1861,25 +1781,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1861
1781
|
# "updated_at": 1714119054559
|
1862
1782
|
# }
|
1863
1783
|
#
|
1864
|
-
# Swap
|
1865
|
-
#
|
1866
|
-
# {
|
1867
|
-
# "amount": "0.0001",
|
1868
|
-
# "client_id": "x-167673045-a7d7714c6478acf6",
|
1869
|
-
# "created_at": 1714187923820,
|
1870
|
-
# "market": "BTCUSDT",
|
1871
|
-
# "market_type": "FUTURES",
|
1872
|
-
# "price": "61000",
|
1873
|
-
# "side": "buy",
|
1874
|
-
# "stop_id": 136984426097,
|
1875
|
-
# "trigger_direction": "higher",
|
1876
|
-
# "trigger_price": "62000",
|
1877
|
-
# "trigger_price_type": "latest_price",
|
1878
|
-
# "type": "limit",
|
1879
|
-
# "updated_at": 1714187974363
|
1880
|
-
# }
|
1881
|
-
#
|
1882
|
-
# Swap fetchOrder v2
|
1784
|
+
# Swap fetchOrder
|
1883
1785
|
#
|
1884
1786
|
# {
|
1885
1787
|
# "amount": "0.0001",
|
@@ -1905,7 +1807,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1905
1807
|
# "updated_at": 1714460987164
|
1906
1808
|
# }
|
1907
1809
|
#
|
1908
|
-
# Spot and Margin fetchOrder
|
1810
|
+
# Spot and Margin fetchOrder
|
1909
1811
|
#
|
1910
1812
|
# {
|
1911
1813
|
# "amount": "0.0001",
|
@@ -1932,77 +1834,94 @@ class coinex(Exchange, ImplicitAPI):
|
|
1932
1834
|
# "updated_at": 1714461638958
|
1933
1835
|
# }
|
1934
1836
|
#
|
1837
|
+
# Swap trigger fetchOpenOrders, fetchClosedOrders - Spot and Swap trigger cancelOrders, cancelOrder
|
1838
|
+
#
|
1839
|
+
# {
|
1840
|
+
# "amount": "0.0001",
|
1841
|
+
# "client_id": "x-167673045-a7d7714c6478acf6",
|
1842
|
+
# "created_at": 1714187923820,
|
1843
|
+
# "market": "BTCUSDT",
|
1844
|
+
# "market_type": "FUTURES",
|
1845
|
+
# "price": "61000",
|
1846
|
+
# "side": "buy",
|
1847
|
+
# "stop_id": 136984426097,
|
1848
|
+
# "trigger_direction": "higher",
|
1849
|
+
# "trigger_price": "62000",
|
1850
|
+
# "trigger_price_type": "latest_price",
|
1851
|
+
# "type": "limit",
|
1852
|
+
# "updated_at": 1714187974363
|
1853
|
+
# }
|
1854
|
+
#
|
1855
|
+
# Spot and Margin trigger fetchOpenOrders, fetchClosedOrders
|
1856
|
+
#
|
1857
|
+
# {
|
1858
|
+
# "stop_id": 117586439530,
|
1859
|
+
# "market": "BTCUSDT",
|
1860
|
+
# "market_type": "SPOT",
|
1861
|
+
# "ccy": "BTC",
|
1862
|
+
# "side": "buy",
|
1863
|
+
# "type": "limit",
|
1864
|
+
# "amount": "0.0001",
|
1865
|
+
# "price": "51000",
|
1866
|
+
# "trigger_price": "52000",
|
1867
|
+
# "trigger_direction": "higher",
|
1868
|
+
# "trigger_price_type": "mark_price",
|
1869
|
+
# "client_id": "x-167673045-df61777094c69312",
|
1870
|
+
# "created_at": 1714551237335,
|
1871
|
+
# "updated_at": 1714551237335
|
1872
|
+
# }
|
1873
|
+
#
|
1935
1874
|
rawStatus = self.safe_string(order, 'status')
|
1936
|
-
timestamp = self.
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
if update is None:
|
1941
|
-
update = self.safe_integer(order, 'updated_at')
|
1875
|
+
timestamp = self.safe_integer(order, 'created_at')
|
1876
|
+
updatedTimestamp = self.safe_integer(order, 'updated_at')
|
1877
|
+
if updatedTimestamp == 0:
|
1878
|
+
updatedTimestamp = timestamp
|
1942
1879
|
marketId = self.safe_string(order, 'market')
|
1943
1880
|
defaultType = self.safe_string(self.options, 'defaultType')
|
1944
|
-
orderType =
|
1945
|
-
|
1946
|
-
|
1881
|
+
orderType = self.safe_string_lower(order, 'market_type', defaultType)
|
1882
|
+
if orderType == 'futures':
|
1883
|
+
orderType = 'swap'
|
1884
|
+
marketType = 'swap' if (orderType == 'swap') else 'spot'
|
1885
|
+
market = self.safe_market(marketId, market, None, marketType)
|
1886
|
+
feeCurrencyId = self.safe_string(order, 'fee_ccy')
|
1947
1887
|
feeCurrency = self.safe_currency_code(feeCurrencyId)
|
1948
1888
|
if feeCurrency is None:
|
1949
1889
|
feeCurrency = market['quote']
|
1950
|
-
|
1951
|
-
|
1952
|
-
side: Str = None
|
1953
|
-
if rawIntegerSide == 1:
|
1954
|
-
side = 'sell'
|
1955
|
-
elif rawIntegerSide == 2:
|
1890
|
+
side = self.safe_string(order, 'side')
|
1891
|
+
if side == 'long':
|
1956
1892
|
side = 'buy'
|
1957
|
-
elif
|
1958
|
-
side =
|
1959
|
-
else:
|
1960
|
-
side = self.safe_string(order, 'type')
|
1961
|
-
rawType = self.safe_string(order, 'order_type')
|
1962
|
-
type: Str = None
|
1963
|
-
if rawType is None:
|
1964
|
-
typeInteger = self.safe_integer(order, 'type')
|
1965
|
-
typeString = self.safe_string(order, 'type')
|
1966
|
-
if typeInteger == 1:
|
1967
|
-
type = 'limit'
|
1968
|
-
elif typeInteger == 2:
|
1969
|
-
type = 'market'
|
1970
|
-
elif (typeString == 'limit') or (typeString == 'market'):
|
1971
|
-
type = typeString
|
1972
|
-
elif typeString == 'maker_only':
|
1973
|
-
type = 'limit'
|
1974
|
-
else:
|
1975
|
-
type = rawType
|
1893
|
+
elif side == 'short':
|
1894
|
+
side = 'sell'
|
1976
1895
|
clientOrderId = self.safe_string(order, 'client_id')
|
1977
1896
|
if clientOrderId == '':
|
1978
1897
|
clientOrderId = None
|
1979
1898
|
return self.safe_order({
|
1980
|
-
'id': self.safe_string_n(order, ['
|
1899
|
+
'id': self.safe_string_n(order, ['position_id', 'order_id', 'stop_id']),
|
1981
1900
|
'clientOrderId': clientOrderId,
|
1982
1901
|
'datetime': self.iso8601(timestamp),
|
1983
1902
|
'timestamp': timestamp,
|
1984
|
-
'lastTradeTimestamp':
|
1903
|
+
'lastTradeTimestamp': updatedTimestamp,
|
1985
1904
|
'status': self.parse_order_status(rawStatus),
|
1986
1905
|
'symbol': market['symbol'],
|
1987
|
-
'type': type,
|
1906
|
+
'type': self.safe_string(order, 'type'),
|
1988
1907
|
'timeInForce': None,
|
1989
1908
|
'postOnly': None,
|
1990
1909
|
'reduceOnly': None,
|
1991
1910
|
'side': side,
|
1992
1911
|
'price': self.safe_string(order, 'price'),
|
1993
|
-
'stopPrice': self.
|
1994
|
-
'triggerPrice': self.
|
1912
|
+
'stopPrice': self.safe_string(order, 'trigger_price'),
|
1913
|
+
'triggerPrice': self.safe_string(order, 'trigger_price'),
|
1995
1914
|
'takeProfitPrice': self.safe_number(order, 'take_profit_price'),
|
1996
1915
|
'stopLossPrice': self.safe_number(order, 'stop_loss_price'),
|
1997
|
-
'cost': self.
|
1998
|
-
'average': self.
|
1916
|
+
'cost': self.safe_string(order, 'filled_value'),
|
1917
|
+
'average': self.safe_string(order, 'avg_entry_price'),
|
1999
1918
|
'amount': self.safe_string(order, 'amount'),
|
2000
|
-
'filled': self.
|
2001
|
-
'remaining': self.
|
1919
|
+
'filled': self.safe_string(order, 'filled_amount'),
|
1920
|
+
'remaining': self.safe_string(order, 'unfilled_amount'),
|
2002
1921
|
'trades': None,
|
2003
1922
|
'fee': {
|
2004
1923
|
'currency': feeCurrency,
|
2005
|
-
'cost': self.
|
1924
|
+
'cost': self.safe_string_2(order, 'quote_fee', 'fee'),
|
2006
1925
|
},
|
2007
1926
|
'info': order,
|
2008
1927
|
}, market)
|
@@ -3138,7 +3057,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
3138
3057
|
#
|
3139
3058
|
else:
|
3140
3059
|
marginMode = None
|
3141
|
-
marginMode, params = self.handle_margin_mode_and_params('
|
3060
|
+
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
3142
3061
|
if marginMode is not None:
|
3143
3062
|
request['market_type'] = 'MARGIN'
|
3144
3063
|
else:
|
@@ -3234,224 +3153,318 @@ class coinex(Exchange, ImplicitAPI):
|
|
3234
3153
|
return self.parse_order(data, market)
|
3235
3154
|
|
3236
3155
|
async def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
3156
|
+
"""
|
3157
|
+
fetch a list of orders
|
3158
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
|
3159
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
|
3160
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
|
3161
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
|
3162
|
+
:param str symbol: unified market symbol of the market orders were made in
|
3163
|
+
:param int [since]: the earliest time in ms to fetch orders for
|
3164
|
+
:param int [limit]: the maximum number of order structures to retrieve
|
3165
|
+
:param boolean [params.trigger]: set to True for fetching trigger orders
|
3166
|
+
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
|
3167
|
+
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3168
|
+
"""
|
3237
3169
|
await self.load_markets()
|
3238
|
-
|
3239
|
-
request = {
|
3240
|
-
'limit': limit,
|
3241
|
-
# 'page': 1, # SPOT
|
3242
|
-
# 'offset': 0, # SWAP
|
3243
|
-
# 'side': 0, # SWAP, 0: All, 1: Sell, 2: Buy
|
3244
|
-
}
|
3245
|
-
stop = self.safe_value(params, 'stop')
|
3246
|
-
side = self.safe_integer(params, 'side')
|
3247
|
-
params = self.omit(params, 'stop')
|
3170
|
+
request = {}
|
3248
3171
|
market = None
|
3249
3172
|
if symbol is not None:
|
3250
3173
|
market = self.market(symbol)
|
3251
3174
|
request['market'] = market['id']
|
3252
|
-
|
3253
|
-
|
3254
|
-
|
3255
|
-
|
3256
|
-
|
3257
|
-
|
3258
|
-
raise BadRequest(self.id + ' fetchOpenOrders() and fetchClosedOrders() require an account_id parameter for margin orders')
|
3259
|
-
request['account_id'] = accountId
|
3260
|
-
params = self.omit(query, 'account_id')
|
3175
|
+
if limit is not None:
|
3176
|
+
request['limit'] = limit
|
3177
|
+
stop = self.safe_bool_2(params, 'stop', 'trigger')
|
3178
|
+
params = self.omit(params, ['stop', 'trigger'])
|
3179
|
+
marketType = None
|
3180
|
+
marketType, params = self.handle_market_type_and_params('fetchOrdersByStatus', market, params)
|
3261
3181
|
response = None
|
3182
|
+
isClosed = (status == 'finished') or (status == 'closed')
|
3183
|
+
isOpen = (status == 'pending') or (status == 'open')
|
3262
3184
|
if marketType == 'swap':
|
3263
|
-
|
3264
|
-
|
3265
|
-
|
3266
|
-
|
3267
|
-
|
3268
|
-
|
3269
|
-
|
3270
|
-
|
3271
|
-
|
3272
|
-
|
3273
|
-
|
3274
|
-
|
3275
|
-
|
3276
|
-
|
3185
|
+
request['market_type'] = 'FUTURES'
|
3186
|
+
if isClosed:
|
3187
|
+
if stop:
|
3188
|
+
response = await self.v2PrivateGetFuturesFinishedStopOrder(self.extend(request, params))
|
3189
|
+
#
|
3190
|
+
# {
|
3191
|
+
# "code": 0,
|
3192
|
+
# "data": [
|
3193
|
+
# {
|
3194
|
+
# "stop_id": 52431158859,
|
3195
|
+
# "market": "BTCUSDT",
|
3196
|
+
# "market_type": "FUTURES",
|
3197
|
+
# "side": "sell",
|
3198
|
+
# "type": "market",
|
3199
|
+
# "amount": "0.0005",
|
3200
|
+
# "price": "20599.64",
|
3201
|
+
# "client_id": "",
|
3202
|
+
# "created_at": 1667547909856,
|
3203
|
+
# "updated_at": 1667547909856,
|
3204
|
+
# "trigger_price": "20599.64",
|
3205
|
+
# "trigger_price_type": "latest_price",
|
3206
|
+
# "trigger_direction": ""
|
3207
|
+
# },
|
3208
|
+
# ],
|
3209
|
+
# "message": "OK",
|
3210
|
+
# "pagination": {
|
3211
|
+
# "has_next": False
|
3212
|
+
# }
|
3213
|
+
# }
|
3214
|
+
#
|
3215
|
+
else:
|
3216
|
+
response = await self.v2PrivateGetFuturesFinishedOrder(self.extend(request, params))
|
3217
|
+
#
|
3218
|
+
# {
|
3219
|
+
# "code": 0,
|
3220
|
+
# "data": [
|
3221
|
+
# {
|
3222
|
+
# "order_id": 136915813578,
|
3223
|
+
# "market": "BTCUSDT",
|
3224
|
+
# "market_type": "FUTURES",
|
3225
|
+
# "side": "sell",
|
3226
|
+
# "type": "market",
|
3227
|
+
# "amount": "0.0001",
|
3228
|
+
# "price": "0",
|
3229
|
+
# "client_id": "x-167673045-4f264600c432ac06",
|
3230
|
+
# "created_at": 1714119323764,
|
3231
|
+
# "updated_at": 1714119323764,
|
3232
|
+
# "unfilled_amount": "0",
|
3233
|
+
# "filled_amount": "0.0001",
|
3234
|
+
# "filled_value": "6.442017",
|
3235
|
+
# "fee": "0.003221",
|
3236
|
+
# "fee_ccy": "USDT",
|
3237
|
+
# "maker_fee_rate": "0",
|
3238
|
+
# "taker_fee_rate": "0.0005"
|
3239
|
+
# },
|
3240
|
+
# ],
|
3241
|
+
# "message": "OK",
|
3242
|
+
# "pagination": {
|
3243
|
+
# "has_next": False
|
3244
|
+
# }
|
3245
|
+
# }
|
3246
|
+
#
|
3247
|
+
elif isOpen:
|
3248
|
+
if stop:
|
3249
|
+
response = await self.v2PrivateGetFuturesPendingStopOrder(self.extend(request, params))
|
3250
|
+
#
|
3251
|
+
# {
|
3252
|
+
# "code": 0,
|
3253
|
+
# "data": [
|
3254
|
+
# {
|
3255
|
+
# "stop_id": 137481469849,
|
3256
|
+
# "market": "BTCUSDT",
|
3257
|
+
# "market_type": "FUTURES",
|
3258
|
+
# "side": "buy",
|
3259
|
+
# "type": "limit",
|
3260
|
+
# "amount": "0.0001",
|
3261
|
+
# "price": "51000",
|
3262
|
+
# "client_id": "x-167673045-2b932341949fa2a1",
|
3263
|
+
# "created_at": 1714552257876,
|
3264
|
+
# "updated_at": 1714552257876,
|
3265
|
+
# "trigger_price": "52000",
|
3266
|
+
# "trigger_price_type": "latest_price",
|
3267
|
+
# "trigger_direction": "higher"
|
3268
|
+
# }
|
3269
|
+
# ],
|
3270
|
+
# "message": "OK",
|
3271
|
+
# "pagination": {
|
3272
|
+
# "total": 1,
|
3273
|
+
# "has_next": False
|
3274
|
+
# }
|
3275
|
+
# }
|
3276
|
+
#
|
3277
|
+
else:
|
3278
|
+
response = await self.v2PrivateGetFuturesPendingOrder(self.extend(request, params))
|
3279
|
+
#
|
3280
|
+
# {
|
3281
|
+
# "code": 0,
|
3282
|
+
# "data": [
|
3283
|
+
# {
|
3284
|
+
# "order_id": 137480580906,
|
3285
|
+
# "market": "BTCUSDT",
|
3286
|
+
# "market_type": "FUTURES",
|
3287
|
+
# "side": "buy",
|
3288
|
+
# "type": "limit",
|
3289
|
+
# "amount": "0.0001",
|
3290
|
+
# "price": "51000",
|
3291
|
+
# "client_id": "",
|
3292
|
+
# "created_at": 1714551877569,
|
3293
|
+
# "updated_at": 1714551877569,
|
3294
|
+
# "unfilled_amount": "0.0001",
|
3295
|
+
# "filled_amount": "0",
|
3296
|
+
# "filled_value": "0",
|
3297
|
+
# "fee": "0",
|
3298
|
+
# "fee_ccy": "USDT",
|
3299
|
+
# "maker_fee_rate": "0.0003",
|
3300
|
+
# "taker_fee_rate": "0.0005",
|
3301
|
+
# "last_filled_amount": "0",
|
3302
|
+
# "last_filled_price": "0",
|
3303
|
+
# "realized_pnl": "0"
|
3304
|
+
# }
|
3305
|
+
# ],
|
3306
|
+
# "message": "OK",
|
3307
|
+
# "pagination": {
|
3308
|
+
# "total": 1,
|
3309
|
+
# "has_next": False
|
3310
|
+
# }
|
3311
|
+
# }
|
3312
|
+
#
|
3277
3313
|
else:
|
3278
|
-
|
3279
|
-
|
3314
|
+
marginMode = None
|
3315
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchOrdersByStatus', params)
|
3316
|
+
if marginMode is not None:
|
3317
|
+
request['market_type'] = 'MARGIN'
|
3318
|
+
else:
|
3319
|
+
request['market_type'] = 'SPOT'
|
3320
|
+
if isClosed:
|
3280
3321
|
if stop:
|
3281
|
-
response = await self.
|
3322
|
+
response = await self.v2PrivateGetSpotFinishedStopOrder(self.extend(request, params))
|
3323
|
+
#
|
3324
|
+
# {
|
3325
|
+
# "code": 0,
|
3326
|
+
# "data": [
|
3327
|
+
# {
|
3328
|
+
# "stop_id": 117654881420,
|
3329
|
+
# "market": "BTCUSDT",
|
3330
|
+
# "market_type": "SPOT",
|
3331
|
+
# "ccy": "USDT",
|
3332
|
+
# "side": "buy",
|
3333
|
+
# "type": "market",
|
3334
|
+
# "amount": "5.83325524",
|
3335
|
+
# "price": "0",
|
3336
|
+
# "trigger_price": "57418",
|
3337
|
+
# "trigger_direction": "lower",
|
3338
|
+
# "trigger_price_type": "mark_price",
|
3339
|
+
# "client_id": "",
|
3340
|
+
# "created_at": 1714618050597,
|
3341
|
+
# "updated_at": 0
|
3342
|
+
# }
|
3343
|
+
# ],
|
3344
|
+
# "message": "OK",
|
3345
|
+
# "pagination": {
|
3346
|
+
# "has_next": False
|
3347
|
+
# }
|
3348
|
+
# }
|
3349
|
+
#
|
3282
3350
|
else:
|
3283
|
-
response = await self.
|
3351
|
+
response = await self.v2PrivateGetSpotFinishedOrder(self.extend(request, params))
|
3352
|
+
#
|
3353
|
+
# {
|
3354
|
+
# "code": 0,
|
3355
|
+
# "data": [
|
3356
|
+
# {
|
3357
|
+
# "order_id": 117180532345,
|
3358
|
+
# "market": "BTCUSDT",
|
3359
|
+
# "market_type": "SPOT",
|
3360
|
+
# "side": "sell",
|
3361
|
+
# "type": "market",
|
3362
|
+
# "ccy": "BTC",
|
3363
|
+
# "amount": "0.00015484",
|
3364
|
+
# "price": "0",
|
3365
|
+
# "client_id": "",
|
3366
|
+
# "created_at": 1714116494219,
|
3367
|
+
# "updated_at": 0,
|
3368
|
+
# "base_fee": "0",
|
3369
|
+
# "quote_fee": "0.0199931699632",
|
3370
|
+
# "discount_fee": "0",
|
3371
|
+
# "maker_fee_rate": "0",
|
3372
|
+
# "taker_fee_rate": "0.002",
|
3373
|
+
# "unfilled_amount": "0",
|
3374
|
+
# "filled_amount": "0.00015484",
|
3375
|
+
# "filled_value": "9.9965849816"
|
3376
|
+
# },
|
3377
|
+
# ],
|
3378
|
+
# "message": "OK",
|
3379
|
+
# "pagination": {
|
3380
|
+
# "has_next": False
|
3381
|
+
# }
|
3382
|
+
# }
|
3383
|
+
#
|
3284
3384
|
elif status == 'pending':
|
3285
3385
|
if stop:
|
3286
|
-
response = await self.
|
3386
|
+
response = await self.v2PrivateGetSpotPendingStopOrder(self.extend(request, params))
|
3387
|
+
#
|
3388
|
+
# {
|
3389
|
+
# "code": 0,
|
3390
|
+
# "data": [
|
3391
|
+
# {
|
3392
|
+
# "stop_id": 117586439530,
|
3393
|
+
# "market": "BTCUSDT",
|
3394
|
+
# "market_type": "SPOT",
|
3395
|
+
# "ccy": "BTC",
|
3396
|
+
# "side": "buy",
|
3397
|
+
# "type": "limit",
|
3398
|
+
# "amount": "0.0001",
|
3399
|
+
# "price": "51000",
|
3400
|
+
# "trigger_price": "52000",
|
3401
|
+
# "trigger_direction": "higher",
|
3402
|
+
# "trigger_price_type": "mark_price",
|
3403
|
+
# "client_id": "x-167673045-df61777094c69312",
|
3404
|
+
# "created_at": 1714551237335,
|
3405
|
+
# "updated_at": 1714551237335
|
3406
|
+
# }
|
3407
|
+
# ],
|
3408
|
+
# "message": "OK",
|
3409
|
+
# "pagination": {
|
3410
|
+
# "total": 1,
|
3411
|
+
# "has_next": False
|
3412
|
+
# }
|
3413
|
+
# }
|
3414
|
+
#
|
3287
3415
|
else:
|
3288
|
-
response = await self.
|
3289
|
-
|
3290
|
-
|
3291
|
-
|
3292
|
-
|
3293
|
-
|
3294
|
-
|
3295
|
-
|
3296
|
-
|
3297
|
-
|
3298
|
-
|
3299
|
-
|
3300
|
-
|
3301
|
-
|
3302
|
-
|
3303
|
-
|
3304
|
-
|
3305
|
-
|
3306
|
-
|
3307
|
-
|
3308
|
-
|
3309
|
-
|
3310
|
-
|
3311
|
-
|
3312
|
-
|
3313
|
-
|
3314
|
-
|
3315
|
-
|
3316
|
-
|
3317
|
-
|
3318
|
-
|
3319
|
-
|
3320
|
-
|
3321
|
-
|
3322
|
-
|
3323
|
-
|
3324
|
-
|
3325
|
-
|
3326
|
-
# },
|
3327
|
-
# "message": "Success"
|
3328
|
-
# }
|
3329
|
-
#
|
3330
|
-
# Swap
|
3331
|
-
#
|
3332
|
-
# {
|
3333
|
-
# "code": 0,
|
3334
|
-
# "data": {
|
3335
|
-
# "limit": 100,
|
3336
|
-
# "offset": 0,
|
3337
|
-
# "records": [
|
3338
|
-
# {
|
3339
|
-
# "amount": "0.0005",
|
3340
|
-
# "client_id": "",
|
3341
|
-
# "create_time": 1651030414.088431,
|
3342
|
-
# "deal_asset_fee": "0",
|
3343
|
-
# "deal_fee": "0.00960069",
|
3344
|
-
# "deal_profit": "0.009825",
|
3345
|
-
# "deal_stock": "19.20138",
|
3346
|
-
# "effect_type": 0,
|
3347
|
-
# "fee_asset": "",
|
3348
|
-
# "fee_discount": "0",
|
3349
|
-
# "left": "0",
|
3350
|
-
# "leverage": "3",
|
3351
|
-
# "maker_fee": "0",
|
3352
|
-
# "market": "BTCUSDT",
|
3353
|
-
# "order_id": 18253447431,
|
3354
|
-
# "position_id": 0,
|
3355
|
-
# "position_type": 1,
|
3356
|
-
# "price": "0",
|
3357
|
-
# "side": 1,
|
3358
|
-
# "source": "web",
|
3359
|
-
# "stop_id": 0,
|
3360
|
-
# "taker_fee": "0.0005",
|
3361
|
-
# "target": 0,
|
3362
|
-
# "type": 2,
|
3363
|
-
# "update_time": 1651030414.08847,
|
3364
|
-
# "user_id": 3620173
|
3365
|
-
# },
|
3366
|
-
# ]
|
3367
|
-
# },
|
3368
|
-
# "message": "OK"
|
3369
|
-
# }
|
3370
|
-
#
|
3371
|
-
# Spot and Margin Stop
|
3372
|
-
#
|
3373
|
-
# {
|
3374
|
-
# "code": 0,
|
3375
|
-
# "data": {
|
3376
|
-
# "count": 1,
|
3377
|
-
# "curr_page": 1,
|
3378
|
-
# "data": [
|
3379
|
-
# {
|
3380
|
-
# "account_id": 0,
|
3381
|
-
# "amount": "155",
|
3382
|
-
# "client_id": "",
|
3383
|
-
# "create_time": 1651089182,
|
3384
|
-
# "fee_asset": null,
|
3385
|
-
# "fee_discount": "1",
|
3386
|
-
# "maker_fee": "0.002",
|
3387
|
-
# "market": "BTCUSDT",
|
3388
|
-
# "order_id": 74660111965,
|
3389
|
-
# "order_type": "market",
|
3390
|
-
# "price": "0",
|
3391
|
-
# "state": 0,
|
3392
|
-
# "stop_price": "31500",
|
3393
|
-
# "taker_fee": "0.002",
|
3394
|
-
# "type": "buy"
|
3395
|
-
# }
|
3396
|
-
# ],
|
3397
|
-
# "has_next": False,
|
3398
|
-
# "total": 0
|
3399
|
-
# },
|
3400
|
-
# "message": "Success"
|
3401
|
-
# }
|
3402
|
-
#
|
3403
|
-
# Swap Stop
|
3404
|
-
#
|
3405
|
-
# {
|
3406
|
-
# "code": 0,
|
3407
|
-
# "data": {
|
3408
|
-
# "limit": 100,
|
3409
|
-
# "offset": 0,
|
3410
|
-
# "records": [
|
3411
|
-
# {
|
3412
|
-
# "amount": "0.0005",
|
3413
|
-
# "client_id": "",
|
3414
|
-
# "create_time": 1651089147.321691,
|
3415
|
-
# "effect_type": 1,
|
3416
|
-
# "fee_asset": "",
|
3417
|
-
# "fee_discount": "0.00000000000000000000",
|
3418
|
-
# "maker_fee": "0.00030",
|
3419
|
-
# "market": "BTCUSDT",
|
3420
|
-
# "order_id": 18332143848,
|
3421
|
-
# "price": "31000.00",
|
3422
|
-
# "side": 2,
|
3423
|
-
# "source": "api.v1",
|
3424
|
-
# "state": 1,
|
3425
|
-
# "stop_price": "31500.00",
|
3426
|
-
# "stop_type": 1,
|
3427
|
-
# "taker_fee": "0.00050",
|
3428
|
-
# "target": 0,
|
3429
|
-
# "type": 1,
|
3430
|
-
# "update_time": 1651089147.321691,
|
3431
|
-
# "user_id": 3620173
|
3432
|
-
# }
|
3433
|
-
# ],
|
3434
|
-
# "total": 1
|
3435
|
-
# },
|
3436
|
-
# "message": "OK"
|
3437
|
-
# }
|
3438
|
-
#
|
3439
|
-
tradeRequest = 'records' if (marketType == 'swap') else 'data'
|
3440
|
-
data = self.safe_value(response, 'data')
|
3441
|
-
orders = self.safe_list(data, tradeRequest, [])
|
3442
|
-
return self.parse_orders(orders, market, since, limit)
|
3416
|
+
response = await self.v2PrivateGetSpotPendingOrder(self.extend(request, params))
|
3417
|
+
#
|
3418
|
+
# {
|
3419
|
+
# "code": 0,
|
3420
|
+
# "data": [
|
3421
|
+
# {
|
3422
|
+
# "order_id": 117585921297,
|
3423
|
+
# "market": "BTCUSDT",
|
3424
|
+
# "market_type": "SPOT",
|
3425
|
+
# "side": "buy",
|
3426
|
+
# "type": "limit",
|
3427
|
+
# "ccy": "BTC",
|
3428
|
+
# "amount": "0.00011793",
|
3429
|
+
# "price": "52000",
|
3430
|
+
# "client_id": "",
|
3431
|
+
# "created_at": 1714550707486,
|
3432
|
+
# "updated_at": 1714550707486,
|
3433
|
+
# "base_fee": "0",
|
3434
|
+
# "quote_fee": "0",
|
3435
|
+
# "discount_fee": "0",
|
3436
|
+
# "maker_fee_rate": "0.002",
|
3437
|
+
# "taker_fee_rate": "0.002",
|
3438
|
+
# "last_fill_amount": "0",
|
3439
|
+
# "last_fill_price": "0",
|
3440
|
+
# "unfilled_amount": "0.00011793",
|
3441
|
+
# "filled_amount": "0",
|
3442
|
+
# "filled_value": "0"
|
3443
|
+
# }
|
3444
|
+
# ],
|
3445
|
+
# "message": "OK",
|
3446
|
+
# "pagination": {
|
3447
|
+
# "total": 1,
|
3448
|
+
# "has_next": False
|
3449
|
+
# }
|
3450
|
+
# }
|
3451
|
+
#
|
3452
|
+
data = self.safe_list(response, 'data', [])
|
3453
|
+
return self.parse_orders(data, market, since, limit)
|
3443
3454
|
|
3444
3455
|
async def fetch_open_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
3445
3456
|
"""
|
3446
3457
|
fetch all unfilled currently open orders
|
3447
|
-
:see: https://
|
3448
|
-
:see: https://
|
3449
|
-
:see: https://
|
3450
|
-
:see: https://
|
3458
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-order
|
3459
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-pending-stop-order
|
3460
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-order
|
3461
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-pending-stop-order
|
3451
3462
|
:param str symbol: unified market symbol
|
3452
3463
|
:param int [since]: the earliest time in ms to fetch open orders for
|
3453
|
-
:param int [limit]: the maximum number of
|
3464
|
+
:param int [limit]: the maximum number of open order structures to retrieve
|
3454
3465
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3466
|
+
:param boolean [params.trigger]: set to True for fetching trigger orders
|
3467
|
+
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
|
3455
3468
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3456
3469
|
"""
|
3457
3470
|
return await self.fetch_orders_by_status('pending', symbol, since, limit, params)
|
@@ -3459,13 +3472,15 @@ class coinex(Exchange, ImplicitAPI):
|
|
3459
3472
|
async def fetch_closed_orders(self, symbol: Str = None, since: Int = None, limit: Int = None, params={}) -> List[Order]:
|
3460
3473
|
"""
|
3461
3474
|
fetches information on multiple closed orders made by the user
|
3462
|
-
:see: https://
|
3463
|
-
:see: https://
|
3464
|
-
:see: https://
|
3475
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-order
|
3476
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/list-finished-stop-order
|
3477
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-order
|
3478
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/list-finished-stop-order
|
3465
3479
|
:param str symbol: unified market symbol of the market orders were made in
|
3466
3480
|
:param int [since]: the earliest time in ms to fetch orders for
|
3467
3481
|
:param int [limit]: the maximum number of order structures to retrieve
|
3468
|
-
:param
|
3482
|
+
:param boolean [params.trigger]: set to True for fetching trigger orders
|
3483
|
+
:param str [params.marginMode]: 'cross' or 'isolated' for fetching spot margin orders
|
3469
3484
|
:returns Order[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3470
3485
|
"""
|
3471
3486
|
return await self.fetch_orders_by_status('finished', symbol, since, limit, params)
|
@@ -5734,6 +5749,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
5734
5749
|
preparedString += nonce + self.secret
|
5735
5750
|
signature = self.hash(self.encode(preparedString), 'sha256')
|
5736
5751
|
headers = {
|
5752
|
+
'Content-Type': 'application/json; charset=utf-8',
|
5753
|
+
'Accept': 'application/json',
|
5737
5754
|
'X-COINEX-KEY': self.apiKey,
|
5738
5755
|
'X-COINEX-SIGN': signature,
|
5739
5756
|
'X-COINEX-TIMESTAMP': nonce,
|