trader.replay.news_at module

A point-in-time NewsProvider over the archive.

LlmStrategy calls get_recent_news(symbol, limit) and nothing else, so substituting this for the live merged feed puts the entire production news path — partition_by_age, the fresh/stale split, ordering, news_fingerprint, the prompt wording — on archived data with no reimplementation. That is the point: the replay must ask the same question the live path would have asked, and “resembles it” is not the same claim.

class trader.replay.news_at.ArchiveNewsAt(archive, as_of, window_hours)[source]

Bases: object

The archived news a symbol had at as_of, and nothing later.

Parameters:
  • archive (_Archive)

  • as_of (datetime)

  • window_hours (float)

get_recent_news(symbol, limit=10)[source]

Most recent first, capped at limit, all published before as_of.

Raises:

ReplayError – the archive returned an item published at or after as_of. The repository already filters published_at < end in SQL, so this is the second, independent check the scoring rule requires — one guard in the query and one on the assembled list, because a single guard is a single place to lose it.

Parameters:
  • symbol (str)

  • limit (int)

Return type:

list[NewsItem]