Skip to content
JingxuanCPublic

About

Athena is a production-grade multi-agent quantitative trading system

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

623 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT Go Agents DeepSeek MCP Markets


Athena · Self-Orchestrating Multi-Agent Quant System

Not an agent demo. A production trading team of 10 LLM agents with a DAG orchestrator, a reliable event bus, a causal-inference engine, and a self-tuning feedback loop — running live across A-Share, US, and Crypto. ~78k lines of Go, 51 packages, 72 test files, 20-page React console.


English

What is Athena?

Most "multi-agent trading" projects are single-session scripts: you hand them one ticker, a few LLM personas chat, and you get an essay. Athena is the opposite: a long-running, event-driven system that wakes up every trading day and operates like a real desk — macro & sentiment analysts brief the researcher before the open, the screener debates every candidate bull-vs-bear, the trader executes under three layers of risk control, the monitor watches positions tick by tick, and after the close the reviewer grades the day and feeds lessons back into tomorrow's prompts. A built-in AutoTuner spends weekends replaying the week's signals to tune the team's parameters — and hot-reloads them without a restart.

10 agents, one DAG orchestrator, zero wall-clock guessing. Athena's thin orchestrator holds the dependency graph (Layer0 analysts → researcher → screener → monitor/trader → reviewer) and dispatches each node when its upstream's completion events arrive — not when a cron hopes they're done. State is persisted per trading day, so restarts resume mid-DAG instead of firing everything at once. Degraded upstream? The pipeline cascades with explicit degraded markers instead of silently freezing all day. Design →

An event bus built for production, not a toy pub/sub. NATS JetStream bridge with per-instance consumers, NAK-with-delay redelivery (no more drop-and-ack), origin-ID echo dedup, and a loop guard that detects self-exciting event cycles (A→B→C→A) and suppresses them automatically.

Causal inference, not just correlation. Every market event flows Bronze→Silver→Gold, then through an event-study engine (CAR via a Python sidecar), causal discovery, and LLM industry-chain propagation — then a DoWhy counterfactual refutation grades each link A–F. Historical backfill recovers causality for events missed while offline. Design →

Athena vs. TradingAgents-style frameworks

Dimension Athena TradingAgents & similar
Runtime model Long-running production system: 24/7 engine, Docker Compose, Postgres + SQLite persistence Session script: runs once per ticker, exits
Orchestration DAG orchestrator — event-driven dispatch, persisted daily state, degraded cascade, cold-start recovery Sequential function calls
Agent roster 10 specialized agents (incl. Layer0 macro/report/sentiment trio, reviewer, autotuner) 4–6 personas in one file
Scheduling Trading-day aware: anchors, timeouts, weekend/holiday skip, catch-up after downtime None — manual runs
Signal flow Structured 3-layer pipeline: ResearchSignal → PoolSignal → TradeSignal with dedup & market isolation One-shot text verdict
Data pipeline Bronze→Silver→Gold event refinement + causal discovery with DoWhy refutation, graded A–F Direct news/social feed into prompt
Self-improvement Reviewer → feedback lessons → AutoTuner weekend param search with train/val replay & hot reload Static prompts & params
Risk control 3-layer (hard limits · LLM judgment · execution rules) + forced-liquidation path that bypasses P&L circuit-breakers Prompt-level "risk discussion"
Event reliability NATS JetStream, NAK redelivery, loop-guard cycle detection, idempotency keys In-process calls
Human-in-the-loop Obsidian vault two-way editing, feedback lessons, stale-note detection None
Observability 20-page React console: agent status, thinking chains, token costs, pipeline metrics, K-line drill-down Log files
Interfaces 22 MCP tools (stdio/SSE) · Copilot chat routed to real agent instances · WeChat push CLI

The Team (10 agents)

Agent Role
MacroAnalyst Pre-open macro regime assessment (risk-on/off, position caps)
ReportAnalyst Sell-side report consensus, rating shifts, earnings revisions
SentimentAnalyst Market sentiment thermometer (limit-up pools, turnover, alerts)
Researcher 9-source knowledge assembly → ReAct engine → daily briefing
Screener WarRoom coarse filter → Top20 → Bull/Bear 5-round debate → Top5
Trader Candidate pool + 3-layer risk control + broker execution
Monitor 30s watchlist scans, entry-condition triggers, alerts
Reviewer Post-close grading: hit rate / Sharpe / drawdown → lessons to vault
TradeAnalyst Your personal coach: FIFO-matched trade analysis from broker statements
AutoTuner Weekend LLM param search, replay validation, versioned hot reload

Athena Architecture

A Trading Day at Athena

Highlights

Signal Pipeline (3-layer, vnpy-style): Researcher(08:01) → ResearchSignal → Screener(09:27/14:55) → PoolSignal → Monitor(30s) → TradeSignal → Trader. Breakout/pullback/volume-spike entry conditions; signals carry market tags and confidence end-to-end. Design →

