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.
Where news backtests see the future
Most news backtests leak in one of a few ordinary ways:
- Dates instead of times. Many datasets keep only the day, or the time an item was collected. An earnings release at 16:05 then looks like news the strategy had at the 16:00 close.
- Time zones. A UTC timestamp read as New York time moves every story four or five hours earlier.
- Trading at the price that reacted to the news. Deciding on a headline and filling at that day's close assumes you traded before everyone else read it.
- Later edits and wrong dates. Articles updated after the fact, or items stamped with a future date.
- Hindsight in the setup. Picking the stocks, dates or rules you already know worked, which an LLM can also do from memory.
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)
- The strategy decides once a day, after the close, and its orders fill at the next trading day's open. Positions are held for days or weeks: swing trading on daily bars.
- A headline counts from the first close after its timestamp: before 16:00 New York time (13:00 on early-close days) it counts that day, otherwise the next trading day.
- An item with only a date counts at the end of that day. A timestamp without a time zone is read as New York time. Items dated in the future are dropped.
- Stories go through the same checks as live trading: a headline counts only for the company it names, and a story is confirmed when two independent outlets, the company's own release or its SEC filing carry it.
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:
| Strategy | Without news | With news | Sharpe | Max 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.
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.