From 40d4170711eece32b2ff34f89393bbab9c241297 Mon Sep 17 00:00:00 2001 From: msincenselee Date: Fri, 24 Apr 2020 11:40:28 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=BC=BA]=20?= =?UTF-8?q?=E6=AF=94=E8=BE=83=E4=BB=93=E4=BD=8D/=E7=AD=96=E7=95=A5?= =?UTF-8?q?=E9=97=B4=E4=BA=92=E8=AE=BF=E9=97=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/app/cta_strategy_pro/engine.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vnpy/app/cta_strategy_pro/engine.py b/vnpy/app/cta_strategy_pro/engine.py index eff51480..5bc5aac3 100644 --- a/vnpy/app/cta_strategy_pro/engine.py +++ b/vnpy/app/cta_strategy_pro/engine.py @@ -1469,7 +1469,16 @@ class CtaEngine(BaseEngine): d.update(strategy.get_parameters()) return d - def compare_pos(self): + def get_strategy_value(self, strategy_name: str, parameter:str): + """获取策略的某个参数值""" + strategy = self.strategies.get(strategy_name) + if not strategy: + return None + + value = getattr(strategy, parameter, None) + return value + + def compare_pos(self, strategy_pos_list=[]): """ 对比账号&策略的持仓,不同的话则发出微信提醒 :return: @@ -1481,7 +1490,8 @@ class CtaEngine(BaseEngine): self.write_log(u'开始对比账号&策略的持仓') # 获取当前策略得持仓 - strategy_pos_list = self.get_all_strategy_pos() + if len(strategy_pos_list) == 0: + strategy_pos_list = self.get_all_strategy_pos() self.write_log(u'策略持仓清单:{}'.format(strategy_pos_list)) # 需要进行对比得合约集合(来自策略持仓/账号持仓)