ccxt 3.0.96__py2.py3-none-any.whl → 3.0.98__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ccxt/__init__.py +1 -1
- ccxt/async_support/__init__.py +1 -1
- ccxt/async_support/base/exchange.py +1 -1
- ccxt/async_support/coinex.py +10 -1
- ccxt/async_support/huobi.py +168 -92
- ccxt/async_support/phemex.py +2 -2
- ccxt/base/exchange.py +2 -2
- ccxt/coinex.py +10 -1
- ccxt/huobi.py +168 -92
- ccxt/phemex.py +2 -2
- ccxt/pro/__init__.py +1 -1
- ccxt/pro/bitfinex2.py +8 -4
- ccxt/pro/deribit.py +2 -0
- ccxt/test/test_async.py +3 -5
- ccxt/test/test_sync.py +3 -5
- {ccxt-3.0.96.dist-info → ccxt-3.0.98.dist-info}/METADATA +4 -4
- {ccxt-3.0.96.dist-info → ccxt-3.0.98.dist-info}/RECORD +19 -19
- {ccxt-3.0.96.dist-info → ccxt-3.0.98.dist-info}/WHEEL +0 -0
- {ccxt-3.0.96.dist-info → ccxt-3.0.98.dist-info}/top_level.txt +0 -0
ccxt/__init__.py
CHANGED
ccxt/async_support/__init__.py
CHANGED
ccxt/async_support/coinex.py
CHANGED
@@ -1679,6 +1679,12 @@ class coinex(Exchange, ImplicitAPI):
|
|
1679
1679
|
async def create_order(self, symbol: str, type, side: OrderSide, amount, price=None, params={}):
|
1680
1680
|
"""
|
1681
1681
|
create a trade order
|
1682
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
|
1683
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
|
1684
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
1685
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
|
1686
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
|
1687
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
|
1682
1688
|
:param str symbol: unified symbol of the market to create an order in
|
1683
1689
|
:param str type: 'market' or 'limit'
|
1684
1690
|
:param str side: 'buy' or 'sell'
|
@@ -1692,6 +1698,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1692
1698
|
:param str params['timeInForce']: "GTC", "IOC", "FOK", "PO"
|
1693
1699
|
:param bool params.postOnly:
|
1694
1700
|
:param bool params.reduceOnly:
|
1701
|
+
:param bool|None params['position_id']: *required for reduce only orders* the position id to reduce
|
1695
1702
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1696
1703
|
"""
|
1697
1704
|
await self.load_markets()
|
@@ -1706,9 +1713,11 @@ class coinex(Exchange, ImplicitAPI):
|
|
1706
1713
|
positionId = self.safe_integer_2(params, 'position_id', 'positionId') # Required for closing swap positions
|
1707
1714
|
timeInForceRaw = self.safe_string(params, 'timeInForce') # Spot: IOC, FOK, PO, GTC, ... NORMAL(default), MAKER_ONLY
|
1708
1715
|
reduceOnly = self.safe_value(params, 'reduceOnly')
|
1709
|
-
if reduceOnly
|
1716
|
+
if reduceOnly:
|
1710
1717
|
if market['type'] != 'swap':
|
1711
1718
|
raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only')
|
1719
|
+
if positionId is None:
|
1720
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders')
|
1712
1721
|
method = None
|
1713
1722
|
request = {
|
1714
1723
|
'market': market['id'],
|
ccxt/async_support/huobi.py
CHANGED
@@ -2309,8 +2309,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
2309
2309
|
# request['end-time'] = self.sum(since, 172800000) # 48 hours window
|
2310
2310
|
method = 'spotPrivateGetV1OrderMatchresults'
|
2311
2311
|
else:
|
2312
|
-
|
2313
|
-
raise ArgumentsRequired(self.id + ' fetchMyTrades() requires a symbol for ' + marketType + ' orders')
|
2312
|
+
self.check_required_symbol('fetchMyTrades', symbol)
|
2314
2313
|
request['contract'] = market['id']
|
2315
2314
|
request['trade_type'] = 0 # 0 all, 1 open long, 2 open short, 3 close short, 4 close long, 5 liquidate long positions, 6 liquidate short positions
|
2316
2315
|
if since is not None:
|
@@ -3095,8 +3094,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
3095
3094
|
else:
|
3096
3095
|
request['order-id'] = id
|
3097
3096
|
else:
|
3098
|
-
|
3099
|
-
raise ArgumentsRequired(self.id + ' fetchOrder() requires a symbol for ' + marketType + ' orders')
|
3097
|
+
self.check_required_symbol('fetchOrder', symbol)
|
3100
3098
|
request['contract_code'] = market['id']
|
3101
3099
|
if market['linear']:
|
3102
3100
|
marginMode = None
|
@@ -3266,8 +3264,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
3266
3264
|
async def fetch_spot_orders_by_states(self, states, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
3267
3265
|
method = self.safe_string(self.options, 'fetchOrdersByStatesMethod', 'spot_private_get_v1_order_orders') # spot_private_get_v1_order_history
|
3268
3266
|
if method == 'spot_private_get_v1_order_orders':
|
3269
|
-
|
3270
|
-
raise ArgumentsRequired(self.id + ' fetchOrders() requires a symbol argument')
|
3267
|
+
self.check_required_symbol('fetchOrders', symbol)
|
3271
3268
|
await self.load_markets()
|
3272
3269
|
market = None
|
3273
3270
|
request = {
|
@@ -3332,8 +3329,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
3332
3329
|
return await self.fetch_spot_orders_by_states('filled,partial-canceled,canceled', symbol, since, limit, params)
|
3333
3330
|
|
3334
3331
|
async def fetch_contract_orders(self, symbol: Optional[str] = None, since: Optional[int] = None, limit: Optional[int] = None, params={}):
|
3335
|
-
|
3336
|
-
raise ArgumentsRequired(self.id + ' fetchContractOrders() requires a symbol argument')
|
3332
|
+
self.check_required_symbol('fetchContractOrders', symbol)
|
3337
3333
|
await self.load_markets()
|
3338
3334
|
market = self.market(symbol)
|
3339
3335
|
request = {
|
@@ -3640,8 +3636,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
3640
3636
|
params = self.omit(params, 'account-id')
|
3641
3637
|
response = await self.spotPrivateGetV1OrderOpenOrders(self.extend(request, params))
|
3642
3638
|
else:
|
3643
|
-
|
3644
|
-
raise ArgumentsRequired(self.id + ' fetchOpenOrders() requires a symbol for ' + marketType + ' orders')
|
3639
|
+
self.check_required_symbol('fetchOpenOrders', symbol)
|
3645
3640
|
if limit is not None:
|
3646
3641
|
request['page_size'] = limit
|
3647
3642
|
request['contract_code'] = market['id']
|
@@ -4485,6 +4480,8 @@ class huobi(Exchange, ImplicitAPI):
|
|
4485
4480
|
:param str id: order id
|
4486
4481
|
:param str|None symbol: unified symbol of the market the order was made in
|
4487
4482
|
:param dict params: extra parameters specific to the huobi api endpoint
|
4483
|
+
:param bool|None params['stop']: *contract only* if the order is a stop trigger order or not
|
4484
|
+
:param bool|None params['stopLossTakeProfit']: *contract only* if the order is a stop-loss or take-profit order
|
4488
4485
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
4489
4486
|
"""
|
4490
4487
|
await self.load_markets()
|
@@ -4505,60 +4502,83 @@ class huobi(Exchange, ImplicitAPI):
|
|
4505
4502
|
# 'pair': 'BTC-USDT',
|
4506
4503
|
# 'contract_type': 'this_week', # swap, self_week, next_week, quarter, next_ quarter
|
4507
4504
|
}
|
4508
|
-
|
4505
|
+
response = None
|
4509
4506
|
if marketType == 'spot':
|
4510
4507
|
clientOrderId = self.safe_string_2(params, 'client-order-id', 'clientOrderId')
|
4511
|
-
method = 'spotPrivatePostV1OrderOrdersOrderIdSubmitcancel'
|
4512
4508
|
if clientOrderId is None:
|
4513
4509
|
request['order-id'] = id
|
4510
|
+
response = await self.spotPrivatePostV1OrderOrdersOrderIdSubmitcancel(self.extend(request, params))
|
4514
4511
|
else:
|
4515
4512
|
request['client-order-id'] = clientOrderId
|
4516
|
-
method = 'spotPrivatePostV1OrderOrdersSubmitCancelClientOrder'
|
4517
4513
|
params = self.omit(params, ['client-order-id', 'clientOrderId'])
|
4514
|
+
response = await self.spotPrivatePostV1OrderOrdersSubmitCancelClientOrder(self.extend(request, params))
|
4518
4515
|
else:
|
4519
|
-
|
4520
|
-
|
4521
|
-
|
4516
|
+
self.check_required_symbol('cancelOrder', symbol)
|
4517
|
+
clientOrderId = self.safe_string_2(params, 'client_order_id', 'clientOrderId')
|
4518
|
+
if clientOrderId is None:
|
4519
|
+
request['order_id'] = id
|
4520
|
+
else:
|
4521
|
+
request['client_order_id'] = clientOrderId
|
4522
|
+
params = self.omit(params, ['client_order_id', 'clientOrderId'])
|
4523
|
+
if market['future']:
|
4524
|
+
request['symbol'] = market['settleId']
|
4525
|
+
else:
|
4526
|
+
request['contract_code'] = market['id']
|
4527
|
+
stop = self.safe_value(params, 'stop')
|
4528
|
+
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
4529
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit'])
|
4522
4530
|
if market['linear']:
|
4523
4531
|
marginMode = None
|
4524
4532
|
marginMode, params = self.handle_margin_mode_and_params('cancelOrder', params)
|
4525
4533
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
4526
4534
|
if marginMode == 'isolated':
|
4527
|
-
|
4535
|
+
if stop:
|
4536
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
4537
|
+
elif stopLossTakeProfit:
|
4538
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
|
4539
|
+
else:
|
4540
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
|
4528
4541
|
elif marginMode == 'cross':
|
4529
|
-
|
4542
|
+
if stop:
|
4543
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
|
4544
|
+
elif stopLossTakeProfit:
|
4545
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
|
4546
|
+
else:
|
4547
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
|
4530
4548
|
elif market['inverse']:
|
4531
|
-
if market['
|
4532
|
-
|
4533
|
-
|
4534
|
-
|
4535
|
-
|
4549
|
+
if market['swap']:
|
4550
|
+
if stop:
|
4551
|
+
response = await self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
4552
|
+
elif stopLossTakeProfit:
|
4553
|
+
response = await self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
|
4554
|
+
else:
|
4555
|
+
response = await self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
|
4556
|
+
elif market['future']:
|
4557
|
+
if stop:
|
4558
|
+
response = await self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
|
4559
|
+
elif stopLossTakeProfit:
|
4560
|
+
response = await self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
|
4561
|
+
else:
|
4562
|
+
response = await self.contractPrivatePostApiV1ContractCancel(self.extend(request, params))
|
4536
4563
|
else:
|
4537
4564
|
raise NotSupported(self.id + ' cancelOrder() does not support ' + marketType + ' markets')
|
4538
|
-
clientOrderId = self.safe_string_2(params, 'client_order_id', 'clientOrderId')
|
4539
|
-
if clientOrderId is None:
|
4540
|
-
request['order_id'] = id
|
4541
|
-
else:
|
4542
|
-
request['client_order_id'] = clientOrderId
|
4543
|
-
params = self.omit(params, ['client_order_id', 'clientOrderId'])
|
4544
|
-
response = await getattr(self, method)(self.extend(request, params))
|
4545
4565
|
#
|
4546
4566
|
# spot
|
4547
4567
|
#
|
4548
4568
|
# {
|
4549
|
-
#
|
4550
|
-
#
|
4569
|
+
# "status": "ok",
|
4570
|
+
# "data": "10138899000",
|
4551
4571
|
# }
|
4552
4572
|
#
|
4553
|
-
#
|
4573
|
+
# future and swap
|
4554
4574
|
#
|
4555
4575
|
# {
|
4556
|
-
# "status":"ok",
|
4557
|
-
# "data":{
|
4558
|
-
# "errors":[],
|
4559
|
-
# "successes":"924660854912552960"
|
4576
|
+
# "status": "ok",
|
4577
|
+
# "data": {
|
4578
|
+
# "errors": [],
|
4579
|
+
# "successes": "924660854912552960"
|
4560
4580
|
# },
|
4561
|
-
# "ts":1640504486089
|
4581
|
+
# "ts": 1640504486089
|
4562
4582
|
# }
|
4563
4583
|
#
|
4564
4584
|
return self.extend(self.parse_order(response, market), {
|
@@ -4572,6 +4592,8 @@ class huobi(Exchange, ImplicitAPI):
|
|
4572
4592
|
:param [str] ids: order ids
|
4573
4593
|
:param str|None symbol: unified market symbol, default is None
|
4574
4594
|
:param dict params: extra parameters specific to the huobi api endpoint
|
4595
|
+
:param bool|None params['stop']: *contract only* if the orders are stop trigger orders or not
|
4596
|
+
:param bool|None params['stopLossTakeProfit']: *contract only* if the orders are stop-loss or take-profit orders
|
4575
4597
|
:returns dict: an list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4576
4598
|
"""
|
4577
4599
|
await self.load_markets()
|
@@ -4582,7 +4604,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
4582
4604
|
marketType, params = self.handle_market_type_and_params('cancelOrders', market, params)
|
4583
4605
|
request = {
|
4584
4606
|
# spot -----------------------------------------------------------
|
4585
|
-
# 'order-ids':
|
4607
|
+
# 'order-ids': ','.join(ids), # max 50
|
4586
4608
|
# 'client-order-ids': ','.join(ids), # max 50
|
4587
4609
|
# contracts ------------------------------------------------------
|
4588
4610
|
# 'order_id': id, # comma separated, max 10
|
@@ -4590,43 +4612,24 @@ class huobi(Exchange, ImplicitAPI):
|
|
4590
4612
|
# 'contract_code': market['id'],
|
4591
4613
|
# 'symbol': market['settleId'],
|
4592
4614
|
}
|
4593
|
-
|
4615
|
+
response = None
|
4594
4616
|
if marketType == 'spot':
|
4595
4617
|
clientOrderIds = self.safe_value_2(params, 'client-order-id', 'clientOrderId')
|
4596
4618
|
clientOrderIds = self.safe_value_2(params, 'client-order-ids', 'clientOrderIds', clientOrderIds)
|
4597
4619
|
if clientOrderIds is None:
|
4598
4620
|
if isinstance(clientOrderIds, str):
|
4599
|
-
request['order-ids'] = ids
|
4621
|
+
request['order-ids'] = [ids]
|
4600
4622
|
else:
|
4601
|
-
request['order-ids'] =
|
4623
|
+
request['order-ids'] = ids
|
4602
4624
|
else:
|
4603
4625
|
if isinstance(clientOrderIds, str):
|
4604
|
-
request['client-order-ids'] = clientOrderIds
|
4626
|
+
request['client-order-ids'] = [clientOrderIds]
|
4605
4627
|
else:
|
4606
|
-
request['client-order-ids'] =
|
4628
|
+
request['client-order-ids'] = clientOrderIds
|
4607
4629
|
params = self.omit(params, ['client-order-id', 'client-order-ids', 'clientOrderId', 'clientOrderIds'])
|
4608
|
-
|
4630
|
+
response = await self.spotPrivatePostV1OrderOrdersBatchcancel(self.extend(request, params))
|
4609
4631
|
else:
|
4610
|
-
|
4611
|
-
raise ArgumentsRequired(self.id + ' cancelOrders() requires a symbol for ' + marketType + ' orders')
|
4612
|
-
marketInner = self.market(symbol)
|
4613
|
-
request['contract_code'] = marketInner['id']
|
4614
|
-
if marketInner['linear']:
|
4615
|
-
marginMode = None
|
4616
|
-
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
4617
|
-
marginMode = 'cross' if (marginMode is None) else marginMode
|
4618
|
-
if marginMode == 'isolated':
|
4619
|
-
method = 'contractPrivatePostLinearSwapApiV1SwapCancel'
|
4620
|
-
elif marginMode == 'cross':
|
4621
|
-
method = 'contractPrivatePostLinearSwapApiV1SwapCrossCancel'
|
4622
|
-
elif marketInner['inverse']:
|
4623
|
-
if marketInner['future']:
|
4624
|
-
method = 'contractPrivatePostApiV1ContractCancel'
|
4625
|
-
request['symbol'] = marketInner['settleId']
|
4626
|
-
elif marketInner['swap']:
|
4627
|
-
method = 'contractPrivatePostSwapApiV1SwapCancel'
|
4628
|
-
else:
|
4629
|
-
raise NotSupported(self.id + ' cancelOrders() does not support ' + marketType + ' markets')
|
4632
|
+
self.check_required_symbol('cancelOrders', symbol)
|
4630
4633
|
clientOrderIds = self.safe_string_2(params, 'client_order_id', 'clientOrderId')
|
4631
4634
|
clientOrderIds = self.safe_string_2(params, 'client_order_ids', 'clientOrderIds', clientOrderIds)
|
4632
4635
|
if clientOrderIds is None:
|
@@ -4634,7 +4637,48 @@ class huobi(Exchange, ImplicitAPI):
|
|
4634
4637
|
else:
|
4635
4638
|
request['client_order_id'] = clientOrderIds
|
4636
4639
|
params = self.omit(params, ['client_order_id', 'client_order_ids', 'clientOrderId', 'clientOrderIds'])
|
4637
|
-
|
4640
|
+
if market['future']:
|
4641
|
+
request['symbol'] = market['settleId']
|
4642
|
+
else:
|
4643
|
+
request['contract_code'] = market['id']
|
4644
|
+
stop = self.safe_value(params, 'stop')
|
4645
|
+
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
4646
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit'])
|
4647
|
+
if market['linear']:
|
4648
|
+
marginMode = None
|
4649
|
+
marginMode, params = self.handle_margin_mode_and_params('cancelOrders', params)
|
4650
|
+
marginMode = 'cross' if (marginMode is None) else marginMode
|
4651
|
+
if marginMode == 'isolated':
|
4652
|
+
if stop:
|
4653
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
4654
|
+
elif stopLossTakeProfit:
|
4655
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancel(self.extend(request, params))
|
4656
|
+
else:
|
4657
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCancel(self.extend(request, params))
|
4658
|
+
elif marginMode == 'cross':
|
4659
|
+
if stop:
|
4660
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancel(self.extend(request, params))
|
4661
|
+
elif stopLossTakeProfit:
|
4662
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancel(self.extend(request, params))
|
4663
|
+
else:
|
4664
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancel(self.extend(request, params))
|
4665
|
+
elif market['inverse']:
|
4666
|
+
if market['swap']:
|
4667
|
+
if stop:
|
4668
|
+
response = await self.contractPrivatePostSwapApiV1SwapTriggerCancel(self.extend(request, params))
|
4669
|
+
elif stopLossTakeProfit:
|
4670
|
+
response = await self.contractPrivatePostSwapApiV1SwapTpslCancel(self.extend(request, params))
|
4671
|
+
else:
|
4672
|
+
response = await self.contractPrivatePostSwapApiV1SwapCancel(self.extend(request, params))
|
4673
|
+
elif market['future']:
|
4674
|
+
if stop:
|
4675
|
+
response = await self.contractPrivatePostApiV1ContractTriggerCancel(self.extend(request, params))
|
4676
|
+
elif stopLossTakeProfit:
|
4677
|
+
response = await self.contractPrivatePostApiV1ContractTpslCancel(self.extend(request, params))
|
4678
|
+
else:
|
4679
|
+
response = await self.contractPrivatePostApiV1ContractCancel(self.extend(request, params))
|
4680
|
+
else:
|
4681
|
+
raise NotSupported(self.id + ' cancelOrders() does not support ' + marketType + ' markets')
|
4638
4682
|
#
|
4639
4683
|
# spot
|
4640
4684
|
#
|
@@ -4669,7 +4713,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
4669
4713
|
# }
|
4670
4714
|
# }
|
4671
4715
|
#
|
4672
|
-
#
|
4716
|
+
# future and swap
|
4673
4717
|
#
|
4674
4718
|
# {
|
4675
4719
|
# "status": "ok",
|
@@ -4693,6 +4737,8 @@ class huobi(Exchange, ImplicitAPI):
|
|
4693
4737
|
cancel all open orders
|
4694
4738
|
:param str|None symbol: unified market symbol, only orders in the market of self symbol are cancelled when symbol is not None
|
4695
4739
|
:param dict params: extra parameters specific to the huobi api endpoint
|
4740
|
+
:param bool|None params['stop']: *contract only* if the orders are stop trigger orders or not
|
4741
|
+
:param bool|None params['stopLossTakeProfit']: *contract only* if the orders are stop-loss or take-profit orders
|
4696
4742
|
:returns [dict]: a list of `order structures <https://docs.ccxt.com/#/?id=order-structure>`
|
4697
4743
|
"""
|
4698
4744
|
await self.load_markets()
|
@@ -4715,34 +4761,56 @@ class huobi(Exchange, ImplicitAPI):
|
|
4715
4761
|
# 'direction': 'buy': # buy, sell
|
4716
4762
|
# 'offset': 'open', # open, close
|
4717
4763
|
}
|
4718
|
-
|
4764
|
+
response = None
|
4719
4765
|
if marketType == 'spot':
|
4720
4766
|
if symbol is not None:
|
4721
|
-
market = self.market(symbol)
|
4722
4767
|
request['symbol'] = market['id']
|
4723
|
-
|
4768
|
+
response = await self.spotPrivatePostV1OrderOrdersBatchCancelOpenOrders(self.extend(request, params))
|
4724
4769
|
else:
|
4725
|
-
|
4726
|
-
|
4727
|
-
|
4728
|
-
request['contract_code'] =
|
4729
|
-
|
4770
|
+
self.check_required_symbol('cancelAllOrders', symbol)
|
4771
|
+
if market['future']:
|
4772
|
+
request['symbol'] = market['settleId']
|
4773
|
+
request['contract_code'] = market['id']
|
4774
|
+
stop = self.safe_value(params, 'stop')
|
4775
|
+
stopLossTakeProfit = self.safe_value(params, 'stopLossTakeProfit')
|
4776
|
+
params = self.omit(params, ['stop', 'stopLossTakeProfit'])
|
4777
|
+
if market['linear']:
|
4730
4778
|
marginMode = None
|
4731
4779
|
marginMode, params = self.handle_margin_mode_and_params('cancelAllOrders', params)
|
4732
4780
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
4733
4781
|
if marginMode == 'isolated':
|
4734
|
-
|
4782
|
+
if stop:
|
4783
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTriggerCancelall(self.extend(request, params))
|
4784
|
+
elif stopLossTakeProfit:
|
4785
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapTpslCancelall(self.extend(request, params))
|
4786
|
+
else:
|
4787
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCancelall(self.extend(request, params))
|
4735
4788
|
elif marginMode == 'cross':
|
4736
|
-
|
4737
|
-
|
4738
|
-
|
4739
|
-
|
4740
|
-
|
4741
|
-
|
4742
|
-
|
4743
|
-
|
4744
|
-
|
4745
|
-
|
4789
|
+
if stop:
|
4790
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTriggerCancelall(self.extend(request, params))
|
4791
|
+
elif stopLossTakeProfit:
|
4792
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossTpslCancelall(self.extend(request, params))
|
4793
|
+
else:
|
4794
|
+
response = await self.contractPrivatePostLinearSwapApiV1SwapCrossCancelall(self.extend(request, params))
|
4795
|
+
elif market['inverse']:
|
4796
|
+
if market['swap']:
|
4797
|
+
if stop:
|
4798
|
+
response = await self.contractPrivatePostSwapApiV1SwapTriggerCancelall(self.extend(request, params))
|
4799
|
+
elif stopLossTakeProfit:
|
4800
|
+
response = await self.contractPrivatePostSwapApiV1SwapTpslCancelall(self.extend(request, params))
|
4801
|
+
else:
|
4802
|
+
response = await self.contractPrivatePostSwapApiV1SwapCancelall(self.extend(request, params))
|
4803
|
+
elif market['future']:
|
4804
|
+
if stop:
|
4805
|
+
response = await self.contractPrivatePostApiV1ContractTriggerCancelall(self.extend(request, params))
|
4806
|
+
elif stopLossTakeProfit:
|
4807
|
+
response = await self.contractPrivatePostApiV1ContractTpslCancelall(self.extend(request, params))
|
4808
|
+
else:
|
4809
|
+
response = await self.contractPrivatePostApiV1ContractCancelall(self.extend(request, params))
|
4810
|
+
else:
|
4811
|
+
raise NotSupported(self.id + ' cancelAllOrders() does not support ' + marketType + ' markets')
|
4812
|
+
#
|
4813
|
+
# spot
|
4746
4814
|
#
|
4747
4815
|
# {
|
4748
4816
|
# code: 200,
|
@@ -4753,6 +4821,17 @@ class huobi(Exchange, ImplicitAPI):
|
|
4753
4821
|
# }
|
4754
4822
|
# }
|
4755
4823
|
#
|
4824
|
+
# future and swap
|
4825
|
+
#
|
4826
|
+
# {
|
4827
|
+
# status: "ok",
|
4828
|
+
# data: {
|
4829
|
+
# errors: [],
|
4830
|
+
# successes: "1104754904426696704"
|
4831
|
+
# },
|
4832
|
+
# ts: "1683435723755"
|
4833
|
+
# }
|
4834
|
+
#
|
4756
4835
|
return response
|
4757
4836
|
|
4758
4837
|
def parse_deposit_address(self, depositAddress, currency=None):
|
@@ -5354,8 +5433,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
5354
5433
|
:param dict params: extra parameters specific to the huobi api endpoint
|
5355
5434
|
:returns [dict]: a list of `funding rate structures <https://docs.ccxt.com/en/latest/manual.html?#funding-rate-history-structure>`
|
5356
5435
|
"""
|
5357
|
-
|
5358
|
-
raise ArgumentsRequired(self.id + ' fetchFundingRateHistory() requires a symbol argument')
|
5436
|
+
self.check_required_symbol('fetchFundingRateHistory', symbol)
|
5359
5437
|
await self.load_markets()
|
5360
5438
|
market = self.market(symbol)
|
5361
5439
|
request = {
|
@@ -5859,8 +5937,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
5859
5937
|
:param dict params: extra parameters specific to the huobi api endpoint
|
5860
5938
|
:returns dict: response from the exchange
|
5861
5939
|
"""
|
5862
|
-
|
5863
|
-
raise ArgumentsRequired(self.id + ' setLeverage() requires a symbol argument')
|
5940
|
+
self.check_required_symbol('setLeverage', symbol)
|
5864
5941
|
await self.load_markets()
|
5865
5942
|
market = self.market(symbol)
|
5866
5943
|
marketType, query = self.handle_market_type_and_params('setLeverage', market, params)
|
@@ -6939,8 +7016,7 @@ class huobi(Exchange, ImplicitAPI):
|
|
6939
7016
|
marginMode = 'cross' if (marginMode is None) else marginMode
|
6940
7017
|
method = None
|
6941
7018
|
if marginMode == 'isolated':
|
6942
|
-
|
6943
|
-
raise ArgumentsRequired(self.id + ' borrowMargin() requires a symbol argument for isolated margin')
|
7019
|
+
self.check_required_symbol('borrowMargin', symbol)
|
6944
7020
|
market = self.market(symbol)
|
6945
7021
|
request['symbol'] = market['id']
|
6946
7022
|
method = 'privatePostMarginOrders'
|
ccxt/async_support/phemex.py
CHANGED
@@ -2399,7 +2399,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2399
2399
|
:param float amount: how much of currency you want to trade in units of base currency
|
2400
2400
|
:param float|None price: the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
2401
2401
|
:param dict params: extra parameters specific to the phemex api endpoint
|
2402
|
-
:param str|None params['posSide']: either '
|
2402
|
+
:param str|None params['posSide']: either 'Merged' or 'Long' or 'Short'
|
2403
2403
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2404
2404
|
"""
|
2405
2405
|
if symbol is None:
|
@@ -2457,7 +2457,7 @@ class phemex(Exchange, ImplicitAPI):
|
|
2457
2457
|
:param str id: order id
|
2458
2458
|
:param str symbol: unified symbol of the market the order was made in
|
2459
2459
|
:param dict params: extra parameters specific to the phemex api endpoint
|
2460
|
-
:param str|None params['posSide']: either '
|
2460
|
+
:param str|None params['posSide']: either 'Merged' or 'Long' or 'Short'
|
2461
2461
|
:returns dict: An `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
2462
2462
|
"""
|
2463
2463
|
if symbol is None:
|
ccxt/base/exchange.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
__version__ = '3.0.
|
7
|
+
__version__ = '3.0.98'
|
8
8
|
|
9
9
|
# -----------------------------------------------------------------------------
|
10
10
|
|
@@ -1429,7 +1429,7 @@ class Exchange(object):
|
|
1429
1429
|
ohlcvs = []
|
1430
1430
|
(timestamp, open, high, low, close, volume, count) = (0, 1, 2, 3, 4, 5, 6)
|
1431
1431
|
num_trades = len(trades)
|
1432
|
-
oldest =
|
1432
|
+
oldest = num_trades if limit is None else min(num_trades, limit)
|
1433
1433
|
for i in range(0, oldest):
|
1434
1434
|
trade = trades[i]
|
1435
1435
|
if (since is not None) and (trade['timestamp'] < since):
|
ccxt/coinex.py
CHANGED
@@ -1678,6 +1678,12 @@ class coinex(Exchange, ImplicitAPI):
|
|
1678
1678
|
def create_order(self, symbol: str, type, side: OrderSide, amount, price=None, params={}):
|
1679
1679
|
"""
|
1680
1680
|
create a trade order
|
1681
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http017_put_limit
|
1682
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http018_put_market
|
1683
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http019_put_limit_stop
|
1684
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http020_put_market_stop
|
1685
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http031_market_close
|
1686
|
+
see https://viabtc.github.io/coinex_api_en_doc/futures/#docsfutures001_http030_limit_close
|
1681
1687
|
:param str symbol: unified symbol of the market to create an order in
|
1682
1688
|
:param str type: 'market' or 'limit'
|
1683
1689
|
:param str side: 'buy' or 'sell'
|
@@ -1691,6 +1697,7 @@ class coinex(Exchange, ImplicitAPI):
|
|
1691
1697
|
:param str params['timeInForce']: "GTC", "IOC", "FOK", "PO"
|
1692
1698
|
:param bool params.postOnly:
|
1693
1699
|
:param bool params.reduceOnly:
|
1700
|
+
:param bool|None params['position_id']: *required for reduce only orders* the position id to reduce
|
1694
1701
|
:returns dict: an `order structure <https://docs.ccxt.com/#/?id=order-structure>`
|
1695
1702
|
"""
|
1696
1703
|
self.load_markets()
|
@@ -1705,9 +1712,11 @@ class coinex(Exchange, ImplicitAPI):
|
|
1705
1712
|
positionId = self.safe_integer_2(params, 'position_id', 'positionId') # Required for closing swap positions
|
1706
1713
|
timeInForceRaw = self.safe_string(params, 'timeInForce') # Spot: IOC, FOK, PO, GTC, ... NORMAL(default), MAKER_ONLY
|
1707
1714
|
reduceOnly = self.safe_value(params, 'reduceOnly')
|
1708
|
-
if reduceOnly
|
1715
|
+
if reduceOnly:
|
1709
1716
|
if market['type'] != 'swap':
|
1710
1717
|
raise InvalidOrder(self.id + ' createOrder() does not support reduceOnly for ' + market['type'] + ' orders, reduceOnly orders are supported for swap markets only')
|
1718
|
+
if positionId is None:
|
1719
|
+
raise ArgumentsRequired(self.id + ' createOrder() requires a position_id/positionId parameter for reduceOnly orders')
|
1711
1720
|
method = None
|
1712
1721
|
request = {
|
1713
1722
|
'market': market['id'],
|