Commit bae42e5b authored by jichao's avatar jichao

6258

parent 66653eb0
......@@ -139,12 +139,12 @@ rebalance: # 再平衡模块
signals: # 信号相关
crisis-signal: # 危机信号相关
exp-years: 3 # 预警期时长,单位自然年,点到点计算
# exp-init: 2008-01-01 # 设置起始危机预警开始时间,如果关闭初始预警起,注释到这一条即可
exp-init: 2008-01-01 # 设置起始危机预警开始时间,如果关闭初始预警起,注释到这一条即可
inversion-years: 1 # 利率倒挂计算时长,单位自然年,点到点取值
inversion-threshold: 0.3 # 利率倒挂触发阀值
crisis-1: # 危机1相关
mean-count: 850 # spx去多少交易日计算平均值
consecut-days: 5 # spx连续多少跌破平均值则触发
consecut-days: 5 # spx连续多少跌破平均值则触发
crisis-2: # 危机2相关
negative-growth: 1 # 实际利率负增长时长,单位年,点到点取值
fed-months: 3 # fed 滚动月份,点到点取值
......
......@@ -77,9 +77,15 @@ class CrisisOneSignal(CrisisSignal, BaseRebalanceSignal):
if exp_date:
crisis_one = rrs.get_first_after(type=SignalType.CRISIS_ONE, risk=risk, min_date=exp_date)
if not crisis_one:
spx = self._navs.get_last_index_close(max_date=day, ticker='SPX Index', count=self.mean_count)
spx_ma850 = pd.DataFrame(spx).close.mean()
return len([x for x in spx[0:5] if x['close'] > spx_ma850]) == 0
spx = self._navs.get_last_index_close(max_date=day, ticker='SPX Index', count=self.mean_count + self.consecut_days)
spx = pd.DataFrame(spx)
spx.sort_values(by='date', inplace=True, ascending=False)
spx.reset_index(drop=True, inplace=True)
for offset in range(self.consecut_days):
spx.loc[0 + offset, 'mean'] = spx.loc[0 + offset: 850 + offset].close.mean()
spx.dropna(inplace=True)
spx['diff'] = spx['close'] - spx['mean']
return spx[spx['diff'] >= 0].empty
return False
......
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