Merge rebrand from AI-Trader to AI-Trader-Server

Complete rebrand of project to reflect REST API service architecture:
- Updated all documentation (README, guides, API reference)
- Updated Docker configuration (compose, Dockerfile, images)
- Updated all repository URLs to Xe138/AI-Trader-Server
- Updated all Docker images to ghcr.io/xe138/ai-trader-server
- Added fork acknowledgment crediting HKUDS/AI-Trader
- Updated GitHub Actions workflows and shell scripts

All 4 phases completed with validation checkpoints.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-01 12:11:34 -04:00
27 changed files with 190 additions and 179 deletions

View File

@@ -1,5 +1,5 @@
# =============================================================================
# AI-Trader Environment Configuration
# AI-Trader-Server Environment Configuration
# =============================================================================
# Copy this file to .env and fill in your actual values
# Docker Compose automatically reads .env from project root

View File

@@ -1,4 +1,4 @@
name: Build and Push Docker Image
name: Build and Push AI-Trader-Server Docker Image
on:
push:
@@ -63,11 +63,11 @@ jobs:
IS_PRERELEASE="${{ steps.meta.outputs.is_prerelease }}"
# Always tag with version
TAGS="ghcr.io/$REPO_OWNER_LOWER/ai-trader:$VERSION"
TAGS="ghcr.io/$REPO_OWNER_LOWER/ai-trader-server:$VERSION"
# Only add 'latest' tag for stable releases
if [[ "$IS_PRERELEASE" == "false" ]]; then
TAGS="${TAGS}"$'\n'"ghcr.io/$REPO_OWNER_LOWER/ai-trader:latest"
TAGS="${TAGS}"$'\n'"ghcr.io/$REPO_OWNER_LOWER/ai-trader-server:latest"
echo "Tagging as both $VERSION and latest"
else
echo "Pre-release detected - tagging as $VERSION only (NOT latest)"
@@ -89,10 +89,10 @@ jobs:
- name: Image published
run: |
echo "✅ Docker image published successfully!"
echo "📦 Pull with: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:${{ steps.meta.outputs.version }}"
echo "📦 Pull with: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader-server:${{ steps.meta.outputs.version }}"
if [[ "${{ steps.meta.outputs.is_prerelease }}" == "false" ]]; then
echo "📦 Or latest: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader:latest"
echo "📦 Or latest: docker pull ghcr.io/${{ steps.meta.outputs.repo_owner_lower }}/ai-trader-server:latest"
else
echo "⚠️ Pre-release version - 'latest' tag not updated"
fi
@@ -123,8 +123,8 @@ jobs:
**Using Docker Compose:**
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
cp .env.example .env
# Edit .env with your API keys
docker-compose up
@@ -132,11 +132,11 @@ jobs:
**Using pre-built image:**
```bash
docker pull ghcr.io/REPO_OWNER/ai-trader:VERSION
docker pull ghcr.io/REPO_OWNER/ai-trader-server:VERSION
docker run --env-file .env \
-v $(pwd)/data:/app/data \
-v $(pwd)/logs:/app/logs \
ghcr.io/REPO_OWNER/ai-trader:VERSION
ghcr.io/REPO_OWNER/ai-trader-server:VERSION
```
### Documentation
@@ -153,8 +153,8 @@ jobs:
---
**Container Registry:** `ghcr.io/REPO_OWNER/ai-trader:VERSION`
**Docker Image:** `ghcr.io/REPO_OWNER/ai-trader:latest`
**Container Registry:** `ghcr.io/REPO_OWNER/ai-trader-server:VERSION`
**Docker Image:** `ghcr.io/REPO_OWNER/ai-trader-server:latest`
EOF
# Replace placeholders

View File

