ccxt 4.3.9__py2.py3-none-any.whl → 4.3.11__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 CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  # ----------------------------------------------------------------------------
24
24
 
25
- __version__ = '4.3.9'
25
+ __version__ = '4.3.11'
26
26
 
27
27
  # ----------------------------------------------------------------------------
28
28
 
ccxt/abstract/blofin.py CHANGED
@@ -24,6 +24,8 @@ class ImplicitAPI:
24
24
  private_get_trade_orders_tpsl_pending = privateGetTradeOrdersTpslPending = Entry('trade/orders-tpsl-pending', 'private', 'GET', {'cost': 1})
25
25
  private_get_trade_orders_history = privateGetTradeOrdersHistory = Entry('trade/orders-history', 'private', 'GET', {'cost': 1})
26
26
  private_get_trade_orders_tpsl_history = privateGetTradeOrdersTpslHistory = Entry('trade/orders-tpsl-history', 'private', 'GET', {'cost': 1})
27
+ private_get_user_query_apikey = privateGetUserQueryApikey = Entry('user/query-apikey', 'private', 'GET', {'cost': 1})
28
+ private_get_affiliate_basic = privateGetAffiliateBasic = Entry('affiliate/basic', 'private', 'GET', {'cost': 1})
27
29
  private_post_trade_order = privatePostTradeOrder = Entry('trade/order', 'private', 'POST', {'cost': 1})
28
30
  private_post_trade_cancel_order = privatePostTradeCancelOrder = Entry('trade/cancel-order', 'private', 'POST', {'cost': 1})
29
31
  private_post_account_set_leverage = privatePostAccountSetLeverage = Entry('account/set-leverage', 'private', 'POST', {'cost': 1})
@@ -184,6 +184,8 @@ class ImplicitAPI:
184
184
  futuresprivate_get_withdrawal_list = futuresPrivateGetWithdrawalList = Entry('withdrawal-list', 'futuresPrivate', 'GET', {'cost': 1})
185
185
  futuresprivate_get_sub_api_key = futuresPrivateGetSubApiKey = Entry('sub/api-key', 'futuresPrivate', 'GET', {'cost': 1})
186
186
  futuresprivate_get_trade_statistics = futuresPrivateGetTradeStatistics = Entry('trade-statistics', 'futuresPrivate', 'GET', {'cost': 1})
187
+ futuresprivate_get_trade_fees = futuresPrivateGetTradeFees = Entry('trade-fees', 'futuresPrivate', 'GET', {'cost': 1})
188
+ futuresprivate_get_history_positions = futuresPrivateGetHistoryPositions = Entry('history-positions', 'futuresPrivate', 'GET', {'cost': 1})
187
189
  futuresprivate_post_transfer_out = futuresPrivatePostTransferOut = Entry('transfer-out', 'futuresPrivate', 'POST', {'cost': 1})
188
190
  futuresprivate_post_transfer_in = futuresPrivatePostTransferIn = Entry('transfer-in', 'futuresPrivate', 'POST', {'cost': 1})
189
191
  futuresprivate_post_orders = futuresPrivatePostOrders = Entry('orders', 'futuresPrivate', 'POST', {'cost': 1.33})
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.3.9'
7
+ __version__ = '4.3.11'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # -----------------------------------------------------------------------------
4
4
 
5
- __version__ = '4.3.9'
5
+ __version__ = '4.3.11'
6
6
 
7
7
  # -----------------------------------------------------------------------------
8
8
 
