stock-ai-agent/backend/run_astock_selector.py
2026-03-11 00:01:18 +08:00

61 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""
A股短期题材选股 - 手动执行脚本
"""
import asyncio
import sys
import os
# 添加项目根目录到Python路径
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from app.utils.logger import logger
from app.astock_agent.astock_agent import get_astock_agent
async def main():
"""手动执行选股"""
# 解析命令行参数
strict_mode = '--strict' in sys.argv or '-s' in sys.argv
try:
print("\n" + "=" * 60)
mode_text = "严格模式" if strict_mode else "宽松模式(适应当前市场)"
print(f"📊 A股短期题材选股 - 手动执行 [{mode_text}]")
print("=" * 60)
if not strict_mode:
print("\n💡 使用宽松模式:")
print(" - 市值: 30-1000亿原50-500亿")
print(" - 换手率: 1%-20%原3%-15%")
print(" - 板块涨幅: ≥1.5%原2%")
print(" - 量比: ≥1.0原1.2")
print("\n使用 --strict 或 -s 参数启用严格模式")
# 获取智能体实例
agent = get_astock_agent()
# 设置模式
agent.selector.strict_mode = strict_mode
# 执行选股
result = await agent.run_once()
# 输出结果
print("\n" + "=" * 60)
print(agent.selector.format_output_text(result))
print("=" * 60 + "\n")
return 0
except Exception as e:
logger.error(f"选股执行失败: {e}")
import traceback
logger.error(traceback.format_exc())
return 1
if __name__ == "__main__":
exit_code = asyncio.run(main())
sys.exit(exit_code)