[Mod]cancel only allowd when cta template trading == true

This commit is contained in:
vn.py 2019-03-29 16:13:55 +08:00
parent 1a569dcf7f
commit 9f9e721983
3 changed files with 13 additions and 6 deletions

View File

@ -309,9 +309,12 @@ class ApexApi:
APEX.Fix_GetLastErrMsg(out, size)
return out.value
def reg_reply_call_func(sess: int, self):
"""注册全局回调函数"""
def reg_reply_call_func(self, sess: int = 0):
"""注册回调函数"""
if not sess:
n = APEX.Fix_RegReplyCallFunc(c_void_p(None), self.reply_call_func)
else:
n = APEX.Fix_RegReplyCallFunc(sess, self.reply_call_func)
return bool(n)
def on_reply(self, conn: int, sess: int, recv: int):

View File

@ -183,18 +183,21 @@ class CtaTemplate(ABC):
"""
Cancel an existing order.
"""
if self.trading:
self.cta_engine.cancel_order(self, vt_orderid)
def cancel_all(self):
"""
Cancel all orders sent by strategy.
"""
if self.trading:
self.cta_engine.cancel_all(self)
def write_log(self, msg: str):
"""
Write a log message.
"""
if self.inited:
self.cta_engine.write_log(msg, self)
def get_engine_type(self):

View File

@ -51,6 +51,7 @@ class Product(Enum):
BOND = "债券"
WARRANT = "权证"
SPREAD = "价差"
FUND = "基金"
class OrderType(Enum):