mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-08 11:47:24 -04:00
Compare commits
3 Commits
v0.2.0-alp
...
v0.2.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
| 55206549c7 | |||
| 9e05ce0891 | |||
| 2f2c1d6ea2 |
@@ -30,3 +30,9 @@ WEB_HTTP_PORT=8888
|
|||||||
|
|
||||||
# Agent Configuration
|
# Agent Configuration
|
||||||
AGENT_MAX_STEP=30
|
AGENT_MAX_STEP=30
|
||||||
|
|
||||||
|
# Data Volume Configuration
|
||||||
|
# Base directory for all persistent data (will contain data/, logs/, configs/ subdirectories)
|
||||||
|
# Use relative paths (./volumes) or absolute paths (/home/user/ai-trader-volumes)
|
||||||
|
# Defaults to current directory (.) if not set
|
||||||
|
VOLUME_PATH=.
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -57,6 +57,7 @@ delete.py
|
|||||||
refresh_data.sh
|
refresh_data.sh
|
||||||
|
|
||||||
# Config files (optional - uncomment if needed)
|
# Config files (optional - uncomment if needed)
|
||||||
|
configs/custom_config.json
|
||||||
configs/day_config.json
|
configs/day_config.json
|
||||||
configs/hour_config.json
|
configs/hour_config.json
|
||||||
configs/test_config.json
|
configs/test_config.json
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ services:
|
|||||||
# build: .
|
# build: .
|
||||||
container_name: ai-trader-app
|
container_name: ai-trader-app
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ${VOLUME_PATH:-.}/data:/app/data
|
||||||
- ./logs:/app/logs
|
- ${VOLUME_PATH:-.}/logs:/app/logs
|
||||||
|
- ${VOLUME_PATH:-.}/configs:/app/configs
|
||||||
environment:
|
environment:
|
||||||
# AI Model API Configuration
|
# AI Model API Configuration
|
||||||
- OPENAI_API_BASE=${OPENAI_API_BASE}
|
- OPENAI_API_BASE=${OPENAI_API_BASE}
|
||||||
|
|||||||
101
docs/DOCKER.md
101
docs/DOCKER.md
@@ -53,10 +53,30 @@ AGENT_MAX_STEP=30
|
|||||||
|
|
||||||
### Custom Trading Configuration
|
### Custom Trading Configuration
|
||||||
|
|
||||||
Pass a custom config file:
|
**Simple Method (Recommended):**
|
||||||
|
|
||||||
|
Create a `configs/custom_config.json` file - it will be automatically used:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose run ai-trader configs/my_config.json
|
# Copy default config as starting point
|
||||||
|
cp configs/default_config.json configs/custom_config.json
|
||||||
|
|
||||||
|
# Edit your custom config
|
||||||
|
nano configs/custom_config.json
|
||||||
|
|
||||||
|
# Run normally - custom_config.json is automatically detected!
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
**Priority order:**
|
||||||
|
1. `configs/custom_config.json` (if exists) - **Highest priority**
|
||||||
|
2. Command-line argument: `docker-compose run ai-trader configs/other.json`
|
||||||
|
3. `configs/default_config.json` (fallback)
|
||||||
|
|
||||||
|
**Advanced: Use a different config file name:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker-compose run ai-trader configs/my_special_config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
@@ -92,16 +112,43 @@ docker-compose up
|
|||||||
|
|
||||||
### Volume Mounts
|
### Volume Mounts
|
||||||
|
|
||||||
Docker Compose mounts two volumes:
|
Docker Compose mounts three volumes for persistent data. By default, these are stored in the project directory:
|
||||||
|
|
||||||
- `./data:/app/data` - Price data and trading records
|
- `./data:/app/data` - Price data and trading records
|
||||||
- `./logs:/app/logs` - MCP service logs
|
- `./logs:/app/logs` - MCP service logs
|
||||||
|
- `./configs:/app/configs` - Configuration files (allows editing configs without rebuilding)
|
||||||
|
|
||||||
Data persists across container restarts. To reset:
|
### Custom Volume Location
|
||||||
|
|
||||||
|
You can change where data is stored by setting `VOLUME_PATH` in your `.env` file:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Store data in a different location
|
||||||
|
VOLUME_PATH=/home/user/trading-data
|
||||||
|
|
||||||
|
# Or use a relative path
|
||||||
|
VOLUME_PATH=./volumes
|
||||||
|
```
|
||||||
|
|
||||||
|
This will store data in:
|
||||||
|
- `/home/user/trading-data/data/`
|
||||||
|
- `/home/user/trading-data/logs/`
|
||||||
|
- `/home/user/trading-data/configs/`
|
||||||
|
|
||||||
|
**Note:** The directory structure is automatically created. You'll need to copy your existing configs:
|
||||||
|
```bash
|
||||||
|
# After changing VOLUME_PATH
|
||||||
|
mkdir -p /home/user/trading-data/configs
|
||||||
|
cp configs/custom_config.json /home/user/trading-data/configs/
|
||||||
|
```
|
||||||
|
|
||||||
|
### Reset Data
|
||||||
|
|
||||||
|
To reset all trading data:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose down
|
docker-compose down
|
||||||
rm -rf data/agent_data/* logs/*
|
rm -rf ${VOLUME_PATH:-.}/data/agent_data/* ${VOLUME_PATH:-.}/logs/*
|
||||||
docker-compose up
|
docker-compose up
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -227,13 +274,45 @@ Services exposed on host:
|
|||||||
|
|
||||||
### Test Different Configurations
|
### Test Different Configurations
|
||||||
|
|
||||||
```bash
|
**Method 1: Use the standard custom_config.json**
|
||||||
# Create test config
|
|
||||||
cp configs/default_config.json configs/test_config.json
|
|
||||||
# Edit test_config.json
|
|
||||||
|
|
||||||
# Run with test config
|
```bash
|
||||||
docker-compose run ai-trader configs/test_config.json
|
# Create and edit your config
|
||||||
|
cp configs/default_config.json configs/custom_config.json
|
||||||
|
nano configs/custom_config.json
|
||||||
|
|
||||||
|
# Run - automatically uses custom_config.json
|
||||||
|
docker-compose up
|
||||||
|
```
|
||||||
|
|
||||||
|
**Method 2: Test multiple configs with different names**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create multiple test configs
|
||||||
|
cp configs/default_config.json configs/conservative.json
|
||||||
|
cp configs/default_config.json configs/aggressive.json
|
||||||
|
|
||||||
|
# Edit each config...
|
||||||
|
|
||||||
|
# Test conservative strategy
|
||||||
|
docker-compose run ai-trader configs/conservative.json
|
||||||
|
|
||||||
|
# Test aggressive strategy
|
||||||
|
docker-compose run ai-trader configs/aggressive.json
|
||||||
|
```
|
||||||
|
|
||||||
|
**Method 3: Temporarily switch configs**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Temporarily rename your custom config
|
||||||
|
mv configs/custom_config.json configs/custom_config.json.backup
|
||||||
|
cp configs/test_strategy.json configs/custom_config.json
|
||||||
|
|
||||||
|
# Run with test strategy
|
||||||
|
docker-compose up
|
||||||
|
|
||||||
|
# Restore original
|
||||||
|
mv configs/custom_config.json.backup configs/custom_config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Production Deployment
|
## Production Deployment
|
||||||
|
|||||||
@@ -38,12 +38,18 @@ fi
|
|||||||
echo "✅ Environment variables validated"
|
echo "✅ Environment variables validated"
|
||||||
|
|
||||||
# Step 1: Data preparation
|
# Step 1: Data preparation
|
||||||
echo "📊 Fetching and merging price data..."
|
echo "📊 Checking price data..."
|
||||||
# Run scripts from /app/scripts but output to /app/data
|
if [ -f "/app/data/merged.jsonl" ] && [ -s "/app/data/merged.jsonl" ]; then
|
||||||
cd /app/data
|
echo "✅ Using existing price data ($(wc -l < /app/data/merged.jsonl) stocks)"
|
||||||
python /app/scripts/get_daily_price.py
|
echo " To refresh data, delete /app/data/merged.jsonl and restart"
|
||||||
python /app/scripts/merge_jsonl.py
|
else
|
||||||
cd /app
|
echo "📊 Fetching and merging price data..."
|
||||||
|
# Run scripts from /app/scripts but output to /app/data
|
||||||
|
cd /app/data
|
||||||
|
python /app/scripts/get_daily_price.py
|
||||||
|
python /app/scripts/merge_jsonl.py
|
||||||
|
cd /app
|
||||||
|
fi
|
||||||
|
|
||||||
# Step 2: Start MCP services in background
|
# Step 2: Start MCP services in background
|
||||||
echo "🔧 Starting MCP services..."
|
echo "🔧 Starting MCP services..."
|
||||||
@@ -57,7 +63,19 @@ sleep 3
|
|||||||
|
|
||||||
# Step 4: Run trading agent with config file
|
# Step 4: Run trading agent with config file
|
||||||
echo "🤖 Starting trading agent..."
|
echo "🤖 Starting trading agent..."
|
||||||
CONFIG_FILE="${1:-configs/default_config.json}"
|
|
||||||
|
# Smart config selection: custom_config.json takes precedence if it exists
|
||||||
|
if [ -f "configs/custom_config.json" ]; then
|
||||||
|
CONFIG_FILE="configs/custom_config.json"
|
||||||
|
echo "✅ Using custom configuration: configs/custom_config.json"
|
||||||
|
elif [ -n "$1" ]; then
|
||||||
|
CONFIG_FILE="$1"
|
||||||
|
echo "✅ Using specified configuration: $CONFIG_FILE"
|
||||||
|
else
|
||||||
|
CONFIG_FILE="configs/default_config.json"
|
||||||
|
echo "✅ Using default configuration: configs/default_config.json"
|
||||||
|
fi
|
||||||
|
|
||||||
python main.py "$CONFIG_FILE"
|
python main.py "$CONFIG_FILE"
|
||||||
|
|
||||||
# Cleanup on exit
|
# Cleanup on exit
|
||||||
|
|||||||
Reference in New Issue
Block a user