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.
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
- Cloning Warehouse:
git clone https://github.com/virattt/ai-hedge-fund.git cd ai-hedge-fund
- Install Poetry (if not already installed):
curl -sSL https://install.python-poetry.org | python3 -
- Install the dependencies:
poetry install
- 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
"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 workflowssrc/backtester.py
: Backtest functionsrc/tools.py
: Technical analysis toolspyproject.toml
: Poetry Configuration.env.example
: Examples of environment variablesREADME.md
: Documentation