fix: address Gemini re-review feedback
- Reorganise cli/main.py imports: move load_dotenv() after all imports so isort can sort cleanly; removes need for global E402 ignore - Remove dead graph.process_signal() call (discarded LLM result) - Drop E501 and E402 from global ruff ignore; fix resulting violations in cli/main.py and cli/utils.py; add per-file E501 ignore for tradingagents/** where LLM system prompt strings are intentionally long - Remove # noqa: I001 from alpha_vantage.py; let isort sort alphabetically Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
264e792295
commit
f0d7e6824f
35
cli/main.py
35
cli/main.py
|
|
@ -1,18 +1,14 @@
|
|||
import datetime
|
||||
import time
|
||||
from collections import deque
|
||||
from functools import wraps
|
||||
from pathlib import Path
|
||||
|
||||
import typer
|
||||
from dotenv import load_dotenv
|
||||
from rich.console import Console
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
import time
|
||||
from collections import deque
|
||||
|
||||
from rich import box
|
||||
from rich.align import Align
|
||||
from rich.console import Console
|
||||
from rich.layout import Layout
|
||||
from rich.live import Live
|
||||
from rich.markdown import Markdown
|
||||
|
|
@ -38,6 +34,9 @@ from cli.utils import (
|
|||
from tradingagents.default_config import DEFAULT_CONFIG
|
||||
from tradingagents.graph.trading_graph import TradingAgentsGraph
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
console = Console()
|
||||
|
||||
app = typer.Typer(
|
||||
|
|
@ -477,7 +476,9 @@ def get_user_selections():
|
|||
welcome_content = f"{welcome_ascii}\n"
|
||||
welcome_content += "[bold green]TradingAgents: Multi-Agents LLM Financial Trading Framework - CLI[/bold green]\n\n"
|
||||
welcome_content += "[bold]Workflow Steps:[/bold]\n"
|
||||
welcome_content += "I. Analyst Team → II. Research Team → III. Trader → IV. Risk Management → V. Portfolio Management\n\n"
|
||||
welcome_content += (
|
||||
"I. Analyst Team → II. Research Team → III. Trader → IV. Risk Management → V. Portfolio Management\n\n"
|
||||
)
|
||||
welcome_content += (
|
||||
"[dim]Built by [Tauric Research](https://github.com/TauricResearch)[/dim]"
|
||||
)
|
||||
|
|
@ -510,7 +511,8 @@ def get_user_selections():
|
|||
console.print(
|
||||
create_question_box(
|
||||
"Step 1: Ticker Symbol",
|
||||
"Enter the exact ticker symbol to analyze, including exchange suffix when needed (examples: SPY, CNC.TO, 7203.T, 0700.HK)",
|
||||
"Enter the exact ticker symbol to analyze, including exchange suffix when needed"
|
||||
" (examples: SPY, CNC.TO, 7203.T, 0700.HK)",
|
||||
"SPY",
|
||||
)
|
||||
)
|
||||
|
|
@ -728,7 +730,8 @@ def save_report_to_disk(final_state, ticker: str, save_path: Path):
|
|||
sections.append(f"## V. Portfolio Manager Decision\n\n### Portfolio Manager\n{risk['judge_decision']}")
|
||||
|
||||
# Write consolidated report
|
||||
header = f"# Trading Analysis Report: {ticker}\n\nGenerated: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
||||
generated = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
header = f"# Trading Analysis Report: {ticker}\n\nGenerated: {generated}\n\n"
|
||||
(save_path / "complete_report.md").write_text(header + "\n\n".join(sections))
|
||||
return save_path / "complete_report.md"
|
||||
|
||||
|
|
@ -771,7 +774,10 @@ def display_complete_report(final_state):
|
|||
# III. Trading Team
|
||||
if final_state.get("trader_investment_plan"):
|
||||
console.print(Panel("[bold]III. Trading Team Plan[/bold]", border_style="yellow"))
|
||||
console.print(Panel(Markdown(final_state["trader_investment_plan"]), title="Trader", border_style="blue", padding=(1, 2)))
|
||||
console.print(Panel(
|
||||
Markdown(final_state["trader_investment_plan"]),
|
||||
title="Trader", border_style="blue", padding=(1, 2),
|
||||
))
|
||||
|
||||
# IV. Risk Management Team
|
||||
if final_state.get("risk_debate_state"):
|
||||
|
|
@ -791,7 +797,10 @@ def display_complete_report(final_state):
|
|||
# V. Portfolio Manager Decision
|
||||
if risk.get("judge_decision"):
|
||||
console.print(Panel("[bold]V. Portfolio Manager Decision[/bold]", border_style="green"))
|
||||
console.print(Panel(Markdown(risk["judge_decision"]), title="Portfolio Manager", border_style="blue", padding=(1, 2)))
|
||||
console.print(Panel(
|
||||
Markdown(risk["judge_decision"]),
|
||||
title="Portfolio Manager", border_style="blue", padding=(1, 2),
|
||||
))
|
||||
|
||||
|
||||
def update_research_team_status(status):
|
||||
|
|
@ -1162,9 +1171,7 @@ def run_analysis():
|
|||
|
||||
trace.append(chunk)
|
||||
|
||||
# Get final state and decision
|
||||
final_state = trace[-1]
|
||||
graph.process_signal(final_state["final_trade_decision"])
|
||||
|
||||
# Update all agent statuses to completed
|
||||
for agent in message_buffer.agent_status:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,11 @@ def select_analysts() -> List[AnalystType]:
|
|||
choices=[
|
||||
questionary.Choice(display, value=value) for display, value in ANALYST_ORDER
|
||||
],
|
||||
instruction="\n- Press Space to select/unselect analysts\n- Press 'a' to select/unselect all\n- Press Enter when done",
|
||||
instruction=(
|
||||
"\n- Press Space to select/unselect analysts"
|
||||
"\n- Press 'a' to select/unselect all"
|
||||
"\n- Press Enter when done"
|
||||
),
|
||||
validate=lambda x: len(x) > 0 or "You must select at least one analyst.",
|
||||
style=questionary.Style(
|
||||
[
|
||||
|
|
|
|||
|
|
@ -46,13 +46,15 @@ line-length = 120
|
|||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I"]
|
||||
ignore = ["E501", "E402", "E731"]
|
||||
ignore = ["E731"]
|
||||
|
||||
[tool.ruff.lint.isort]
|
||||
combine-as-imports = true
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
"__init__.py" = ["F401"]
|
||||
# LLM system prompt strings are intentionally long; wrapping them reduces readability.
|
||||
"tradingagents/**/*.py" = ["E501"]
|
||||
|
||||
[tool.uv]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
# Import functions from specialized modules
|
||||
from .alpha_vantage_stock import get_stock # noqa: I001
|
||||
from .alpha_vantage_indicator import get_indicator
|
||||
from .alpha_vantage_fundamentals import (
|
||||
get_fundamentals,
|
||||
get_balance_sheet,
|
||||
get_cashflow,
|
||||
get_fundamentals,
|
||||
get_income_statement,
|
||||
)
|
||||
from .alpha_vantage_indicator import get_indicator
|
||||
from .alpha_vantage_news import (
|
||||
get_news,
|
||||
get_global_news,
|
||||
get_insider_transactions,
|
||||
get_news,
|
||||
)
|
||||
from .alpha_vantage_stock import get_stock
|
||||
|
||||
__all__ = [
|
||||
"get_stock",
|
||||
|
|
|
|||
Loading…
Reference in New Issue