Commit c81dcea7 authored by jichao's avatar jichao

调整信号规则逻辑

parent 894c849f
...@@ -48,11 +48,18 @@ class CrisisSignal(BaseRebalanceSignal, ABC): ...@@ -48,11 +48,18 @@ class CrisisSignal(BaseRebalanceSignal, ABC):
two_today = self._navs.get_last_index_close(max_date=day, ticker='USGG2YR Index') two_today = self._navs.get_last_index_close(max_date=day, ticker='USGG2YR Index')
if ten_today['close'] - two_today['close'] <= ten_before['close'] - two_before['close'] and \ if ten_today['close'] - two_today['close'] <= ten_before['close'] - two_before['close'] and \
ten_today['close'] - two_today['close'] <= self.inversion_threshold: ten_today['close'] - two_today['close'] <= self.inversion_threshold:
rrs.insert({ last_signal = rrs.get_last_one(max_date=day, risk=risk)
'date': day, if SignalType(last_signal['type']) is SignalType.NONE:
'type': SignalType.CRISIS_EXP, rrs.update(last_signal['id'], {
'risk': risk, 'date': day,
}) 'type': SignalType.CRISIS_EXP,
})
else:
rrs.insert({
'date': day,
'type': SignalType.CRISIS_EXP,
'risk': risk,
})
exp_signal = rrs.get_first_after(type=SignalType.CRISIS_EXP, risk=risk, min_date=exp_date) exp_signal = rrs.get_first_after(type=SignalType.CRISIS_EXP, risk=risk, min_date=exp_date)
return exp_signal['date'] if exp_signal else None return exp_signal['date'] if exp_signal else 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