Risk-Aware Trading Agents

Home › Guides

Backtest trading strategies with news, without look-ahead bias

News strategies are easy to fool yourself with. If a backtest lets a strategy read a headline before it was published, or a story that came out after the close it trades on, the result looks better than anything you could trade. Risk-Aware Trading Agents is an open-source Python package that replays news at the time it was published and checks every experiment for look-ahead.

Get it on GitHub The 2026 dataset Testing LLM agents

Where news backtests see the future

Most news backtests leak in one of a few ordinary ways:

How the package replays news

day t, 16:00 New York        after the close                      day t+1, 09:30
    stocks close    ->   the strategy sees day t and earlier   ->   orders fill at the open
                         news published before 16:00               (+5 bps slippage)

Try it

git clone https://github.com/jackson-cmd/risk-aware-trading-agents
cd risk-aware-trading-agents
pip install -e ".[dashboard,mcp]"        # Python 3.10+

riskaware backtest --strategy risk_aware --preset megacap --start 2026-01-02 --news
riskaware research run --strategy swing_trend --split 2026-07-01   # look-ahead check and a saved record
riskaware research day 2026-04-08 --symbols NVDA,TSLA              # what was known at that close

The 2026 news ships with the package, so nothing has to be downloaded. To test your own idea, write it as a small Python class, or describe it to Claude and let it write the code (see LLM agents and MCP).

Prove it: the look-ahead check

Rules about timestamps can still leak through a bug. So each research experiment runs again three times, on copies of the market where every price and every headline after a cut day is replaced by random ones, invented good and bad news and bankruptcy filings included. A strategy that only uses what it may know makes exactly the same decisions up to each cut. If a decision before a cut changes, the check fails and names the first day and decision that changed. The package's tests plant such a bug, an indicator that reads the next day's close, to show that the check catches it.

What we found in 2026

Five common swing strategies on 56 large caps, January 2 to November 11, 2026, with at most 10 equal positions and orders at the next open:

StrategyWithout newsWith newsSharpeMax drawdown
Trend following (EMA20 / EMA50 cross)+21.1%+19.6%1.44-4.7%
Post-news drift (without news: the same trade on a price jump)+15.7%+4.4%1.01-9.8%
Connors RSI(2) mean reversion+12.7%+10.8%0.85-7.9%
Pullback in an uptrend+2.3%+1.7%-0.13-4.4%
20-day breakout-0.3%-3.5%-0.15-15.6%
SPY buy and hold+12.1%0.77-8.9%

Sharpe and drawdown without news. Reproduce with riskaware research baselines.

Five swing strategies in 2026, with and without news, against SPY

The news filter made every strategy slightly worse, and buying on positive headlines did worse than buying the same price move without them. With one headline feed most stories have a single source, so the filter mostly reacts to noise. The package's own risk-aware agent did better with news (+15.9%, against +15.4% without and +12.1% for SPY), but ten months cannot separate these numbers with confidence: the 95% intervals overlap. Every run passed the look-ahead check.

News for other years

riskaware news-history builds a point-in-time archive on your own machine: SEC 8-K filings since 2018 for free (with the time SEC accepted each one), Benzinga headlines with your own API key, or any CSV with a timestamp, a ticker and a headline. riskaware news-history show NVDA --date 2024-05-22 prints exactly what a backtest saw at that close. See docs/news-history.md.

Questions

Is this intraday?

No. Decisions happen after each close and orders fill at the next open, so the package tests swing and position trading on daily bars, not day trading.

Can I use my own news?

Yes: import a CSV with a publication time, a ticker and a headline, or add headlines to a single experiment to see how a strategy reacts to a story that never ran.

Can an AI write the strategy for me?

Yes. Over MCP, Claude, Codex or Gemini writes the strategy as code; the code is checked for dates, tickers and side effects before it runs in a separate process.

More guides

Point-in-time market data for 2026Prices, VIX and news with SHA-256 hashes Test LLM trading agentsStep by step, blind, over MCP Risk-Aware Trading AgentsThe agents, brokers and dashboard