feat: 股票分析加政策注入(A股CN/港美股CN+INTL) + 新建calc_cn_levels.py+fetch_policy.py

This commit is contained in:
2026-07-23 10:33:47 +08:00
parent 2b78639b9e
commit fca5bfc24d
4 changed files with 203 additions and 6 deletions
+32 -2
View File
@@ -121,6 +121,26 @@ def calc_levels(symbol: str, klines: list, quote: dict, side: str, min_rr: float
), strategy
def _read_policy(path):
"""读取政策文件,不存在则返回 None"""
p = Path(path)
return p.read_text(encoding="utf-8").strip() if p.exists() else None
def _build_header(args, strategy_label):
"""构建推送头部: 政策 + 策略"""
lines = []
# 政策注入
if args.policy:
pol = _read_policy(args.policy)
if pol:
lines.append(pol)
# 策略说明
if strategy_label and strategy_label != 'rsi2_revert':
lines.append(f"(策略: {strategy_label})")
return "\n".join(lines) if lines else ""
def format_cn_output(levels, change_pct, current_price, side, symbol, info, mode):
"""A 股格式: ¥ 符号, 股息率"""
name = info.get('name', symbol)
@@ -164,6 +184,9 @@ def main():
ap.add_argument('--strategy', default='rsi2_revert',
choices=['rsi2_revert', 'vwap_revert', 'early_bird', 'turtle_breakout'],
help='策略 (default rsi2_revert, A 股推荐)')
ap.add_argument('--policy',
default='/tmp/policy_cn.txt',
help='国内政策文件路径 (default /tmp/policy_cn.txt, 空则跳过)')
args = ap.parse_args()
# 过滤高股息
@@ -229,9 +252,16 @@ def main():
print()
if output_lines:
header = f"📊 A 股日内做T点位 ({today})\n⚠️ 仅参考, 不交易\n"
header_parts = []
pol = _read_policy(args.policy)
if pol:
header_parts.append(pol)
header_parts.append(f"📊 A 股日内做T点位 ({today})\n⚠️ 仅参考, 不交易")
if args.strategy != 'rsi2_revert':
header_parts.append(f"(策略: {args.strategy})")
header = "\n".join(header_parts)
print("\n=== QQ 推送内容 ===")
print(header + "\n---\n".join(output_lines))
print(header + "\n" + "\n---\n".join(output_lines))
else:
print("\n💤 全部场景否决, 无输出")