Bull vs Bear Debate: Every candidate survives 5 rounds of adversarial debate with a judge verdict. Every claim must cite a [source: ...] — anti-hallucination by design.

9-Layer Knowledge Assembly: Before every Researcher run, nine sources (human feedback, review performance, debate verdicts, Obsidian vault notes, Gold events, causal chains, cross-references…) are assembled into one context block and injected — the agent reads what the team learned yesterday before it speaks today.

AutoTuner — self-tuning on weekends: LLM-driven search over screener thresholds, risk config, and entry conditions; candidates validated by signal replay on a train/validation split; the winner is written back as a versioned skills update and hot-reloaded into all 5 consumers without a restart. Design →

Copilot V2 — talk to the real agents: @screener 选股 triggers the actual Screener pipeline; @researcher 日报 reads the genuine persisted briefing. Grounded in DB data with a no-fabrication fallback. Roundtable mode (@researcher @screener @trader) lets several agents answer in turn.

Second-pass deep analysis → WeChat: Top picks from each screening round get an independent LLM deep-dive (thesis / risks / stop levels), compiled into a Markdown digest and pushed via Server酱.

22 MCP Tools on One Endpoint: Hermes, Codex, Claude, or any MCP client connects and gets the whole desk — briefings, signals, FRED macro, StockTwits sentiment, and more.

3 Markets, Same Pipeline:

Market Data Broker Schedule
🇨🇳 A-Share Tencent API · akshare MCP PaperBroker DAG 07:00→15:05
🌐 Crypto Binance API Ai4TradeBroker GlobalRunner 24/7
🇺🇸 US yfinance · FRED · Reddit · StockTwits · Polymarket PaperBroker GlobalRunner NY hours

Quick Start

# 1. Clone
git clone https://github.com/hjx/athena.git && cd athena

# 2. Set your DeepSeek API key
cp .env.example .env   # then edit .env and fill DEEPSEEK_API_KEY

# 3. Start the engine (build + Docker Compose)
make run

# 4. Talk to the team
./ask "分析通鼎互联002491"
./ask "BTC 后市怎么看"
./ask "美股存储板块有没有机会"

Open http://localhost:8765 for the console. Optional: add ATHENA_SCT_SENDKEY to .env for WeChat push of the daily deep-dive digest.

📐 Agent Workflow Diagram — EventBus topology, event routing table, daily timeline, data matrix.

License

MIT License. See LICENSE for details.

Disclaimer: Athena is a research tool. It is not financial, investment, or trading advice. Trading performance varies based on model, temperature, data quality, and market conditions. Use at your own risk.


中文

Athena 是什么?

大多数"多 Agent 交易"项目是单次会话脚本:丢给它一只股票,几个 LLM 角色聊一轮,输出一篇小作文。Athena 相反:它是一个长驻、事件驱动的生产系统,每个交易日自动醒来,像真实交易团队一样运转——开盘前宏观/情绪/研报三位分析师先给研究员做简报,选股官对每只候选股做多空辩论,交易官在三层风控下执行,盯盘官逐 tick 监控持仓,收盘后复盘官给全天打分并把教训回流到明天的 prompt 里。内置的 AutoTuner 每周末回放本周信号、自动调参,并免重启热加载到所有消费方。

10 个 Agent,一个 DAG 编排者,零 wall-clock 猜测。 编排者持有依赖图(Layer0 分析师 → 研究员 → 选股官 → 盯盘/交易 → 复盘官),在上游完成事件到达时才派发下游——而不是靠 cron 祈祷对方跑完了。状态按交易日持久化,重启后从断点按序追赶而不是全部并发;上游降级时以显式 degraded 标记级联,不再全天静默固化。设计 →

为生产而生的事件总线,不是玩具 pub/sub。 NATS JetStream 桥接、每实例独立 consumer、NAK 延迟重投(不再"丢了还 Ack")、OriginID 回声去重,以及 LoopGuard 自激环检测——A→B→C→A 型事件环路自动识别并抑制。

因果推断,而非相关。 每个市场事件经 Bronze→Silver→Gold 精炼后,进入事件研究引擎(Python sidecar 算 CAR)、因果发现、LLM 产业链传导,最后由 DoWhy 反事实反驳给每条因果链打 A–F 级。历史回溯补齐系统离线期间错过的事件因果。设计 →

Athena vs. TradingAgents 类框架