@@ -7864,7 +7864,7 @@ class bitget(Exchange, ImplicitAPI):
7864
7864
  """
7865
7865
  fetches historical positions
7866
7866
  :see: https://www.bitget.com/api-doc/contract/position/Get-History-Position
7867
- :param str [symbol]: unified contract symbols
7867
+ :param str[] [symbols]: unified contract symbols
7868
7868
  :param int [since]: timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
7869
7869
  :param int [limit]: the maximum amount of records to fetch, default=20, max=100
7870
7870
  :param dict params: extra parameters specific to the exchange api endpoint
@@ -201,6 +201,8 @@ class blofin(Exchange, ImplicitAPI):
201
201
  'trade/orders-tpsl-pending': 1,
202
202
  'trade/orders-history': 1,
203
203
  'trade/orders-tpsl-history': 1,
204
+ 'user/query-apikey': 1,
205
+ 'affiliate/basic': 1,
204
206
  },
205
207
  'post': {
206
208
  'trade/order': 1,
@@ -1689,7 +1689,7 @@ class coinex(Exchange, ImplicitAPI):
1689
1689
  # "client_id": "",
1690
1690
  # }
1691
1691
  #
1692
- # Spot and Margin cancelOrder, cancelOrders, fetchOrder
1692
+ # Spot and Margin cancelOrder, fetchOrder
1693
1693
  #
1694
1694
  # {
1695
1695
  # "amount":"1.5",
@@ -1884,49 +1884,7 @@ class coinex(Exchange, ImplicitAPI):
1884
1884
  # "user_id": 3620173
1885
1885
  # }
1886
1886
  #
1887
- # swap: cancelOrders
1888
- #
1889
- # {
1890
- # "amount": "0.0005",
1891
- # "client_id": "x-167673045-b0cee0c584718b65",
1892
- # "create_time": 1701233683.294231,
1893
- # "deal_asset_fee": "0.00000000000000000000",
1894
- # "deal_fee": "0.00000000000000000000",
1895
- # "deal_profit": "0.00000000000000000000",
1896
- # "deal_stock": "0.00000000000000000000",
1897
- # "effect_type": 1,
1898
- # "fee_asset": "",
1899
- # "fee_discount": "0.00000000000000000000",
1900
- # "last_deal_amount": "0.00000000000000000000",
1901
- # "last_deal_id": 0,
1902
- # "last_deal_price": "0.00000000000000000000",
1903
- # "last_deal_role": 0,
1904
- # "last_deal_time": 0,
1905
- # "last_deal_type": 0,
1906
- # "left": "0.0005",
1907
- # "leverage": "3",
1908
- # "maker_fee": "0.00030",
1909
- # "market": "BTCUSDT",
1910
- # "option": 0,
1911
- # "order_id": 115940476323,
1912
- # "position_id": 0,
1913
- # "position_type": 2,
1914
- # "price": "25000.00",
1915
- # "side": 2,
1916
- # "source": "api.v1",
1917
- # "stop_id": 0,
1918
- # "stop_loss_price": "0.00000000000000000000",
1919
- # "stop_loss_type": 0,
1920
- # "take_profit_price": "0.00000000000000000000",
1921
- # "take_profit_type": 0,
1922
- # "taker_fee": "0.00050",
1923
- # "target": 0,
1924
- # "type": 1,
1925
- # "update_time": 1701233721.718884,
1926
- # "user_id": 3620173
1927
- # }
1928
- #
1929
- # Spot and Margin createOrder, createOrders v2
1887
+ # Spot and Margin createOrder, createOrders, cancelOrders v2
1930
1888
  #
1931
1889
  # {
1932
1890
  # "amount": "0.0001",
@@ -1958,7 +1916,7 @@ class coinex(Exchange, ImplicitAPI):
1958
1916
  # "stop_id": 117180138153
1959
1917
  # }
1960
1918
  #
1961
- # Swap createOrder, createOrders v2
1919
+ # Swap createOrder, createOrders, cancelOrders v2
1962
1920
  #
1963
1921
  # {
1964
1922
  # "amount": "0.0001",
@@ -2018,6 +1976,24 @@ class coinex(Exchange, ImplicitAPI):
2018
1976
  # "updated_at": 1714119054559
2019
1977
  # }
2020
1978
  #
1979
+ # Swap and Spot stop cancelOrders v2
1980
+ #
1981
+ # {
1982
+ # "amount": "0.0001",
1983
+ # "client_id": "x-167673045-a7d7714c6478acf6",
1984
+ # "created_at": 1714187923820,
1985
+ # "market": "BTCUSDT",
1986
+ # "market_type": "FUTURES",
1987
+ # "price": "61000",
1988
+ # "side": "buy",
1989
+ # "stop_id": 136984426097,
1990
+ # "trigger_direction": "higher",
1991
+ # "trigger_price": "62000",
1992
+ # "trigger_price_type": "latest_price",
1993
+ # "type": "limit",
1994
+ # "updated_at": 1714187974363
1995
+ # }
1996
+ #
2021
1997
  rawStatus = self.safe_string(order, 'status')
2022
1998
  timestamp = self.safe_timestamp(order, 'create_time')
2023
1999
  if timestamp is None:
@@ -2076,8 +2052,8 @@ class coinex(Exchange, ImplicitAPI):
2076
2052
  'reduceOnly': None,
2077
2053
  'side': side,
2078
2054
  'price': self.safe_string(order, 'price'),
2079
- 'stopPrice': self.safe_string(order, 'stop_price'),
2080
- 'triggerPrice': self.safe_string(order, 'stop_price'),
2055
+ 'stopPrice': self.safe_string_2(order, 'stop_price', 'trigger_price'),
2056
+ 'triggerPrice': self.safe_string_2(order, 'stop_price', 'trigger_price'),
2081
2057
  'takeProfitPrice': self.safe_number(order, 'take_profit_price'),
2082
2058
  'stopLossPrice': self.safe_number(order, 'stop_loss_price'),
2083
2059
  'cost': self.safe_string_2(order, 'deal_money', 'filled_value'),
@@ -2616,11 +2592,14 @@ class coinex(Exchange, ImplicitAPI):
2616
2592
  async def cancel_orders(self, ids, symbol: Str = None, params={}):
2617
2593
  """
