mirror of
https://github.com/TauricResearch/TradingAgents.git
synced 2026-11-17 14:51:50 +02:00
feat(reports): name the rating in the report header
- the header lists the run's rating, REVIEW when the decision has none
This commit is contained in:
@@ -106,3 +106,16 @@ def test_run_settings_name_the_version_of_the_running_code():
|
||||
graph = object.__new__(TradingAgentsGraph)
|
||||
graph.selected_analysts, graph.config = ("market",), {}
|
||||
assert graph.run_settings()["version"] == tradingagents.__version__
|
||||
|
||||
|
||||
@pytest.mark.unit
|
||||
@pytest.mark.parametrize("decision, rating", [
|
||||
("**Rating**: Overweight\n\nAdd on weakness.", "Overweight"),
|
||||
("Add on weakness.", "REVIEW"), # no readable rating is said, not left out
|
||||
])
|
||||
def test_the_report_header_names_the_rating(tmp_path, decision, rating):
|
||||
state = dict(_state(), final_trade_decision=decision)
|
||||
|
||||
header = write_report_tree(state, "NVDA", tmp_path, settings=SETTINGS).read_text().split("## ")[0]
|
||||
|
||||
assert f"- Rating: {rating}" in header
|
||||
|
||||
@@ -9,12 +9,16 @@ run produces the same on-disk report tree a CLI run does.
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from tradingagents.agents.rating import run_rating
|
||||
|
||||
|
||||
def _header(ticker: str, final_state: dict, settings: dict | None) -> str:
|
||||
"""The report's title and what produced it: analysis date, version, models, analysts, vendors."""
|
||||
lines = [f"# Trading Analysis Report: {ticker}", ""]
|
||||
if final_state.get("trade_date"):
|
||||
lines.append(f"- Analysis date: {final_state['trade_date']}")
|
||||
if final_state.get("final_trade_decision"):
|
||||
lines.append(f"- Rating: {run_rating(final_state)}")
|
||||
lines.append(f"- Generated: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
if settings:
|
||||
s = settings.get
|
||||
|
||||
Reference in New Issue
Block a user