ccxt 4.3.56__py2.py3-none-any.whl → 4.3.57__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/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/base/ws/client.py +25 -5
- ccxt/async_support/bingx.py +45 -7
- ccxt/async_support/bitget.py +56 -47
- ccxt/async_support/coinone.py +15 -19
- ccxt/async_support/gate.py +96 -2
- ccxt/async_support/htx.py +84 -25
- ccxt/async_support/huobijp.py +61 -2
- ccxt/base/exchange.py +1 -1
- ccxt/bingx.py +45 -7
- ccxt/bitget.py +56 -47
- ccxt/coinone.py +15 -19
- ccxt/gate.py +96 -2
- ccxt/htx.py +84 -25
- ccxt/huobijp.py +61 -2
- ccxt/pro/__init__.py +1 -1
- {ccxt-4.3.56.dist-info → ccxt-4.3.57.dist-info}/METADATA +4 -4
- {ccxt-4.3.56.dist-info → ccxt-4.3.57.dist-info}/RECORD +23 -23
- {ccxt-4.3.56.dist-info → ccxt-4.3.57.dist-info}/LICENSE.txt +0 -0
- {ccxt-4.3.56.dist-info → ccxt-4.3.57.dist-info}/WHEEL +0 -0
- {ccxt-4.3.56.dist-info → ccxt-4.3.57.dist-info}/top_level.txt +0 -0
ccxt/async_support/huobijp.py
CHANGED
@@ -1468,7 +1468,61 @@ class huobijp(Exchange, ImplicitAPI):
|
|
1468
1468
|
# }
|
1469
1469
|
# }
|
1470
1470
|
#
|
1471
|
-
return response
|
1471
|
+
return self.parse_cancel_orders(response)
|
1472
|
+
|
1473
|
+
def parse_cancel_orders(self, orders):
|
1474
|
+
#
|
1475
|
+
# {
|
1476
|
+
# "success": [
|
1477
|
+
# "5983466"
|
1478
|
+
# ],
|
1479
|
+
# "failed": [
|
1480
|
+
# {
|
1481
|
+
# "err-msg": "Incorrect order state",
|
1482
|
+
# "order-state": 7,
|
1483
|
+
# "order-id": "",
|
1484
|
+
# "err-code": "order-orderstate-error",
|
1485
|
+
# "client-order-id": "first"
|
1486
|
+
# },
|
1487
|
+
# ...
|
1488
|
+
# ]
|
1489
|
+
# }
|
1490
|
+
#
|
1491
|
+
# {
|
1492
|
+
# "errors": [
|
1493
|
+
# {
|
1494
|
+
# "order_id": "769206471845261312",
|
1495
|
+
# "err_code": 1061,
|
1496
|
+
# "err_msg": "This order doesnt exist."
|
1497
|
+
# }
|
1498
|
+
# ],
|
1499
|
+
# "successes": "1258075374411399168,1258075393254871040"
|
1500
|
+
# }
|
1501
|
+
#
|
1502
|
+
successes = self.safe_string(orders, 'successes')
|
1503
|
+
success = None
|
1504
|
+
if successes is not None:
|
1505
|
+
success = successes.split(',')
|
1506
|
+
else:
|
1507
|
+
success = self.safe_list(orders, 'success', [])
|
1508
|
+
failed = self.safe_list_2(orders, 'errors', 'failed', [])
|
1509
|
+
result = []
|
1510
|
+
for i in range(0, len(success)):
|
1511
|
+
order = success[i]
|
1512
|
+
result.append(self.safe_order({
|
1513
|
+
'info': order,
|
1514
|
+
'id': order,
|
1515
|
+
'status': 'canceled',
|
1516
|
+
}))
|
1517
|
+
for i in range(0, len(failed)):
|
1518
|
+
order = failed[i]
|
1519
|
+
result.append(self.safe_order({
|
1520
|
+
'info': order,
|
1521
|
+
'id': self.safe_string_2(order, 'order-id', 'order_id'),
|
1522
|
+
'status': 'failed',
|
1523
|
+
'clientOrderId': self.safe_string(order, 'client-order-id'),
|
1524
|
+
}))
|
1525
|
+
return result
|
1472
1526
|
|
1473
1527
|
async def cancel_all_orders(self, symbol: Str = None, params={}):
|
1474
1528
|
"""
|
@@ -1500,7 +1554,12 @@ class huobijp(Exchange, ImplicitAPI):
|
|
1500
1554
|
# }
|
1501
1555
|
# }
|
1502
1556
|
#
|
1503
|
-
|
1557
|
+
data = self.safe_dict(response, 'data', {})
|
1558
|
+
return [
|
1559
|
+
self.safe_order({
|
1560
|
+
'info': data,
|
1561
|
+
}),
|
1562
|
+
]
|
1504
1563
|
|
1505
1564
|
def currency_to_precision(self, code, fee, networkCode=None):
|
1506
1565
|
return self.decimal_to_precision(fee, 0, self.currencies[code]['precision'], self.precisionMode)
|
ccxt/base/exchange.py
CHANGED
ccxt/bingx.py
CHANGED
@@ -674,6 +674,29 @@ class bingx(Exchange, ImplicitAPI):
|
|
674
674
|
markets = self.safe_list(response, 'data', [])
|
675
675
|
return self.parse_markets(markets)
|
676
676
|
|
677
|
+
def fetch_inverse_swap_markets(self, params):
|
678
|
+
response = self.cswapV1PublicGetMarketContracts(params)
|
679
|
+
#
|
680
|
+
# {
|
681
|
+
# "code": 0,
|
682
|
+
# "msg": "",
|
683
|
+
# "timestamp": 1720074487610,
|
684
|
+
# "data": [
|
685
|
+
# {
|
686
|
+
# "symbol": "BNB-USD",
|
687
|
+
# "pricePrecision": 2,
|
688
|
+
# "minTickSize": "10",
|
689
|
+
# "minTradeValue": "10",
|
690
|
+
# "minQty": "1.00000000",
|
691
|
+
# "status": 1,
|
692
|
+
# "timeOnline": 1713175200000
|
693
|
+
# },
|
694
|
+
# ]
|
695
|
+
# }
|
696
|
+
#
|
697
|
+
markets = self.safe_list(response, 'data', [])
|
698
|
+
return self.parse_markets(markets)
|
699
|
+
|
677
700
|
def parse_market(self, market: dict) -> Market:
|
678
701
|
id = self.safe_string(market, 'symbol')
|
679
702
|
symbolParts = id.split('-')
|
@@ -682,6 +705,14 @@ class bingx(Exchange, ImplicitAPI):
|
|
682
705
|
base = self.safe_currency_code(baseId)
|
683
706
|
quote = self.safe_currency_code(quoteId)
|
684
707
|
currency = self.safe_string(market, 'currency')
|
708
|
+
checkIsInverse = False
|
709
|
+
checkIsLinear = True
|
710
|
+
minTickSize = self.safe_number(market, 'minTickSize')
|
711
|
+
if minTickSize is not None:
|
712
|
+
# inverse swap market
|
713
|
+
currency = baseId
|
714
|
+
checkIsInverse = True
|
715
|
+
checkIsLinear = False
|
685
716
|
settle = self.safe_currency_code(currency)
|
686
717
|
pricePrecision = self.safe_number(market, 'tickSize')
|
687
718
|
if pricePrecision is None:
|
@@ -698,8 +729,11 @@ class bingx(Exchange, ImplicitAPI):
|
|
698
729
|
fees = self.safe_dict(self.fees, type, {})
|
699
730
|
contractSize = self.parse_number('1') if (swap) else None
|
700
731
|
isActive = self.safe_string(market, 'status') == '1'
|
701
|
-
isInverse = None if (spot) else
|
702
|
-
isLinear = None if (spot) else
|
732
|
+
isInverse = None if (spot) else checkIsInverse
|
733
|
+
isLinear = None if (spot) else checkIsLinear
|
734
|
+
timeOnline = self.safe_integer(market, 'timeOnline')
|
735
|
+
if timeOnline == 0:
|
736
|
+
timeOnline = None
|
703
737
|
return self.safe_market_structure({
|
704
738
|
'id': id,
|
705
739
|
'symbol': symbol,
|
@@ -741,15 +775,15 @@ class bingx(Exchange, ImplicitAPI):
|
|
741
775
|
'max': self.safe_number(market, 'maxQty'),
|
742
776
|
},
|
743
777
|
'price': {
|
744
|
-
'min':
|
778
|
+
'min': minTickSize,
|
745
779
|
'max': None,
|
746
780
|
},
|
747
781
|
'cost': {
|
748
|
-
'min': self.
|
782
|
+
'min': self.safe_number_n(market, ['minNotional', 'tradeMinUSDT', 'minTradeValue']),
|
749
783
|
'max': self.safe_number(market, 'maxNotional'),
|
750
784
|
},
|
751
785
|
},
|
752
|
-
'created':
|
786
|
+
'created': timeOnline,
|
753
787
|
'info': market,
|
754
788
|
})
|
755
789
|
|
@@ -758,16 +792,20 @@ class bingx(Exchange, ImplicitAPI):
|
|
758
792
|
retrieves data on all markets for bingx
|
759
793
|
:see: https://bingx-api.github.io/docs/#/spot/market-api.html#Query%20Symbols
|
760
794
|
:see: https://bingx-api.github.io/docs/#/swapV2/market-api.html#Contract%20Information
|
795
|
+
:see: https://bingx-api.github.io/docs/#/en-us/cswap/market-api.html#Contract%20Information
|
761
796
|
:param dict [params]: extra parameters specific to the exchange API endpoint
|
762
797
|
:returns dict[]: an array of objects representing market data
|
763
798
|
"""
|
764
799
|
requests = [self.fetch_swap_markets(params)]
|
765
800
|
isSandbox = self.safe_bool(self.options, 'sandboxMode', False)
|
766
801
|
if not isSandbox:
|
802
|
+
requests.append(self.fetch_inverse_swap_markets(params))
|
767
803
|
requests.append(self.fetch_spot_markets(params)) # sandbox is swap only
|
768
804
|
promises = requests
|
769
|
-
|
770
|
-
|
805
|
+
linearSwapMarkets = self.safe_list(promises, 0, [])
|
806
|
+
inverseSwapMarkets = self.safe_list(promises, 1, [])
|
807
|
+
spotMarkets = self.safe_list(promises, 2, [])
|
808
|
+
swapMarkets = self.array_concat(linearSwapMarkets, inverseSwapMarkets)
|
771
809
|
return self.array_concat(spotMarkets, swapMarkets)
|
772
810
|
|
773
811
|
def fetch_ohlcv(self, symbol: str, timeframe='1m', since: Int = None, limit: Int = None, params={}) -> List[list]:
|
ccxt/bitget.py
CHANGED
@@ -4691,6 +4691,22 @@ class bitget(Exchange, ImplicitAPI):
|
|
4691
4691
|
response = self.privateMarginPostMarginV1CrossOrderBatchCancelOrder(self.extend(request, params))
|
4692
4692
|
else:
|
4693
4693
|
response = self.privateMarginPostMarginV1IsolatedOrderBatchCancelOrder(self.extend(request, params))
|
4694
|
+
#
|
4695
|
+
# {
|
4696
|
+
# "code": "00000",
|
4697
|
+
# "msg": "success",
|
4698
|
+
# "requestTime": 1700717155622,
|
4699
|
+
# "data": {
|
4700
|
+
# "resultList": [
|
4701
|
+
# {
|
4702
|
+
# "orderId": "1111453253721796609",
|
4703
|
+
# "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
|
4704
|
+
# },
|
4705
|
+
# ],
|
4706
|
+
# "failure": []
|
4707
|
+
# }
|
4708
|
+
# }
|
4709
|
+
#
|
4694
4710
|
else:
|
4695
4711
|
if stop:
|
4696
4712
|
stopRequest: dict = {
|
@@ -4699,6 +4715,27 @@ class bitget(Exchange, ImplicitAPI):
|
|
4699
4715
|
response = self.privateSpotPostV2SpotTradeBatchCancelPlanOrder(self.extend(stopRequest, params))
|
4700
4716
|
else:
|
4701
4717
|
response = self.privateSpotPostV2SpotTradeCancelSymbolOrder(self.extend(request, params))
|
4718
|
+
#
|
4719
|
+
# {
|
4720
|
+
# "code": "00000",
|
4721
|
+
# "msg": "success",
|
4722
|
+
# "requestTime": 1700716953996,
|
4723
|
+
# "data": {
|
4724
|
+
# "symbol": "BTCUSDT"
|
4725
|
+
# }
|
4726
|
+
# }
|
4727
|
+
#
|
4728
|
+
timestamp = self.safe_integer(response, 'requestTime')
|
4729
|
+
responseData = self.safe_dict(response, 'data')
|
4730
|
+
marketId = self.safe_string(responseData, 'symbol')
|
4731
|
+
return [
|
4732
|
+
self.safe_order({
|
4733
|
+
'info': response,
|
4734
|
+
'symbol': self.safe_symbol(marketId, None, None, 'spot'),
|
4735
|
+
'timestamp': timestamp,
|
4736
|
+
'datetime': self.iso8601(timestamp),
|
4737
|
+
}),
|
4738
|
+
]
|
4702
4739
|
else:
|
4703
4740
|
productType = None
|
4704
4741
|
productType, params = self.handle_product_type_and_params(market, params)
|
@@ -4707,53 +4744,25 @@ class bitget(Exchange, ImplicitAPI):
|
|
4707
4744
|
response = self.privateMixPostV2MixOrderCancelPlanOrder(self.extend(request, params))
|
4708
4745
|
else:
|
4709
4746
|
response = self.privateMixPostV2MixOrderBatchCancelOrders(self.extend(request, params))
|
4710
|
-
|
4711
|
-
|
4712
|
-
|
4713
|
-
|
4714
|
-
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
|
4722
|
-
|
4723
|
-
|
4724
|
-
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
|
4729
|
-
# "successList": [
|
4730
|
-
# {
|
4731
|
-
# "orderId": "1024598257429823488",
|
4732
|
-
# "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
|
4733
|
-
# },
|
4734
|
-
# ],
|
4735
|
-
# "failureList": []
|
4736
|
-
# }
|
4737
|
-
# }
|
4738
|
-
#
|
4739
|
-
# spot margin
|
4740
|
-
#
|
4741
|
-
# {
|
4742
|
-
# "code": "00000",
|
4743
|
-
# "msg": "success",
|
4744
|
-
# "requestTime": 1700717155622,
|
4745
|
-
# "data": {
|
4746
|
-
# "resultList": [
|
4747
|
-
# {
|
4748
|
-
# "orderId": "1111453253721796609",
|
4749
|
-
# "clientOid": "2ae7fc8a4ff949b6b60d770ca3950e2d"
|
4750
|
-
# },
|
4751
|
-
# ],
|
4752
|
-
# "failure": []
|
4753
|
-
# }
|
4754
|
-
# }
|
4755
|
-
#
|
4756
|
-
return response
|
4747
|
+
# {
|
4748
|
+
# "code": "00000",
|
4749
|
+
# "msg": "success",
|
4750
|
+
# "requestTime": "1680008815965",
|
4751
|
+
# "data": {
|
4752
|
+
# "successList": [
|
4753
|
+
# {
|
4754
|
+
# "orderId": "1024598257429823488",
|
4755
|
+
# "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
|
4756
|
+
# },
|
4757
|
+
# ],
|
4758
|
+
# "failureList": []
|
4759
|
+
# }
|
4760
|
+
# }
|
4761
|
+
data = self.safe_dict(response, 'data')
|
4762
|
+
resultList = self.safe_list_2(data, 'resultList', 'successList')
|
4763
|
+
failureList = self.safe_list_2(data, 'failure', 'failureList')
|
4764
|
+
responseList = self.array_concat(resultList, failureList)
|
4765
|
+
return self.parse_orders(responseList)
|
4757
4766
|
|
4758
4767
|
def fetch_order(self, id: str, symbol: Str = None, params={}):
|
4759
4768
|
"""
|
ccxt/coinone.py
CHANGED
@@ -25,8 +25,7 @@ class coinone(Exchange, ImplicitAPI):
|
|
25
25
|
'id': 'coinone',
|
26
26
|
'name': 'CoinOne',
|
27
27
|
'countries': ['KR'], # Korea
|
28
|
-
|
29
|
-
'rateLimit': 667,
|
28
|
+
'rateLimit': 50,
|
30
29
|
'version': 'v2',
|
31
30
|
'pro': False,
|
32
31
|
'has': {
|
@@ -198,10 +197,10 @@ class coinone(Exchange, ImplicitAPI):
|
|
198
197
|
},
|
199
198
|
'precisionMode': TICK_SIZE,
|
200
199
|
'exceptions': {
|
201
|
-
'
|
202
|
-
'
|
203
|
-
'108': BadSymbol,
|
204
|
-
'
|
200
|
+
'104': OrderNotFound,
|
201
|
+
'107': BadRequest,
|
202
|
+
'108': BadSymbol,
|
203
|
+
'405': OnMaintenance,
|
205
204
|
},
|
206
205
|
'commonCurrencies': {
|
207
206
|
'SOC': 'Soda Coin',
|
@@ -1111,17 +1110,14 @@ class coinone(Exchange, ImplicitAPI):
|
|
1111
1110
|
|
1112
1111
|
def handle_errors(self, code: int, reason: str, url: str, method: str, headers: dict, body: str, response, requestHeaders, requestBody):
|
1113
1112
|
if response is None:
|
1114
|
-
return None
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
raise ExchangeError(feedback)
|
1125
|
-
else:
|
1126
|
-
raise ExchangeError(self.id + ' ' + body)
|
1113
|
+
return None # fallback to default error handler
|
1114
|
+
#
|
1115
|
+
# {"result":"error","error_code":"107","error_msg":"Parameter value is wrong"}
|
1116
|
+
# {"result":"error","error_code":"108","error_msg":"Unknown CryptoCurrency"}
|
1117
|
+
#
|
1118
|
+
errorCode = self.safe_string(response, 'error_code')
|
1119
|
+
if errorCode != '0':
|
1120
|
+
feedback = self.id + ' ' + body
|
1121
|
+
self.throw_exactly_matched_exception(self.exceptions, errorCode, feedback)
|
1122
|
+
raise ExchangeError(feedback) # unknown message
|
1127
1123
|
return None
|
ccxt/gate.py
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
from ccxt.base.exchange import Exchange
|
7
7
|
from ccxt.abstract.gate import ImplicitAPI
|
8
8
|
import hashlib
|
9
|
-
from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, OrderSide, OrderType, Position, Str, Strings, Ticker, Tickers, Trade, TradingFeeInterface, TradingFees, Transaction, TransferEntry
|
9
|
+
from ccxt.base.types import Balances, Currencies, Currency, FundingHistory, Greeks, Int, Leverage, Leverages, LeverageTier, LeverageTiers, MarginModification, Market, MarketInterface, Num, Option, OptionChain, Order, OrderBook, OrderRequest, CancellationRequest, 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
|
@@ -99,6 +99,8 @@ class gate(Exchange, ImplicitAPI):
|
|
99
99
|
'borrowIsolatedMargin': True,
|
100
100
|
'cancelAllOrders': True,
|
101
101
|
'cancelOrder': True,
|
102
|
+
'cancelOrders': True,
|
103
|
+
'cancelOrdersForSymbols': True,
|
102
104
|
'createMarketBuyOrderWithCost': True,
|
103
105
|
'createMarketOrder': True,
|
104
106
|
'createMarketOrderWithCost': False,
|
@@ -4184,6 +4186,8 @@ class gate(Exchange, ImplicitAPI):
|
|
4184
4186
|
# "message": "Not enough balance"
|
4185
4187
|
# }
|
4186
4188
|
#
|
4189
|
+
# {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
|
4190
|
+
#
|
4187
4191
|
succeeded = self.safe_bool(order, 'succeeded', True)
|
4188
4192
|
if not succeeded:
|
4189
4193
|
# cancelOrders response
|
@@ -4191,6 +4195,7 @@ class gate(Exchange, ImplicitAPI):
|
|
4191
4195
|
'clientOrderId': self.safe_string(order, 'text'),
|
4192
4196
|
'info': order,
|
4193
4197
|
'status': 'rejected',
|
4198
|
+
'id': self.safe_string(order, 'id'),
|
4194
4199
|
})
|
4195
4200
|
put = self.safe_value_2(order, 'put', 'initial', {})
|
4196
4201
|
trigger = self.safe_value(order, 'trigger', {})
|
@@ -4726,6 +4731,81 @@ class gate(Exchange, ImplicitAPI):
|
|
4726
4731
|
#
|
4727
4732
|
return self.parse_order(response, market)
|
4728
4733
|
|
4734
|
+
def cancel_orders(self, ids: List[str], symbol: Str = None, params={}):
|
4735
|
+
"""
|
4736
|
+
cancel multiple orders
|
4737
|
+
:see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
|
4738
|
+
:see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list-2
|
4739
|
+
:param str[] ids: order ids
|
4740
|
+
:param str symbol: unified symbol of the market the order was made in
|
4741
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4742
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4743
|
+
"""
|
4744
|
+
self.load_markets()
|
4745
|
+
market = None
|
4746
|
+
if symbol is not None:
|
4747
|
+
market = self.market(symbol)
|
4748
|
+
type = None
|
4749
|
+
defaultSettle = 'usdt' if (market is None) else market['settle']
|
4750
|
+
settle = self.safe_string_lower(params, 'settle', defaultSettle)
|
4751
|
+
type, params = self.handle_market_type_and_params('cancelOrders', market, params)
|
4752
|
+
isSpot = (type == 'spot')
|
4753
|
+
if isSpot and (symbol is None):
|
4754
|
+
raise ArgumentsRequired(self.id + ' cancelOrders requires a symbol argument for spot markets')
|
4755
|
+
if isSpot:
|
4756
|
+
ordersRequests = []
|
4757
|
+
for i in range(0, len(ids)):
|
4758
|
+
id = ids[i]
|
4759
|
+
orderItem: dict = {
|
4760
|
+
'id': id,
|
4761
|
+
'symbol': symbol,
|
4762
|
+
}
|
4763
|
+
ordersRequests.append(orderItem)
|
4764
|
+
return self.cancel_orders_for_symbols(ordersRequests, params)
|
4765
|
+
request = {
|
4766
|
+
'settle': settle,
|
4767
|
+
}
|
4768
|
+
finalList = [request] # hacky but needs to be done here
|
4769
|
+
for i in range(0, len(ids)):
|
4770
|
+
finalList.append(ids[i])
|
4771
|
+
response = self.privateFuturesPostSettleBatchCancelOrders(finalList)
|
4772
|
+
return self.parse_orders(response)
|
4773
|
+
|
4774
|
+
def cancel_orders_for_symbols(self, orders: List[CancellationRequest], params={}):
|
4775
|
+
"""
|
4776
|
+
cancel multiple orders for multiple symbols
|
4777
|
+
:see: https://www.gate.io/docs/developers/apiv4/en/#cancel-a-batch-of-orders-with-an-id-list
|
4778
|
+
:param str[] ids: order ids
|
4779
|
+
:param str symbol: unified symbol of the market the order was made in
|
4780
|
+
:param dict [params]: extra parameters specific to the exchange API endpoint
|
4781
|
+
:param str[] [params.clientOrderIds]: client order ids
|
4782
|
+
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4783
|
+
"""
|
4784
|
+
self.load_markets()
|
4785
|
+
ordersRequests = []
|
4786
|
+
for i in range(0, len(orders)):
|
4787
|
+
order = orders[i]
|
4788
|
+
symbol = self.safe_string(order, 'symbol')
|
4789
|
+
market = self.market(symbol)
|
4790
|
+
if not market['spot']:
|
4791
|
+
raise NotSupported(self.id + ' cancelOrdersForSymbols() supports only spot markets')
|
4792
|
+
id = self.safe_string(order, 'id')
|
4793
|
+
orderItem: dict = {
|
4794
|
+
'id': id,
|
4795
|
+
'currency_pair': market['id'],
|
4796
|
+
}
|
4797
|
+
ordersRequests.append(orderItem)
|
4798
|
+
response = self.privateSpotPostCancelBatchOrders(ordersRequests)
|
4799
|
+
#
|
4800
|
+
# [
|
4801
|
+
# {
|
4802
|
+
# "currency_pair": "BTC_USDT",
|
4803
|
+
# "id": "123456"
|
4804
|
+
# }
|
4805
|
+
# ]
|
4806
|
+
#
|
4807
|
+
return self.parse_orders(response)
|
4808
|
+
|
4729
4809
|
def cancel_all_orders(self, symbol: Str = None, params={}):
|
4730
4810
|
"""
|
4731
4811
|
cancel all open orders
|
@@ -5652,7 +5732,20 @@ class gate(Exchange, ImplicitAPI):
|
|
5652
5732
|
authentication = api[0] # public, private
|
5653
5733
|
type = api[1] # spot, margin, future, delivery
|
5654
5734
|
query = self.omit(params, self.extract_params(path))
|
5655
|
-
|
5735
|
+
containsSettle = path.find('settle') > -1
|
5736
|
+
if containsSettle and path.endswith('batch_cancel_orders'): # weird check to prevent $settle in php and converting {settle} to array(settle)
|
5737
|
+
# special case where we need to extract the settle from the path
|
5738
|
+
# but the body is an array of strings
|
5739
|
+
settle = self.safe_dict(params, 0)
|
5740
|
+
path = self.implode_params(path, settle)
|
5741
|
+
# remove the first element from params
|
5742
|
+
newParams = []
|
5743
|
+
anyParams = params
|
5744
|
+
for i in range(1, len(anyParams)):
|
5745
|
+
newParams.append(params[i])
|
5746
|
+
params = newParams
|
5747
|
+
query = newParams
|
5748
|
+
elif isinstance(params, list):
|
5656
5749
|
# endpoints like createOrders use an array instead of an object
|
5657
5750
|
# so we infer the settle from one of the elements
|
5658
5751
|
# they have to be all the same so relying on the first one is fine
|
@@ -7011,6 +7104,7 @@ class gate(Exchange, ImplicitAPI):
|
|
7011
7104
|
# {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: Trigger.rule"}
|
7012
7105
|
# {"label": "INVALID_PARAM_VALUE", "message": "invalid argument: trigger.expiration invalid range"}
|
7013
7106
|
# {"label": "INVALID_ARGUMENT", "detail": "invalid size"}
|
7107
|
+
# {"user_id":10406147,"id":"id","succeeded":false,"message":"INVALID_PROTOCOL","label":"INVALID_PROTOCOL"}
|
7014
7108
|
#
|
7015
7109
|
label = self.safe_string(response, 'label')
|
7016
7110
|
if label is not None:
|
ccxt/htx.py
CHANGED
@@ -5521,7 +5521,62 @@ class htx(Exchange, ImplicitAPI):
|
|
5521
5521
|
# "ts": 1604367997451
|
5522
5522
|
# }
|
5523
5523
|
#
|
5524
|
-
|
5524
|
+
data = self.safe_dict(response, 'data')
|
5525
|
+
return self.parse_cancel_orders(data)
|
5526
|
+
|
5527
|
+
def parse_cancel_orders(self, orders):
|
5528
|
+
#
|
5529
|
+
# {
|
5530
|
+
# "success": [
|
5531
|
+
# "5983466"
|
5532
|
+
# ],
|
5533
|
+
# "failed": [
|
5534
|
+
# {
|
5535
|
+
# "err-msg": "Incorrect order state",
|
5536
|
+
# "order-state": 7,
|
5537
|
+
# "order-id": "",
|
5538
|
+
# "err-code": "order-orderstate-error",
|
5539
|
+
# "client-order-id": "first"
|
5540
|
+
# },
|
5541
|
+
# ...
|
5542
|
+
# ]
|
5543
|
+
# }
|
5544
|
+
#
|
5545
|
+
# {
|
5546
|
+
# "errors": [
|
5547
|
+
# {
|
5548
|
+
# "order_id": "769206471845261312",
|
5549
|
+
# "err_code": 1061,
|
5550
|
+
# "err_msg": "This order doesnt exist."
|
5551
|
+
# }
|
5552
|
+
# ],
|
5553
|
+
# "successes": "1258075374411399168,1258075393254871040"
|
5554
|
+
# }
|
5555
|
+
#
|
5556
|
+
successes = self.safe_string(orders, 'successes')
|
5557
|
+
success = None
|
5558
|
+
if successes is not None:
|
5559
|
+
success = successes.split(',')
|
5560
|
+
else:
|
5561
|
+
success = self.safe_list(orders, 'success', [])
|
5562
|
+
failed = self.safe_list_2(orders, 'errors', 'failed', [])
|
5563
|
+
result = []
|
5564
|
+
for i in range(0, len(success)):
|
5565
|
+
order = success[i]
|
5566
|
+
result.append(self.safe_order({
|
5567
|
+
'info': order,
|
5568
|
+
'id': order,
|
5569
|
+
'status': 'canceled',
|
5570
|
+
}))
|
5571
|
+
for i in range(0, len(failed)):
|
5572
|
+
order = failed[i]
|
5573
|
+
result.append(self.safe_order({
|
5574
|
+
'info': order,
|
5575
|
+
'id': self.safe_string_2(order, 'order-id', 'order_id'),
|
5576
|
+
'status': 'failed',
|
5577
|
+
'clientOrderId': self.safe_string(order, 'client-order-id'),
|
5578
|
+
}))
|
5579
|
+
return result
|
5525
5580
|
|
5526
5581
|
def cancel_all_orders(self, symbol: Str = None, params={}):
|
5527
5582
|
"""
|
@@ -5558,6 +5613,22 @@ class htx(Exchange, ImplicitAPI):
|
|
5558
5613
|
if symbol is not None:
|
5559
5614
|
request['symbol'] = market['id']
|
5560
5615
|
response = self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
|
5616
|
+
#
|
5617
|
+
# {
|
5618
|
+
# "code": 200,
|
5619
|
+
# "data": {
|
5620
|
+
# "success-count": 2,
|
5621
|
+
# "failed-count": 0,
|
5622
|
+
# "next-id": 5454600
|
5623
|
+
# }
|
5624
|
+
# }
|
5625
|
+
#
|
5626
|
+
data = self.safe_dict(response, 'data')
|
5627
|
+
return [
|
5628
|
+
self.safe_order({
|
5629
|
+
'info': data,
|
5630
|
+
}),
|
5631
|
+
]
|
5561
5632
|
else:
|
5562
5633
|
if symbol is None:
|
5563
5634
|
raise ArgumentsRequired(self.id + ' cancelAllOrders() requires a symbol argument')
|
@@ -5611,30 +5682,18 @@ class htx(Exchange, ImplicitAPI):
|
|
5611
5682
|
response = self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
|
5612
5683
|
else:
|
5613
5684
|
raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
|
5614
|
-
|
5615
|
-
|
5616
|
-
|
5617
|
-
|
5618
|
-
|
5619
|
-
|
5620
|
-
|
5621
|
-
|
5622
|
-
|
5623
|
-
|
5624
|
-
|
5625
|
-
|
5626
|
-
# future and swap
|
5627
|
-
#
|
5628
|
-
# {
|
5629
|
-
# "status": "ok",
|
5630
|
-
# "data": {
|
5631
|
-
# "errors": [],
|
5632
|
-
# "successes": "1104754904426696704"
|
5633
|
-
# },
|
5634
|
-
# "ts": "1683435723755"
|
5635
|
-
# }
|
5636
|
-
#
|
5637
|
-
return response
|
5685
|
+
#
|
5686
|
+
# {
|
5687
|
+
# "status": "ok",
|
5688
|
+
# "data": {
|
5689
|
+
# "errors": [],
|
5690
|
+
# "successes": "1104754904426696704"
|
5691
|
+
# },
|
5692
|
+
# "ts": "1683435723755"
|
5693
|
+
# }
|
5694
|
+
#
|
5695
|
+
data = self.safe_dict(response, 'data')
|
5696
|
+
return self.parse_cancel_orders(data)
|
5638
5697
|
|
5639
5698
|
def cancel_all_orders_after(self, timeout: Int, params={}):
|
5640
5699
|
"""
|