ccxt 4.3.9__py2.py3-none-any.whl → 4.3.10__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.
Potentially problematic release.
This version of ccxt might be problematic. Click here for more details.
- ccxt/__init__.py +1 -1
- ccxt/abstract/kucoinfutures.py +2 -0
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/bitget.py +1 -1
- ccxt/async_support/coinex.py +169 -148
- ccxt/async_support/kucoinfutures.py +148 -12
- ccxt/base/exchange.py +4 -4
- ccxt/base/types.py +2 -0
- ccxt/bitget.py +1 -1
- ccxt/coinex.py +169 -148
- ccxt/kucoinfutures.py +148 -12
- ccxt/pro/__init__.py +1 -1
- {ccxt-4.3.9.dist-info → ccxt-4.3.10.dist-info}/METADATA +4 -4
- {ccxt-4.3.9.dist-info → ccxt-4.3.10.dist-info}/RECORD +17 -17
- {ccxt-4.3.9.dist-info → ccxt-4.3.10.dist-info}/WHEEL +0 -0
- {ccxt-4.3.9.dist-info → ccxt-4.3.10.dist-info}/top_level.txt +0 -0
ccxt/coinex.py
CHANGED
@@ -1688,7 +1688,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1688
1688
|
# "client_id": "",
|
1689
1689
|
# }
|
1690
1690
|
#
|
1691
|
-
# Spot and Margin cancelOrder,
|
1691
|
+
# Spot and Margin cancelOrder, fetchOrder
|
1692
1692
|
#
|
1693
1693
|
# {
|
1694
1694
|
# "amount":"1.5",
|
@@ -1883,49 +1883,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1883
1883
|
# "user_id": 3620173
|
1884
1884
|
# }
|
1885
1885
|
#
|
1886
|
-
#
|
1887
|
-
#
|
1888
|
-
# {
|
1889
|
-
# "amount": "0.0005",
|
1890
|
-
# "client_id": "x-167673045-b0cee0c584718b65",
|
1891
|
-
# "create_time": 1701233683.294231,
|
1892
|
-
# "deal_asset_fee": "0.00000000000000000000",
|
1893
|
-
# "deal_fee": "0.00000000000000000000",
|
1894
|
-
# "deal_profit": "0.00000000000000000000",
|
1895
|
-
# "deal_stock": "0.00000000000000000000",
|
1896
|
-
# "effect_type": 1,
|
1897
|
-
# "fee_asset": "",
|
1898
|
-
# "fee_discount": "0.00000000000000000000",
|
1899
|
-
# "last_deal_amount": "0.00000000000000000000",
|
1900
|
-
# "last_deal_id": 0,
|
1901
|
-
# "last_deal_price": "0.00000000000000000000",
|
1902
|
-
# "last_deal_role": 0,
|
1903
|
-
# "last_deal_time": 0,
|
1904
|
-
# "last_deal_type": 0,
|
1905
|
-
# "left": "0.0005",
|
1906
|
-
# "leverage": "3",
|
1907
|
-
# "maker_fee": "0.00030",
|
1908
|
-
# "market": "BTCUSDT",
|
1909
|
-
# "option": 0,
|
1910
|
-
# "order_id": 115940476323,
|
1911
|
-
# "position_id": 0,
|
1912
|
-
# "position_type": 2,
|
1913
|
-
# "price": "25000.00",
|
1914
|
-
# "side": 2,
|
1915
|
-
# "source": "api.v1",
|
1916
|
-
# "stop_id": 0,
|
1917
|
-
# "stop_loss_price": "0.00000000000000000000",
|
1918
|
-
# "stop_loss_type": 0,
|
1919
|
-
# "take_profit_price": "0.00000000000000000000",
|
1920
|
-
# "take_profit_type": 0,
|
1921
|
-
# "taker_fee": "0.00050",
|
1922
|
-
# "target": 0,
|
1923
|
-
# "type": 1,
|
1924
|
-
# "update_time": 1701233721.718884,
|
1925
|
-
# "user_id": 3620173
|
1926
|
-
# }
|
1927
|
-
#
|
1928
|
-
# Spot and Margin createOrder, createOrders v2
|
1886
|
+
# Spot and Margin createOrder, createOrders, cancelOrders v2
|
1929
1887
|
#
|
1930
1888
|
# {
|
1931
1889
|
# "amount": "0.0001",
|
@@ -1957,7 +1915,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1957
1915
|
# "stop_id": 117180138153
|
1958
1916
|
# }
|
1959
1917
|
#
|
1960
|
-
# Swap createOrder, createOrders v2
|
1918
|
+
# Swap createOrder, createOrders, cancelOrders v2
|
1961
1919
|
#
|
1962
1920
|
# {
|
1963
1921
|
# "amount": "0.0001",
|
@@ -2017,6 +1975,24 @@ class coinex(Exchange, ImplicitAPI):
|
|
2017
1975
|
# "updated_at": 1714119054559
|
2018
1976
|
# }
|
2019
1977
|
#
|
1978
|
+
# Swap and Spot stop cancelOrders v2
|
1979
|
+
#
|
1980
|
+
# {
|
1981
|
+
# "amount": "0.0001",
|
1982
|
+
# "client_id": "x-167673045-a7d7714c6478acf6",
|
1983
|
+
# "created_at": 1714187923820,
|
1984
|
+
# "market": "BTCUSDT",
|
1985
|
+
# "market_type": "FUTURES",
|
1986
|
+
# "price": "61000",
|
1987
|
+
# "side": "buy",
|
1988
|
+
# "stop_id": 136984426097,
|
1989
|
+
# "trigger_direction": "higher",
|
1990
|
+
# "trigger_price": "62000",
|
1991
|
+
# "trigger_price_type": "latest_price",
|
1992
|
+
# "type": "limit",
|
1993
|
+
# "updated_at": 1714187974363
|
1994
|
+
# }
|
1995
|
+
#
|
2020
1996
|
rawStatus = self.safe_string(order, 'status')
|
2021
1997
|
timestamp = self.safe_timestamp(order, 'create_time')
|
2022
1998
|
if timestamp is None:
|
@@ -2075,8 +2051,8 @@ class coinex(Exchange, ImplicitAPI):
|
|
2075
2051
|
'reduceOnly': None,
|
2076
2052
|
'side': side,
|
2077
2053
|
'price': self.safe_string(order, 'price'),
|
2078
|
-
'stopPrice': self.
|
2079
|
-
'triggerPrice': self.
|
2054
|
+
'stopPrice': self.safe_string_2(order, 'stop_price', 'trigger_price'),
|
2055
|
+
'triggerPrice': self.safe_string_2(order, 'stop_price', 'trigger_price'),
|
2080
2056
|
'takeProfitPrice': self.safe_number(order, 'take_profit_price'),
|
2081
2057
|
'stopLossPrice': self.safe_number(order, 'stop_loss_price'),
|
2082
2058
|
'cost': self.safe_string_2(order, 'deal_money', 'filled_value'),
|
@@ -2615,11 +2591,14 @@ class coinex(Exchange, ImplicitAPI):
|
|
2615
2591
|
def cancel_orders(self, ids, symbol: Str = None, params={}):
|
2616
2592
|
"""
|
2617
2593
|
cancel multiple orders
|
2618
|
-
:see: https://
|
2619
|
-
:see: https://
|
2594
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
|
2595
|
+
:see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
|
2596
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
|
2597
|
+
:see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
|
2620
2598
|
:param str[] ids: order ids
|
2621
2599
|
:param str symbol: unified market symbol
|
2622
2600
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2601
|
+
:param boolean [params.stop]: set to True for canceling stop orders
|
2623
2602
|
:returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
2624
2603
|
"""
|
2625
2604
|
if symbol is None:
|
@@ -2629,111 +2608,153 @@ class coinex(Exchange, ImplicitAPI):
|
|
2629
2608
|
request = {
|
2630
2609
|
'market': market['id'],
|
2631
2610
|
}
|
2632
|
-
|
2611
|
+
stop = self.safe_bool_2(params, 'stop', 'trigger')
|
2612
|
+
params = self.omit(params, ['stop', 'trigger'])
|
2633
2613
|
response = None
|
2614
|
+
if stop:
|
2615
|
+
request['stop_ids'] = ids
|
2616
|
+
else:
|
2617
|
+
request['order_ids'] = ids
|
2634
2618
|
if market['spot']:
|
2635
|
-
|
2636
|
-
|
2619
|
+
if stop:
|
2620
|
+
response = self.v2PrivatePostSpotCancelBatchStopOrder(self.extend(request, params))
|
2621
|
+
#
|
2622
|
+
# {
|
2623
|
+
# "code": 0,
|
2624
|
+
# "data": [
|
2625
|
+
# {
|
2626
|
+
# "code": 0,
|
2627
|
+
# "data": {
|
2628
|
+
# "amount": "0.0001",
|
2629
|
+
# "ccy": "BTC",
|
2630
|
+
# "client_id": "x-167673045-8e33d6f4a4bcb022",
|
2631
|
+
# "created_at": 1714188827291,
|
2632
|
+
# "market": "BTCUSDT",
|
2633
|
+
# "market_type": "SPOT",
|
2634
|
+
# "price": "61000",
|
2635
|
+
# "side": "buy",
|
2636
|
+
# "stop_id": 117248845854,
|
2637
|
+
# "trigger_direction": "higher",
|
2638
|
+
# "trigger_price": "62000",
|
2639
|
+
# "trigger_price_type": "mark_price",
|
2640
|
+
# "type": "limit",
|
2641
|
+
# "updated_at": 1714188827291
|
2642
|
+
# },
|
2643
|
+
# "message": "OK"
|
2644
|
+
# },
|
2645
|
+
# ],
|
2646
|
+
# "message": "OK"
|
2647
|
+
# }
|
2648
|
+
#
|
2649
|
+
else:
|
2650
|
+
response = self.v2PrivatePostSpotCancelBatchOrder(self.extend(request, params))
|
2651
|
+
#
|
2652
|
+
# {
|
2653
|
+
# "code": 0,
|
2654
|
+
# "data": [
|
2655
|
+
# {
|
2656
|
+
# "code": 0,
|
2657
|
+
# "data": {
|
2658
|
+
# "amount": "0.0001",
|
2659
|
+
# "base_fee": "0",
|
2660
|
+
# "ccy": "BTC",
|
2661
|
+
# "client_id": "x-167673045-c1cc78e5b42d8c4e",
|
2662
|
+
# "created_at": 1714188449497,
|
2663
|
+
# "discount_fee": "0",
|
2664
|
+
# "filled_amount": "0",
|
2665
|
+
# "filled_value": "0",
|
2666
|
+
# "last_fill_amount": "0",
|
2667
|
+
# "last_fill_price": "0",
|
2668
|
+
# "maker_fee_rate": "0.002",
|
2669
|
+
# "market": "BTCUSDT",
|
2670
|
+
# "market_type": "SPOT",
|
2671
|
+
# "order_id": 117248494358,
|
2672
|
+
# "price": "60000",
|
2673
|
+
# "quote_fee": "0",
|
2674
|
+
# "side": "buy",
|
2675
|
+
# "taker_fee_rate": "0.002",
|
2676
|
+
# "type": "limit",
|
2677
|
+
# "unfilled_amount": "0.0001",
|
2678
|
+
# "updated_at": 1714188449497
|
2679
|
+
# },
|
2680
|
+
# "message": ""
|
2681
|
+
# },
|
2682
|
+
# ],
|
2683
|
+
# "message": "OK"
|
2684
|
+
# }
|
2685
|
+
#
|
2637
2686
|
else:
|
2638
|
-
request['
|
2639
|
-
|
2640
|
-
|
2641
|
-
|
2642
|
-
|
2643
|
-
|
2644
|
-
|
2645
|
-
|
2646
|
-
|
2647
|
-
|
2648
|
-
|
2649
|
-
|
2650
|
-
|
2651
|
-
|
2652
|
-
|
2653
|
-
|
2654
|
-
|
2655
|
-
|
2656
|
-
|
2657
|
-
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2661
|
-
|
2662
|
-
|
2663
|
-
|
2664
|
-
|
2665
|
-
|
2666
|
-
|
2667
|
-
|
2668
|
-
|
2669
|
-
|
2670
|
-
|
2671
|
-
|
2672
|
-
|
2673
|
-
|
2674
|
-
|
2675
|
-
|
2676
|
-
|
2677
|
-
|
2678
|
-
|
2679
|
-
|
2680
|
-
|
2681
|
-
|
2682
|
-
|
2683
|
-
|
2684
|
-
|
2685
|
-
|
2686
|
-
|
2687
|
-
|
2688
|
-
|
2689
|
-
|
2690
|
-
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2697
|
-
|
2698
|
-
|
2699
|
-
|
2700
|
-
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
# "leverage": "3",
|
2706
|
-
# "maker_fee": "0.00030",
|
2707
|
-
# "market": "BTCUSDT",
|
2708
|
-
# "option": 0,
|
2709
|
-
# "order_id": 115940476323,
|
2710
|
-
# "position_id": 0,
|
2711
|
-
# "position_type": 2,
|
2712
|
-
# "price": "25000.00",
|
2713
|
-
# "side": 2,
|
2714
|
-
# "source": "api.v1",
|
2715
|
-
# "stop_id": 0,
|
2716
|
-
# "stop_loss_price": "0.00000000000000000000",
|
2717
|
-
# "stop_loss_type": 0,
|
2718
|
-
# "take_profit_price": "0.00000000000000000000",
|
2719
|
-
# "take_profit_type": 0,
|
2720
|
-
# "taker_fee": "0.00050",
|
2721
|
-
# "target": 0,
|
2722
|
-
# "type": 1,
|
2723
|
-
# "update_time": 1701233721.718884,
|
2724
|
-
# "user_id": 3620173
|
2725
|
-
# }
|
2726
|
-
# },
|
2727
|
-
# ],
|
2728
|
-
# "message": "OK"
|
2729
|
-
# }
|
2730
|
-
#
|
2731
|
-
data = self.safe_value(response, 'data', [])
|
2687
|
+
request['market_type'] = 'FUTURES'
|
2688
|
+
if stop:
|
2689
|
+
response = self.v2PrivatePostFuturesCancelBatchStopOrder(self.extend(request, params))
|
2690
|
+
#
|
2691
|
+
# {
|
2692
|
+
# "code": 0,
|
2693
|
+
# "data": [
|
2694
|
+
# {
|
2695
|
+
# "code": 0,
|
2696
|
+
# "data": {
|
2697
|
+
# "amount": "0.0001",
|
2698
|
+
# "client_id": "x-167673045-a7d7714c6478acf6",
|
2699
|
+
# "created_at": 1714187923820,
|
2700
|
+
# "market": "BTCUSDT",
|
2701
|
+
# "market_type": "FUTURES",
|
2702
|
+
# "price": "61000",
|
2703
|
+
# "side": "buy",
|
2704
|
+
# "stop_id": 136984426097,
|
2705
|
+
# "trigger_direction": "higher",
|
2706
|
+
# "trigger_price": "62000",
|
2707
|
+
# "trigger_price_type": "latest_price",
|
2708
|
+
# "type": "limit",
|
2709
|
+
# "updated_at": 1714187974363
|
2710
|
+
# },
|
2711
|
+
# "message": ""
|
2712
|
+
# },
|
2713
|
+
# ],
|
2714
|
+
# "message": "OK"
|
2715
|
+
# }
|
2716
|
+
#
|
2717
|
+
else:
|
2718
|
+
response = self.v2PrivatePostFuturesCancelBatchOrder(self.extend(request, params))
|
2719
|
+
#
|
2720
|
+
# {
|
2721
|
+
# "code": 0,
|
2722
|
+
# "data": [
|
2723
|
+
# {
|
2724
|
+
# "code": 0,
|
2725
|
+
# "data": {
|
2726
|
+
# "amount": "0.0001",
|
2727
|
+
# "client_id": "x-167673045-9f80fde284339a72",
|
2728
|
+
# "created_at": 1714187491784,
|
2729
|
+
# "fee": "0",
|
2730
|
+
# "fee_ccy": "USDT",
|
2731
|
+
# "filled_amount": "0",
|
2732
|
+
# "filled_value": "0",
|
2733
|
+
# "last_filled_amount": "0",
|
2734
|
+
# "last_filled_price": "0",
|
2735
|
+
# "maker_fee_rate": "0.0003",
|
2736
|
+
# "market": "BTCUSDT",
|
2737
|
+
# "market_type": "FUTURES",
|
2738
|
+
# "order_id": 136983851788,
|
2739
|
+
# "price": "61000",
|
2740
|
+
# "realized_pnl": "0",
|
2741
|
+
# "side": "buy",
|
2742
|
+
# "taker_fee_rate": "0.0005",
|
2743
|
+
# "type": "limit",
|
2744
|
+
# "unfilled_amount": "0.0001",
|
2745
|
+
# "updated_at": 1714187567079
|
2746
|
+
# },
|
2747
|
+
# "message": ""
|
2748
|
+
# },
|
2749
|
+
# ],
|
2750
|
+
# "message": "OK"
|
2751
|
+
# }
|
2752
|
+
#
|
2753
|
+
data = self.safe_list(response, 'data', [])
|
2732
2754
|
results = []
|
2733
2755
|
for i in range(0, len(data)):
|
2734
2756
|
entry = data[i]
|
2735
|
-
|
2736
|
-
item = self.safe_value(entry, dataRequest, {})
|
2757
|
+
item = self.safe_dict(entry, 'data', {})
|
2737
2758
|
order = self.parse_order(item, market)
|
2738
2759
|
results.append(order)
|
2739
2760
|
return results
|
ccxt/kucoinfutures.py
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
from ccxt.kucoin import kucoin
|
7
7
|
from ccxt.abstract.kucoinfutures import ImplicitAPI
|
8
|
-
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, Transaction, TransferEntry
|
8
|
+
from ccxt.base.types import Balances, Currency, Int, MarginModification, Market, Num, Order, OrderBook, OrderRequest, OrderSide, OrderType, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, Transaction, TransferEntry
|
9
9
|
from typing import List
|
10
10
|
from ccxt.base.errors import AuthenticationError
|
11
11
|
from ccxt.base.errors import PermissionDenied
|
@@ -94,13 +94,14 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
94
94
|
'fetchPositionHistory': False,
|
95
95
|
'fetchPositionMode': False,
|
96
96
|
'fetchPositions': True,
|
97
|
-
'fetchPositionsHistory':
|
97
|
+
'fetchPositionsHistory': True,
|
98
98
|
'fetchPremiumIndexOHLCV': False,
|
99
99
|
'fetchStatus': True,
|
100
100
|
'fetchTicker': True,
|
101
101
|
'fetchTickers': True,
|
102
102
|
'fetchTime': True,
|
103
103
|
'fetchTrades': True,
|
104
|
+
'fetchTradingFee': True,
|
104
105
|
'fetchTransactionFee': False,
|
105
106
|
'fetchWithdrawals': True,
|
106
107
|
'setLeverage': False,
|
@@ -177,6 +178,8 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
177
178
|
'funding-history': 4.44,
|
178
179
|
'sub/api-key': 1,
|
179
180
|
'trade-statistics': 1,
|
181
|
+
'trade-fees': 1,
|
182
|
+
'history-positions': 1,
|
180
183
|
},
|
181
184
|
'post': {
|
182
185
|
'withdrawals': 1,
|
@@ -1107,6 +1110,71 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1107
1110
|
data = self.safe_list(response, 'data')
|
1108
1111
|
return self.parse_positions(data, symbols)
|
1109
1112
|
|
1113
|
+
def fetch_positions_history(self, symbols: Strings = None, since: Int = None, limit: Int = None, params={}):
|
1114
|
+
"""
|
1115
|
+
fetches historical positions
|
1116
|
+
:see: https://www.kucoin.com/docs/rest/futures-trading/positions/get-positions-history
|
1117
|
+
:param str[] [symbols]: list of unified market symbols
|
1118
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
1119
|
+
:param int [params.until]: closing end time
|
1120
|
+
:param int [params.pageId]: page id
|
1121
|
+
:returns dict[]: a list of `position structure <https://docs.ccxt.com/#/?id=position-structure>`
|
1122
|
+
"""
|
1123
|
+
self.load_markets()
|
1124
|
+
if limit is None:
|
1125
|
+
limit = 200
|
1126
|
+
request = {
|
1127
|
+
'limit': limit,
|
1128
|
+
}
|
1129
|
+
if since is not None:
|
1130
|
+
request['from'] = since
|
1131
|
+
until = self.safe_integer(params, 'until')
|
1132
|
+
if until is not None:
|
1133
|
+
params = self.omit(params, 'until')
|
1134
|
+
request['to'] = until
|
1135
|
+
response = self.futuresPrivateGetHistoryPositions(self.extend(request, params))
|
1136
|
+
#
|
1137
|
+
# {
|
1138
|
+
# "success": True,
|
1139
|
+
# "code": "200",
|
1140
|
+
# "msg": "success",
|
1141
|
+
# "retry": False,
|
1142
|
+
# "data": {
|
1143
|
+
# "currentPage": 1,
|
1144
|
+
# "pageSize": 10,
|
1145
|
+
# "totalNum": 25,
|
1146
|
+
# "totalPage": 3,
|
1147
|
+
# "items": [
|
1148
|
+
# {
|
1149
|
+
# "closeId": "300000000000000030",
|
1150
|
+
# "positionId": "300000000000000009",
|
1151
|
+
# "uid": 99996908309485,
|
1152
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1153
|
+
# "symbol": "XBTUSDM",
|
1154
|
+
# "settleCurrency": "XBT",
|
1155
|
+
# "leverage": "0.0",
|
1156
|
+
# "type": "LIQUID_LONG",
|
1157
|
+
# "side": null,
|
1158
|
+
# "closeSize": null,
|
1159
|
+
# "pnl": "-1.0000003793999999",
|
1160
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1161
|
+
# "withdrawPnl": "0.0",
|
1162
|
+
# "roe": null,
|
1163
|
+
# "tradeFee": "0.0006154045",
|
1164
|
+
# "fundingFee": "0.0",
|
1165
|
+
# "openTime": 1713785751181,
|
1166
|
+
# "closeTime": 1713785752784,
|
1167
|
+
# "openPrice": null,
|
1168
|
+
# "closePrice": null
|
1169
|
+
# }
|
1170
|
+
# ]
|
1171
|
+
# }
|
1172
|
+
# }
|
1173
|
+
#
|
1174
|
+
data = self.safe_dict(response, 'data')
|
1175
|
+
items = self.safe_list(data, 'items', [])
|
1176
|
+
return self.parse_positions(items, symbols)
|
1177
|
+
|
1110
1178
|
def parse_position(self, position, market: Market = None):
|
1111
1179
|
#
|
1112
1180
|
# {
|
@@ -1153,16 +1221,46 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1153
1221
|
# }
|
1154
1222
|
# ]
|
1155
1223
|
# }
|
1224
|
+
# position history
|
1225
|
+
# {
|
1226
|
+
# "closeId": "300000000000000030",
|
1227
|
+
# "positionId": "300000000000000009",
|
1228
|
+
# "uid": 99996908309485,
|
1229
|
+
# "userId": "6527d4fc8c7f3d0001f40f5f",
|
1230
|
+
# "symbol": "XBTUSDM",
|
1231
|
+
# "settleCurrency": "XBT",
|
1232
|
+
# "leverage": "0.0",
|
1233
|
+
# "type": "LIQUID_LONG",
|
1234
|
+
# "side": null,
|
1235
|
+
# "closeSize": null,
|
1236
|
+
# "pnl": "-1.0000003793999999",
|
1237
|
+
# "realisedGrossCost": "0.9993849748999999",
|
1238
|
+
# "withdrawPnl": "0.0",
|
1239
|
+
# "roe": null,
|
1240
|
+
# "tradeFee": "0.0006154045",
|
1241
|
+
# "fundingFee": "0.0",
|
1242
|
+
# "openTime": 1713785751181,
|
1243
|
+
# "closeTime": 1713785752784,
|
1244
|
+
# "openPrice": null,
|
1245
|
+
# "closePrice": null
|
1246
|
+
# }
|
1156
1247
|
#
|
1157
1248
|
symbol = self.safe_string(position, 'symbol')
|
1158
1249
|
market = self.safe_market(symbol, market)
|
1159
1250
|
timestamp = self.safe_integer(position, 'currentTimestamp')
|
1160
1251
|
size = self.safe_string(position, 'currentQty')
|
1161
1252
|
side = None
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1253
|
+
type = self.safe_string_lower(position, 'type')
|
1254
|
+
if size is not None:
|
1255
|
+
if Precise.string_gt(size, '0'):
|
1256
|
+
side = 'long'
|
1257
|
+
elif Precise.string_lt(size, '0'):
|
1258
|
+
side = 'short'
|
1259
|
+
elif type is not None:
|
1260
|
+
if type.find('long') > -1:
|
1261
|
+
side = 'long'
|
1262
|
+
else:
|
1263
|
+
side = 'short'
|
1166
1264
|
notional = Precise.string_abs(self.safe_string(position, 'posCost'))
|
1167
1265
|
initialMargin = self.safe_string(position, 'posInit')
|
1168
1266
|
initialMarginPercentage = Precise.string_div(initialMargin, notional)
|
@@ -1170,25 +1268,27 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
1170
1268
|
unrealisedPnl = self.safe_string(position, 'unrealisedPnl')
|
1171
1269
|
crossMode = self.safe_value(position, 'crossMode')
|
1172
1270
|
# currently crossMode is always set to False and only isolated positions are supported
|
1173
|
-
marginMode =
|
1271
|
+
marginMode = None
|
1272
|
+
if crossMode is not None:
|
1273
|
+
marginMode = 'cross' if crossMode else 'isolated'
|
1174
1274
|
return self.safe_position({
|
1175
1275
|
'info': position,
|
1176
|
-
'id': self.
|
1276
|
+
'id': self.safe_string_2(position, 'id', 'positionId'),
|
1177
1277
|
'symbol': self.safe_string(market, 'symbol'),
|
1178
1278
|
'timestamp': timestamp,
|
1179
1279
|
'datetime': self.iso8601(timestamp),
|
1180
|
-
'lastUpdateTimestamp':
|
1280
|
+
'lastUpdateTimestamp': self.safe_integer(position, 'closeTime'),
|
1181
1281
|
'initialMargin': self.parse_number(initialMargin),
|
1182
1282
|
'initialMarginPercentage': self.parse_number(initialMarginPercentage),
|
1183
1283
|
'maintenanceMargin': self.safe_number(position, 'posMaint'),
|
1184
1284
|
'maintenanceMarginPercentage': self.safe_number(position, 'maintMarginReq'),
|
1185
|
-
'entryPrice': self.
|
1285
|
+
'entryPrice': self.safe_number_2(position, 'avgEntryPrice', 'openPrice'),
|
1186
1286
|
'notional': self.parse_number(notional),
|
1187
|
-
'leverage': self.
|
1287
|
+
'leverage': self.safe_number_2(position, 'realLeverage', 'leverage'),
|
1188
1288
|
'unrealizedPnl': self.parse_number(unrealisedPnl),
|
1189
1289
|
'contracts': self.parse_number(Precise.string_abs(size)),
|
1190
1290
|
'contractSize': self.safe_value(market, 'contractSize'),
|
1191
|
-
'realizedPnl': self.
|
1291
|
+
'realizedPnl': self.safe_number_2(position, 'realisedPnl', 'pnl'),
|
1192
1292
|
'marginRatio': None,
|
1193
1293
|
'liquidationPrice': self.safe_number(position, 'liquidationPrice'),
|
1194
1294
|
'markPrice': self.safe_number(position, 'markPrice'),
|
@@ -2560,3 +2660,39 @@ class kucoinfutures(kucoin, ImplicitAPI):
|
|
2560
2660
|
else:
|
2561
2661
|
response = self.futuresPrivatePostOrders(self.extend(request, params))
|
2562
2662
|
return self.parse_order(response, market)
|
2663
|
+
|
2664
|
+
def fetch_trading_fee(self, symbol: str, params={}) -> TradingFeeInterface:
|
2665
|
+
"""
|
2666
|
+
fetch the trading fees for a market
|
2667
|
+
:see: https://www.kucoin.com/docs/rest/funding/trade-fee/trading-pair-actual-fee-futures
|
2668
|
+
:param str symbol: unified market symbol
|
2669
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
2670
|
+
:returns dict: a `fee structure <https://docs.ccxt.com/#/?id=fee-structure>`
|
2671
|
+
"""
|
2672
|
+
self.load_markets()
|
2673
|
+
market = self.market(symbol)
|
2674
|
+
request = {
|
2675
|
+
'symbols': market['id'],
|
2676
|
+
}
|
2677
|
+
response = self.privateGetTradeFees(self.extend(request, params))
|
2678
|
+
#
|
2679
|
+
# {
|
2680
|
+
# "code": "200000",
|
2681
|
+
# "data": {
|
2682
|
+
# "symbol": "XBTUSDTM",
|
2683
|
+
# "takerFeeRate": "0.0006",
|
2684
|
+
# "makerFeeRate": "0.0002"
|
2685
|
+
# }
|
2686
|
+
# }
|
2687
|
+
#
|
2688
|
+
data = self.safe_list(response, 'data', [])
|
2689
|
+
first = self.safe_dict(data, 0)
|
2690
|
+
marketId = self.safe_string(first, 'symbol')
|
2691
|
+
return {
|
2692
|
+
'info': response,
|
2693
|
+
'symbol': self.safe_symbol(marketId, market),
|
2694
|
+
'maker': self.safe_number(first, 'makerFeeRate'),
|
2695
|
+
'taker': self.safe_number(first, 'takerFeeRate'),
|
2696
|
+
'percentage': True,
|
2697
|
+
'tierBased': True,
|
2698
|
+
}
|
ccxt/pro/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ccxt
|
3
|
-
Version: 4.3.
|
3
|
+
Version: 4.3.10
|
4
4
|
Summary: A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 100+ exchanges
|
5
5
|
Home-page: https://ccxt.com
|
6
6
|
Author: Igor Kroitor
|
@@ -262,13 +262,13 @@ console.log(version, Object.keys(exchanges));
|
|
262
262
|
|
263
263
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
264
264
|
|
265
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
266
|
-
* unpkg: https://unpkg.com/ccxt@4.3.
|
265
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.10/dist/ccxt.browser.js
|
266
|
+
* unpkg: https://unpkg.com/ccxt@4.3.10/dist/ccxt.browser.js
|
267
267
|
|
268
268
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
269
269
|
|
270
270
|
```HTML
|
271
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
271
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.10/dist/ccxt.browser.js"></script>
|
272
272
|
```
|
273
273
|
|
274
274
|
Creates a global `ccxt` object:
|