mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-12 12:22:38 +02:00
fix(backtest): run and settle a ticker or date given twice once (#1415)
- run_backtest drops repeated tickers and dates before building the grid
This commit is contained in:
@@ -296,3 +296,11 @@ def test_a_resumed_sweep_reports_only_the_cells_it_runs(tmp_path):
|
||||
progress=lambda done, total, ticker, date: seen.append((done, total, date)))
|
||||
|
||||
assert seen == [(1, 1, "2026-01-12")]
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
def test_a_ticker_or_date_given_twice_runs_and_settles_once(tmp_path):
|
||||
run_backtest(["NVDA", "NVDA"], ["2026-01-05", "2026-01-05"], _config(tmp_path))
|
||||
graph = _FakeGraph.instances[-1]
|
||||
assert graph.calls == [("NVDA", "2026-01-05")]
|
||||
assert graph.settled == ["NVDA"]
|
||||
|
||||
@@ -155,6 +155,8 @@ def run_backtest(
|
||||
result = BacktestResult(run_id=run_id, log_path=Path(run_config["memory_log_path"]))
|
||||
done = {(e["ticker"], e["date"]) for e in graph.memory_log.load_entries()}
|
||||
|
||||
# A ticker or date given twice is one cell, run and settled once.
|
||||
tickers, dates = list(dict.fromkeys(tickers)), list(dict.fromkeys(dates))
|
||||
cells = [(ticker, date) for ticker in tickers for date in dates]
|
||||
todo = [cell for cell in cells if cell not in done]
|
||||
result.skipped = len(cells) - len(todo)
|
||||
|
||||
Reference in New Issue
Block a user