mirror of
https://github.com/farcasclaudiu/TradingAgents.git
synced 2026-06-29 01:01:33 +03:00
fix: prevent look-ahead bias in backtesting data fetchers (#475)
This commit is contained in:
@@ -167,6 +167,11 @@ def get_global_news_yfinance(
|
||||
# Handle both flat and nested structures
|
||||
if "content" in article:
|
||||
data = _extract_article_data(article)
|
||||
# Skip articles published after curr_date (look-ahead guard)
|
||||
if data.get("pub_date"):
|
||||
pub_naive = data["pub_date"].replace(tzinfo=None) if hasattr(data["pub_date"], "replace") else data["pub_date"]
|
||||
if pub_naive > curr_dt + relativedelta(days=1):
|
||||
continue
|
||||
title = data["title"]
|
||||
publisher = data["publisher"]
|
||||
link = data["link"]
|
||||
|
||||
Reference in New Issue
Block a user