Commit 3052be21 authored by jichao's avatar jichao

依赖注入实现中

parent 4fb82792
...@@ -80,6 +80,15 @@ class Datum(ABC): ...@@ -80,6 +80,15 @@ class Datum(ABC):
''' '''
pass pass
@abstractmethod
def get_high_risk_datums(self, risk: PortfoliosRisk):
'''
根据指定的投组风险等级,获取高风险资产资料数据
:param risk: 投组风险等级
:return: 高风险资料信息
'''
pass
class Navs(ABC): class Navs(ABC):
''' '''
......
...@@ -114,10 +114,7 @@ class CrisisTwoSignal(CrisisSignal): ...@@ -114,10 +114,7 @@ class CrisisTwoSignal(CrisisSignal):
def get_signal(self, day, risk: PortfoliosRisk): def get_signal(self, day, risk: PortfoliosRisk):
exp_date = self.get_exp_start_date(day, risk) exp_date = self.get_exp_start_date(day, risk)
if exp_date: if exp_date:
crisis_one = rrs.get_last_one(type=SignalType.CRISIS_ONE, risk=risk, max_date=day, effective=True) crisis_two = rrs.get_first_after(type=SignalType.CRISIS_TWO, risk=risk, min_date=exp_date)
if crisis_one:
return None
crisis_two = rrs.get_first_after(type=SignalType.CRISIS_TWO, risk=risk, min_date=exp_date, effective=True)
if not crisis_two: if not crisis_two:
ng_date = day - relativedelta(years=self.negative_growth_years) ng_date = day - relativedelta(years=self.negative_growth_years)
ten_today = self._navs.get_last_index_close(max_date=day, ticker='USGG10YR Index') ten_today = self._navs.get_last_index_close(max_date=day, ticker='USGG10YR Index')
......
from framework import component, autowired
from api import SignalBuilder, PortfoliosRisk, SignalType
from rebalance.dao import robo_rebalance_signal as rrs
@component(bean_name='curve-drift')
class CurveDrift(SignalBuilder):
@property
def exclude_last_type(self):
return [
SignalType.CRISIS_ONE,
SignalType.CRISIS_TWO,
SignalType.MARKET_RIGHT,
SignalType.INIT,
SignalType.LOW_BUY
]
def get_signal(self, day, risk: PortfoliosRisk):
last_re = rrs.get_last_one(max_date=day, risk=risk, effective=True)
if last_re is None or SignalType(last_re['type']) in self.exclude_last_type:
return None
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment