币种标记标准化 + data-pipeline诊断文档
stale_detector: HK股价格输出加(HKD)标记,防止LLM混读CNY/HKD per_stock_reassess: 写回decisions.json的HK股加上currency: HKD docs/data-pipeline-diagnosis.md: 完整数据管道重构需求文档 避免建滔积层板CNY/HKD错配类问题复发
This commit is contained in:
@@ -55,6 +55,9 @@ def fetch_prices(codes):
|
||||
if not oc:
|
||||
continue
|
||||
p = float(fld[3]) if fld[3] else 0
|
||||
# NOTE: HK stock prices kept in HKD — decisions.json also stores HK values in HKD
|
||||
# (stop_loss/take_profit/entry). Never convert here or we mismatch CNY price vs HKD stop.
|
||||
# Downstream tools that need CNY should convert at display time.
|
||||
c = fld[32] if len(fld) > 32 else "0"
|
||||
results[oc] = (p, c)
|
||||
except (ValueError, IndexError):
|
||||
@@ -120,6 +123,10 @@ def main():
|
||||
|
||||
issues, flags = [], []
|
||||
tag = "[自选]" if is_wl else "[持仓]"
|
||||
# 币种标记(港股HKD vs A股CNY,辅助下游LLM避免混读)
|
||||
currency_suffix = "(HKD)" if len(str(code)) == 5 and str(code)[0] in '01' else ""
|
||||
price_str = f"{price:.2f}{currency_suffix}"
|
||||
buy_zone_str = f"{el}~{eh}{currency_suffix}" if currency_suffix else f"{el}~{eh}"
|
||||
|
||||
# -- 偏离 --
|
||||
if is_wl and el and eh:
|
||||
@@ -152,16 +159,16 @@ def main():
|
||||
if strategy_deficient:
|
||||
flags.append("[STRATEGY_STALE]")
|
||||
prefix = "⚠️仓位挤占 " if position_pct > 80 else ""
|
||||
issues.append(f"[STRATEGY_STALE] {prefix}价{price:.2f}在买入区{el}~{eh}但策略不完整({'RR='+f'{rr:.2f}<1.5' if rr_invalid else '无止盈位' if not tp else '非买入信号'}),买入区需重评")
|
||||
issues.append(f"[STRATEGY_STALE] {prefix}价{price_str}在买入区{buy_zone_str}但策略不完整({'RR='+f'{rr:.2f}<1.5' if rr_invalid else '无止盈位' if not tp else '非买入信号'}),买入区需重评")
|
||||
else:
|
||||
prefix = "⚠️仓位挤占 " if position_pct > 80 else ""
|
||||
issues.append(f"[PUSH] {prefix}价{price:.2f}入买入区{el}~{eh}")
|
||||
issues.append(f"[PUSH] {prefix}价{price_str}入买入区{buy_zone_str}")
|
||||
elif price > eh * 1.35:
|
||||
flags.append("[WL_HIGH]")
|
||||
issues.append(f"价{price:.2f}高出买入区+{((price/eh)-1)*100:.0f}%,买入区需重评")
|
||||
issues.append(f"价{price_str}高出买入区+{((price/eh)-1)*100:.0f}%,买入区需重评")
|
||||
elif price > eh * 1.20:
|
||||
flags.append("[WL_DRIFT]")
|
||||
issues.append(f"价{price:.2f}高于买入区+{((price/eh)-1)*100:.0f}%")
|
||||
issues.append(f"价{price_str}高于买入区+{((price/eh)-1)*100:.0f}%")
|
||||
elif not is_wl and eh:
|
||||
dp = (price / eh - 1) * 100
|
||||
if dp > 35:
|
||||
@@ -215,7 +222,7 @@ def main():
|
||||
pass
|
||||
|
||||
if issues:
|
||||
print(f"{' '.join(flags)} {tag} {name}({code}) 价{price:.2f}{chg} | 买入{el}~{eh} | {'; '.join(issues)}")
|
||||
print(f"{' '.join(flags)} {tag} {name}({code}) 价{price_str}{chg} | 买入{el}~{eh} | {'; '.join(issues)}")
|
||||
found += 1
|
||||
|
||||
if found == 0:
|
||||
|
||||
Reference in New Issue
Block a user