diff --git a/vnpy/api/apex/vnapex.py b/vnpy/api/apex/vnapex.py index d6709825..cd4e3469 100644 --- a/vnpy/api/apex/vnapex.py +++ b/vnpy/api/apex/vnapex.py @@ -309,9 +309,12 @@ class ApexApi: APEX.Fix_GetLastErrMsg(out, size) return out.value - def reg_reply_call_func(sess: int, self): - """注册全局回调函数""" - n = APEX.Fix_RegReplyCallFunc(c_void_p(None), self.reply_call_func) + 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): diff --git a/vnpy/app/cta_strategy/template.py b/vnpy/app/cta_strategy/template.py index 91abef05..35c9818a 100644 --- a/vnpy/app/cta_strategy/template.py +++ b/vnpy/app/cta_strategy/template.py @@ -183,19 +183,22 @@ class CtaTemplate(ABC): """ Cancel an existing order. """ - self.cta_engine.cancel_order(self, vt_orderid) + if self.trading: + self.cta_engine.cancel_order(self, vt_orderid) def cancel_all(self): """ Cancel all orders sent by strategy. """ - self.cta_engine.cancel_all(self) + if self.trading: + self.cta_engine.cancel_all(self) def write_log(self, msg: str): """ Write a log message. """ - self.cta_engine.write_log(msg, self) + if self.inited: + self.cta_engine.write_log(msg, self) def get_engine_type(self): """ diff --git a/vnpy/trader/constant.py b/vnpy/trader/constant.py index aee7ff4c..92492f5b 100644 --- a/vnpy/trader/constant.py +++ b/vnpy/trader/constant.py @@ -51,6 +51,7 @@ class Product(Enum): BOND = "债券" WARRANT = "权证" SPREAD = "价差" + FUND = "基金" class OrderType(Enum):