@@ -1,6 +1,6 @@
# AI-Trader API Reference
# AI-Trader-Server API Reference
Complete reference for the AI-Trader REST API service.
Complete reference for the AI-Trader-Server REST API service.
**Base URL:** `http://localhost:8080` (default)
@@ -672,7 +672,7 @@ Interactive API documentation available at:
import requests
import time
class AITraderClient:
class AITraderServerClient:
def __init__(self, base_url="http://localhost:8080"):
self.base_url = base_url
@@ -720,7 +720,7 @@ class AITraderClient:
return response.json()
# Usage
client = AITraderClient()
client = AITraderServerClient()
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
result = client.wait_for_completion(job["job_id"])
results = client.get_results(job_id=job["job_id"])
@@ -729,7 +729,7 @@ results = client.get_results(job_id=job["job_id"])
### TypeScript/JavaScript
```typescript
class AITraderClient {
class AITraderServerClient {
constructor(private baseUrl: string = "http://localhost:8080") {}
async triggerSimulation(
@@ -788,7 +788,7 @@ class AITraderClient {
}
// Usage
const client = new AITraderClient();
const client = new AITraderServerClient();
const job = await client.triggerSimulation("2025-01-16", null, ["gpt-4"]);
const result = await client.waitForCompletion(job.job_id);
const results = await client.getResults({ jobId: job.job_id });

View File

@@ -1,6 +1,6 @@
# Changelog
All notable changes to the AI-Trader project will be documented in this file.
All notable changes to the AI-Trader-Server project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
@@ -61,7 +61,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 8 existing integration tests
- **Docker Deployment** - Persistent REST API service
- API-only deployment (batch mode removed for simplicity)
- Single docker-compose service (ai-trader)
- Single docker-compose service (ai-trader-server)
- Health check configuration (30s interval, 3 retries)
- Volume persistence for SQLite database and logs
- Configurable API_PORT for flexible deployment
@@ -95,7 +95,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Only API port (8080) is exposed to host
- Reduces configuration complexity and attack surface
- **Requirements** - Added fastapi>=0.120.0, uvicorn[standard]>=0.27.0, pydantic>=2.0.0
- **Docker Compose** - Single service (ai-trader) instead of dual-mode
- **Docker Compose** - Single service (ai-trader-server) instead of dual-mode
- **Dockerfile** - Added system dependencies (curl, procps) and port 8080 exposure
- **.env.example** - Simplified configuration with only essential variables
- **Entrypoint** - Unified entrypoint.sh with proper signal handling (exec uvicorn)
@@ -162,7 +162,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Environment variable configuration via docker-compose
- Sequential startup script (entrypoint.sh) for data fetch, MCP services, and trading agent
- Volume mounts for data and logs persistence
- Pre-built image support from ghcr.io/xe138/ai-trader
- Pre-built image support from ghcr.io/xe138/ai-trader-server
- Configurable volume path for persistent data
- Configurable web interface host port
- Automated merged.jsonl creation during price fetching
@@ -172,7 +172,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated .env.example with Docker-specific configuration, API key URLs, and paths
- Updated .gitignore to exclude git worktrees directory
- Removed deprecated version tag from docker-compose.yml
- Updated repository URLs to Xe138/AI-Trader fork
- Updated repository URLs to Xe138/AI-Trader-Server 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
@@ -251,7 +251,7 @@ For future releases, use this template:
---
[Unreleased]: https://github.com/Xe138/AI-Trader/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/Xe138/AI-Trader/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/Xe138/AI-Trader/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/Xe138/AI-Trader/releases/tag/v0.1.0
[Unreleased]: https://github.com/Xe138/AI-Trader-Server/compare/v0.3.0...HEAD
[0.3.0]: https://github.com/Xe138/AI-Trader-Server/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/Xe138/AI-Trader-Server/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/Xe138/AI-Trader-Server/releases/tag/v0.1.0

View File

@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview
AI-Trader is an autonomous AI trading competition platform where multiple AI models compete in NASDAQ 100 trading with zero human intervention. Each AI starts with $10,000 and uses standardized MCP (Model Context Protocol) tools to make fully autonomous trading decisions.
AI-Trader-Server is a REST API service for autonomous AI trading competitions where multiple AI models compete in NASDAQ 100 trading with zero human intervention. Each AI starts with $10,000 and uses standardized MCP (Model Context Protocol) tools to make fully autonomous trading decisions.
**Key Innovation:** Historical replay architecture with anti-look-ahead controls ensures AI agents can only access data from the current simulation date and earlier.
@@ -56,7 +56,7 @@ docker-compose up
docker-compose up -d
# Run with custom config
docker-compose run ai-trader configs/my_config.json
docker-compose run ai-trader-server configs/my_config.json
# View logs
docker-compose logs -f
@@ -65,11 +65,11 @@ docker-compose logs -f
docker-compose down
# Pull pre-built image
docker pull ghcr.io/hkuds/ai-trader:latest
docker pull ghcr.io/xe138/ai-trader-server:latest
# Test local Docker build
docker build -t ai-trader-test .
docker run --env-file .env -v $(pwd)/data:/app/data ai-trader-test
docker build -t ai-trader-server-test .
docker run --env-file .env -v $(pwd)/data:/app/data ai-trader-server-test
```
### Releasing Docker Images
@@ -82,10 +82,10 @@ git push origin v1.0.0
# GitHub Actions automatically:
# 1. Builds Docker image
# 2. Tags with version and latest
# 3. Pushes to ghcr.io/hkuds/ai-trader
# 3. Pushes to ghcr.io/xe138/ai-trader-server
# Verify build in Actions tab
# https://github.com/HKUDS/AI-Trader/actions
# https://github.com/Xe138/AI-Trader-Server/actions
```
### Running Trading Simulations

View File

@@ -1,6 +1,11 @@
# Base stage - dependency installation
FROM python:3.10-slim AS base
# Metadata labels
LABEL org.opencontainers.image.title="AI-Trader-Server"
LABEL org.opencontainers.image.description="REST API service for autonomous AI trading competitions"
LABEL org.opencontainers.image.source="https://github.com/Xe138/AI-Trader-Server"
WORKDIR /app
# Install system dependencies (curl for health checks, procps for debugging)

View File

@@ -1,6 +1,6 @@
# Quick Start Guide
Get AI-Trader running in under 5 minutes using Docker.
Get AI-Trader-Server running in under 5 minutes using Docker.
---
@@ -21,8 +21,8 @@ Get AI-Trader running in under 5 minutes using Docker.
## Step 1: Clone Repository
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
```
---
@@ -62,7 +62,7 @@ docker-compose up -d
This will:
- Build the Docker image (~5-10 minutes first time)
- Start the AI-Trader API service
- Start the AI-Trader-Server API service
- Start internal MCP services (math, search, trade, price)
- Initialize the SQLite database
@@ -70,7 +70,7 @@ This will:
```bash
# View logs
docker logs -f ai-trader
docker logs -f ai-trader-server
# Wait for this message:
# "Application startup complete"
@@ -261,7 +261,7 @@ curl "http://localhost:8080/results?date=2025-01-16&model=gpt-4"
```bash
# Check logs
docker logs ai-trader
docker logs ai-trader-server
# Common issues:
# - Missing API keys in .env
@@ -288,13 +288,13 @@ docker-compose up -d
```bash
# Check if container is running
docker ps | grep ai-trader
docker ps | grep ai-trader-server
# Restart service
docker-compose restart
# Check for errors in logs
docker logs ai-trader | grep -i error
docker logs ai-trader-server | grep -i error
```
### Job stays "pending"
@@ -303,7 +303,7 @@ The simulation might still be downloading price data on first run.
```bash
# Watch logs in real-time
docker logs -f ai-trader
docker logs -f ai-trader-server
# Look for messages like:
# "Downloading missing price data..."
@@ -321,7 +321,7 @@ This means price data is missing for the requested date range.
**Solution 2:** Manually download price data:
```bash
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
cd data
python get_daily_price.py
python merge_jsonl.py
@@ -334,7 +334,7 @@ exit
```bash
# View logs
docker logs -f ai-trader
docker logs -f ai-trader-server
# Stop service
docker-compose down
@@ -349,10 +349,10 @@ docker-compose restart
curl http://localhost:8080/health
# Access container shell
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
# View database
docker exec -it ai-trader sqlite3 /app/data/jobs.db
docker exec -it ai-trader-server sqlite3 /app/data/jobs.db
```
---
@@ -369,5 +369,5 @@ docker exec -it ai-trader sqlite3 /app/data/jobs.db
## Need Help?
- Check [docs/user-guide/troubleshooting.md](docs/user-guide/troubleshooting.md)
- Review logs: `docker logs ai-trader`
- Open an issue: [GitHub Issues](https://github.com/Xe138/AI-Trader/issues)
- Review logs: `docker logs ai-trader-server`
- Open an issue: [GitHub Issues](https://github.com/Xe138/AI-Trader-Server/issues)

View File

@@ -1,6 +1,6 @@
<div align="center">
# 🚀 AI-Trader: Can AI Beat the Market?
# 🚀 AI-Trader-Server: REST API for AI Trading
[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg)](https://python.org)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
@@ -15,9 +15,9 @@
---
## 🌟 What is AI-Trader?
## 🌟 What is AI-Trader-Server?
> **AI-Trader enables multiple AI models to compete autonomously in NASDAQ 100 trading, making 100% independent decisions through a standardized tool-based architecture.**
> **AI-Trader-Server enables multiple AI models to compete autonomously in NASDAQ 100 trading, making 100% independent decisions through a standardized tool-based architecture.**
### Key Features
@@ -77,8 +77,8 @@
**2. Setup**
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
# Configure environment
cp .env.example .env
@@ -193,7 +193,7 @@ Through the MCP (Model Context Protocol) toolchain, AI agents can:
import requests
import time
class AITraderClient:
class AITraderServerClient:
def __init__(self, base_url="http://localhost:8080"):
self.base_url = base_url
@@ -224,7 +224,7 @@ class AITraderClient:
time.sleep(poll_interval)
# Usage
client = AITraderClient()
client = AITraderServerClient()
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
result = client.wait_for_completion(job["job_id"])
```
@@ -445,7 +445,7 @@ SQLite database at `data/jobs.db` contains:
Query directly:
```bash
docker exec -it ai-trader sqlite3 /app/data/jobs.db
docker exec -it ai-trader-server sqlite3 /app/data/jobs.db
sqlite> SELECT * FROM jobs ORDER BY created_at DESC LIMIT 5;
```
@@ -509,6 +509,12 @@ Contributions welcome! Please read [docs/developer/CONTRIBUTING.md](docs/develop
---
## 🙏 Acknowledgments
This project is a fork of [HKUDS/AI-Trader](https://github.com/HKUDS/AI-Trader), re-architected as a REST API service for external orchestration and integration.
---
## 📄 License
MIT License - see [LICENSE](LICENSE) for details
@@ -517,9 +523,9 @@ MIT License - see [LICENSE](LICENSE) for details
## 🔗 Links
- **GitHub**: https://github.com/Xe138/AI-Trader
- **Docker Hub**: `ghcr.io/xe138/ai-trader:latest`
- **Issues**: https://github.com/Xe138/AI-Trader/issues
- **GitHub**: https://github.com/Xe138/AI-Trader-Server
- **Docker Hub**: `ghcr.io/xe138/ai-trader-server:latest`
- **Issues**: https://github.com/Xe138/AI-Trader-Server/issues
- **API Docs**: http://localhost:8080/docs (when running)
---
@@ -528,6 +534,6 @@ MIT License - see [LICENSE](LICENSE) for details
**Built with FastAPI, SQLite, Docker, and the MCP Protocol**
[⬆ Back to top](#-ai-trader-can-ai-beat-the-market)
[⬆ Back to top](#-ai-trader-server-rest-api-for-ai-trading)
</div>

View File

@@ -1,6 +1,6 @@
# Configuration Files
This directory contains configuration files for the AI-Trader Bench. These JSON configuration files define the parameters and settings used by the trading agents during execution.
This directory contains configuration files for AI-Trader-Server. These JSON configuration files define the parameters and settings used by the trading agents during execution.
## Files

View File

@@ -1,10 +1,10 @@
services:
# REST API server for Windmill integration
ai-trader:
# image: ghcr.io/xe138/ai-trader:latest
ai-trader-server:
# image: ghcr.io/xe138/ai-trader-server:latest
# Uncomment to build locally instead of pulling:
build: .
container_name: ai-trader
container_name: ai-trader-server
volumes:
- ${VOLUME_PATH:-.}/data:/app/data
- ${VOLUME_PATH:-.}/logs:/app/logs

View File

@@ -11,8 +11,8 @@
1. **Clone repository:**
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
```
2. **Configure environment:**
@@ -70,13 +70,13 @@ 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`
2. Command-line argument: `docker-compose run ai-trader-server 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
docker-compose run ai-trader-server configs/my_special_config.json
```
## Usage Examples
@@ -94,7 +94,7 @@ docker-compose logs -f # Follow logs
### Run with custom config
```bash
docker-compose run ai-trader configs/custom_config.json
docker-compose run ai-trader-server configs/custom_config.json
```
### Stop containers
@@ -156,10 +156,10 @@ docker-compose up
```bash
# Backup
tar -czf ai-trader-backup-$(date +%Y%m%d).tar.gz data/agent_data/
tar -czf ai-trader-server-backup-$(date +%Y%m%d).tar.gz data/agent_data/
# Restore
tar -xzf ai-trader-backup-YYYYMMDD.tar.gz
tar -xzf ai-trader-server-backup-YYYYMMDD.tar.gz
```
## Using Pre-built Images
@@ -167,7 +167,7 @@ tar -xzf ai-trader-backup-YYYYMMDD.tar.gz
### Pull from GitHub Container Registry
```bash
docker pull ghcr.io/hkuds/ai-trader:latest
docker pull ghcr.io/xe138/ai-trader-server:latest
```
### Run without Docker Compose
@@ -177,12 +177,12 @@ docker run --env-file .env \
-v $(pwd)/data:/app/data \
-v $(pwd)/logs:/app/logs \
-p 8000-8003:8000-8003 \
ghcr.io/hkuds/ai-trader:latest
ghcr.io/xe138/ai-trader-server:latest
```
### Specific version
```bash
docker pull ghcr.io/hkuds/ai-trader:v1.0.0
docker pull ghcr.io/xe138/ai-trader-server:v1.0.0
```
## Troubleshooting
@@ -239,7 +239,7 @@ docker pull ghcr.io/hkuds/ai-trader:v1.0.0
Run bash inside container for debugging:
```bash
docker-compose run --entrypoint /bin/bash ai-trader
docker-compose run --entrypoint /bin/bash ai-trader-server
```
### Build Multi-platform Images
@@ -247,13 +247,13 @@ docker-compose run --entrypoint /bin/bash ai-trader
For ARM64 (Apple Silicon) and AMD64:
```bash
docker buildx build --platform linux/amd64,linux/arm64 -t ai-trader .
docker buildx build --platform linux/amd64,linux/arm64 -t ai-trader-server .
```
### View Container Resource Usage
```bash
docker stats ai-trader-app
docker stats ai-trader-server
```
### Access MCP Services Directly
@@ -295,10 +295,10 @@ cp configs/default_config.json configs/aggressive.json
# Edit each config...
# Test conservative strategy
docker-compose run ai-trader configs/conservative.json
docker-compose run ai-trader-server configs/conservative.json
# Test aggressive strategy
docker-compose run ai-trader configs/aggressive.json
docker-compose run ai-trader-server configs/aggressive.json
```
**Method 3: Temporarily switch configs**

View File

@@ -31,30 +31,30 @@ Tag push automatically triggers `.github/workflows/docker-release.yml`:
3. ✅ Logs into GitHub Container Registry
4. ✅ Extracts version from tag
5. ✅ Builds Docker image with caching
6. ✅ Pushes to `ghcr.io/hkuds/ai-trader:VERSION`
7. ✅ Pushes to `ghcr.io/hkuds/ai-trader:latest`
6. ✅ Pushes to `ghcr.io/xe138/ai-trader-server:VERSION`
7. ✅ Pushes to `ghcr.io/xe138/ai-trader-server:latest`
### 4. Verify Build
1. Check GitHub Actions: https://github.com/Xe138/AI-Trader/actions
1. Check GitHub Actions: https://github.com/Xe138/AI-Trader-Server/actions
2. Verify workflow completed successfully (green checkmark)
3. Check packages: https://github.com/Xe138/AI-Trader/pkgs/container/ai-trader
3. Check packages: https://github.com/Xe138/AI-Trader-Server/pkgs/container/ai-trader-server
### 5. Test Release
```bash
# Pull released image
docker pull ghcr.io/hkuds/ai-trader:v1.0.0
docker pull ghcr.io/xe138/ai-trader-server:v1.0.0
# Test run
docker run --env-file .env \
-v $(pwd)/data:/app/data \
ghcr.io/hkuds/ai-trader:v1.0.0
ghcr.io/xe138/ai-trader-server:v1.0.0
```
### 6. Create GitHub Release (Optional)
1. Go to https://github.com/Xe138/AI-Trader/releases/new
1. Go to https://github.com/Xe138/AI-Trader-Server/releases/new
2. Select tag: `v1.0.0`
3. Release title: `v1.0.0 - Docker Deployment Support`
4. Add release notes:
@@ -67,8 +67,8 @@ This release adds full Docker support for easy deployment.
### Pull and Run
```bash
docker pull ghcr.io/hkuds/ai-trader:v1.0.0
docker run --env-file .env -v $(pwd)/data:/app/data ghcr.io/hkuds/ai-trader:v1.0.0
docker pull ghcr.io/xe138/ai-trader-server:v1.0.0
docker run --env-file .env -v $(pwd)/data:/app/data ghcr.io/xe138/ai-trader-server:v1.0.0
```
Or use Docker Compose:
@@ -137,13 +137,13 @@ If automated build fails, manual push:
```bash
# Build locally
docker build -t ghcr.io/hkuds/ai-trader:v1.0.0 .
docker build -t ghcr.io/xe138/ai-trader-server:v1.0.0 .
# Login to GHCR
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
# Push
docker push ghcr.io/hkuds/ai-trader:v1.0.0
docker tag ghcr.io/hkuds/ai-trader:v1.0.0 ghcr.io/hkuds/ai-trader:latest
docker push ghcr.io/hkuds/ai-trader:latest
docker push ghcr.io/xe138/ai-trader-server:v1.0.0
docker tag ghcr.io/xe138/ai-trader-server:v1.0.0 ghcr.io/xe138/ai-trader-server:latest
docker push ghcr.io/xe138/ai-trader-server:latest
```

View File

@@ -7,8 +7,8 @@ Production Docker deployment guide.
## Quick Deployment
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
cp .env.example .env
# Edit .env with API keys
docker-compose up -d
@@ -23,8 +23,8 @@ docker-compose up -d
```yaml
# docker-compose.yml
services:
ai-trader:
image: ghcr.io/xe138/ai-trader:latest
ai-trader-server:
image: ghcr.io/xe138/ai-trader-server:latest
# ... rest of config
```
@@ -33,7 +33,7 @@ services:
```yaml
# docker-compose.yml
services:
ai-trader:
ai-trader-server:
build: .
# ... rest of config
```
@@ -84,10 +84,10 @@ healthcheck:
docker ps
# Resource usage
docker stats ai-trader
docker stats ai-trader-server
# Logs
docker logs -f ai-trader
docker logs -f ai-trader-server
```
---

View File

@@ -20,13 +20,13 @@ curl http://localhost:8080/health
```bash
# View logs
docker logs -f ai-trader
docker logs -f ai-trader-server
# Filter errors
docker logs ai-trader 2>&1 | grep -i error
docker logs ai-trader-server 2>&1 | grep -i error
# Export logs
docker logs ai-trader > ai-trader.log 2>&1
docker logs ai-trader-server > ai-trader-server.log 2>&1
```
---
@@ -35,10 +35,10 @@ docker logs ai-trader > ai-trader.log 2>&1
```bash
# Database size
docker exec ai-trader du -h /app/data/jobs.db
docker exec ai-trader-server du -h /app/data/jobs.db
# Job statistics
docker exec ai-trader sqlite3 /app/data/jobs.db \
docker exec ai-trader-server sqlite3 /app/data/jobs.db \
"SELECT status, COUNT(*) FROM jobs GROUP BY status;"
```

View File

@@ -19,15 +19,15 @@ For parallel simulations, deploy multiple instances:
```yaml
# docker-compose.yml
services:
ai-trader-1:
image: ghcr.io/xe138/ai-trader:latest
ai-trader-server-1:
image: ghcr.io/xe138/ai-trader-server:latest
ports:
- "8081:8080"
volumes:
- ./data1:/app/data
ai-trader-2:
image: ghcr.io/xe138/ai-trader:latest
ai-trader-server-2:
image: ghcr.io/xe138/ai-trader-server:latest
ports:
- "8082:8080"
volumes:

View File

@@ -1,4 +1,4 @@
# Contributing to AI-Trader
# Contributing to AI-Trader-Server
Guidelines for contributing to the project.

View File

@@ -17,8 +17,8 @@ Local development without Docker.
### 1. Clone Repository
```bash
git clone https://github.com/Xe138/AI-Trader.git
cd AI-Trader
git clone https://github.com/Xe138/AI-Trader-Server.git
cd AI-Trader-Server
```
### 2. Create Virtual Environment

View File

@@ -1,6 +1,6 @@
# Testing Guide
Guide for testing AI-Trader during development.
Guide for testing AI-Trader-Server during development.
---

View File

@@ -1,6 +1,6 @@
# Data Formats
File formats and schemas used by AI-Trader.
File formats and schemas used by AI-Trader-Server.
---

View File

@@ -1,6 +1,6 @@
# Configuration Guide
Complete guide to configuring AI-Trader.
Complete guide to configuring AI-Trader-Server.
---
@@ -323,5 +323,5 @@ docker-compose up -d
curl http://localhost:8080/health
# Check logs for errors
docker logs ai-trader | grep -i error
docker logs ai-trader-server | grep -i error
```

View File

@@ -1,6 +1,6 @@
# Integration Examples
Examples for integrating AI-Trader with external systems.
Examples for integrating AI-Trader-Server with external systems.
---
@@ -14,7 +14,7 @@ See complete Python client in [API_REFERENCE.md](../../API_REFERENCE.md#client-l
import aiohttp
import asyncio
class AsyncAITraderClient:
class AsyncAITraderServerClient:
def __init__(self, base_url="http://localhost:8080"):
self.base_url = base_url
@@ -48,7 +48,7 @@ class AsyncAITraderClient:
# Usage
async def main():
client = AsyncAITraderClient()
client = AsyncAITraderServerClient()
job = await client.trigger_simulation("2025-01-16", models=["gpt-4"])
result = await client.wait_for_completion(job["job_id"])
print(f"Simulation completed: {result['status']}")
@@ -104,7 +104,7 @@ echo "Results saved to results_$DATE.json"
Add to crontab:
```bash
0 6 * * * /path/to/daily_simulation.sh >> /var/log/ai-trader.log 2>&1
0 6 * * * /path/to/daily_simulation.sh >> /var/log/ai-trader-server.log 2>&1
```
---
@@ -120,7 +120,7 @@ import time
def trigger_simulation(**context):
response = requests.post(
"http://ai-trader:8080/simulate/trigger",
"http://ai-trader-server:8080/simulate/trigger",
json={"start_date": "{{ ds }}", "models": ["gpt-4"]}
)
response.raise_for_status()
@@ -128,19 +128,19 @@ def trigger_simulation(**context):
def wait_for_completion(**context):
job_id = context["task_instance"].xcom_pull(task_ids="trigger")
while True:
response = requests.get(f"http://ai-trader:8080/simulate/status/{job_id}")
response = requests.get(f"http://ai-trader-server:8080/simulate/status/{job_id}")
status = response.json()
if status["status"] in ["completed", "partial", "failed"]:
return status
time.sleep(30)
def fetch_results(**context):
job_id = context["task_instance"].xcom_pull(task_ids="trigger")
response = requests.get(f"http://ai-trader:8080/results?job_id={job_id}")
response = requests.get(f"http://ai-trader-server:8080/results?job_id={job_id}")
return response.json()
default_args = {
@@ -152,7 +152,7 @@ default_args = {
}
dag = DAG(
"ai_trader_simulation",
"ai_trader_server_simulation",
default_args=default_args,
schedule_interval="0 6 * * *", # Daily at 6 AM
catchup=False
@@ -183,7 +183,7 @@ trigger_task >> wait_task >> fetch_task
## Generic Workflow Automation
Any HTTP-capable automation service can integrate with AI-Trader:
Any HTTP-capable automation service can integrate with AI-Trader-Server:
1. **Trigger:** POST to `/simulate/trigger`
2. **Poll:** GET `/simulate/status/{job_id}` every 10-30 seconds

View File

@@ -1,6 +1,6 @@
# Troubleshooting Guide
Common issues and solutions for AI-Trader.
Common issues and solutions for AI-Trader-Server.
---
@@ -9,16 +9,16 @@ Common issues and solutions for AI-Trader.
### Container Won't Start
**Symptoms:**
- `docker ps` shows no ai-trader container
- `docker ps` shows no ai-trader-server container
- Container exits immediately after starting
**Debug:**
```bash
# Check logs
docker logs ai-trader
docker logs ai-trader-server
# Check if container exists (stopped)
docker ps -a | grep ai-trader
docker ps -a | grep ai-trader-server
```
**Common Causes & Solutions:**
@@ -64,10 +64,10 @@ chmod -R 755 data logs configs
**Debug:**
```bash
# Check if API process is running
docker exec ai-trader ps aux | grep uvicorn
docker exec ai-trader-server ps aux | grep uvicorn
# Test internal health (always port 8080 inside container)
docker exec ai-trader curl http://localhost:8080/health
docker exec ai-trader-server curl http://localhost:8080/health
# Check configured port
grep API_PORT .env
@@ -82,7 +82,7 @@ Another service is using your configured port.
# Find conflicting service
sudo lsof -i :8080
# Change AI-Trader port
# Change AI-Trader-Server port
echo "API_PORT=8889" >> .env
docker-compose down
docker-compose up -d
@@ -94,7 +94,7 @@ curl http://localhost:8889/health
**If MCP services didn't start:**
```bash
# Check MCP processes
docker exec ai-trader ps aux | grep python
docker exec ai-trader-server ps aux | grep python
# Should see 4 MCP services on ports 8000-8003
```
@@ -102,7 +102,7 @@ docker exec ai-trader ps aux | grep python
**If database issues:**
```bash
# Check database file
docker exec ai-trader ls -l /app/data/jobs.db
docker exec ai-trader-server ls -l /app/data/jobs.db
# If missing, restart to recreate
docker-compose restart
@@ -121,13 +121,13 @@ docker-compose restart
**Debug:**
```bash
# Check worker logs
docker logs ai-trader | grep -i "worker\|simulation"
docker logs ai-trader-server | grep -i "worker\|simulation"
# Check database
docker exec ai-trader sqlite3 /app/data/jobs.db "SELECT * FROM job_details;"
docker exec ai-trader-server sqlite3 /app/data/jobs.db "SELECT * FROM job_details;"
# Check MCP service accessibility
docker exec ai-trader curl http://localhost:8000/health
docker exec ai-trader-server curl http://localhost:8000/health
```
**Solutions:**
@@ -173,7 +173,7 @@ done
**Check if agent is stuck:**
```bash
# View real-time logs
docker logs -f ai-trader
docker logs -f ai-trader-server
# Look for repeated errors or infinite loops
```
@@ -204,7 +204,7 @@ curl -X POST http://localhost:8080/simulate/trigger \
**Option 2: Manually Download Data**
```bash
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
cd data
python get_daily_price.py # Downloads latest data
python merge_jsonl.py # Merges into database
@@ -242,7 +242,7 @@ grep AUTO_DOWNLOAD_PRICE_DATA .env
**Workaround:**
```bash
# Pre-download data in batches
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
cd data
# Download in stages (wait 1 min between runs)
@@ -269,7 +269,7 @@ exit
}
```
**Cause:** AI-Trader allows only 1 concurrent job by default.
**Cause:** AI-Trader-Server allows only 1 concurrent job by default.
**Solutions:**
@@ -279,7 +279,7 @@ exit
curl http://localhost:8080/health # Verify API is up
# Query recent jobs (need to check database)
docker exec ai-trader sqlite3 /app/data/jobs.db \
docker exec ai-trader-server sqlite3 /app/data/jobs.db \
"SELECT job_id, status FROM jobs ORDER BY created_at DESC LIMIT 5;"
```
@@ -292,7 +292,7 @@ curl http://localhost:8080/simulate/status/{job_id}
**Force-stop stuck job (last resort):**
```bash
# Update job status in database
docker exec ai-trader sqlite3 /app/data/jobs.db \
docker exec ai-trader-server sqlite3 /app/data/jobs.db \
"UPDATE jobs SET status='failed' WHERE status IN ('pending', 'running');"
# Restart service
@@ -386,7 +386,7 @@ docker-compose up -d
```bash
# Re-download price data
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
cd data
python get_daily_price.py
python merge_jsonl.py
@@ -418,7 +418,7 @@ exit
**3. MCP services overloaded**
```bash
# Check CPU usage
docker stats ai-trader
docker stats ai-trader-server
```
---
@@ -430,7 +430,7 @@ docker stats ai-trader
**If higher:**
```bash
# Check memory
docker stats ai-trader
docker stats ai-trader-server
# Restart if needed
docker-compose restart
@@ -442,34 +442,34 @@ docker-compose restart
```bash
# Container status
docker ps | grep ai-trader
docker ps | grep ai-trader-server
# Real-time logs
docker logs -f ai-trader
docker logs -f ai-trader-server
# Check errors only
docker logs ai-trader 2>&1 | grep -i error
docker logs ai-trader-server 2>&1 | grep -i error
# Container resource usage
docker stats ai-trader
docker stats ai-trader-server
# Access container shell
docker exec -it ai-trader bash
docker exec -it ai-trader-server bash
# Database inspection
docker exec -it ai-trader sqlite3 /app/data/jobs.db
docker exec -it ai-trader-server sqlite3 /app/data/jobs.db
sqlite> SELECT * FROM jobs ORDER BY created_at DESC LIMIT 5;
sqlite> SELECT status, COUNT(*) FROM jobs GROUP BY status;
sqlite> .quit
# Check file permissions
docker exec ai-trader ls -la /app/data
docker exec ai-trader-server ls -la /app/data
# Test API connectivity
curl -v http://localhost:8080/health
# View all environment variables
docker exec ai-trader env | sort
docker exec ai-trader-server env | sort
```
---
@@ -480,7 +480,7 @@ If your issue isn't covered here:
1. **Check logs** for specific error messages
2. **Review** [API_REFERENCE.md](../../API_REFERENCE.md) for correct usage
3. **Search** [GitHub Issues](https://github.com/Xe138/AI-Trader/issues)
3. **Search** [GitHub Issues](https://github.com/Xe138/AI-Trader-Server/issues)
4. **Open new issue** with:
- Error messages from logs
- Steps to reproduce

View File

@@ -1,6 +1,6 @@
# Using the API
Common workflows and best practices for AI-Trader API.
Common workflows and best practices for AI-Trader-Server API.
---

View File

@@ -1,7 +1,7 @@
#!/bin/bash
set -e # Exit on any error
echo "🚀 Starting AI-Trader API Server..."
echo "🚀 Starting AI-Trader-Server API..."
# Validate required environment variables
echo "🔍 Validating environment variables..."

View File

@@ -1,11 +1,11 @@
#!/bin/bash
# AI-Trader 主启动脚本
# AI-Trader-Server 主启动脚本
# 用于启动完整的交易环境
set -e # 遇到错误时退出
echo "🚀 Launching AI Trader Environment..."
echo "🚀 Launching AI-Trader-Server Environment..."
echo "📊 Now getting and merging price data..."
@@ -25,7 +25,7 @@ sleep 2
echo "🤖 Now starting the main trading agent..."
python main.py configs/default_config.json
echo "✅ AI-Trader stopped"
echo "✅ AI-Trader-Server stopped"
echo "🔄 Starting web server..."
cd ./docs

View File

@@ -5,7 +5,7 @@
set -e
echo "=========================================="
echo "AI-Trader API Endpoint Testing"
echo "AI-Trader-Server API Endpoint Testing"
echo "=========================================="
echo ""
@@ -34,7 +34,7 @@ echo "Checking if API is accessible..."
if ! curl -f "$API_BASE_URL/health" &> /dev/null; then
echo -e "${RED}${NC} API is not accessible at $API_BASE_URL"
echo "Make sure the container is running:"
echo " docker-compose up -d ai-trader"
echo " docker-compose up -d ai-trader-server"
exit 1
fi
echo -e "${GREEN}${NC} API is accessible"

View File

@@ -5,7 +5,7 @@
set -e # Exit on error
echo "=========================================="
echo "AI-Trader Docker Build Validation"
echo "AI-Trader-Server Docker Build Validation"
echo "=========================================="
echo ""
@@ -112,7 +112,7 @@ echo "Step 3: Building Docker image..."
echo "This may take several minutes on first build..."
echo ""
if docker build -t ai-trader-test . ; then
if docker build -t ai-trader-server-test . ; then
print_status 0 "Docker image built successfully"
else
print_status 1 "Docker build failed"
@@ -124,11 +124,11 @@ echo ""
# Step 4: Check image
echo "Step 4: Verifying Docker image..."
IMAGE_SIZE=$(docker images ai-trader-test --format "{{.Size}}")
IMAGE_SIZE=$(docker images ai-trader-server-test --format "{{.Size}}")
print_status 0 "Image size: $IMAGE_SIZE"
# List exposed ports
EXPOSED_PORTS=$(docker inspect ai-trader-test --format '{{range $p, $conf := .Config.ExposedPorts}}{{$p}} {{end}}')
EXPOSED_PORTS=$(docker inspect ai-trader-server-test --format '{{range $p, $conf := .Config.ExposedPorts}}{{$p}} {{end}}')
print_status 0 "Exposed ports: $EXPOSED_PORTS"
echo ""
@@ -137,7 +137,7 @@ echo ""
echo "Step 5: Testing API mode startup..."
echo "Starting container in background..."
$COMPOSE_CMD up -d ai-trader
$COMPOSE_CMD up -d ai-trader-server
if [ $? -eq 0 ]; then
print_status 0 "Container started successfully"
@@ -146,20 +146,20 @@ if [ $? -eq 0 ]; then
sleep 10
# Check if container is still running
if docker ps | grep -q ai-trader; then
if docker ps | grep -q ai-trader-server; then
print_status 0 "Container is running"
# Check logs for errors
ERROR_COUNT=$(docker logs ai-trader 2>&1 | grep -i "error" | grep -v "ERROR:" | wc -l)
ERROR_COUNT=$(docker logs ai-trader-server 2>&1 | grep -i "error" | grep -v "ERROR:" | wc -l)
if [ $ERROR_COUNT -gt 0 ]; then
print_warning "Found $ERROR_COUNT error messages in logs"
echo "Check logs with: docker logs ai-trader"
echo "Check logs with: docker logs ai-trader-server"
else
print_status 0 "No critical errors in logs"
fi
else
print_status 1 "Container stopped unexpectedly"
echo "Check logs with: docker logs ai-trader"
echo "Check logs with: docker logs ai-trader-server"
exit 1
fi
else
@@ -209,14 +209,14 @@ else
print_warning "Diagnostics:"
# Check if container is still running
if docker ps | grep -q ai-trader; then
if docker ps | grep -q ai-trader-server; then
echo " ✓ Container is running"
else
echo " ✗ Container has stopped"
fi
# Check if port is listening
if docker exec ai-trader netstat -tuln 2>/dev/null | grep -q ":8080"; then
if docker exec ai-trader-server netstat -tuln 2>/dev/null | grep -q ":8080"; then
echo " ✓ Port 8080 is listening inside container"
else
echo " ✗ Port 8080 is NOT listening inside container"
@@ -224,7 +224,7 @@ else
# Try curl from inside container
echo " Testing from inside container..."
INTERNAL_TEST=$(docker exec ai-trader curl -f -s http://localhost:8080/health 2>&1)
INTERNAL_TEST=$(docker exec ai-trader-server curl -f -s http://localhost:8080/health 2>&1)
if [ $? -eq 0 ]; then
echo " ✓ Health endpoint works inside container: $INTERNAL_TEST"
echo " ✗ Issue is with port mapping or host networking"
@@ -235,7 +235,7 @@ else
echo ""
echo "Recent logs:"
docker logs ai-trader 2>&1 | tail -20
docker logs ai-trader-server 2>&1 | tail -20
fi
echo ""
@@ -262,7 +262,7 @@ echo "2. Test batch mode:"
echo " bash scripts/test_batch_mode.sh"
echo ""
echo "3. If any checks failed, review logs:"
echo " docker logs ai-trader"
echo " docker logs ai-trader-server"
echo ""
echo "4. For troubleshooting, see: DOCKER_API.md"
echo ""