ccxt 4.3.11__py2.py3-none-any.whl → 4.3.13__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/abstract/bybit.py +1 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bigone.py +22 -22
- ccxt/async_support/binance.py +7 -7
- ccxt/async_support/bingx.py +2 -2
- ccxt/async_support/bitget.py +10 -8
- ccxt/async_support/bitmart.py +7 -11
- ccxt/async_support/bitmex.py +2 -2
- ccxt/async_support/bybit.py +76 -65
- ccxt/async_support/coinbase.py +8 -8
- ccxt/async_support/coinbaseinternational.py +2 -2
- ccxt/async_support/coinex.py +501 -445
- ccxt/async_support/coinlist.py +12 -12
- ccxt/async_support/coinmetro.py +2 -2
- ccxt/async_support/cryptocom.py +16 -16
- ccxt/async_support/digifinex.py +3 -3
- ccxt/async_support/gate.py +2 -2
- ccxt/async_support/hitbtc.py +3 -3
- ccxt/async_support/htx.py +6 -9
- ccxt/async_support/indodax.py +2 -2
- ccxt/async_support/kraken.py +3 -1
- ccxt/async_support/kucoin.py +4 -4
- ccxt/async_support/kucoinfutures.py +6 -6
- ccxt/async_support/mexc.py +5 -5
- ccxt/async_support/okx.py +9 -9
- ccxt/async_support/poloniexfutures.py +4 -4
- ccxt/async_support/probit.py +2 -2
- ccxt/async_support/whitebit.py +72 -1
- ccxt/async_support/woo.py +2 -2
- ccxt/base/exchange.py +14 -2
- ccxt/base/types.py +25 -0
- ccxt/bigone.py +22 -22
- ccxt/binance.py +7 -7
- ccxt/bingx.py +2 -2
- ccxt/bitget.py +10 -8
- ccxt/bitmart.py +7 -11
- ccxt/bitmex.py +2 -2
- ccxt/bybit.py +76 -65
- ccxt/coinbase.py +8 -8
- ccxt/coinbaseinternational.py +2 -2
- ccxt/coinex.py +501 -445
- ccxt/coinlist.py +12 -12
- ccxt/coinmetro.py +2 -2
- ccxt/cryptocom.py +16 -16
- ccxt/digifinex.py +3 -3
- ccxt/gate.py +2 -2
- ccxt/hitbtc.py +3 -3
- ccxt/htx.py +6 -9
- ccxt/indodax.py +2 -2
- ccxt/kraken.py +3 -1
- ccxt/kucoin.py +4 -4
- ccxt/kucoinfutures.py +6 -6
- ccxt/mexc.py +5 -5
- ccxt/okx.py +9 -9
- ccxt/poloniexfutures.py +4 -4
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitget.py +139 -87
- ccxt/pro/bybit.py +192 -12
- ccxt/pro/coinbase.py +90 -20
- ccxt/pro/mexc.py +21 -1
- ccxt/probit.py +2 -2
- ccxt/test/base/test_datetime.py +6 -0
- ccxt/test/base/test_ledger_entry.py +2 -2
- ccxt/whitebit.py +72 -1
- ccxt/woo.py +2 -2
- {ccxt-4.3.11.dist-info → ccxt-4.3.13.dist-info}/METADATA +4 -4
- {ccxt-4.3.11.dist-info → ccxt-4.3.13.dist-info}/RECORD +71 -73
- ccxt/async_support/flowbtc.py +0 -34
- ccxt/flowbtc.py +0 -34
- {ccxt-4.3.11.dist-info → ccxt-4.3.13.dist-info}/WHEEL +0 -0
- {ccxt-4.3.11.dist-info → ccxt-4.3.13.dist-info}/top_level.txt +0 -0
ccxt/async_support/coinex.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.async_support.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.coinex import ImplicitAPI
|
8
8
|
import asyncio
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, Int, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, Int, IsolatedBorrowRate, IsolatedBorrowRates, Leverage, Leverages, MarginModification, Market, Num, Order, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
10
10
|
from typing import List
|
11
11
|
from ccxt.base.errors import ExchangeError
|
12
12
|
from ccxt.base.errors import AuthenticationError
|
@@ -1664,121 +1664,6 @@ class coinex(Exchange, ImplicitAPI):
|
|
1664
1664
|
return self.safe_string(statuses, status, status)
|
1665
1665
|
|
1666
1666
|
def parse_order(self, order, market: Market = None) -> Order:
|
1667
|
-
#
|
1668
|
-
# fetchOrder
|
1669
|
-
#
|
1670
|
-
# {
|
1671
|
-
# "amount": "0.1",
|
1672
|
-
# "asset_fee": "0.22736197736197736197",
|
1673
|
-
# "avg_price": "196.85000000000000000000",
|
1674
|
-
# "create_time": 1537270135,
|
1675
|
-
# "deal_amount": "0.1",
|
1676
|
-
# "deal_fee": "0",
|
1677
|
-
# "deal_money": "19.685",
|
1678
|
-
# "fee_asset": "CET",
|
1679
|
-
# "fee_discount": "0.5",
|
1680
|
-
# "id": 1788259447,
|
1681
|
-
# "left": "0",
|
1682
|
-
# "maker_fee_rate": "0",
|
1683
|
-
# "market": "ETHUSDT",
|
1684
|
-
# "order_type": "limit",
|
1685
|
-
# "price": "170.00000000",
|
1686
|
-
# "status": "done",
|
1687
|
-
# "taker_fee_rate": "0.0005",
|
1688
|
-
# "type": "sell",
|
1689
|
-
# "client_id": "",
|
1690
|
-
# }
|
1691
|
-
#
|
1692
|
-
# Spot and Margin cancelOrder, fetchOrder
|
1693
|
-
#
|
1694
|
-
# {
|
1695
|
-
# "amount":"1.5",
|
1696
|
-
# "asset_fee":"0",
|
1697
|
-
# "avg_price":"0.14208538",
|
1698
|
-
# "client_id":"",
|
1699
|
-
# "create_time":1650993819,
|
1700
|
-
# "deal_amount":"10.55703267",
|
1701
|
-
# "deal_fee":"0.0029999999971787292",
|
1702
|
-
# "deal_money":"1.4999999985893646",
|
1703
|
-
# "fee_asset":null,
|
1704
|
-
# "fee_discount":"1",
|
1705
|
-
# "finished_time":null,
|
1706
|
-
# "id":74556296907,
|
1707
|
-
# "left":"0.0000000014106354",
|
1708
|
-
# "maker_fee_rate":"0",
|
1709
|
-
# "market":"DOGEUSDT",
|
1710
|
-
# "money_fee":"0.0029999999971787292",
|
1711
|
-
# "order_type":"market",
|
1712
|
-
# "price":"0",
|
1713
|
-
# "status":"done",
|
1714
|
-
# "stock_fee":"0",
|
1715
|
-
# "taker_fee_rate":"0.002",
|
1716
|
-
# "type":"buy"
|
1717
|
-
# "client_id": "",
|
1718
|
-
# }
|
1719
|
-
#
|
1720
|
-
# Swap cancelOrder, fetchOrder
|
1721
|
-
#
|
1722
|
-
# {
|
1723
|
-
# "amount": "0.0005",
|
1724
|
-
# "client_id": "",
|
1725
|
-
# "create_time": 1651004578.618224,
|
1726
|
-
# "deal_asset_fee": "0.00000000000000000000",
|
1727
|
-
# "deal_fee": "0.00000000000000000000",
|
1728
|
-
# "deal_profit": "0.00000000000000000000",
|
1729
|
-
# "deal_stock": "0.00000000000000000000",
|
1730
|
-
# "effect_type": 1,
|
1731
|
-
# "fee_asset": "",
|
1732
|
-
# "fee_discount": "0.00000000000000000000",
|
1733
|
-
# "last_deal_amount": "0.00000000000000000000",
|
1734
|
-
# "last_deal_id": 0,
|
1735
|
-
# "last_deal_price": "0.00000000000000000000",
|
1736
|
-
# "last_deal_role": 0,
|
1737
|
-
# "last_deal_time": 0,
|
1738
|
-
# "last_deal_type": 0,
|
1739
|
-
# "left": "0.0005",
|
1740
|
-
# "leverage": "3",
|
1741
|
-
# "maker_fee": "0.00030",
|
1742
|
-
# "market": "BTCUSDT",
|
1743
|
-
# "order_id": 18221659097,
|
1744
|
-
# "position_id": 0,
|
1745
|
-
# "position_type": 1,
|
1746
|
-
# "price": "30000.00",
|
1747
|
-
# "side": 2,
|
1748
|
-
# "source": "api.v1",
|
1749
|
-
# "stop_id": 0,
|
1750
|
-
# "taker_fee": "0.00050",
|
1751
|
-
# "target": 0,
|
1752
|
-
# "type": 1,
|
1753
|
-
# "update_time": 1651004578.618224,
|
1754
|
-
# "user_id": 3620173
|
1755
|
-
# }
|
1756
|
-
#
|
1757
|
-
# Swap Stop cancelOrder, fetchOrder
|
1758
|
-
#
|
1759
|
-
# {
|
1760
|
-
# "amount": "0.0005",
|
1761
|
-
# "client_id": "",
|
1762
|
-
# "create_time": 1651034023.008771,
|
1763
|
-
# "effect_type": 1,
|
1764
|
-
# "fee_asset": "",
|
1765
|
-
# "fee_discount": "0.00000000000000000000",
|
1766
|
-
# "maker_fee": "0.00030",
|
1767
|
-
# "market": "BTCUSDT",
|
1768
|
-
# "order_id": 18256915101,
|
1769
|
-
# "price": "31000.00",
|
1770
|
-
# "side": 2,
|
1771
|
-
# "source": "api.v1",
|
1772
|
-
# "state": 1,
|
1773
|
-
# "stop_price": "31500.00",
|
1774
|
-
# "stop_type": 1,
|
1775
|
-
# "taker_fee": "0.00050",
|
1776
|
-
# "target": 0,
|
1777
|
-
# "type": 1,
|
1778
|
-
# "update_time": 1651034397.193624,
|
1779
|
-
# "user_id": 3620173
|
1780
|
-
# }
|
1781
|
-
#
|
1782
1667
|
#
|
1783
1668
|
# Spot and Margin fetchOpenOrders, fetchClosedOrders
|
1784
1669
|
#
|
@@ -1884,7 +1769,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1884
1769
|
# "user_id": 3620173
|
1885
1770
|
# }
|
1886
1771
|
#
|
1887
|
-
# Spot and Margin createOrder, createOrders, cancelOrders v2
|
1772
|
+
# Spot and Margin createOrder, createOrders, editOrder, cancelOrders, cancelOrder v2
|
1888
1773
|
#
|
1889
1774
|
# {
|
1890
1775
|
# "amount": "0.0001",
|
@@ -1910,13 +1795,13 @@ class coinex(Exchange, ImplicitAPI):
|
|
1910
1795
|
# "updated_at": 1714114386250
|
1911
1796
|
# }
|
1912
1797
|
#
|
1913
|
-
# Spot, Margin and Swap trigger createOrder, createOrders v2
|
1798
|
+
# Spot, Margin and Swap trigger createOrder, createOrders, editOrder v2
|
1914
1799
|
#
|
1915
1800
|
# {
|
1916
1801
|
# "stop_id": 117180138153
|
1917
1802
|
# }
|
1918
1803
|
#
|
1919
|
-
# Swap createOrder, createOrders, cancelOrders v2
|
1804
|
+
# Swap createOrder, createOrders, editOrder, cancelOrders, cancelOrder v2
|
1920
1805
|
#
|
1921
1806
|
# {
|
1922
1807
|
# "amount": "0.0001",
|
@@ -1976,7 +1861,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1976
1861
|
# "updated_at": 1714119054559
|
1977
1862
|
# }
|
1978
1863
|
#
|
1979
|
-
# Swap and Spot stop cancelOrders v2
|
1864
|
+
# Swap and Spot stop cancelOrders, cancelOrder v2
|
1980
1865
|
#
|
1981
1866
|
# {
|
1982
1867
|
# "amount": "0.0001",
|
@@ -1994,6 +1879,59 @@ class coinex(Exchange, ImplicitAPI):
|
|
1994
1879
|
# "updated_at": 1714187974363
|
1995
1880
|
# }
|
1996
1881
|
#
|
1882
|
+
# Swap fetchOrder v2
|
1883
|
+
#
|
1884
|
+
# {
|
1885
|
+
# "amount": "0.0001",
|
1886
|
+
# "client_id": "x-167673045-da5f31dcd478a829",
|
1887
|
+
# "created_at": 1714460987164,
|
1888
|
+
# "fee": "0",
|
1889
|
+
# "fee_ccy": "USDT",
|
1890
|
+
# "filled_amount": "0",
|
1891
|
+
# "filled_value": "0",
|
1892
|
+
# "last_filled_amount": "0",
|
1893
|
+
# "last_filled_price": "0",
|
1894
|
+
# "maker_fee_rate": "0.0003",
|
1895
|
+
# "market": "BTCUSDT",
|
1896
|
+
# "market_type": "FUTURES",
|
1897
|
+
# "order_id": 137319868771,
|
1898
|
+
# "price": "61000",
|
1899
|
+
# "realized_pnl": "0",
|
1900
|
+
# "side": "buy",
|
1901
|
+
# "status": "open",
|
1902
|
+
# "taker_fee_rate": "0.0005",
|
1903
|
+
# "type": "limit",
|
1904
|
+
# "unfilled_amount": "0.0001",
|
1905
|
+
# "updated_at": 1714460987164
|
1906
|
+
# }
|
1907
|
+
#
|
1908
|
+
# Spot and Margin fetchOrder v2
|
1909
|
+
#
|
1910
|
+
# {
|
1911
|
+
# "amount": "0.0001",
|
1912
|
+
# "base_fee": "0",
|
1913
|
+
# "ccy": "BTC",
|
1914
|
+
# "client_id": "x-167673045-da918d6724e3af81",
|
1915
|
+
# "created_at": 1714461638958,
|
1916
|
+
# "discount_fee": "0",
|
1917
|
+
# "filled_amount": "0",
|
1918
|
+
# "filled_value": "0",
|
1919
|
+
# "last_fill_amount": "0",
|
1920
|
+
# "last_fill_price": "0",
|
1921
|
+
# "maker_fee_rate": "0.002",
|
1922
|
+
# "market": "BTCUSDT",
|
1923
|
+
# "market_type": "SPOT",
|
1924
|
+
# "order_id": 117492012985,
|
1925
|
+
# "price": "61000",
|
1926
|
+
# "quote_fee": "0",
|
1927
|
+
# "side": "buy",
|
1928
|
+
# "status": "open",
|
1929
|
+
# "taker_fee_rate": "0.002",
|
1930
|
+
# "type": "limit",
|
1931
|
+
# "unfilled_amount": "0.0001",
|
1932
|
+
# "updated_at": 1714461638958
|
1933
|
+
# }
|
1934
|
+
#
|
1997
1935
|
rawStatus = self.safe_string(order, 'status')
|
1998
1936
|
timestamp = self.safe_timestamp(order, 'create_time')
|
1999
1937
|
if timestamp is None:
|
@@ -2599,7 +2537,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
2599
2537
|
:param str[] ids: order ids
|
2600
2538
|
:param str symbol: unified market symbol
|
2601
2539
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2602
|
-
:param boolean [params.
|
2540
|
+
:param boolean [params.trigger]: set to True for canceling stop orders
|
2603
2541
|
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2604
2542
|
"""
|
2605
2543
|
if symbol is None:
|
@@ -2763,7 +2701,10 @@ class coinex(Exchange, ImplicitAPI):
|
|
2763
2701
|
async def edit_order(self, id: str, symbol: str, type: OrderType, side: OrderSide, amount: Num = None, price: Num = None, params={}):
|
2764
2702
|
"""
|
2765
2703
|
edit a trade order
|
2766
|
-
:see: https://
|
2704
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/edit-order
|
2705
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/edit-stop-order
|
2706
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/edit-order
|
2707
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/edit-stop-order
|
2767
2708
|
:param str id: order id
|
2768
2709
|
:param str symbol: unified symbol of the market to create an order in
|
2769
2710
|
:param str type: 'market' or 'limit'
|
@@ -2771,282 +2712,448 @@ class coinex(Exchange, ImplicitAPI):
|
|
2771
2712
|
:param float amount: how much of the currency you want to trade in units of the base currency
|
2772
2713
|
:param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
|
2773
2714
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2715
|
+
:param float [params.triggerPrice]: the price to trigger stop orders
|
2774
2716
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2775
2717
|
"""
|
2776
2718
|
if symbol is None:
|
2777
2719
|
raise ArgumentsRequired(self.id + ' editOrder() requires a symbol argument')
|
2778
2720
|
await self.load_markets()
|
2779
2721
|
market = self.market(symbol)
|
2780
|
-
if not market['spot']:
|
2781
|
-
raise NotSupported(self.id + ' editOrder() does not support ' + market['type'] + ' orders, only spot orders are accepted')
|
2782
2722
|
request = {
|
2783
2723
|
'market': market['id'],
|
2784
|
-
'id': int(id),
|
2785
2724
|
}
|
2786
2725
|
if amount is not None:
|
2787
2726
|
request['amount'] = self.amount_to_precision(symbol, amount)
|
2788
2727
|
if price is not None:
|
2789
2728
|
request['price'] = self.price_to_precision(symbol, price)
|
2790
|
-
response =
|
2791
|
-
|
2792
|
-
|
2793
|
-
|
2794
|
-
|
2795
|
-
|
2796
|
-
|
2797
|
-
|
2798
|
-
|
2799
|
-
|
2800
|
-
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2807
|
-
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
|
2814
|
-
|
2815
|
-
|
2816
|
-
|
2817
|
-
|
2818
|
-
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2729
|
+
response = None
|
2730
|
+
triggerPrice = self.safe_string_n(params, ['stopPrice', 'triggerPrice', 'trigger_price'])
|
2731
|
+
params = self.omit(params, ['stopPrice', 'triggerPrice'])
|
2732
|
+
isTriggerOrder = triggerPrice is not None
|
2733
|
+
if isTriggerOrder:
|
2734
|
+
request['trigger_price'] = self.price_to_precision(symbol, triggerPrice)
|
2735
|
+
request['stop_id'] = self.parse_to_numeric(id)
|
2736
|
+
else:
|
2737
|
+
request['order_id'] = self.parse_to_numeric(id)
|
2738
|
+
marginMode = None
|
2739
|
+
marginMode, params = self.handle_margin_mode_and_params('editOrder', params)
|
2740
|
+
if market['spot']:
|
2741
|
+
if marginMode is not None:
|
2742
|
+
request['market_type'] = 'MARGIN'
|
2743
|
+
else:
|
2744
|
+
request['market_type'] = 'SPOT'
|
2745
|
+
if isTriggerOrder:
|
2746
|
+
response = await self.v2PrivatePostSpotModifyStopOrder(self.extend(request, params))
|
2747
|
+
#
|
2748
|
+
# {
|
2749
|
+
# "code": 0,
|
2750
|
+
# "data": {
|
2751
|
+
# "stop_id": 117337235167
|
2752
|
+
# },
|
2753
|
+
# "message": "OK"
|
2754
|
+
# }
|
2755
|
+
#
|
2756
|
+
else:
|
2757
|
+
response = await self.v2PrivatePostSpotModifyOrder(self.extend(request, params))
|
2758
|
+
#
|
2759
|
+
# {
|
2760
|
+
# "code": 0,
|
2761
|
+
# "data": {
|
2762
|
+
# "amount": "0.0001",
|
2763
|
+
# "base_fee": "0",
|
2764
|
+
# "ccy": "BTC",
|
2765
|
+
# "client_id": "x-167673045-87eb2bebf42882d8",
|
2766
|
+
# "created_at": 1714290302047,
|
2767
|
+
# "discount_fee": "0",
|
2768
|
+
# "filled_amount": "0",
|
2769
|
+
# "filled_value": "0",
|
2770
|
+
# "last_fill_amount": "0",
|
2771
|
+
# "last_fill_price": "0",
|
2772
|
+
# "maker_fee_rate": "0.002",
|
2773
|
+
# "market": "BTCUSDT",
|
2774
|
+
# "market_type": "SPOT",
|
2775
|
+
# "order_id": 117336922195,
|
2776
|
+
# "price": "61000",
|
2777
|
+
# "quote_fee": "0",
|
2778
|
+
# "side": "buy",
|
2779
|
+
# "status": "open",
|
2780
|
+
# "taker_fee_rate": "0.002",
|
2781
|
+
# "type": "limit",
|
2782
|
+
# "unfilled_amount": "0.0001",
|
2783
|
+
# "updated_at": 1714290191141
|
2784
|
+
# },
|
2785
|
+
# "message": "OK"
|
2786
|
+
# }
|
2787
|
+
#
|
2788
|
+
else:
|
2789
|
+
request['market_type'] = 'FUTURES'
|
2790
|
+
if isTriggerOrder:
|
2791
|
+
response = await self.v2PrivatePostFuturesModifyStopOrder(self.extend(request, params))
|
2792
|
+
#
|
2793
|
+
# {
|
2794
|
+
# "code": 0,
|
2795
|
+
# "data": {
|
2796
|
+
# "stop_id": 137091875605
|
2797
|
+
# },
|
2798
|
+
# "message": "OK"
|
2799
|
+
# }
|
2800
|
+
#
|
2801
|
+
else:
|
2802
|
+
response = await self.v2PrivatePostFuturesModifyOrder(self.extend(request, params))
|
2803
|
+
#
|
2804
|
+
# {
|
2805
|
+
# "code": 0,
|
2806
|
+
# "data": {
|
2807
|
+
# "amount": "0.0001",
|
2808
|
+
# "client_id": "x-167673045-3f2d09191462b207",
|
2809
|
+
# "created_at": 1714290927630,
|
2810
|
+
# "fee": "0",
|
2811
|
+
# "fee_ccy": "USDT",
|
2812
|
+
# "filled_amount": "0",
|
2813
|
+
# "filled_value": "0",
|
2814
|
+
# "last_filled_amount": "0",
|
2815
|
+
# "last_filled_price": "0",
|
2816
|
+
# "maker_fee_rate": "0.0003",
|
2817
|
+
# "market": "BTCUSDT",
|
2818
|
+
# "market_type": "FUTURES",
|
2819
|
+
# "order_id": 137091566717,
|
2820
|
+
# "price": "61000",
|
2821
|
+
# "realized_pnl": "0",
|
2822
|
+
# "side": "buy",
|
2823
|
+
# "taker_fee_rate": "0.0005",
|
2824
|
+
# "type": "limit",
|
2825
|
+
# "unfilled_amount": "0.0001",
|
2826
|
+
# "updated_at": 1714290927630
|
2827
|
+
# },
|
2828
|
+
# "message": "OK"
|
2829
|
+
# }
|
2830
|
+
#
|
2822
2831
|
data = self.safe_dict(response, 'data', {})
|
2823
2832
|
return self.parse_order(data, market)
|
2824
2833
|
|
2825
2834
|
async def cancel_order(self, id: str, symbol: Str = None, params={}):
|
2826
2835
|
"""
|
2827
2836
|
cancels an open order
|
2828
|
-
:see: https://
|
2829
|
-
:see: https://
|
2830
|
-
:see: https://
|
2831
|
-
:see: https://
|
2832
|
-
:see: https://
|
2833
|
-
:see: https://
|
2834
|
-
:see: https://
|
2835
|
-
:see: https://
|
2837
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order
|
2838
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order
|
2839
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-order-by-client-id
|
2840
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-stop-order-by-client-id
|
2841
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order
|
2842
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order
|
2843
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-order-by-client-id
|
2844
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-stop-order-by-client-id
|
2836
2845
|
:param str id: order id
|
2837
2846
|
:param str symbol: unified symbol of the market the order was made in
|
2838
2847
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2839
2848
|
:param str [params.clientOrderId]: client order id, defaults to id if not passed
|
2840
|
-
:param boolean [params.
|
2841
|
-
:returns dict:
|
2849
|
+
:param boolean [params.trigger]: set to True for canceling a trigger order
|
2850
|
+
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2842
2851
|
"""
|
2843
2852
|
if symbol is None:
|
2844
2853
|
raise ArgumentsRequired(self.id + ' cancelOrder() requires a symbol argument')
|
2845
2854
|
await self.load_markets()
|
2846
2855
|
market = self.market(symbol)
|
2847
|
-
|
2856
|
+
isTriggerOrder = self.safe_bool_2(params, 'stop', 'trigger')
|
2848
2857
|
swap = market['swap']
|
2849
2858
|
request = {
|
2850
2859
|
'market': market['id'],
|
2851
2860
|
}
|
2852
|
-
accountId = self.safe_integer(params, 'account_id')
|
2853
2861
|
marginMode = None
|
2854
2862
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
|
2863
|
+
if swap:
|
2864
|
+
request['market_type'] = 'FUTURES'
|
2865
|
+
else:
|
2866
|
+
if marginMode is not None:
|
2867
|
+
request['market_type'] = 'MARGIN'
|
2868
|
+
else:
|
2869
|
+
request['market_type'] = 'SPOT'
|
2855
2870
|
clientOrderId = self.safe_string_2(params, 'client_id', 'clientOrderId')
|
2856
|
-
|
2857
|
-
if accountId is None:
|
2858
|
-
raise BadRequest(self.id + ' cancelOrder() requires an account_id parameter for margin orders')
|
2859
|
-
request['account_id'] = accountId
|
2860
|
-
query = self.omit(params, ['stop', 'account_id', 'clientOrderId'])
|
2871
|
+
params = self.omit(params, ['stop', 'trigger', 'clientOrderId'])
|
2861
2872
|
response = None
|
2862
2873
|
if clientOrderId is not None:
|
2863
2874
|
request['client_id'] = clientOrderId
|
2864
|
-
if
|
2875
|
+
if isTriggerOrder:
|
2865
2876
|
if swap:
|
2866
|
-
response = await self.
|
2877
|
+
response = await self.v2PrivatePostFuturesCancelStopOrderByClientId(self.extend(request, params))
|
2878
|
+
# {
|
2879
|
+
# "code": 0,
|
2880
|
+
# "data": [
|
2881
|
+
# {
|
2882
|
+
# "code": 0,
|
2883
|
+
# "data": {
|
2884
|
+
# "amount": "0.0001",
|
2885
|
+
# "client_id": "client01",
|
2886
|
+
# "created_at": 1714368624473,
|
2887
|
+
# "market": "BTCUSDT",
|
2888
|
+
# "market_type": "FUTURES",
|
2889
|
+
# "price": "61000",
|
2890
|
+
# "side": "buy",
|
2891
|
+
# "stop_id": 137175823891,
|
2892
|
+
# "trigger_direction": "higher",
|
2893
|
+
# "trigger_price": "61500",
|
2894
|
+
# "trigger_price_type": "latest_price",
|
2895
|
+
# "type": "limit",
|
2896
|
+
# "updated_at": 1714368661444
|
2897
|
+
# },
|
2898
|
+
# "message": ""
|
2899
|
+
# }
|
2900
|
+
# ],
|
2901
|
+
# "message": "OK"
|
2902
|
+
# }
|
2867
2903
|
else:
|
2868
|
-
response = await self.
|
2904
|
+
response = await self.v2PrivatePostSpotCancelStopOrderByClientId(self.extend(request, params))
|
2905
|
+
# {
|
2906
|
+
# "code" :0,
|
2907
|
+
# "data": [
|
2908
|
+
# {
|
2909
|
+
# "code": 0,
|
2910
|
+
# "data": {
|
2911
|
+
# "amount": "0.0001",
|
2912
|
+
# "ccy": "BTC",
|
2913
|
+
# "client_id": "client01",
|
2914
|
+
# "created_at": 1714366950279,
|
2915
|
+
# "market": "BTCUSDT",
|
2916
|
+
# "market_type": "SPOT",
|
2917
|
+
# "price": "61000",
|
2918
|
+
# "side": "buy",
|
2919
|
+
# "stop_id": 117402512706,
|
2920
|
+
# "trigger_direction": "higher",
|
2921
|
+
# "trigger_price": "61500",
|
2922
|
+
# "trigger_price_type": "mark_price",
|
2923
|
+
# "type": "limit",
|
2924
|
+
# "updated_at": 1714366950279
|
2925
|
+
# },
|
2926
|
+
# "message": "OK"
|
2927
|
+
# }
|
2928
|
+
# ],
|
2929
|
+
# "message": "OK"
|
2930
|
+
# }
|
2869
2931
|
else:
|
2870
2932
|
if swap:
|
2871
|
-
response = await self.
|
2933
|
+
response = await self.v2PrivatePostFuturesCancelOrderByClientId(self.extend(request, params))
|
2934
|
+
# {
|
2935
|
+
# "code": 0,
|
2936
|
+
# "data": [
|
2937
|
+
# {
|
2938
|
+
# "code": 0,
|
2939
|
+
# "data": {
|
2940
|
+
# "amount": "0.0001",
|
2941
|
+
# "client_id": "x-167673045-bf60e24bb437a3df",
|
2942
|
+
# "created_at": 1714368416437,
|
2943
|
+
# "fee": "0",
|
2944
|
+
# "fee_ccy": "USDT",
|
2945
|
+
# "filled_amount": "0",
|
2946
|
+
# "filled_value": "0",
|
2947
|
+
# "last_filled_amount": "0",
|
2948
|
+
# "last_filled_price": "0",
|
2949
|
+
# "maker_fee_rate": "0.0003",
|
2950
|
+
# "market": "BTCUSDT",
|
2951
|
+
# "market_type": "FUTURES",
|
2952
|
+
# "order_id": 137175616437,
|
2953
|
+
# "price": "61000",
|
2954
|
+
# "realized_pnl": "0",
|
2955
|
+
# "side": "buy",
|
2956
|
+
# "taker_fee_rate": "0.0005",
|
2957
|
+
# "type": "limit",
|
2958
|
+
# "unfilled_amount": "0.0001",
|
2959
|
+
# "updated_at": 1714368507174
|
2960
|
+
# },
|
2961
|
+
# "message": ""
|
2962
|
+
# }
|
2963
|
+
# ],
|
2964
|
+
# "message": "OK"
|
2965
|
+
# }
|
2872
2966
|
else:
|
2873
|
-
response = await self.
|
2967
|
+
response = await self.v2PrivatePostSpotCancelOrderByClientId(self.extend(request, params))
|
2968
|
+
# {
|
2969
|
+
# "code": 0,
|
2970
|
+
# "data": [
|
2971
|
+
# {
|
2972
|
+
# "code": 0,
|
2973
|
+
# "data": {
|
2974
|
+
# "amount": "0.0001",
|
2975
|
+
# "base_fee": "0",
|
2976
|
+
# "ccy": "BTC",
|
2977
|
+
# "client_id": "x-167673045-d49eaca5f412afc8",
|
2978
|
+
# "created_at": 1714366502807,
|
2979
|
+
# "discount_fee": "0",
|
2980
|
+
# "filled_amount": "0",
|
2981
|
+
# "filled_value": "0",
|
2982
|
+
# "last_fill_amount": "0",
|
2983
|
+
# "last_fill_price": "0",
|
2984
|
+
# "maker_fee_rate": "0.002",
|
2985
|
+
# "market": "BTCUSDT",
|
2986
|
+
# "market_type": "SPOT",
|
2987
|
+
# "order_id": 117402157490,
|
2988
|
+
# "price": "61000",
|
2989
|
+
# "quote_fee": "0",
|
2990
|
+
# "side": "buy",
|
2991
|
+
# "taker_fee_rate": "0.002",
|
2992
|
+
# "type": "limit",
|
2993
|
+
# "unfilled_amount": "0.0001",
|
2994
|
+
# "updated_at": 1714366502807
|
2995
|
+
# },
|
2996
|
+
# "message": "OK"
|
2997
|
+
# }
|
2998
|
+
# ],
|
2999
|
+
# "message": "OK"
|
3000
|
+
# }
|
2874
3001
|
else:
|
2875
|
-
|
2876
|
-
|
2877
|
-
if stop:
|
3002
|
+
if isTriggerOrder:
|
3003
|
+
request['stop_id'] = self.parse_to_numeric(id)
|
2878
3004
|
if swap:
|
2879
|
-
response = await self.
|
3005
|
+
response = await self.v2PrivatePostFuturesCancelStopOrder(self.extend(request, params))
|
3006
|
+
# {
|
3007
|
+
# "code": 0,
|
3008
|
+
# "data": {
|
3009
|
+
# "amount": "0.0001",
|
3010
|
+
# "ccy": "BTC",
|
3011
|
+
# "client_id": "x-167673045-f21ecfd7542abf1f",
|
3012
|
+
# "created_at": 1714366177334,
|
3013
|
+
# "market": "BTCUSDT",
|
3014
|
+
# "market_type": "SPOT",
|
3015
|
+
# "price": "61000",
|
3016
|
+
# "side": "buy",
|
3017
|
+
# "stop_id": 117401897954,
|
3018
|
+
# "trigger_direction": "higher",
|
3019
|
+
# "trigger_price": "61500",
|
3020
|
+
# "trigger_price_type": "mark_price",
|
3021
|
+
# "type": "limit",
|
3022
|
+
# "updated_at": 1714366177334
|
3023
|
+
# },
|
3024
|
+
# "message": "OK"
|
3025
|
+
# }
|
2880
3026
|
else:
|
2881
|
-
response = await self.
|
3027
|
+
response = await self.v2PrivatePostSpotCancelStopOrder(self.extend(request, params))
|
3028
|
+
# {
|
3029
|
+
# "code": 0,
|
3030
|
+
# "data": {
|
3031
|
+
# "amount": "0.0001",
|
3032
|
+
# "ccy": "BTC",
|
3033
|
+
# "client_id": "x-167673045-f21ecfd7542abf1f",
|
3034
|
+
# "created_at": 1714366177334,
|
3035
|
+
# "market": "BTCUSDT",
|
3036
|
+
# "market_type": "SPOT",
|
3037
|
+
# "price": "61000",
|
3038
|
+
# "side": "buy",
|
3039
|
+
# "stop_id": 117401897954,
|
3040
|
+
# "trigger_direction": "higher",
|
3041
|
+
# "trigger_price": "61500",
|
3042
|
+
# "trigger_price_type": "mark_price",
|
3043
|
+
# "type": "limit",
|
3044
|
+
# "updated_at": 1714366177334
|
3045
|
+
# },
|
3046
|
+
# "message": "OK"
|
3047
|
+
# }
|
2882
3048
|
else:
|
3049
|
+
request['order_id'] = self.parse_to_numeric(id)
|
2883
3050
|
if swap:
|
2884
|
-
response = await self.
|
3051
|
+
response = await self.v2PrivatePostFuturesCancelOrder(self.extend(request, params))
|
3052
|
+
# {
|
3053
|
+
# "code": 0,
|
3054
|
+
# "data": {
|
3055
|
+
# "amount": "0.0001",
|
3056
|
+
# "client_id": "x-167673045-7f14381c74a98a85",
|
3057
|
+
# "created_at": 1714367342024,
|
3058
|
+
# "fee": "0",
|
3059
|
+
# "fee_ccy": "USDT",
|
3060
|
+
# "filled_amount": "0",
|
3061
|
+
# "filled_value": "0",
|
3062
|
+
# "last_filled_amount": "0",
|
3063
|
+
# "last_filled_price": "0",
|
3064
|
+
# "maker_fee_rate": "0.0003",
|
3065
|
+
# "market": "BTCUSDT",
|
3066
|
+
# "market_type": "FUTURES",
|
3067
|
+
# "order_id": 137174472136,
|
3068
|
+
# "price": "61000",
|
3069
|
+
# "realized_pnl": "0",
|
3070
|
+
# "side": "buy",
|
3071
|
+
# "taker_fee_rate": "0.0005",
|
3072
|
+
# "type": "limit",
|
3073
|
+
# "unfilled_amount": "0.0001",
|
3074
|
+
# "updated_at": 1714367515978
|
3075
|
+
# },
|
3076
|
+
# "message": "OK"
|
3077
|
+
# }
|
2885
3078
|
else:
|
2886
|
-
response = await self.
|
2887
|
-
|
2888
|
-
|
2889
|
-
|
2890
|
-
|
2891
|
-
|
2892
|
-
|
2893
|
-
|
2894
|
-
|
2895
|
-
|
2896
|
-
|
2897
|
-
|
2898
|
-
|
2899
|
-
|
2900
|
-
|
2901
|
-
|
2902
|
-
|
2903
|
-
|
2904
|
-
|
2905
|
-
|
2906
|
-
|
2907
|
-
|
2908
|
-
|
2909
|
-
|
2910
|
-
|
2911
|
-
|
2912
|
-
|
2913
|
-
|
2914
|
-
|
2915
|
-
|
2916
|
-
|
2917
|
-
|
2918
|
-
|
2919
|
-
|
2920
|
-
#
|
2921
|
-
# {
|
2922
|
-
# "code": 0,
|
2923
|
-
# "data": {
|
2924
|
-
# "amount": "0.0005",
|
2925
|
-
# "client_id": "",
|
2926
|
-
# "create_time": 1651004578.618224,
|
2927
|
-
# "deal_asset_fee": "0.00000000000000000000",
|
2928
|
-
# "deal_fee": "0.00000000000000000000",
|
2929
|
-
# "deal_profit": "0.00000000000000000000",
|
2930
|
-
# "deal_stock": "0.00000000000000000000",
|
2931
|
-
# "effect_type": 1,
|
2932
|
-
# "fee_asset": "",
|
2933
|
-
# "fee_discount": "0.00000000000000000000",
|
2934
|
-
# "last_deal_amount": "0.00000000000000000000",
|
2935
|
-
# "last_deal_id": 0,
|
2936
|
-
# "last_deal_price": "0.00000000000000000000",
|
2937
|
-
# "last_deal_role": 0,
|
2938
|
-
# "last_deal_time": 0,
|
2939
|
-
# "last_deal_type": 0,
|
2940
|
-
# "left": "0.0005",
|
2941
|
-
# "leverage": "3",
|
2942
|
-
# "maker_fee": "0.00030",
|
2943
|
-
# "market": "BTCUSDT",
|
2944
|
-
# "order_id": 18221659097,
|
2945
|
-
# "position_id": 0,
|
2946
|
-
# "position_type": 1,
|
2947
|
-
# "price": "30000.00",
|
2948
|
-
# "side": 2,
|
2949
|
-
# "source": "api.v1",
|
2950
|
-
# "stop_id": 0,
|
2951
|
-
# "taker_fee": "0.00050",
|
2952
|
-
# "target": 0,
|
2953
|
-
# "type": 1,
|
2954
|
-
# "update_time": 1651004578.618224,
|
2955
|
-
# "user_id": 3620173
|
2956
|
-
# },
|
2957
|
-
# "message": "OK"
|
2958
|
-
# }
|
2959
|
-
#
|
2960
|
-
# Swap Stop
|
2961
|
-
#
|
2962
|
-
# {
|
2963
|
-
# "code": 0,
|
2964
|
-
# "data": {
|
2965
|
-
# "amount": "0.0005",
|
2966
|
-
# "client_id": "",
|
2967
|
-
# "create_time": 1651034023.008771,
|
2968
|
-
# "effect_type": 1,
|
2969
|
-
# "fee_asset": "",
|
2970
|
-
# "fee_discount": "0.00000000000000000000",
|
2971
|
-
# "maker_fee": "0.00030",
|
2972
|
-
# "market": "BTCUSDT",
|
2973
|
-
# "order_id": 18256915101,
|
2974
|
-
# "price": "31000.00",
|
2975
|
-
# "side": 2,
|
2976
|
-
# "source": "api.v1",
|
2977
|
-
# "state": 1,
|
2978
|
-
# "stop_price": "31500.00",
|
2979
|
-
# "stop_type": 1,
|
2980
|
-
# "taker_fee": "0.00050",
|
2981
|
-
# "target": 0,
|
2982
|
-
# "type": 1,
|
2983
|
-
# "update_time": 1651034397.193624,
|
2984
|
-
# "user_id": 3620173
|
2985
|
-
# },
|
2986
|
-
# "message":"OK"
|
2987
|
-
# }
|
2988
|
-
#
|
2989
|
-
# Spot and Margin Stop
|
2990
|
-
#
|
2991
|
-
# {"code":0,"data":{},"message":"Success"}
|
2992
|
-
#
|
2993
|
-
data = self.safe_dict(response, 'data')
|
3079
|
+
response = await self.v2PrivatePostSpotCancelOrder(self.extend(request, params))
|
3080
|
+
# {
|
3081
|
+
# "code": 0,
|
3082
|
+
# "data": {
|
3083
|
+
# "amount": "0.0001",
|
3084
|
+
# "base_fee": "0",
|
3085
|
+
# "ccy": "BTC",
|
3086
|
+
# "client_id": "x-167673045-86fbe37b54a2aea3",
|
3087
|
+
# "created_at": 1714365277437,
|
3088
|
+
# "discount_fee": "0",
|
3089
|
+
# "filled_amount": "0",
|
3090
|
+
# "filled_value": "0",
|
3091
|
+
# "last_fill_amount": "0",
|
3092
|
+
# "last_fill_price": "0",
|
3093
|
+
# "maker_fee_rate": "0.002",
|
3094
|
+
# "market": "BTCUSDT",
|
3095
|
+
# "market_type": "SPOT",
|
3096
|
+
# "order_id": 117401168172,
|
3097
|
+
# "price": "61000",
|
3098
|
+
# "quote_fee": "0",
|
3099
|
+
# "side": "buy",
|
3100
|
+
# "taker_fee_rate": "0.002",
|
3101
|
+
# "type": "limit",
|
3102
|
+
# "unfilled_amount": "0.0001",
|
3103
|
+
# "updated_at": 1714365277437
|
3104
|
+
# },
|
3105
|
+
# "message": "OK"
|
3106
|
+
# }
|
3107
|
+
data = None
|
3108
|
+
if clientOrderId is not None:
|
3109
|
+
rows = self.safe_list(response, 'data', [])
|
3110
|
+
data = self.safe_dict(rows[0], 'data', {})
|
3111
|
+
else:
|
3112
|
+
data = self.safe_dict(response, 'data', {})
|
2994
3113
|
return self.parse_order(data, market)
|
2995
3114
|
|
2996
3115
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
2997
3116
|
"""
|
2998
3117
|
cancel all open orders in a market
|
2999
|
-
:see: https://
|
3000
|
-
:see: https://
|
3001
|
-
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http024_cancel_stop_all
|
3002
|
-
:see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http022_cancel_all
|
3118
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-all-order
|
3119
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-all-order
|
3003
3120
|
:param str symbol: unified market symbol of the market to cancel orders in
|
3004
3121
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3122
|
+
:param str [params.marginMode]: 'cross' or 'isolated' for canceling spot margin orders
|
3005
3123
|
:returns dict[]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
3006
3124
|
"""
|
3007
3125
|
if symbol is None:
|
3008
3126
|
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
3009
3127
|
await self.load_markets()
|
3010
3128
|
market = self.market(symbol)
|
3011
|
-
marketId = market['id']
|
3012
|
-
accountId = self.safe_integer(params, 'account_id', 0)
|
3013
3129
|
request = {
|
3014
|
-
'market':
|
3015
|
-
# '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 >
|
3016
|
-
# 'side': 0, # SWAP, 0: All, 1: Sell, 2: Buy
|
3130
|
+
'market': market['id'],
|
3017
3131
|
}
|
3018
|
-
swap = market['swap']
|
3019
|
-
stop = self.safe_value(params, 'stop')
|
3020
|
-
params = self.omit(params, ['stop', 'account_id'])
|
3021
3132
|
response = None
|
3022
|
-
if swap:
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3133
|
+
if market['swap']:
|
3134
|
+
request['market_type'] = 'FUTURES'
|
3135
|
+
response = await self.v2PrivatePostFuturesCancelAllOrder(self.extend(request, params))
|
3136
|
+
#
|
3137
|
+
# {"code":0,"data":{},"message":"OK"}
|
3138
|
+
#
|
3027
3139
|
else:
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3140
|
+
marginMode = None
|
3141
|
+
marginMode, params = self.handle_margin_mode_and_params('fetchOrdersByStatus', params)
|
3142
|
+
if marginMode is not None:
|
3143
|
+
request['market_type'] = 'MARGIN'
|
3031
3144
|
else:
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
#
|
3038
|
-
# Swap
|
3039
|
-
#
|
3040
|
-
# {"code": 0, "data": {"status":"success"}, "message": "OK"}
|
3041
|
-
#
|
3145
|
+
request['market_type'] = 'SPOT'
|
3146
|
+
response = await self.v2PrivatePostSpotCancelAllOrder(self.extend(request, params))
|
3147
|
+
#
|
3148
|
+
# {"code":0,"data":{},"message":"OK"}
|
3149
|
+
#
|
3042
3150
|
return response
|
3043
3151
|
|
3044
3152
|
async def fetch_order(self, id: str, symbol: Str = None, params={}):
|
3045
3153
|
"""
|
3046
3154
|
fetches information on an order made by the user
|
3047
|
-
:see: https://
|
3048
|
-
:see: https://
|
3049
|
-
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade007_order_status
|
3155
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/get-order-status
|
3156
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/get-order-status
|
3050
3157
|
:param str symbol: unified symbol of the market the order was made in
|
3051
3158
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
3052
3159
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
@@ -3055,123 +3162,75 @@ class coinex(Exchange, ImplicitAPI):
|
|
3055
3162
|
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol argument')
|
3056
3163
|
await self.load_markets()
|
3057
3164
|
market = self.market(symbol)
|
3058
|
-
swap = market['swap']
|
3059
|
-
stop = self.safe_value(params, 'stop')
|
3060
|
-
params = self.omit(params, 'stop')
|
3061
3165
|
request = {
|
3062
3166
|
'market': market['id'],
|
3063
|
-
|
3064
|
-
# 'order_id': id, # SWAP
|
3167
|
+
'order_id': self.parse_to_numeric(id),
|
3065
3168
|
}
|
3066
|
-
idRequest = 'order_id' if swap else 'id'
|
3067
|
-
request[idRequest] = id
|
3068
3169
|
response = None
|
3069
|
-
if swap:
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3073
|
-
|
3170
|
+
if market['swap']:
|
3171
|
+
response = await self.v2PrivateGetFuturesOrderStatus(self.extend(request, params))
|
3172
|
+
#
|
3173
|
+
# {
|
3174
|
+
# "code": 0,
|
3175
|
+
# "data": {
|
3176
|
+
# "amount": "0.0001",
|
3177
|
+
# "client_id": "x-167673045-da5f31dcd478a829",
|
3178
|
+
# "created_at": 1714460987164,
|
3179
|
+
# "fee": "0",
|
3180
|
+
# "fee_ccy": "USDT",
|
3181
|
+
# "filled_amount": "0",
|
3182
|
+
# "filled_value": "0",
|
3183
|
+
# "last_filled_amount": "0",
|
3184
|
+
# "last_filled_price": "0",
|
3185
|
+
# "maker_fee_rate": "0.0003",
|
3186
|
+
# "market": "BTCUSDT",
|
3187
|
+
# "market_type": "FUTURES",
|
3188
|
+
# "order_id": 137319868771,
|
3189
|
+
# "price": "61000",
|
3190
|
+
# "realized_pnl": "0",
|
3191
|
+
# "side": "buy",
|
3192
|
+
# "status": "open",
|
3193
|
+
# "taker_fee_rate": "0.0005",
|
3194
|
+
# "type": "limit",
|
3195
|
+
# "unfilled_amount": "0.0001",
|
3196
|
+
# "updated_at": 1714460987164
|
3197
|
+
# },
|
3198
|
+
# "message": "OK"
|
3199
|
+
# }
|
3200
|
+
#
|
3074
3201
|
else:
|
3075
|
-
response = await self.
|
3076
|
-
|
3077
|
-
|
3078
|
-
|
3079
|
-
|
3080
|
-
|
3081
|
-
|
3082
|
-
|
3083
|
-
|
3084
|
-
|
3085
|
-
|
3086
|
-
|
3087
|
-
|
3088
|
-
|
3089
|
-
|
3090
|
-
|
3091
|
-
|
3092
|
-
|
3093
|
-
|
3094
|
-
|
3095
|
-
|
3096
|
-
|
3097
|
-
|
3098
|
-
|
3099
|
-
|
3100
|
-
|
3101
|
-
|
3102
|
-
|
3103
|
-
|
3104
|
-
|
3105
|
-
|
3106
|
-
|
3107
|
-
# "code": 0,
|
3108
|
-
# "data": {
|
3109
|
-
# "amount": "0.0005",
|
3110
|
-
# "client_id": "",
|
3111
|
-
# "create_time": 1651004578.618224,
|
3112
|
-
# "deal_asset_fee": "0.00000000000000000000",
|
3113
|
-
# "deal_fee": "0.00000000000000000000",
|
3114
|
-
# "deal_profit": "0.00000000000000000000",
|
3115
|
-
# "deal_stock": "0.00000000000000000000",
|
3116
|
-
# "effect_type": 1,
|
3117
|
-
# "fee_asset": "",
|
3118
|
-
# "fee_discount": "0.00000000000000000000",
|
3119
|
-
# "last_deal_amount": "0.00000000000000000000",
|
3120
|
-
# "last_deal_id": 0,
|
3121
|
-
# "last_deal_price": "0.00000000000000000000",
|
3122
|
-
# "last_deal_role": 0,
|
3123
|
-
# "last_deal_time": 0,
|
3124
|
-
# "last_deal_type": 0,
|
3125
|
-
# "left": "0.0005",
|
3126
|
-
# "leverage": "3",
|
3127
|
-
# "maker_fee": "0.00030",
|
3128
|
-
# "market": "BTCUSDT",
|
3129
|
-
# "order_id": 18221659097,
|
3130
|
-
# "position_id": 0,
|
3131
|
-
# "position_type": 1,
|
3132
|
-
# "price": "30000.00",
|
3133
|
-
# "side": 2,
|
3134
|
-
# "source": "api.v1",
|
3135
|
-
# "stop_id": 0,
|
3136
|
-
# "taker_fee": "0.00050",
|
3137
|
-
# "target": 0,
|
3138
|
-
# "type": 1,
|
3139
|
-
# "update_time": 1651004578.618224,
|
3140
|
-
# "user_id": 3620173
|
3141
|
-
# },
|
3142
|
-
# "message": "OK"
|
3143
|
-
# }
|
3144
|
-
#
|
3145
|
-
# Swap Stop
|
3146
|
-
#
|
3147
|
-
# {
|
3148
|
-
# "code": 0,
|
3149
|
-
# "data": {
|
3150
|
-
# "amount": "0.0005",
|
3151
|
-
# "client_id": "",
|
3152
|
-
# "create_time": 1651034023.008771,
|
3153
|
-
# "effect_type": 1,
|
3154
|
-
# "fee_asset": "",
|
3155
|
-
# "fee_discount": "0.00000000000000000000",
|
3156
|
-
# "maker_fee": "0.00030",
|
3157
|
-
# "market": "BTCUSDT",
|
3158
|
-
# "order_id": 18256915101,
|
3159
|
-
# "price": "31000.00",
|
3160
|
-
# "side": 2,
|
3161
|
-
# "source": "api.v1",
|
3162
|
-
# "state": 1,
|
3163
|
-
# "stop_price": "31500.00",
|
3164
|
-
# "stop_type": 1,
|
3165
|
-
# "taker_fee": "0.00050",
|
3166
|
-
# "target": 0,
|
3167
|
-
# "type": 1,
|
3168
|
-
# "update_time": 1651034397.193624,
|
3169
|
-
# "user_id": 3620173
|
3170
|
-
# },
|
3171
|
-
# "message":"OK"
|
3172
|
-
# }
|
3173
|
-
#
|
3174
|
-
data = self.safe_dict(response, 'data')
|
3202
|
+
response = await self.v2PrivateGetSpotOrderStatus(self.extend(request, params))
|
3203
|
+
#
|
3204
|
+
# {
|
3205
|
+
# "code": 0,
|
3206
|
+
# "data": {
|
3207
|
+
# "amount": "0.0001",
|
3208
|
+
# "base_fee": "0",
|
3209
|
+
# "ccy": "BTC",
|
3210
|
+
# "client_id": "x-167673045-da918d6724e3af81",
|
3211
|
+
# "created_at": 1714461638958,
|
3212
|
+
# "discount_fee": "0",
|
3213
|
+
# "filled_amount": "0",
|
3214
|
+
# "filled_value": "0",
|
3215
|
+
# "last_fill_amount": "0",
|
3216
|
+
# "last_fill_price": "0",
|
3217
|
+
# "maker_fee_rate": "0.002",
|
3218
|
+
# "market": "BTCUSDT",
|
3219
|
+
# "market_type": "SPOT",
|
3220
|
+
# "order_id": 117492012985,
|
3221
|
+
# "price": "61000",
|
3222
|
+
# "quote_fee": "0",
|
3223
|
+
# "side": "buy",
|
3224
|
+
# "status": "open",
|
3225
|
+
# "taker_fee_rate": "0.002",
|
3226
|
+
# "type": "limit",
|
3227
|
+
# "unfilled_amount": "0.0001",
|
3228
|
+
# "updated_at": 1714461638958
|
3229
|
+
# },
|
3230
|
+
# "message": "OK"
|
3231
|
+
# }
|
3232
|
+
#
|
3233
|
+
data = self.safe_dict(response, 'data', {})
|
3175
3234
|
return self.parse_order(data, market)
|
3176
3235
|
|
3177
3236
|
async def fetch_orders_by_status(self, status, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
@@ -5080,7 +5139,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5080
5139
|
data = self.safe_value(data, 'data', [])
|
5081
5140
|
return self.parse_transactions(data, currency, since, limit)
|
5082
5141
|
|
5083
|
-
def parse_isolated_borrow_rate(self, info, market: Market = None):
|
5142
|
+
def parse_isolated_borrow_rate(self, info, market: Market = None) -> IsolatedBorrowRate:
|
5084
5143
|
#
|
5085
5144
|
# {
|
5086
5145
|
# "market": "BTCUSDT",
|
@@ -5113,7 +5172,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5113
5172
|
'info': info,
|
5114
5173
|
}
|
5115
5174
|
|
5116
|
-
async def fetch_isolated_borrow_rate(self, symbol: str, params={}):
|
5175
|
+
async def fetch_isolated_borrow_rate(self, symbol: str, params={}) -> IsolatedBorrowRate:
|
5117
5176
|
"""
|
5118
5177
|
fetch the rate of interest to borrow a currency for margin trading
|
5119
5178
|
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
|
@@ -5150,7 +5209,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5150
5209
|
data = self.safe_value(response, 'data', {})
|
5151
5210
|
return self.parse_isolated_borrow_rate(data, market)
|
5152
5211
|
|
5153
|
-
async def fetch_isolated_borrow_rates(self, params={}):
|
5212
|
+
async def fetch_isolated_borrow_rates(self, params={}) -> IsolatedBorrowRates:
|
5154
5213
|
"""
|
5155
5214
|
fetch the borrow interest rates of all currencies
|
5156
5215
|
:see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot002_account007_margin_account_settings
|
@@ -5182,10 +5241,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
5182
5241
|
# }
|
5183
5242
|
#
|
5184
5243
|
data = self.safe_value(response, 'data', [])
|
5185
|
-
|
5186
|
-
for i in range(0, len(data)):
|
5187
|
-
rates.append(self.parse_isolated_borrow_rate(data[i]))
|
5188
|
-
return rates
|
5244
|
+
return self.parse_isolated_borrow_rates(data)
|
5189
5245
|
|
5190
5246
|
async def fetch_borrow_interest(self, code: Str = None, symbol: Str = None, since: Int = None, limit: Int = None, params={}):
|
5191
5247
|
await self.load_markets()
|