mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-06 10:47:24 -04:00
Compare commits
4 Commits
v0.2.0-alp
...
v0.2.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 5da02b4ba0 | |||
| 11509ba8c7 | |||
| 1785f9b06f | |||
| 55206549c7 |
@@ -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=.
|
||||||
|
|||||||
26
CHANGELOG.md
26
CHANGELOG.md
@@ -7,30 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
## [0.2.0] - 2025-10-30
|
## [0.2.0] - 2025-10-31
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Complete Docker deployment support with containerization
|
- Complete Docker deployment support with containerization
|
||||||
- Docker Compose orchestration for easy local deployment
|
- Docker Compose orchestration for easy local deployment
|
||||||
- Multi-stage Dockerfile with Python 3.10-slim base image
|
- Multi-stage Dockerfile with Python 3.10-slim base image
|
||||||
- Automated CI/CD pipeline via GitHub Actions for release builds
|
- Automated CI/CD pipeline via GitHub Actions for release builds
|
||||||
|
- Automatic draft release creation with version tagging
|
||||||
- Docker images published to GitHub Container Registry (ghcr.io)
|
- Docker images published to GitHub Container Registry (ghcr.io)
|
||||||
- Comprehensive Docker documentation (docs/DOCKER.md)
|
- Comprehensive Docker documentation (docs/DOCKER.md)
|
||||||
- Release process documentation (docs/RELEASING.md)
|
- Release process documentation (docs/RELEASING.md)
|
||||||
|
- Data cache reuse design documentation (docs/DESIGN_DATA_CACHE_REUSE.md)
|
||||||
- CLAUDE.md repository guidance for development
|
- CLAUDE.md repository guidance for development
|
||||||
- Docker deployment section in main README
|
- Docker deployment section in main README
|
||||||
- Environment variable configuration via docker-compose
|
- Environment variable configuration via docker-compose
|
||||||
- Sequential startup script (entrypoint.sh) for data fetch, MCP services, and trading agent
|
- Sequential startup script (entrypoint.sh) for data fetch, MCP services, and trading agent
|
||||||
- Volume mounts for data and logs persistence
|
- Volume mounts for data and logs persistence
|
||||||
- Pre-built image support from ghcr.io/hkuds/ai-trader
|
- Pre-built image support from ghcr.io/xe138/ai-trader
|
||||||
|
- Configurable volume path for persistent data
|
||||||
|
- Configurable web interface host port
|
||||||
|
- Automated merged.jsonl creation during price fetching
|
||||||
|
- API key registration URLs in .env.example
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Updated .env.example with Docker-specific configuration and paths
|
- Updated .env.example with Docker-specific configuration, API key URLs, and paths
|
||||||
- Updated .gitignore to exclude git worktrees directory
|
- Updated .gitignore to exclude git worktrees directory
|
||||||
- Removed deprecated version tag from docker-compose.yml
|
- Removed deprecated version tag from docker-compose.yml
|
||||||
|
- Updated repository URLs to Xe138/AI-Trader fork
|
||||||
|
- Docker Compose now uses pre-built image by default
|
||||||
|
- Simplified Docker config file selection with convention over configuration
|
||||||
|
- Fixed internal ports with configurable host ports
|
||||||
|
- Separated data scripts from volume mount directory
|
||||||
|
- Reduced log flooding during data fetch
|
||||||
|
- OPENAI_API_BASE can now be left empty in configuration
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Docker Compose configuration now follows modern best practices (version-less)
|
- Docker Compose configuration now follows modern best practices (version-less)
|
||||||
|
- Prevent restart loop on missing API keys with proper validation
|
||||||
|
- Docker tag generation now converts repository owner to lowercase
|
||||||
|
- Validate GITHUB_REF is a tag in docker-release workflow
|
||||||
|
- Correct Dockerfile FROM AS casing
|
||||||
|
- Module import errors for MCP services resolved with PYTHONPATH
|
||||||
|
- Prevent price data overwrite on container restart
|
||||||
|
- Merge script now writes to current directory for volume compatibility
|
||||||
|
|
||||||
## [0.1.0] - Initial Release
|
## [0.1.0] - Initial Release
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import requests
|
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv
|
|
||||||
load_dotenv()
|
|
||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
all_nasdaq_100_symbols = [
|
all_nasdaq_100_symbols = [
|
||||||
@@ -42,4 +46,15 @@ if __name__ == "__main__":
|
|||||||
for symbol in all_nasdaq_100_symbols:
|
for symbol in all_nasdaq_100_symbols:
|
||||||
get_daily_price(symbol)
|
get_daily_price(symbol)
|
||||||
|
|
||||||
get_daily_price("QQQ")
|
get_daily_price("QQQ")
|
||||||
|
|
||||||
|
# Automatically run merge after fetching
|
||||||
|
print("\n📦 Merging price data...")
|
||||||
|
try:
|
||||||
|
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
merge_script = os.path.join(script_dir, "merge_jsonl.py")
|
||||||
|
subprocess.run([sys.executable, merge_script], check=True)
|
||||||
|
print("✅ Price data merged successfully")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"⚠️ Failed to merge data: {e}")
|
||||||
|
print(" Please run 'python merge_jsonl.py' manually")
|
||||||
@@ -18,7 +18,8 @@ all_nasdaq_100_symbols = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# 合并所有以 daily_price 开头的 json,逐文件一行写入 merged.jsonl
|
# 合并所有以 daily_price 开头的 json,逐文件一行写入 merged.jsonl
|
||||||
current_dir = os.path.dirname(__file__)
|
# Use current working directory instead of script directory for volume compatibility
|
||||||
|
current_dir = os.getcwd()
|
||||||
pattern = os.path.join(current_dir, 'daily_price*.json')
|
pattern = os.path.join(current_dir, 'daily_price*.json')
|
||||||
files = sorted(glob.glob(pattern))
|
files = sorted(glob.glob(pattern))
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +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
|
||||||
- ./configs:/app/configs
|
- ${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}
|
||||||
|
|||||||
@@ -112,17 +112,43 @@ docker-compose up
|
|||||||
|
|
||||||
### Volume Mounts
|
### Volume Mounts
|
||||||
|
|
||||||
Docker Compose mounts three 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)
|
- `./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
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ if [ -f "/app/data/merged.jsonl" ] && [ -s "/app/data/merged.jsonl" ]; then
|
|||||||
echo " To refresh data, delete /app/data/merged.jsonl and restart"
|
echo " To refresh data, delete /app/data/merged.jsonl and restart"
|
||||||
else
|
else
|
||||||
echo "📊 Fetching and merging price data..."
|
echo "📊 Fetching and merging price data..."
|
||||||
# Run scripts from /app/scripts but output to /app/data
|
# Run script from /app/scripts but output to /app/data
|
||||||
|
# Note: get_daily_price.py now automatically calls merge_jsonl.py after fetching
|
||||||
cd /app/data
|
cd /app/data
|
||||||
python /app/scripts/get_daily_price.py
|
python /app/scripts/get_daily_price.py
|
||||||
python /app/scripts/merge_jsonl.py
|
|
||||||
cd /app
|
cd /app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
2
main.sh
2
main.sh
@@ -10,8 +10,8 @@ echo "🚀 Launching AI Trader Environment..."
|
|||||||
|
|
||||||
echo "📊 Now getting and merging price data..."
|
echo "📊 Now getting and merging price data..."
|
||||||
cd ./data
|
cd ./data
|
||||||
|
# Note: get_daily_price.py now automatically calls merge_jsonl.py after fetching
|
||||||
python get_daily_price.py
|
python get_daily_price.py
|
||||||
python merge_jsonl.py
|
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
echo "🔧 Now starting MCP services..."
|
echo "🔧 Now starting MCP services..."
|
||||||
|
|||||||
Reference in New Issue
Block a user