mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-09-27 06:56:39 +03:00
fix: name no date after the run in what a historical run reads
- coverage and withholding notices named where a vendor's coverage starts or today's date - the instrument context named today's date in every analyst prompt
This commit is contained in:
@@ -68,7 +68,7 @@ class TestYFinanceHistoricalRun:
|
||||
out = _yf(_PAST)
|
||||
assert f"Point-in-time as of: {_PAST}" in out
|
||||
assert "withheld" in out
|
||||
assert _PAST in out and _TODAY in out
|
||||
assert _PAST in out and _TODAY not in out
|
||||
|
||||
def test_no_wall_clock_retrieval_stamp(self):
|
||||
# The old header stamped datetime.now(), which is what surfaced the leak.
|
||||
|
||||
@@ -128,7 +128,7 @@ def test_ticker_news_window_before_feed_coverage_is_unavailable(monkeypatch):
|
||||
out = ynews.get_news_yfinance("AAPL", "2026-08-07", "2026-08-14")
|
||||
assert "RECENT" not in out
|
||||
assert "unavailable" in out and "not an absence" in out
|
||||
assert "2026-09-10" in out # says how far back the feed actually reaches
|
||||
assert "2026-09-10" not in out # an article after the window
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
|
||||
@@ -42,7 +42,7 @@ def test_yfinance_insider_filings_after_the_date_are_dropped():
|
||||
def test_yfinance_insider_date_before_coverage_is_unavailable_not_absent():
|
||||
out = _yf_insider(_insider_frame("2026-09-08", "2025-06-02"), "2024-01-01")
|
||||
assert "unavailable" in out and "No insider transactions reported" not in out
|
||||
assert "2025-06-02" in out # where coverage starts
|
||||
assert "2025-06-02" not in out # a transaction after the run date
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@@ -271,3 +271,27 @@ def test_a_historical_run_is_not_told_todays_date(func, args):
|
||||
out = getattr(y_finance, func)(*args)
|
||||
|
||||
assert date.today().isoformat() not in out
|
||||
|
||||
|
||||
def _dates_after(text: str, cutoff: str) -> list[str]:
|
||||
import re
|
||||
return [d for d in re.findall(r"\d{4}-\d{2}-\d{2}", text) if d > cutoff]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_an_unavailable_notice_names_no_date_after_the_run():
|
||||
"""A notice explaining why data is missing named where the vendor's coverage
|
||||
starts or today's date, both after a historical run's date."""
|
||||
from tradingagents.agents.utils.agent_utils import build_instrument_context
|
||||
from tradingagents.dataflows.date_window import coverage_gap, withhold_live_profile
|
||||
from tradingagents.dataflows.utils import get_current_date
|
||||
|
||||
today = get_current_date()
|
||||
notices = [
|
||||
coverage_gap([pd.Timestamp(today, tz="UTC")], "2025-01-01", "2025-01-07", "Feed", "news"),
|
||||
withhold_live_profile("2025-01-07", "AAPL"),
|
||||
_yf_insider(_insider_frame(today), "2025-01-07"),
|
||||
build_instrument_context("EXMP", "stock", {"company_name": "Example"}, curr_date="2025-01-07"),
|
||||
]
|
||||
for notice in notices:
|
||||
assert _dates_after(notice, "2025-01-07") == [], notice
|
||||
|
||||
Reference in New Issue
Block a user