Skip to content

keyboardstaff/trading-agent

Repository files navigation

Trading Agent

Multi-agent LLM trading analysis framework with a configurable pipeline, Bull/Bear debate, and risk assessment.

What It Does

This plugin runs a structured, multi-stage analysis pipeline for any stock ticker. A team of specialized LLM agents collects market data, debates investment theses, and produces a final BUY / HOLD / SELL decision with a detailed rationale. The dashboard provides a terminal-style report viewer and persistent analysis history.

Main Behavior

  • Data collection (parallel)
    • Fetches price history, technical indicators, fundamental metrics, news headlines, and sentiment data for the target ticker via the configured data source.
  • Analyst team (parallel)
    • Four analyst agents each produce an independent Markdown report: technical, fundamentals, sentiment, news.
  • Bull / Bear debate (optional)
    • A research manager moderates multiple rounds of Bull vs. Bear argumentation, producing a consolidated research_summary.
  • Trader
    • A trader agent synthesizes all analyst output and the debate summary into a trading_plan.
  • Risk assessment (optional)
    • Three risk agents (aggressive, neutral, conservative) evaluate the plan and produce a risk_assessment.
  • Portfolio manager
    • A portfolio manager issues the final_decision with a BUY / HOLD / SELL signal and key factors.
  • Report persistence
    • Results are saved to JSON and optionally exported as Markdown to the project workdir.
  • Dashboard UI
    • A collapsible, terminal-style report panel shows all pipeline stages with clear visual hierarchy. Analysis history is persisted across sessions.

Key Files

  • Pipeline orchestration
    • helpers/pipeline.py — runs all agents in sequence, manages state, extracts signal.
  • Role definitions
    • helpers/roles.py — maps role names to LLM prompt files and agent configurations.
  • LLM caller
    • helpers/llm_caller.py — wraps Agent Zero LLM calls with retry logic.
  • Report utilities
    • helpers/report.py — Markdown report export and formatting helpers.
  • Data sources
    • helpers/data_sources/yfinance_source.py — yfinance provider (default).
    • helpers/data_sources/alpha_vantage_source.py — Alpha Vantage provider.
    • helpers/data_sources/base.py — abstract base class for custom providers.
  • API endpoints
    • api/analysis_run.py — starts a new analysis task.
    • api/analysis_status.py — polls running task progress.
    • api/analysis_result.py — retrieves a completed result.
    • api/analysis_list.py — lists analysis history.
    • api/analysis_delete.py — deletes a history entry.
    • api/data_source_test.py — validates data source connectivity.
  • Tool
    • tools/trading_analysis.py — exposes the pipeline as an Agent Zero tool so agents can invoke it conversationally.
  • Prompts
    • prompts/technical_analyst.md, fundamentals_analyst.md, sentiment_analyst.md, news_analyst.md — analyst system prompts.
    • prompts/bull_researcher.md, bear_researcher.md, research_manager.md — debate prompts.
    • prompts/trader.md — trading plan prompt.
    • prompts/risk_aggressive.md, risk_neutral.md, risk_conservative.md — risk agent prompts.
    • prompts/portfolio_manager.md — final decision prompt.
  • WebUI
    • webui/main.html — dashboard HTML, CSS, and Alpine.js bindings.
    • webui/trading-agent-store.js — Alpine store managing state, API calls, and Markdown rendering.
    • webui/config.html — plugin settings panel.

Configuration

Edit default_config.yaml or configure via the plugin settings panel.

Key Default Description
pipeline.analysts [technical, fundamentals, sentiment, news] Analyst agents to run (parallel)
pipeline.debate.enabled true Enable Bull/Bear debate stage
pipeline.debate.max_rounds 2 Number of debate rounds
pipeline.risk_assessment.enabled true Enable risk assessment stage
data_sources.provider yfinance Data provider: yfinance, alpha_vantage, or custom
data_sources.alpha_vantage_api_key "" API key for Alpha Vantage
data_sources.lookback_days 30 Historical data lookback window (trading days)
output.language auto Report language (auto detects from user locale)
output.save_reports true Export reports as Markdown to workdir
output.reports_subdir trading_reports Subdirectory name for saved reports

Plugin Metadata

  • Name: trading_agent
  • Title: Trading Agent
  • Version: 0.1.0
  • Description: Multi-agent LLM trading analysis framework with configurable pipeline, debate, and risk assessment.

About

adding a full multi-agent LLM trading analysis framework to Agent Zero.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors