AI Personal Learning
and practical guidance
豆包Marscode1

AI Hedge Fund: open-source automated trading system utilizing multiple intelligences for complex hedge fund trading decisions

General Introduction

AI Hedge Fund is an artificially intelligent hedge fund that utilizes a multi-agent system to make trading decisions. The system works in concert with multiple specialized agents, including market data agents, quantitative agents, risk management agents, and portfolio management agents, to enable complex trading decisions and automated trading.

This Python open-source project allows ordinary developers to build their own algorithmic trading systems by using four professional AI intelligences (market data, quantitative analysis, risk management, and portfolio management) to work together to automate the entire process from data collection and analysis to trading decisions.


AI Hedge Fund:开源的自动化交易系统,利用多智能体进行复杂对冲基金交易决策-1

 

Function List

  • Multi-agent system architecture: Multiple specialized agents work together to make complex trading decisions.
  • Technical Analysis: Using technical indicators such as MACD, RSI, Bollinger Bands and OBV.
  • Risk management: Provide position sizing recommendations and assess portfolio risk.
  • Portfolio management: automate trading decisions and generate orders.
  • Backtesting function: provides performance analysis and supports multiple stock codes.

 

Using Help

Installation process

  1. Cloning Warehouse:
    git clone https://github.com/virattt/ai-hedge-fund.git
    cd ai-hedge-fund
    
  2. Install Poetry (if not already installed):
    curl -sSL https://install.python-poetry.org | python3 -
    
  3. Install the dependencies:
    poetry install
    
  4. Setting environment variables:
    cp .env.example .env
    export OPENAI_API_KEY='your-api-key-here'
    export FINANCIAL_DATASETS_API_KEY='your-api-key-here'
    

Instructions for use

Running a hedge fund

Use the following command to run the hedge fund:

poetry run python src/agents.py --ticker AAPL --start-date 2024-01-01 --end-date 2024-03-01

Sample Output:

{
"action": "buy",
"quantity": 50000
}

Run the backtesting tool

Use the following command to run the backtesting tool:

poetry run python src/backtester.py --ticker AAPL --start-date 2024-01-01 --end-date 2024-03-01

Sample Output:

Starting backtest...
Date         Ticker Action Quantity    Price         Cash    Stock  Total Value
----------------------------------------------------------------------
2024-01-01   AAPL   buy       519.0   192.53        76.93    519.0    100000.00
2024-01-02   AAPL   hold          0   185.64        76.93    519.0     96424.09
2024-01-03   AAPL   hold          0   184.25        76.93    519.0     95702.68
2024-01-04   AAPL   hold          0   181.91        76.93    519.0     94488.22
2024-01-05   AAPL   hold          0   181.18        76.93    519.0     94109.35
2024-01-08   AAPL   sell        519   185.56     96382.57      0.0     96382.57
2024-01-09   AAPL   buy       520.0   185.14       109.77    520.0     96382.57

Project structure

  • src/agents.py: Key agent definitions and workflows
  • src/backtester.py: Backtest function
  • src/tools.py: Technical analysis tools
  • pyproject.toml: Poetry Configuration
  • .env.example: Examples of environment variables
  • README.md: Documentation
May not be reproduced without permission:Chief AI Sharing Circle " AI Hedge Fund: open-source automated trading system utilizing multiple intelligences for complex hedge fund trading decisions
en_USEnglish