AI trading agents that check the macro calendar and the fear index before they buy先看宏观日历和恐慌指数,再决定买不买的 AI 交易智能体
An open-source, long-only system for US stocks. It buys pullbacks to EMA 50/100/200 and quality dips that pass an earnings check, follows trends when the market is healthy, holds instead of panic-selling when it is not, and always keeps 30% in cash or T-bills. Backtest it, paper trade it, then connect one of 10 brokers.开源的美股做多系统。回踩 EMA 50/100/200 时买入,财报过关的好公司大跌时抄底;行情好时顺势持有,行情不明朗时只持有、不恐慌卖出;现金加短期国债始终不低于 30%。先回测,再模拟盘,然后接入 10 家券商中的任意一家。
What it does它能做什么
Every agent writes down why it said yes or no, so each trade comes with its reasons.每个智能体都会写下赞成或反对的理由,所以每笔交易都能看到依据。
Macro-aware regimes看宏观的市场状态
VIX and its term structure, sector breadth, credit appetite, a fear-and-greed gauge and the FOMC, CPI and jobs-report calendar decide one of four regimes.根据 VIX 及其期限结构、板块广度、信用利差、恐慌贪婪指数,以及 FOMC、CPI、非农日历,把市场分成四种状态。
Buy low, sell high低买高卖
Pullbacks to EMA 50/100/200, RSI(2) mean reversion, quality dips after an earnings check, breakouts in strong markets; trims winners when they are stretched.回踩 EMA 50/100/200、RSI(2) 均值回归、财报过关后抄底、强势行情做突破;涨得太远时减仓止盈。
Risk first风控优先
30% cash + T-bill floor, position, sector and speculative caps, volatility-scaled sizes, buying in tranches, Treasury sleeve, drawdown pause, kill switch.现金加短债 30% 底线,单票、板块、高波动仓位上限,按波动率定仓位,分批建仓,国债仓位,回撤暂停,一键停止。
No panic selling不恐慌卖出
In uncertain or risk-off markets the agent holds and only buys at strong support. Only a disaster the company itself confirms (bankruptcy, restatement) can force an exit.不确定或避险时只持有,只在强支撑位买入。只有公司自己确认的重大利空(破产、财报重述)才会强制卖出。
Cross-verified news交叉验证新闻
Finviz, Google News, Nasdaq, Seeking Alpha, Yahoo and SEC 8-K filings. Red flags from two independent outlets block new buys; only the company's own 8-K, or its press release confirming earlier reports, can force a sale, so one fake headline or press release cannot.汇总 Finviz、Google News、Nasdaq、Seeking Alpha、Yahoo 和 SEC 8-K。两家独立媒体确认的风险信号会挡住买入;只有公司自己的 8-K 公告,或者公司通稿证实了先前的报道,才会触发强制卖出,一条假新闻或一份假通稿都带不动它。
Your own strategies写你自己的策略
Write one Python method, then backtest, compare and paper trade it with the same risk engine. Optional bull / bear / judge LLM review with hard bounds.只要写一个 Python 方法,就能用同一套风控去回测、对比和模拟盘交易。可选的 LLM 多空辩论复核,影响有硬性上限。
Agents that trade every day每天自动交易的智能体
Give any strategy its own paper account. A background job on macOS, Linux or Windows trades every agent once per trading day on free prices, and a leaderboard compares them with SPY.给任意策略配一个独立的模拟账户。macOS、Linux 或 Windows 上的后台任务每个交易日用免费价格让每个智能体交易一次,排行榜拿它们和 SPY 对比。
Works with Claude (MCP)能在 Claude 里用(MCP)
riskaware mcp lets Claude, Codex, Gemini or any MCP client read the regime, scan, backtest and run the paper agents. Describe a strategy in words and the AI writes it as code and backtests it, checked for look-ahead. No tool can touch a live account.riskaware mcp 让 Claude、Codex、Gemini 或任何 MCP 客户端查市场状态、扫描、回测和运行模拟盘智能体。用大白话说出策略,AI 把它写成代码并回测,代码会先检查有没有偷看未来。没有任何工具能碰实盘账户。
News in backtests, no look-ahead回测带新闻,不偷看未来
2026 headlines and SEC 8-K filings for the built-in lists ship with the package. Each backtest day sees only what was published before its close, and orders fill the next day.安装包自带内置股票池 2026 年的新闻标题和 SEC 8-K 公告。回测每天只能看到收盘前已发布的新闻,第二天才成交。
Paper-trading agents that run every day每天自动运行的模拟盘智能体
Give any strategy a name, a risk profile and starting cash. It trades its own paper account on free prices every trading day, and the leaderboard shows which one beats SPY.给任意策略起个名字,配上风险档位和初始资金。它每个交易日用免费价格在自己的模拟账户里交易,排行榜告诉你谁跑赢了 SPY。
riskaware agents init # four starter agents / 四个示例智能体
riskaware agents run # trade once now / 现在交易一次
riskaware agents schedule --install # every trading day / 每个交易日自动运行
riskaware mcp # use them from Claude / 在 Claude 里使用
A tour of the dashboard看板一览
Run riskaware dashboard and open it in your browser. Everything runs on your computer.运行 riskaware dashboard,在浏览器里打开。所有东西都在你自己的电脑上运行。
















