34 lines
1.7 KiB
Python
34 lines
1.7 KiB
Python
"""提议当前分析的业务表达与实质变化判断,不改变合议规则。"""
|
|
|
|
|
|
def timing_view(timing):
|
|
t = timing or {}
|
|
stance = t.get('stance')
|
|
event = t.get('event') or t.get('intraday_event') or {}
|
|
if stance in ('看多', '看空', '中性'):
|
|
return {'label': stance, 'reason': event.get('reason') or {
|
|
'看多': '当前择时支持买入,仍需满足限价和资金条件',
|
|
'看空': '当前择时不支持买入', '中性': '暂无明确多空倾向'}[stance]}
|
|
signs = {g.get('direction') for g in (event.get('groups') or {}).values()
|
|
if g.get('state') == 'VALID'}
|
|
if 1 in signs and -1 in signs:
|
|
return {'label': '多空分歧', 'reason': '有效看多与看空证据并存,当前不支持买入'}
|
|
return {'label': '买入依据不足', 'reason': '有效择时证据尚不足以支持买入'}
|
|
|
|
|
|
def decision_basis(hard):
|
|
"""只比较影响建议的判断,不因证据刷新时间或事件标识变化反复打断确认。"""
|
|
h = hard or {}
|
|
con, tech, timing = h.get('consensus') or {}, h.get('tech') or {}, h.get('timing') or {}
|
|
votes = con.get('votes') or {}
|
|
return {'fund': (h.get('fund_stance') or {}).get('stance') or votes.get('fund'),
|
|
'tech': {k: tech.get(k) for k in ('stance', 'phase', 'data_date', 'sar_side')},
|
|
'intraday_confirmation': (tech.get('intraday') or {}).get('kind'),
|
|
'timing': timing.get('stance') or votes.get('timing'),
|
|
'timing_label': timing_view(timing)['label'],
|
|
'consensus': {k: con.get(k) for k in ('direction', 'strength', 'route')}}
|
|
|
|
|
|
def changed(old, current):
|
|
return decision_basis(old) != decision_basis(current)
|