2618
2594
  cancel multiple orders
2619
- :see: https://viabtc.github.io/coinex_api_en_doc/spot/#docsspot003_trade016_batch_cancel_order
2620
- :see: https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http021-0_cancel_order_batch
2595
+ :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-order
2596
+ :see: https://docs.coinex.com/api/v2/spot/order/http/cancel-batch-stop-order
2597
+ :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-order
2598
+ :see: https://docs.coinex.com/api/v2/futures/order/http/cancel-batch-stop-order
2621
2599
  :param str[] ids: order ids
2622
2600
  :param str symbol: unified market symbol
2623
2601
  :param dict [params]: extra parameters specific to the exchange API endpoint
2602
+ :param boolean [params.stop]: set to True for canceling stop orders
2624
2603
  :returns dict: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
2625
2604
  """
2626
2605
  if symbol is None:
@@ -2630,111 +2609,153 @@ class coinex(Exchange, ImplicitAPI):
2630
2609
  request = {
2631
2610
  'market': market['id'],
2632
2611
  }
2633
- idsString = ','.join(ids)
2612
+ stop = self.safe_bool_2(params, 'stop', 'trigger')
2613
+ params = self.omit(params, ['stop', 'trigger'])
2634
2614
  response = None
2615
+ if stop:
2616
+ request['stop_ids'] = ids
2617
+ else:
2618
+ request['order_ids'] = ids
2635
2619
  if market['spot']:
2636
- request['batch_ids'] = idsString
2637
- response = await self.v1PrivateDeleteOrderPendingBatch(self.extend(request, params))
2620
+ if stop:
2621
+ response = await self.v2PrivatePostSpotCancelBatchStopOrder(self.extend(request, params))
2622
+ #
2623
+ # {
2624
+ # "code": 0,
2625
+ # "data": [
2626
+ # {
2627
+ # "code": 0,
2628
+ # "data": {
2629
+ # "amount": "0.0001",
2630
+ # "ccy": "BTC",
2631
+ # "client_id": "x-167673045-8e33d6f4a4bcb022",
2632
+ # "created_at": 1714188827291,
2633
+ # "market": "BTCUSDT",
2634
+ # "market_type": "SPOT",
2635
+ # "price": "61000",
2636
+ # "side": "buy",
2637
+ # "stop_id": 117248845854,
2638
+ # "trigger_direction": "higher",
2639
+ # "trigger_price": "62000",
2640
+ # "trigger_price_type": "mark_price",
2641
+ # "type": "limit",
2642
+ # "updated_at": 1714188827291
2643
+ # },
2644
+ # "message": "OK"
2645
+ # },
2646
+ # ],
2647
+ # "message": "OK"
2648
+ # }
2649
+ #
2650
+ else:
2651
+ response = await self.v2PrivatePostSpotCancelBatchOrder(self.extend(request, params))
2652
+ #
2653
+ # {
2654
+ # "code": 0,
2655
+ # "data": [
2656
+ # {
2657
+ # "code": 0,
2658
+ # "data": {
2659
+ # "amount": "0.0001",
2660
+ # "base_fee": "0",
2661
+ # "ccy": "BTC",
2662
+ # "client_id": "x-167673045-c1cc78e5b42d8c4e",
2663
+ # "created_at": 1714188449497,
2664
+ # "discount_fee": "0",
2665
+ # "filled_amount": "0",
2666
+ # "filled_value": "0",
2667
+ # "last_fill_amount": "0",
2668
+ # "last_fill_price": "0",
2669
+ # "maker_fee_rate": "0.002",
2670
+ # "market": "BTCUSDT",
2671
+ # "market_type": "SPOT",
2672
+ # "order_id": 117248494358,
2673
+ # "price": "60000",
2674
+ # "quote_fee": "0",
2675
+ # "side": "buy",
2676
+ # "taker_fee_rate": "0.002",
2677
+ # "type": "limit",
2678
+ # "unfilled_amount": "0.0001",
2679
+ # "updated_at": 1714188449497
2680
+ # },
2681
+ # "message": ""
2682
+ # },
2683
+ # ],
2684
+ # "message": "OK"
2685
+ # }
2686
+ #
2638
2687
  else:
2639
- request['order_ids'] = idsString
2640
- response = await self.v1PerpetualPrivatePostOrderCancelBatch(self.extend(request, params))
2641
- #
2642
- # spot
2643
- #
2644
- # {
2645
- # "code": 0,
2646
- # "data": [
2647
- # {
2648
- # "code": 0,
2649
- # "data": {
2650
- # "account_id": 0,
2651
- # "amount": "0.0005",
2652
- # "asset_fee": "0",
2653
- # "avg_price": "0.00",
2654
- # "client_id": "x-167673045-d4e03c38f4d19b4e",
2655
- # "create_time": 1701229157,
2656
- # "deal_amount": "0",
2657
- # "deal_fee": "0",
2658
- # "deal_money": "0",
2659
- # "fee_asset": null,
2660
- # "fee_discount": "1",
2661
- # "finished_time": 0,
2662
- # "id": 107745856682,
2663
- # "left": "0",
2664
- # "maker_fee_rate": "0.002",
2665
- # "market": "BTCUSDT",
2666
- # "money_fee": "0",
2667
- # "order_type": "limit",
2668
- # "price": "22000",
2669
- # "status": "not_deal",
2670
- # "stock_fee": "0",
2671
- # "taker_fee_rate": "0.002",
2672
- # "type": "buy"
2673
- # },
2674
- # "message": ""
2675
- # },
2676
- # ],
2677
- # "message": "Success"
2678
- # }
2679
- #
2680
- # swap
2681
- #
2682
- # {
2683
- # "code": 0,
2684
- # "data": [
2685
- # {
2686
- # "code": 0,
2687
- # "message": "",
2688
- # "order": {
2689
- # "amount": "0.0005",
2690
- # "client_id": "x-167673045-b0cee0c584718b65",
2691
- # "create_time": 1701233683.294231,
2692
- # "deal_asset_fee": "0.00000000000000000000",
2693
- # "deal_fee": "0.00000000000000000000",
2694
- # "deal_profit": "0.00000000000000000000",
2695
- # "deal_stock": "0.00000000000000000000",
2696
- # "effect_type": 1,
2697
- # "fee_asset": "",
2698
- # "fee_discount": "0.00000000000000000000",
2699
- # "last_deal_amount": "0.00000000000000000000",
2700
- # "last_deal_id": 0,
2701
- # "last_deal_price": "0.00000000000000000000",
2702
- # "last_deal_role": 0,
2703
- # "last_deal_time": 0,
2704
- # "last_deal_type": 0,
2705
- # "left": "0.0005",
2706
- # "leverage": "3",
2707
- # "maker_fee": "0.00030",
2708
- # "market": "BTCUSDT",
2709
- # "option": 0,
2710
- # "order_id": 115940476323,
2711
- # "position_id": 0,
2712
- # "position_type": 2,
2713
- # "price": "25000.00",
2714
- # "side": 2,
2715
- # "source": "api.v1",
2716
- # "stop_id": 0,
2717
- # "stop_loss_price": "0.00000000000000000000",
2718
- # "stop_loss_type": 0,
2719
- # "take_profit_price": "0.00000000000000000000",
2720
- # "take_profit_type": 0,
2721
- # "taker_fee": "0.00050",
2722
- # "target": 0,
2723
- # "type": 1,
2724
- # "update_time": 1701233721.718884,
2725
- # "user_id": 3620173
2726
- # }
2727
- # },
2728
- # ],
2729
- # "message": "OK"
2730
- # }
2731
- #
2732
- data = self.safe_value(response, 'data', [])
2688
+ request['market_type'] = 'FUTURES'
2689
+ if stop:
2690
+ response = await self.v2PrivatePostFuturesCancelBatchStopOrder(self.extend(request, params))
2691
+ #
2692
+ # {
2693
+ # "code": 0,
2694
+ # "data": [
2695
+ # {
2696
+ # "code": 0,
2697
+ # "data": {
2698
+ # "amount": "0.0001",
2699
+ # "client_id": "x-167673045-a7d7714c6478acf6",
2700
+ # "created_at": 1714187923820,
2701
+ # "market": "BTCUSDT",
2702
+ # "market_type": "FUTURES",
2703
+ # "price": "61000",
2704
+ # "side": "buy",
2705
+ # "stop_id": 136984426097,
2706
+ # "trigger_direction": "higher",
2707
+ # "trigger_price": "62000",
2708
+ # "trigger_price_type": "latest_price",
2709
+ # "type": "limit",
2710
+ # "updated_at": 1714187974363
2711
+ # },
2712
+ # "message": ""
2713
+ # },
2714
+ # ],
2715
+ # "message": "OK"
2716
+ # }
2717
+ #
2718
+ else:
2719
+ response = await self.v2PrivatePostFuturesCancelBatchOrder(self.extend(request, params))
2720
+ #
2721
+ # {
2722
+ # "code": 0,
2723
+ # "data": [
2724
+ # {
2725
+ # "code": 0,
2726
+ # "data": {
2727
+ # "amount": "0.0001",
2728
+ # "client_id": "x-167673045-9f80fde284339a72",
2729
+ # "created_at": 1714187491784,
2730
+ # "fee": "0",
2731
+ # "fee_ccy": "USDT",
2732
+ # "filled_amount": "0",
2733
+ # "filled_value": "0",
2734
+ # "last_filled_amount": "0",
2735
+ # "last_filled_price": "0",
2736
+ # "maker_fee_rate": "0.0003",
2737
+ # "market": "BTCUSDT",
2738
+ # "market_type": "FUTURES",
2739
+ # "order_id": 136983851788,
2740
+ # "price": "61000",
2741
+ # "realized_pnl": "0",
2742
+ # "side": "buy",
2743
+ # "taker_fee_rate": "0.0005",
2744
+ # "type": "limit",
2745
+ # "unfilled_amount": "0.0001",
2746
+ # "updated_at": 1714187567079
2747
+ # },
2748
+ # "message": ""
2749
+ # },
2750
+ # ],
2751
+ # "message": "OK"
2752
+ # }
2753
+ #
2754
+ data = self.safe_list(response, 'data', [])
2733
2755
  results = []
2734
2756
  for i in range(0, len(data)):
2735
2757
  entry = data[i]
2736
- dataRequest = 'data' if market['spot'] else 'order'
2737
- item = self.safe_value(entry, dataRequest, {})
2758
+ item = self.safe_dict(entry, 'data', {})
2738
2759
  order = self.parse_order(item, market)
2739
2760
  results.append(order)
2740
2761
  return results