How it works工作原理
The same objects run in backtests, paper trading and live trading.回测、模拟盘和实盘用的是同一套代码。
What the agent does in each regime不同市场状态下的做法
| Regime状态 | Typical trigger典型触发条件 | Buys买入 | Sells卖出 | Size仓位 |
|---|---|---|---|---|
| RISK-ON | SPY above a rising EMA50 and EMA200, VIX < 20, most sectors above EMA200SPY 在上行的 EMA50 和 EMA200 之上,VIX < 20,多数板块站上 EMA200 | pullbacks, breakouts, dips回调、突破、抄底 | take profit, trend exits止盈、趋势破位减仓 | 100% |
| NEUTRAL | none of the others其余情况 | EMA support, mean reversion, quality dipsEMA 支撑、均值回归、优质股抄底 | take profit止盈 | 75% |
| UNCERTAIN | FOMC / CPI / jobs-report window, VIX 20–30, fear gauge < 35, downtrendFOMC、CPI、非农前后,VIX 20–30,恐慌指数 < 35,下跌趋势 | EMA100 / EMA200 support only只在 EMA100 / EMA200 支撑买 | none (hold)不卖(持有) | 50% |
| RISK-OFF | VIX ≥ 30, VIX backwardation below EMA200, credit stressVIX ≥ 30,跌破 EMA200 且 VIX 期限倒挂,信用紧张 | quality dips, broad ETFs, small tranches只抄优质股和宽基 ETF,小批量 | none (hold)不卖(持有) | 35% |
Backtest, 2018 – 2026回测:2018 – 2026
Built-in strategy, balanced profile, 55 large caps, $100k, signals at the close and fills the next day. Shading shows the regime.内置策略、平衡档、55 只大盘股、10 万美元,收盘出信号、次日成交。底色表示市场状态。
| risk_aware | SPY buy & hold | |
|---|---|---|
| CAGR年化收益 | 10.4% | 14.1% |
| Volatility波动率 | 9.3% | 19.0% |
| Sharpe夏普比率 | 0.84 | 0.66 |
| Max drawdown最大回撤 | -18.2% | -33.7% |
| Worst calendar year最差年份 | -3.7% | -18.2% |
| Average stocks / cash + T-bills平均股票 / 现金加短债 | 57% / 39% | 100% / 0% |
Read this honestly: it earns less than the index in a long bull market and loses about half as much in the bad stretches. The list is today's large caps (survivorship bias), this long run uses no news or fundamentals (2026 with news is below), and past results do not predict future ones. Reproduce it with riskaware backtest --compare buy_and_hold.要客观地看:在长牛市里它赚得比指数少,跌的时候亏得大约只有指数的一半。股票池是今天的大盘股(有幸存者偏差),这组长期回测没有用新闻和财报数据(2026 年带新闻的结果见下方),过去的表现也不代表未来。用 riskaware backtest --compare buy_and_hold 可以自己复现。
2026 so far, with news2026 年至今,带新闻
The same agent from January 2 to November 11, 2026, reading the 15,542 headlines and 605 SEC filings for these stocks that ship with the package; each day sees only what was out before its close.同一个智能体回测 2026 年 1 月 2 日到 11 月 11 日,读安装包自带的这些股票的 15,542 条标题和 605 份 SEC 公告;每天只看当天收盘前已经发布的新闻。
| risk_aware + newsrisk_aware + 新闻 | SPY buy & hold | |
|---|---|---|
| Return收益 | +15.9% | +12.1% |
| Volatility波动率 | 8.2% | 14.0% |
| Sharpe夏普比率 | 1.70 | 0.77 |
| Max drawdown最大回撤 | -5.3% | -8.9% |
| Average stocks / cash + T-bills平均股票 / 现金加短债 | 60% / 35% | 100% / 0% |
It beat SPY by 3.8 points with 60% of its money in stocks on average, and fell 5.3% in the March sell-off while SPY fell 8.9%. Without news it returned +15.4%. Ten months is a short test. Reproduce it with riskaware backtest --preset megacap --start 2026-01-02 --end 2026-11-11 --news.它平均只用 60% 的资金持股,收益比 SPY 多 3.8 个百分点;三月那波下跌里它跌了 5.3%,SPY 跌了 8.9%。不带新闻时收益是 +15.4%。十个月的回测时间偏短。用 riskaware backtest --preset megacap --start 2026-01-02 --end 2026-11-11 --news 可以自己复现。
Research kit: the frozen 2026 market研究工具箱:冻结的 2026 年市场
The whole of 2026 ships with the package, point in time: prices since 2024, the VIX term structure, 16,945 headlines and SEC filings, every indicator and regime reading. Each experiment is re-run with a random future after three cut days to prove it never looked ahead, and saved with its data hashes for papers. Over MCP, Claude can test a strategy you describe or trade the year step by step, blind if you like.整个 2026 年随安装包提供,全部按时间点记录:2024 年以来的价格、VIX 期限结构、16,945 条标题和 SEC 公告、每个技术指标和市场状态读数。每次实验都会把三个切点之后的数据换成随机的再跑一遍,证明它没有偷看未来,并连同数据哈希一起保存,可以直接用于论文。通过 MCP,Claude 可以测试你描述的策略,也可以一步一步把这一年交易一遍,还能盲测。
| Swing strategy, 2026波段策略,2026 年 | Without news不开新闻 | With news开新闻 | Sharpe | Max drawdown最大回撤 |
|---|---|---|---|---|
| Trend following (EMA20 / EMA50)趋势跟随(EMA20 / EMA50) | +21.1% | +19.6% | 1.44 | -4.7% |
| Post-news drift (without news: a price jump)新闻后的惯性(不开新闻:价格异动) | +15.7% | +4.4% | 1.01 | -9.8% |
| Connors RSI(2) | +12.7% | +10.8% | 0.85 | -7.9% |
| Pullback in an uptrend上升趋势中买回调 | +2.3% | +1.7% | -0.13 | -4.4% |
| 20-day breakout20 日突破 | -0.3% | -3.5% | -0.15 | -15.6% |
| SPY buy & hold | +12.1% | 0.77 | -8.9% |
56 large caps, at most 10 equal positions, orders at the next open; Sharpe and drawdown without news. Trend following beat SPY with half its drawdown; the news filter made every strategy slightly worse, and every run passed the look-ahead check. Ten months cannot separate these strategies with confidence: the 95% intervals overlap. Reproduce with riskaware research baselines; more in docs/research.md.56 只大盘股,最多 10 个等额仓位,次日开盘成交;Sharpe 和回撤是不开新闻时的数字。趋势跟随跑赢 SPY,回撤只有 SPY 的一半;加新闻过滤让每个策略都略差一点;每次运行都通过了防偷看检查。十个月的数据不足以有把握地区分这些策略:95% 区间彼此重叠。用 riskaware research baselines 可以复现;详见 docs/zh/research.md。
Quick start快速开始
Python 3.10+. No account or API key needed for the first four commands.需要 Python 3.10+。前四条命令不需要券商账户或 API key。
git clone https://github.com/jackson-cmd/risk-aware-trading-agents
cd risk-aware-trading-agents
pip install -e ".[dashboard,mcp]"
riskaware init # 2-minute wizard / 两分钟配置向导
riskaware regime # market regime, VIX, fear & greed, FOMC countdown
riskaware scan # today's signals with reasons
riskaware backtest --compare buy_and_hold,ema_bounce
riskaware run # paper trading (built-in paper account)
riskaware agents init # paper-trading agents / 模拟盘智能体
riskaware agents schedule --install # trade every trading day / 每天自动交易
riskaware dashboard # web UI, English / 中文
Bring your own strategy写你自己的策略
from riskaware.strategy import Strategy, Signal, Action
class Rsi2Dip(Strategy):
name = "rsi2_dip"
def on_bar(self, ctx):
out = []
for sym in ctx.universe:
row = ctx.row(sym)
if row and row["close"] > row["ema200"] and row["rsi2"] < 10:
out.append(Signal(sym, Action.BUY, strength=0.7, reason="RSI2 dip"))
return out
# riskaware backtest --strategy my_strategy.py --compare risk_aware
Brokers支持的券商
Paper trading is the default. Live orders need three explicit switches.默认是模拟盘。实盘下单需要同时打开三个开关。
Guides指南
Longer answers to the questions people search for.大家常搜的几个问题,这里有更完整的回答。
Backtest with news, without look-ahead bias
Point-in-time news replay, a 16:00 cutoff, orders at the next open, and a check that proves it.
用新闻回测,不用未来函数
按发布时间回放新闻、以 16:00 收盘为界、次日开盘成交,并用防偷看检查证明。
Point-in-time market data for 2026
Daily prices since 2024, the VIX term structure, 16,945 headlines and SEC filings, with SHA-256 hashes.
按时间点记录的 2026 年美股数据
2024 年起的日线、VIX 期限结构、16,945 条标题和 SEC 公告,附 SHA-256 哈希。
Test LLM trading agents
Let any model trade 2026 step by step on point-in-time data, blind if you like, from Python or over MCP.
测试 LLM 交易智能体
让任何模型在按时间点记录的数据上一步一步交易 2026 年,可以盲测,支持 Python 和 MCP。
FAQ
Will it place real trades by itself?它会自己下实盘单吗?
No. It starts in paper mode. A live order needs execution.mode: live in the config, the --live flag and a confirmation (or --yes). riskaware halt stops all orders.不会。默认是模拟盘。实盘需要配置文件里写 execution.mode: live、命令加 --live,并手动确认(或加 --yes)。riskaware halt 可以一键停止所有下单。
Do I need paid data?需要付费数据吗?
No. Prices come from Yahoo Finance, news from Finviz and public RSS feeds, calendars from the Federal Reserve, BLS and BEA. You can also load your own CSV files.不需要。价格来自 Yahoo Finance,新闻来自 Finviz 和公开 RSS,宏观日历来自美联储、BLS 和 BEA。也可以导入自己的 CSV 数据。
Why not sell when the market is scary?市场吓人的时候为什么不卖?
Panic selling at the bottom is how long-term investors lose most. Losses are bounded up front by diversification, position caps and the cash floor; the agent uses fear to buy quality at support instead.长期投资者最大的损失,往往来自在底部恐慌卖出。这个系统事先用分散持仓、仓位上限和现金底线控制住亏损,市场恐慌时反而在支撑位买入优质股。
Is this investment advice?这是投资建议吗?
No. It is software for research and education. Markets are risky; trade at your own risk.不是。这是用于研究和学习的软件。市场有风险,交易后果自负。