Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add langgraph.json configuration file #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ Thumbs.db

# Txt files
*.txt
.langgraph_api
62 changes: 56 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AI Hedge Fund

This is a proof of concept for an AI-powered hedge fund. The goal of this project is to explore the use of AI to make trading decisions. This project is for **educational** purposes only and is not intended for real trading or investment.
This is a proof of concept for an AI-powered hedge fund. The goal of this project is to explore the use of AI to make trading decisions. This project is for **educational** purposes only and is not intended for real trading or investment.

This system employs several agents working together:

Expand All @@ -16,7 +16,6 @@ This system employs several agents working together:

<img width="1117" alt="Screenshot 2025-02-09 at 11 26 14 AM" src="https://github.com/user-attachments/assets/16509cc2-4b64-4c67-8de6-00d224893d58" />


**Note**: the system simulates trading decisions, it does not actually trade.

[![Twitter Follow](https://img.shields.io/twitter/follow/virattt?style=social)](https://twitter.com/virattt)
Expand All @@ -34,6 +33,7 @@ This project is for **educational and research purposes only**.
By using this software, you agree to use it solely for learning purposes.

## Table of Contents

- [Setup](#setup)
- [Usage](#usage)
- [Running the Hedge Fund](#running-the-hedge-fund)
Expand All @@ -46,28 +46,33 @@ By using this software, you agree to use it solely for learning purposes.
## Setup

Clone the repository:

```bash
git clone https://github.com/virattt/ai-hedge-fund.git
cd ai-hedge-fund
```

1. Install Poetry (if not already installed):

```bash
curl -sSL https://install.python-poetry.org | python3 -
```

2. Install dependencies:

```bash
poetry install
```

3. Set up your environment variables:

```bash
# Create .env file for your API keys
cp .env.example .env
```

4. Set your API keys:

```bash
# For running LLMs hosted by openai (gpt-4o, gpt-4o-mini, etc.)
# Get your OpenAI API key from https://platform.openai.com/
Expand All @@ -82,7 +87,7 @@ GROQ_API_KEY=your-groq-api-key
FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
```

**Important**: You must set `OPENAI_API_KEY`, `GROQ_API_KEY`, or `ANTHROPIC_API_KEY` for the hedge fund to work. If you want to use LLMs from all providers, you will need to set all API keys.
**Important**: You must set `OPENAI_API_KEY`, `GROQ_API_KEY`, or `ANTHROPIC_API_KEY` for the hedge fund to work. If you want to use LLMs from all providers, you will need to set all API keys.

Financial data for AAPL, GOOGL, MSFT, NVDA, and TSLA is free and does not require an API key.

Expand All @@ -91,6 +96,7 @@ For any other ticker, you will need to set the `FINANCIAL_DATASETS_API_KEY` in t
## Usage

### Running the Hedge Fund

```bash
poetry run python src/main.py --ticker AAPL,MSFT,NVDA
```
Expand All @@ -103,12 +109,55 @@ You can also specify a `--show-reasoning` flag to print the reasoning of each ag
```bash
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --show-reasoning
```

You can optionally specify the start and end dates to make decisions for a specific time period.

```bash
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
poetry run python src/main.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
```

### Using LangGraph CLI (Development)

The project uses LangGraph for agent orchestration and provides a development server with visualization capabilities.

To start the LangGraph development server:

```bash

poetry shell

langgraph dev

```

This will start:

- 🚀 API Server: http://127.0.0.1:2024

- 🎨 Studio UI: https://smith.langchain.com/studio/?baseUrl=http://127.0.0.1:2024

- 📚 API Documentation: http://127.0.0.1:2024/docs

The LangGraph Studio UI provides:

- Visual representation of the agent workflow

- Real-time monitoring of agent interactions

- Debugging tools for agent communication

- Performance metrics for the system

You can use the Studio UI to:

1. Visualize how agents communicate

2. Debug agent decision-making processes

3. Monitor system performance

4. Test different agent configurations

### Running the Backtester

```bash
Expand All @@ -124,7 +173,8 @@ You can optionally specify the start and end dates to backtest over a specific t
poetry run python src/backtester.py --ticker AAPL,MSFT,NVDA --start-date 2024-01-01 --end-date 2024-03-01
```

## Project Structure
## Project Structure

```
ai-hedge-fund/
├── src/
Expand Down Expand Up @@ -153,7 +203,7 @@ ai-hedge-fund/
4. Push to the branch
5. Create a Pull Request

**Important**: Please keep your pull requests small and focused. This will make it easier to review and merge.
**Important**: Please keep your pull requests small and focused. This will make it easier to review and merge.

## Feature Requests

Expand Down
8 changes: 8 additions & 0 deletions langgraph.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": ["src"],
"graphs": {
"hedge_fund": "src/main.py:app"
},
"env": ".env",
"dockerfile_lines": ["RUN apt-get update && apt-get install -y libgomp1"]
}
Loading