Summary
When trade_date is historical, the Sentiment Analyst correctly requests Yahoo news for the historical window, but still fetches the current StockTwits stream and Reddit's current last week. Those current posts are then placed in a prompt that says they cover the historical start_date..end_date window.
This introduces look-ahead bias and can make backtests use information that did not exist on the requested trading date.
Reproduction
- Run the sentiment analyst with a historical date, for example
trade_date="2020-01-15".
- In
sentiment_analyst_node, compare the three fetches:
- Yahoo news receives
start_date="2020-01-08" and end_date="2020-01-15".
fetch_stocktwits_messages(ticker, limit=30) receives no date and calls the current symbol-stream endpoint.
fetch_reddit_posts(ticker) receives no date, and _search_qs hard-codes t=week (the current week).
- The resulting prompt nevertheless says the report covers
2020-01-08 through 2020-01-15 and labels Reddit as “past 7 days”.
Relevant code:
tradingagents/agents/analysts/sentiment_analyst.py:62-71
tradingagents/agents/analysts/sentiment_analyst.py:131-150
tradingagents/dataflows/reddit.py:52-58
tradingagents/dataflows/stocktwits.py:26,41-52
Expected behavior
Every observation used for an analysis should have a timestamp at or before trade_date. If the public social APIs cannot provide historical data, historical runs should omit those sources and inject an explicit “historical data unavailable” placeholder rather than substituting current posts.
Actual behavior
Current social posts are included in historical analyses and presented to the LLM as though they came from the requested historical period.
Suggested regression coverage
Add a test using an old trade_date that verifies neither social fetcher can return observations newer than end_date (or verifies that the sources are marked unavailable when historical retrieval is unsupported).
Environment
- TradingAgents main at
01477f9 (v0.3.1)
- Python 3.12
Summary
When
trade_dateis historical, the Sentiment Analyst correctly requests Yahoo news for the historical window, but still fetches the current StockTwits stream and Reddit's current last week. Those current posts are then placed in a prompt that says they cover the historicalstart_date..end_datewindow.This introduces look-ahead bias and can make backtests use information that did not exist on the requested trading date.
Reproduction
trade_date="2020-01-15".sentiment_analyst_node, compare the three fetches:start_date="2020-01-08"andend_date="2020-01-15".fetch_stocktwits_messages(ticker, limit=30)receives no date and calls the current symbol-stream endpoint.fetch_reddit_posts(ticker)receives no date, and_search_qshard-codest=week(the current week).2020-01-08through2020-01-15and labels Reddit as “past 7 days”.Relevant code:
tradingagents/agents/analysts/sentiment_analyst.py:62-71tradingagents/agents/analysts/sentiment_analyst.py:131-150tradingagents/dataflows/reddit.py:52-58tradingagents/dataflows/stocktwits.py:26,41-52Expected behavior
Every observation used for an analysis should have a timestamp at or before
trade_date. If the public social APIs cannot provide historical data, historical runs should omit those sources and inject an explicit “historical data unavailable” placeholder rather than substituting current posts.Actual behavior
Current social posts are included in historical analyses and presented to the LLM as though they came from the requested historical period.
Suggested regression coverage
Add a test using an old
trade_datethat verifies neither social fetcher can return observations newer thanend_date(or verifies that the sources are marked unavailable when historical retrieval is unsupported).Environment
01477f9(v0.3.1)