FinRobot Documentation

repository·master·Indexed 27 days ago

https://github.com/ai4finance-foundation/finrobot

An open-source AI agent platform for financial applications that unifies LLMs, reinforcement learning, and quantitative analytics. FinRobot automates investment research, algorithmic trading, and risk assessment, featuring a specialized equity research pipeline, a FastAPI-based web interface, and a native macOS desktop application (v0.1.0). It includes tools for financial analysis, report generation, and automated charting for metrics such as Revenue, EBITDA, and EV/EBITDA peer comparisons.

Tokens
18.9K
Snippets
35
Records
85
Agent score
93%

What's inside FinRobot

  1. Configure API Keys for FinRobot Pro

    master

    Before running FinRobot Pro, you must configure your API keys in a config.ini file.

    1. Copy the example configuration file to the active config path:
      cp finrobot_equity/core/config/config.ini.example finrobot_equity/core/config/config.ini
    2. Edit finrobot_equity/core/config/config.ini and provide your keys under the [API_KEYS] section:
      • fmp_api_key: Financial Modeling Prep API key.
      • openai_api_key: OpenAI API key.
      • adanos_api_key: (Optional) Enables Retail Sentiment Insights.
    cp finrobot_equity/core/config/config.ini.example finrobot_equity/core/config/config.ini
  2. Install FinRobot

    master

    Follow these steps to set up a FinRobot development environment using Conda and Pip.

    1. Create and activate a virtual environment:

      conda create --name finrobot python=3.10
      conda activate finrobot
    2. Clone the repository:

      git clone https://github.com/AI4Finance-Foundation/FinRobot.git
      cd FinRobot
    3. Install the package: You can install the latest release from PyPI:

      pip install -U finrobot

      Or install directly from the local repository in editable mode:

      pip install -e .
    conda create --name finrobot python=3.10
    conda activate finrobot
    git clone https://github.com/AI4Finance-Foundation/FinRobot.git
    cd FinRobot
    pip install -U finrobot
    # OR
    pip install -e .
  3. Deploy FinRobot Pro Web Interface

    master

    You can deploy FinRobot Pro with a single command using the provided deployment script, which handles dependency installation.

    Using deploy.sh:

    chmod +x deploy.sh
    ./deploy.sh start

    Manual Deployment (if deploy.sh fails): If the script does not work, follow these steps to set up a virtual environment and run the app manually:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements-equity.txt
    python run_web_app.py

    Once running, access the interface at http://127.0.0.1:8001.

    Deployment Commands Reference:

    CommandDescription
    ./deploy.sh startStart the web app (auto-installs dependencies)
    ./deploy.sh stopStop the application
    ./deploy.sh restartRestart the application
    ./deploy.sh statusCheck running status
    ./deploy.sh start
  4. Run the FinRobot Equity Research pipeline via CLI

    master

    The research process is a two-step pipeline. You can run each step manually via the command line.

    Step 1: Financial Analysis

    Fetches data from FMP API, processes metrics, generates 3-year forecasts, runs peer comparisons, and generates AI text. Outputs CSV, JSON, and TXT files.

    Step 2: Report Generation

    Loads the analysis outputs, fetches market data, generates charts, and renders a 3-page HTML report.

    # Step 1: Financial analysis
    python finrobot_equity/core/src/generate_financial_analysis.py \
        --company-ticker NVDA \
        --company-name "NVIDIA Corporation" \
        --config-file finrobot_equity/core/config/config.ini \
        --peer-tickers AMD INTC \
        --generate-text-sections
    
    # Step 2: Generate report
    python finrobot_equity/core/src/create_equity_report.py \
        --company-ticker NVDA \
        --company-name "NVIDIA Corporation" \
        --analysis-csv output/NVDA/analysis/financial_metrics_and_forecasts.csv \
        --ratios-csv output/NVDA/analysis/ratios_raw_data.csv \
        --tagline-file output/NVDA/analysis/tagline.txt \
        --company-overview-file output/NVDA/analysis/company_overview.txt \
        --investment-overview-file output/NVDA/analysis/investment_overview.txt \
        --valuation-overview-file output/NVDA/analysis/valuation_overview.txt \
        --risks-file output/NVDA/analysis/risks.txt \
        --competitor-analysis-file output/NVDA/analysis/competitor_analysis.txt \
        --major-takeaways-file output/NVDA/analysis/major_takeaways.txt \
        --peer-ev-ebitda-csv output/NVDA/analysis/peer_ev_ebitda_comparison.csv \
        --enable-text-regeneration \
        --config-file finrobot_equity/core/config/config.ini
  5. Explore FinRobot Tutorials and Notebooks

    master

    After installation and configuration, you can explore the following notebooks located in the tutorials_beginner and tutorials_advanced directories to see the agents in action:

    Beginner Tutorials:

    • agent_fingpt_forecaster.ipynb
    • agent_annual_report.ipynb

    Advanced Tutorials:

    • agent_trade_strategist.ipynb
    • agent_fingpt_forecaster.ipynb
    • agent_annual_report.ipynb
    • lmm_agent_mplfinance.ipynb
    • lmm_agent_opt_smacross.ipynb
  6. Install FinRobot Desktop v0.1.0 on macOS

    master

    FinRobot Desktop is a native macOS application for equity research.

    Requirements:

    • Apple Silicon Macs (M1, M2, M3, or later). Intel Mac builds are not supported in this release.

    Installation Steps:

    1. Download FinRobot_0.1.0_aarch64.dmg from the latest releases.
    2. Drag FinRobot into your Applications folder.

    Troubleshooting macOS Security Error: Because the app is not yet Apple-notarized, macOS may report it as "damaged" on first launch. To fix this, run the following command in your Terminal:

    xattr -cr /Applications/FinRobot.app
    xattr -cr /Applications/FinRobot.app
  7. Configure API keys for FinRobot Equity Research

    master

    Before running the analysis or report generation, you must configure your API keys. Copy the template to a new config.ini file and populate it with your credentials.

    Required keys:

    • fmp_api_key: For financial data and market metrics from Financial Modeling Prep.
    • openai_api_key: For LLM-powered text generation.

    Optional key:

    • adanos_api_key: Enables Retail Sentiment Insights (Reddit, X.com, and Polymarket data).
    cp finrobot_equity/core/config/config.ini.template finrobot_equity/core/config/config.ini
    [API_KEYS]
    fmp_api_key = YOUR_FMP_API_KEY
    openai_api_key = YOUR_OPENAI_API_KEY
    adanos_api_key = YOUR_ADANOS_API_KEY
  8. Configure API Keys for FinRobot

    master

    FinRobot requires configuration for OpenAI and various financial data providers. You must set up two specific configuration files in the root directory.

    1. OpenAI Configuration

    1. Rename OAI_CONFIG_LIST_sample to OAI_CONFIG_LIST.
    2. Remove the four lines of comments within the file.
    3. Add your OpenAI API key.

    2. Financial Data Provider Configuration

    1. Rename config_api_keys_sample to config_api_keys.
    2. Remove the comments within the file.
    3. Add your specific API keys for the following services:
      • finnhub-api: YOUR_FINNHUB_API_KEY
      • financialmodelingprep (FMP): YOUR_FMP_API_KEY
      • sec-api: YOUR_SEC_API_KEY (required for financial report generation)
  9. Configure Web Application Environment Variables

    master

    The following environment variables control the behavior and authentication of the web application:

    | Variable | Default | Description |
    |:---|:---|:---|
    | `GITHUB_CLIENT_ID` | — | GitHub OAuth client ID |
    | `GITHUB_CLIENT_SECRET` | — | GitHub OAuth client secret |
    | `FINROBOT_ADMIN_EMAIL` | `admin@finrobot.com` | Initial admin email |
    | `FINROBOT_ADMIN_PASSWORD` | (random) | Initial admin password |
    | `WEB_HOST` | `127.0.0.1` | Server bind address |
    | `WEB_PORT` | `8001` | Server port |
  10. Configure FinRobot API keys and LLM settings

    master

    To use FinRobot, you must configure your OpenAI, SecApi, and FMPApi credentials.

    1. OpenAI Configuration: Rename your OAI_CONFIG_LIST_sample file to OAI_CONFIG_LIST and update the API keys. Use autogen.config_list_from_json to load it.
    2. Financial API Keys: Rename config_api_keys_sample to config_api_keys and replace the placeholder keys with your actual SecApi and FMPApi keys. Use register_keys_from_json to load them into the environment.

    Ensure you define a work_dir for intermediate file storage (e.g., reports and instruction files).

  11. Initialize FinRobot agents with API keys and local LLM

    master

    To set up a multi-agent workflow:

    1. Use register_keys_from_json to load your API credentials from a JSON file.
    2. Initialize an AssistantAgent with your llm_config.
    3. Initialize a UserProxyAgent to manage code execution and termination logic.
    from finrobot.utils import register_keys_from_json
    from autogen import AssistantAgent, UserProxyAgent
    
    # Load API keys
    register_keys_from_json("../config_api_keys")
    
    # Initialize Analyst
    analyst = AssistantAgent(
        name="Market_Analyst",
        llm_config=llm_config,
    )
    
    # Initialize User Proxy
    user_proxy = UserProxyAgent(
        "user_proxy", 
        code_execution_config=False, 
        max_consecutive_auto_reply=1,  
        is_termination_msg=lambda x: x.get("content", "") and "TERMINATE" in x.get("content", ""),
        human_input_mode="NEVER"
    )