维度 Athena TradingAgents 及同类
运行形态 长驻生产系统:7×24 引擎、Docker Compose、Postgres + SQLite 持久化 会话脚本:一次分析一只票,跑完即退
编排 DAG 编排者——事件驱动派发、日级状态持久化、降级级联、冷启动恢复 顺序函数调用
Agent 阵容 10 个专业 Agent(含 Layer0 宏观/研报/情绪三人组、复盘官、调参器) 单文件里 4–6 个角色
调度 交易日感知:锚点/超时/周末节假日跳过/宕机后追赶 无——手动运行
信号流 结构化三层管线:ResearchSignal → PoolSignal → TradeSignal,带去重与市场隔离 一次性文本结论
数据管线 Bronze→Silver→Gold 事件精炼 + DoWhy 反驳分级的因果发现 新闻/社媒直接进 prompt
自我进化 复盘 → 教训回流 → AutoTuner 周末调参、训练/验证回放、热加载 静态 prompt 与参数
风控 三层(硬限制 · LLM 研判 · 执行规则)+ 强平通道绕过盈亏熔断 prompt 层"风险讨论"
事件可靠性 NATS JetStream、NAK 重投、LoopGuard 环检测、幂等键 进程内调用
人机协同 Obsidian 双向编辑、反馈教训、过期检测 无
可观测 20 页 React 控制台:Agent 状态、思维链、Token 成本、管线指标、K线钻取 日志文件
接口 22 个 MCP 工具(stdio/SSE)· Copilot 路由到真实 Agent 实例 · 微信推送 CLI

团队成员(10 个 Agent)

Agent 职责
MacroAnalyst 盘前宏观 regime 评估(风险偏好、仓位上限)
ReportAnalyst 券商研报共识、评级迁移、盈利预测修正
SentimentAnalyst 市场情绪温度计(涨停池、换手、告警)
Researcher 9 源知识组装 → ReAct 引擎 → 每日简报
Screener WarRoom 粗筛 → Top20 → 多空 5 轮辩论 → Top5
Trader 候选池 + 三层风控 + Broker 执行
Monitor 30 秒自选股扫描、入场条件触发、告警
Reviewer 收盘打分:命中率/夏普/回撤 → 教训入库
TradeAnalyst 你的私人教练:交割单 FIFO 配对复盘分析
AutoTuner 周末 LLM 调参、回放验证、版本化热加载

Athena 的一个交易日

亮点

三层信号管线(vnpy 风格): Researcher(08:01) → ResearchSignal → Screener(09:27/14:55) → PoolSignal → Monitor(30s) → TradeSignal → Trader。突破/回踩/放量入场条件;信号全链路携带市场标签与置信度。设计 →

多空辩论引擎: 每只候选标的经受 5 轮对抗辩论 + 裁判裁决。每个论点必须标注 [来源: ...]——天然反幻觉。

9 层知识注入: 每次研究员运行前,9 个数据源(人类反馈、复盘绩效、辩论裁决、Obsidian 笔记、Gold 事件、因果链、交叉引用……)组装成单一上下文注入——Agent 开口前先读完团队昨天学到的东西。

AutoTuner 周末自动调参: LLM 搜索选股阈值/风控/入场条件,训练/验证切分回放防过拟合,最优解版本化写回 DB skills 并免重启热加载到全部 5 个消费方。设计 →

Copilot V2 —— 和真 Agent 对话: @screener 选股 触发真实选股管线;@researcher 日报 读真实落库简报。基于 DB 数据、带防编造回退。圆桌模式让多个 Agent 轮流发言。

二度深度分析 → 微信: 每轮选股的 Top 标的会再做一次独立 LLM 深挖(核心逻辑/风险/止损位),汇编成 Markdown 简报经 Server酱 推送。

22 个 MCP 工具: Hermes、Codex、Claude 或任何 MCP 客户端接入即可调用整个交易团队——简报、信号、FRED 宏观、StockTwits 情绪……

三大市场,同一管线:

市场 数据源 Broker 调度
🇨🇳 A股 腾讯API · akshare MCP PaperBroker DAG 07:00→15:05
🌐 加密货币 Binance API Ai4TradeBroker GlobalRunner 24/7
🇺🇸 美股 yfinance · FRED · Reddit · StockTwits · Polymarket PaperBroker 纽约时段

快速开始

# 1. 克隆项目
git clone https://github.com/hjx/athena.git && cd athena

# 2. 配置 DeepSeek API key
cp .env.example .env   # 编辑 .env 填入 DEEPSEEK_API_KEY

# 3. 启动引擎(编译 + Docker Compose)
make run

# 4. 与团队对话
./ask "分析通鼎互联002491"
./ask "BTC 后市怎么看"
./ask "美股存储板块有没有机会"

打开 http://localhost:8765 查看控制台。可选:.env 加 ATHENA_SCT_SENDKEY 开启每日深度分析微信推送。

📐 Agent 工作流图 — EventBus 拓扑、事件路由表、交易日时间线、数据落库矩阵。

开源协议

MIT 协议。详见 LICENSE。

免责声明: Athena 是研究工具,不构成任何投资建议。交易表现因模型、温度、数据质量与市场环境而异,使用风险自负。

About

Athena is a production-grade multi-agent quantitative trading system

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages