AI Stock (LLM TradeBot)

repository·main·Indexed 43 days ago

https://github.com/ethanalgox/llm-tradebot

A financial decision workspace for researching and paper-trading equities in mainland China, Hong Kong, and the US. It features an Agent-based architecture for research assistance, expert roundtables with Pipeline, Debate, and Voting modes, and a system for creating custom trading strategies via YAML-defined Strategy Skills.

Tokens
192.5K
Snippets
391
Records
786
Agent score
53%

What's inside AI Stock

  1. Overview of LLM Configuration Methods

    main

    The project provides a unified AI model access flow powered by LiteLLM, supporting official APIs, OpenAI-compatible platforms, and local models. Users can configure LLMs using a three-tier hierarchy depending on their needs:

    1. Simple Model Config (Beginners): For getting the system running quickly with minimal setup.
    2. Channels Mode Config (Advanced Users): For managing multiple API keys, configuring fallback models, and defining custom Base URLs.
    3. Advanced YAML Config (Veterans): For complex load balancing, request routing, and high availability.

    For specific provider presets, GitHub Actions Secrets mapping, or troubleshooting details.reason errors, refer to the Provider Configuration Guide.

  2. Overview of AI Stock Workspaces

    main

    AI Stock is organized into six interconnected workspaces, each serving a specific part of the investment research lifecycle:

    WorkspaceRoutePrimary Use
    Market Intelligence (市场雷达)/market-intelligenceView market snapshots, news, macro observations, and analysis subscriptions.
    Research Assistant (投研助理)/overviewDaily Q&A, managing conversations, and inviting experts to form comprehensive reports.
    Expert Roundtable (专家圆桌)/expert-reviewA continuous group chat showing expert identities, interactions, and moderator summaries.
    Stock Research (个股研究)/stock-researchRunning research strategies and reading conclusions, evidence, risks, and historical reports.
    Screening (策略选股)/screeningExecuting screening rules, viewing candidate rankings, and performing deep research on candidates.
    Trading Simulation (交易推演)/tradingResearching simulated trading proposals, risk assessments, and signal performance.

    Note: Current built-in screening rules are primarily oriented towards A-shares.

  3. Understand the project structure

    main

    The project is organized into several key directories that separate core logic, data handling, and user interfaces:

    • main.py: The primary entry point for the application.
    • src/: Contains core business logic, including analyzer.py (AI analysis), config.py (configuration management), and notification.py (message pushing).
    • data_provider/: Contains adapters for various data sources.
    • bot/: Modules for robot/agent interaction.
    • api/: The FastAPI backend service.
    • apps/dsa-web/: The React-based frontend application.
    • docker/: Docker configuration files.
    • docs/: Project documentation.
    • .github/workflows/: GitHub Actions automation workflows.
    daily_stock_analysis/
    ├── main.py              # 主程序入口
    ├── src/                 # 核心业务逻辑
    │   ├── analyzer.py      # AI 分析器
    │   ├── config.py        # 配置管理
    │   ├── notification.py  # 消息推送
    │   └── ...
    ├── data_provider/       # 多数据源适配器
    ├── bot/                 # 机器人交互模块
    ├── api/                 # FastAPI 后端服务
    ├── apps/dsa-web/        # React 前端
    ├── docker/              # Docker 配置
    ├── docs/                # 项目文档
    └── .github/workflows/   # GitHub Actions
  4. Design System Overview: AI Stock

    main

    The AI Stock design system is modeled as an "Agent Decision Desk," intended to function as a precise institutional research instrument. It prioritizes calm, dense, and explicit state transitions over decorative elements.

    Core Principles:

    • Continuous Workspace: Uses a continuous canvas rather than isolated floating panels.
    • Restrained Palette: Uses "Cool Porcelain" (light mode) and "Carbon Graphite" (dark mode) with Cobalt reserved strictly for primary actions, focus, and active states.
    • Structural Elevation: Employs thin mineral rules and shallow structural elevation instead of decorative glass, neon, or glows.
    • Compact Controls: Focuses on compact, familiar controls that integrate into the task flow.

    Key Design Rules:

    • The One Signal Rule: Cobalt identifies what is active or actionable; inactive content remains neutral.
    • The Semantic State Rule: Green, amber, and red are used only for real semantic states (success, warning, danger) and never for decoration.
    • The Mono Evidence Rule: Monospace fonts are used for evidence formatting (identifiers, code, timestamps, measurements) rather than as a stylistic choice.
  5. Configure LLM access via LiteLLM

    main

    The project provides a unified AI model access experience supporting official APIs, OpenAI-compatible platforms, and local models. It is powered by LiteLLM.

    Users can choose from three configuration levels based on their needs:

    1. Simple Model Configuration: For beginners who want to get the system running quickly.
    2. Channel (Channels) Mode: For advanced users managing multiple API keys and custom Base URLs.
    3. YAML Advanced Configuration: For power users requiring complex load balancing, request routing, or multi-platform high availability.

    For specific provider details, GitHub Actions Secrets configuration, or troubleshooting details.reason errors, refer to the LLM Service Provider Configuration Guide.

  6. Navigate the Web Agent Workspaces

    main

    The application is organized into several functional workspaces based on the investment decision flow:

    Core Workspaces

    • /overview: Interaction with the Main Agent.
    • /market-intelligence: Market intelligence and macro snapshots.
    • /stock-research: Structured individual stock analysis.
    • /screening: Structured stock screening.
    • /trading: Configuration of trading strategies and running simulation proposals.

    Auxiliary Workspaces

    • /expert-review: Peer review by specific experts or a custom expert group.
    • /schedules: Management of persistent scheduled tasks (stocks, screening, trading).
    • /runs: The unified ledger for all Task, Run, DataSnapshot, and Artifact objects.
    • /capabilities/*: Configuration for Skills, Tools, MCP, Data Sources, and Experts.
    • /settings: System-wide configuration for models, the Main Agent Runtime, authentication, and system settings.
  7. Navigate the llm-tradebot documentation

    main

    The documentation for llm-tradebot is organized by user intent. Use the following paths to find specific guidance:

    Getting Started

    Configuration

    Advanced Usage & Features

    Deployment & Development

  8. Understand the AI Stock Analysis System project structure

    main

    The project is organized into several key directories that separate core logic, data ingestion, and user interfaces:

    • main.py: The primary entry point for the application.
    • src/: Contains core business logic, including analyzer.py (AI analysis), config.py (configuration management), and notification.py (push notifications).
    • data_provider/: Houses multi-source data adapters for fetching market data.
    • bot/: Module for interacting with bots.
    • api/: The FastAPI backend service.
    • apps/dsa-web/: The React-based frontend application.
    • docker/: Docker-related configuration files.
    • docs/: Project documentation.
    • .github/workflows/: GitHub Actions automation workflows.
    daily_stock_analysis/
    ├── main.py              # Main entry point
    ├── src/                 # Core business logic
    │   ├── analyzer.py      # AI analyzer
    │   ├── config.py        # Configuration management
    │   ├── notification.py  # Message push notifications
    │   └── ...
    ├── data_provider/       # Multi-source data adapters
    ├── bot/                 # Bot interaction module
    ├── api/                 # FastAPI backend service
    ├── apps/dsa-web/        # React frontend
    ├── docker/              # Docker configuration
    ├── docs/                # Project documentation
    └── .github/workflows/   # GitHub Actions
  9. Understand Field Quality Status in AnalysisContextPack

    main

    The AnalysisContextPack uses specific status tokens to describe the quality of data fields or data blocks. These statuses describe the state of the data itself, not whether a business process (like an analysis or notification) succeeded.

    Available Statuses:

    • available: Field exists, source and timestamp are interpretable, and the current path is usable (e.g., real-time price is returned).
    • missing: The required field was not retrieved or is empty (e.g., no recent daily line in DB).
    • not_supported: The field is not supported by the current market, data source, or path (e.g., certain markets lack chip distribution).
    • fallback: The preferred source was unavailable, and a backup source or older path was used (e.g., falling back from real-time price to historical close).
    • stale: The field exists, but the data is not fresh enough (e.g., price_stale or fx_stale).
    • estimated: The field is an estimated value and should not be treated as a complete fact.
    • partial: The data block is partially available and partially missing.
    • fetch_failed: A retrieval attempt was explicitly made, but the fetch failed (e.g., fundamental_context.status == "failed").
  10. Support for Japan (JP) and South Korea (KR) Portfolios

    main

    The system allows JP and KR accounts, trades, and holdings snapshots to enter the existing pipeline. However, these markets are treated as data_quality=partial.

    Capabilities:

    • Supports creating and querying JP/KR accounts, trades, cash flows, and corporate actions.

    Limitations & Constraints:

    • Data Quality: Snapshots are marked with data_quality=partial. Limitations include realtime_quote_best_effort, fx_and_cost_basis_partial, and sector_and_risk_metrics_limited.
    • No FX/Tax Models: The system does not provide JPY/KRW exchange rates, tax models, or specific trading unit/tick size validations.
    • Market Light Alerts: Market Light snapshots and alerts only support cn, hk, and us. JP and KR markets will not appear in the Market Light alert dropdown.
    • Market Review Configuration: In the Web UI, MARKET_REVIEW_REGION has changed from a fixed dropdown to a free-text input. You can enter comma-separated values like cn,us,jp to include Japan in market reviews.
  11. Understand DecisionSignal core concepts and boundaries

    main

    A DecisionSignal is a structured asset that indexes AI suggestions, evidence summaries, risks, and observation conditions from stock analysis, Agents, alerts, and portfolio risk assessments.

    Key characteristics:

    • Non-executable: It records advice and evidence but does not execute trades or rebalance portfolios.
    • Decoupled: Failures in writing, extracting, or notifying signals do not block the primary analysis, alert triggers, or report saving.
    • Structured Index: It acts as a structured index sitting above Markdown reports and operation_advice text.
    • Identity & Deduplication: Signals are identified by a combination of (source_report_id, source_type, market, stock_code, decision_profile, action, horizon, market_phase). If no report is present, trace_id is used for deduplication.
  12. Use the Expert Review section for research validation

    main

    The ExpertReview feature aggregates ExpertOpinion into a single reading area to allow users to validate research findings against multiple perspectives.

    Review Structure

    1. Host Summary: A high-level overview of the discussion.
    2. Conflict Matrix: Displays a comparison of Original Report / Expert Opinion / Host Resolution.
    3. Independent Opinions: Each opinion is broken down into Viewpoint / Supporting Evidence / Counter-evidence & Limitations.

    Key Features

    • Deduplication: Identical aggregate snapshots are deduplicated based on full payload (top-level fields sorted) while preserving distinct revisions or failures.
    • Confidence Scores: Self-rated confidence must be a finite value between 0 and 1 (e.g., 0.85). It is not a success probability and is not averaged into a consensus score.
    • AI Attribution: Experts named within the framework are explicitly labeled as AI-simulated personas, not real individuals.
    • Workspace Integration: This expert review view is reused across the Screening and Trading workspaces.