1、新增SMCPureH1LongStrategy策略
2、修复实盘bug
This commit is contained in:
@@ -112,7 +112,8 @@ class Strategy(ABC):
|
||||
|
||||
return self.context.cancel_order(order_id)
|
||||
|
||||
def cancel_all_pending_orders(self) -> int:
|
||||
|
||||
def cancel_all_pending_orders(self, main_symbol = None) -> int:
|
||||
"""取消当前策略的未决订单,仅限于当前策略关注的Symbol。"""
|
||||
# 注意:在换月模式下,引擎会自动取消旧合约的挂单,这里是策略主动取消
|
||||
if not self.trading:
|
||||
@@ -123,9 +124,14 @@ class Strategy(ABC):
|
||||
# orders_to_cancel = [
|
||||
# order.id for order in pending_orders.values() if order.symbol == self.symbol
|
||||
# ]
|
||||
orders_to_cancel = [
|
||||
order.id for order in pending_orders.values()
|
||||
]
|
||||
if main_symbol is not None:
|
||||
orders_to_cancel = [
|
||||
order.id for order in pending_orders.values() if main_symbol in order.symbol
|
||||
]
|
||||
else:
|
||||
orders_to_cancel = [
|
||||
order.id for order in pending_orders.values()
|
||||
]
|
||||
for order_id in orders_to_cancel:
|
||||
if self.cancel_order(order_id):
|
||||
cancelled_count += 1
|
||||
|
||||
Reference in New Issue
Block a user