dragon-trading-agent
龙头交易Agent · Dragon Trading Agent
一套把个人交易规则写成代码的完整系统:定时决策报告 + 规则引擎 + MCP Server + 桌面对话 Agent。
Python 3.12 · FastAPI · MCP 协议 · LLM Tool-Use · SQLite · PyInstaller
⚠️ 免责声明 / Disclaimer
中文:本项目为个人编程学习与技术研究,不构成任何投资建议,严禁用于实盘交易或商业用途,使用者后果自负。
English: This project is for personal programming learning and technical research only. It does NOT constitute investment advice. Any use for live trading or commercial purposes is strictly prohibited. All consequences are borne by the user.
Related MCP server: AI-Kline MCP Server
项目亮点
完整闭环,不是 demo:从定时调度(APScheduler)、真实行情采集、规则引擎决策,到 MCP Server 暴露给 LLM、桌面聊天交互——一整套能跑的系统。
规则引擎 21 个模块:大盘环境分级、龙头连板节点理论、波段低吸选股、策略回测、风险护栏、交易记忆(轻量 RAG)、绩效复盘,全部可独立调用。
防幻觉设计:关键行情双源交叉验证,不一致标「数据存疑」;LLM 工具结果只在当轮内存,不回写历史,历史只存纯文本。
多 Agent 决策:决策类问题(该不该做 / 买 / 卖)由 3 个分析师 + 1 个主持人多轮辩论收敛,输出动作与置信度。
产品化落地:pywebview 桌面端 + 自定义图标打包成 exe,配置面板带 key 校验;同时是标准 MCP Server,任意 LLM 可调用。
系统架构
┌─────────────────────────────────────────────┐
行情源 │ 规则引擎 (src/, 21 模块) │
┌──────────┐ │ │
│ 东方财富 │──┐ │ scheduler ──► market_env ──► node_engine │
│ 同花顺 │──┤ 真实 │ │ │ │ │
│ 腾讯行情 │──┼─行情─►│ market_review stock_picker │ │
│ 新浪行情 │──┘ │ │ │ │ │
└──────────┘ │ data_check ◄── risk_guard ◄── agent_core │
└───────┬─────────────┬─────────────┬──────────┘
│ │ │
┌────────▼──┐ ┌──────▼─────┐ ┌────▼─────────┐
│ 每日决策报告 │ │ MCP Server │ │ 桌面对话 Agent│
│ (Markdown, │ │ (32 工具) │ │ (pywebview + │
│ 可同步 │ │ 供 LLM 调用│ │ DeepSeek + │
│ Obsidian) │ │ │ │ 妙想数据源) │
└───────────┘ └────────────┘ └──────────────┘技术栈
层面 | 技术 |
后端 | Python 3.12 · FastAPI · APScheduler 定时调度 |
协议 | MCP (Model Context Protocol) Server,32 个 |
AI | DeepSeek 流式 tool-use · 妙想金融数据 MCP · 多 Agent 辩论收敛 |
数据 | 东方财富 / 同花顺 / 腾讯 qt.gtimg.cn / 新浪 —— 双源交叉验证,只信真实行情 |
存储 | SQLite(会话持久化)· JSON 账本 |
桌面 | pywebview · PyInstaller 打包(自定义龙头主题图标) |
功能总览
入口 | 说明 |
每个模块能干什么,工具清单,桌面端能力 | |
完整交易规则公开(从代码原文摘录,供学习借鉴) | |
系统每天产出的一份报告样例 |
核心产出是每日决策报告:数据校验 → 大盘环境 → 市场复盘 → 节点追踪 → 涨停板 → 波段低吸候选 → 持仓检查 → 决策结论,共 10 个 section,每段带 mermaid 流程图。
快速开始
1. 安装依赖
# 规则引擎 + 定时报告(src/)
pip install -r requirements.txt
# 桌面对话版(chat_agent/)
pip install -r chat_agent/requirements.txt2. 配置密钥(桌面版才需要)
桌面版「龙头交易Agent」需要两个 key,存到本地 config/chat_agent.json(已 gitignore,不进仓库):
cp config/chat_agent.example.json config/chat_agent.json
cp config/agent_config.example.json config/agent_config.jsonapi_key:DeepSeek(sk-...),调 DeepSeek 模型用mx_api_key:东方财富妙想 MCP(em_...),查行情/财务/新闻用
也可用环境变量替代(优先级更高):DEEPSEEK_API_KEY、MX_EM_API_KEY。
密钥只存在本地,仓库里只有占位模板,占位符会被校验拒绝。
3. 生成一份报告
py src/scheduler.py once报告输出到 data/交易报告_YYYY-MM-DD.md。想同步到 Obsidian,在 config/agent_config.json 里配 obsidian_dir。
4. 启动桌面对话版
py chat_agent/main.py4.1 打包成 exe(带自定义图标)
pyinstaller chat_agent/dragon_agent.spec产物:dist/龙头交易Agent.exe。图标是生成的龙头主题(红色圆形底 + 金色「龙」字 + 上扬K线),源脚本在 tools/make_icon.py,想换图标改它重新生成再打包。打包细节与踩坑见 spec 文件注释。
5. Windows 开机自启定时报告
把 start_scheduler.vbs 放到「启动」文件夹(Win+R → shell:startup)。文件里路径按你自己的环境改。
目录结构
src/ 规则引擎 + MCP Server(核心,21 模块)
chat_agent/ 桌面对话版「龙头交易Agent」
config/ 配置(示例模板 + 本地真实配置,后者 gitignore)
data/ 运行数据(报告/持仓/日志,gitignore 不进仓库)
docs/ 功能说明 / 交易策略 / 示例报告
tests/ 测试(80+ 用例)
tools/ 工具脚本(图标生成等)数据源
数据源 | 用途 |
东方财富 | 日 K、涨停池、涨跌家数、资金流(有节流与封禁保护) |
同花顺 | 涨停池交叉验证 |
腾讯行情 | 指数/实时行情(不封 IP) |
新浪行情 | 指数/实时行情 |
妙想 MCP | 桌面版自然语言查 A股/港股/美股/基金/债券/宏观/新闻 |
License
⚠️ 免责声明 / Disclaimer
中文:本项目仅为个人编程学习与技术研究,不构成任何投资建议,严禁用于实盘交易或商业用途,使用者后果自负。
English: This project is for personal programming learning and technical research only. It does NOT constitute investment advice. Any use for live trading or commercial purposes is strictly prohibited. All consequences are borne by the user.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseCqualityDmaintenanceThe MCP provides comprehensive financial data and analytical tool support for AI large language models, specifically including the following five core data capabilities: Stock Analysis/ETF Analysis/Public Funds/News & Information/General Tools More Info: https://github.com/shenqingtech/deepq-finan44357ISC
- FlicenseNot gradedqualityDmaintenanceMCP server for A-share stock technical analysis and AI prediction, enabling LLM-based interaction to analyze stocks.340
- AlicenseAqualityDmaintenanceProvides professional financial data access for LLMs via MCP, supporting providers like Tushare, Wind, and DataYes.1458Apache 2.0
- AlicenseBqualityCmaintenanceMCP server that wraps AKShare's 1000+ financial data functions, enabling LLMs to query Chinese stock, macro, futures, fund, bond, option, forex, and alternative data through standardized tools.143Apache 2.0
Related MCP Connectors
MCP server exposing the Backtest360 engine API as tools for AI agents.
Read-only China A-share data for AI agents: market, limit-up, capital flow and disclosures.
Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/BAI2007-Dev/dragon-trading-agent'
If you have feedback or need assistance with the MCP directory API, please join our Discord server