[功能增强] 比较仓位/策略间互访问

This commit is contained in:
msincenselee 2020-04-24 11:40:28 +08:00
parent 8fcb5b6452
commit 40d4170711

View File

@ -1469,7 +1469,16 @@ class CtaEngine(BaseEngine):
d.update(strategy.get_parameters()) d.update(strategy.get_parameters())
return d 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: :return:
@ -1481,6 +1490,7 @@ class CtaEngine(BaseEngine):
self.write_log(u'开始对比账号&策略的持仓') self.write_log(u'开始对比账号&策略的持仓')
# 获取当前策略得持仓 # 获取当前策略得持仓
if len(strategy_pos_list) == 0:
strategy_pos_list = self.get_all_strategy_pos() strategy_pos_list = self.get_all_strategy_pos()
self.write_log(u'策略持仓清单:{}'.format(strategy_pos_list)) self.write_log(u'策略持仓清单:{}'.format(strategy_pos_list))