mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-01 17:17:24 -04:00
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:
@@ -1,5 +1,5 @@
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
# AI-Trader Environment Configuration
|
# AI-Trader-Server Environment Configuration
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# Copy this file to .env and fill in your actual values
|
# Copy this file to .env and fill in your actual values
|
||||||
# Docker Compose automatically reads .env from project root
|
# Docker Compose automatically reads .env from project root
|
||||||
|
|||||||
22
.github/workflows/docker-release.yml
vendored
22
.github/workflows/docker-release.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Build and Push Docker Image
|
name: Build and Push AI-Trader-Server Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -63,11 +63,11 @@ jobs:
|
|||||||
IS_PRERELEASE="${{ steps.meta.outputs.is_prerelease }}"
|
IS_PRERELEASE="${{ steps.meta.outputs.is_prerelease }}"
|
||||||
|
|
||||||
# Always tag with version
|
# 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
|
# Only add 'latest' tag for stable releases
|
||||||
if [[ "$IS_PRERELEASE" == "false" ]]; then
|
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"
|
echo "Tagging as both $VERSION and latest"
|
||||||
else
|
else
|
||||||
echo "Pre-release detected - tagging as $VERSION only (NOT latest)"
|
echo "Pre-release detected - tagging as $VERSION only (NOT latest)"
|
||||||
@@ -89,10 +89,10 @@ jobs:
|
|||||||
- name: Image published
|
- name: Image published
|
||||||
run: |
|
run: |
|
||||||
echo "✅ Docker image published successfully!"
|
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
|
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
|
else
|
||||||
echo "⚠️ Pre-release version - 'latest' tag not updated"
|
echo "⚠️ Pre-release version - 'latest' tag not updated"
|
||||||
fi
|
fi
|
||||||
@@ -123,8 +123,8 @@ jobs:
|
|||||||
|
|
||||||
**Using Docker Compose:**
|
**Using Docker Compose:**
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
# Edit .env with your API keys
|
# Edit .env with your API keys
|
||||||
docker-compose up
|
docker-compose up
|
||||||
@@ -132,11 +132,11 @@ jobs:
|
|||||||
|
|
||||||
**Using pre-built image:**
|
**Using pre-built image:**
|
||||||
```bash
|
```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 \
|
docker run --env-file .env \
|
||||||
-v $(pwd)/data:/app/data \
|
-v $(pwd)/data:/app/data \
|
||||||
-v $(pwd)/logs:/app/logs \
|
-v $(pwd)/logs:/app/logs \
|
||||||
ghcr.io/REPO_OWNER/ai-trader:VERSION
|
ghcr.io/REPO_OWNER/ai-trader-server:VERSION
|
||||||
```
|
```
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
@@ -153,8 +153,8 @@ jobs:
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
**Container Registry:** `ghcr.io/REPO_OWNER/ai-trader:VERSION`
|
**Container Registry:** `ghcr.io/REPO_OWNER/ai-trader-server:VERSION`
|
||||||
**Docker Image:** `ghcr.io/REPO_OWNER/ai-trader:latest`
|
**Docker Image:** `ghcr.io/REPO_OWNER/ai-trader-server:latest`
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Replace placeholders
|
# Replace placeholders
|
||||||
|
|||||||
@@ -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)
|
**Base URL:** `http://localhost:8080` (default)
|
||||||
|
|
||||||
@@ -672,7 +672,7 @@ Interactive API documentation available at:
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class AITraderClient:
|
class AITraderServerClient:
|
||||||
def __init__(self, base_url="http://localhost:8080"):
|
def __init__(self, base_url="http://localhost:8080"):
|
||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
|
|
||||||
@@ -720,7 +720,7 @@ class AITraderClient:
|
|||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
client = AITraderClient()
|
client = AITraderServerClient()
|
||||||
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
||||||
result = client.wait_for_completion(job["job_id"])
|
result = client.wait_for_completion(job["job_id"])
|
||||||
results = client.get_results(job_id=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/JavaScript
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
class AITraderClient {
|
class AITraderServerClient {
|
||||||
constructor(private baseUrl: string = "http://localhost:8080") {}
|
constructor(private baseUrl: string = "http://localhost:8080") {}
|
||||||
|
|
||||||
async triggerSimulation(
|
async triggerSimulation(
|
||||||
@@ -788,7 +788,7 @@ class AITraderClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Usage
|
// Usage
|
||||||
const client = new AITraderClient();
|
const client = new AITraderServerClient();
|
||||||
const job = await client.triggerSimulation("2025-01-16", null, ["gpt-4"]);
|
const job = await client.triggerSimulation("2025-01-16", null, ["gpt-4"]);
|
||||||
const result = await client.waitForCompletion(job.job_id);
|
const result = await client.waitForCompletion(job.job_id);
|
||||||
const results = await client.getResults({ jobId: job.job_id });
|
const results = await client.getResults({ jobId: job.job_id });
|
||||||
|
|||||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -1,6 +1,6 @@
|
|||||||
# Changelog
|
# 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/),
|
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).
|
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
|
- 8 existing integration tests
|
||||||
- **Docker Deployment** - Persistent REST API service
|
- **Docker Deployment** - Persistent REST API service
|
||||||
- API-only deployment (batch mode removed for simplicity)
|
- 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)
|
- Health check configuration (30s interval, 3 retries)
|
||||||
- Volume persistence for SQLite database and logs
|
- Volume persistence for SQLite database and logs
|
||||||
- Configurable API_PORT for flexible deployment
|
- 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
|
- Only API port (8080) is exposed to host
|
||||||
- Reduces configuration complexity and attack surface
|
- Reduces configuration complexity and attack surface
|
||||||
- **Requirements** - Added fastapi>=0.120.0, uvicorn[standard]>=0.27.0, pydantic>=2.0.0
|
- **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
|
- **Dockerfile** - Added system dependencies (curl, procps) and port 8080 exposure
|
||||||
- **.env.example** - Simplified configuration with only essential variables
|
- **.env.example** - Simplified configuration with only essential variables
|
||||||
- **Entrypoint** - Unified entrypoint.sh with proper signal handling (exec uvicorn)
|
- **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
|
- 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/xe138/ai-trader
|
- Pre-built image support from ghcr.io/xe138/ai-trader-server
|
||||||
- Configurable volume path for persistent data
|
- Configurable volume path for persistent data
|
||||||
- Configurable web interface host port
|
- Configurable web interface host port
|
||||||
- Automated merged.jsonl creation during price fetching
|
- 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 .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
|
- Updated repository URLs to Xe138/AI-Trader-Server fork
|
||||||
- Docker Compose now uses pre-built image by default
|
- Docker Compose now uses pre-built image by default
|
||||||
- Simplified Docker config file selection with convention over configuration
|
- Simplified Docker config file selection with convention over configuration
|
||||||
- Fixed internal ports with configurable host ports
|
- 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
|
[Unreleased]: https://github.com/Xe138/AI-Trader-Server/compare/v0.3.0...HEAD
|
||||||
[0.3.0]: https://github.com/Xe138/AI-Trader/compare/v0.2.0...v0.3.0
|
[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/compare/v0.1.0...v0.2.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/releases/tag/v0.1.0
|
[0.1.0]: https://github.com/Xe138/AI-Trader-Server/releases/tag/v0.1.0
|
||||||
|
|||||||
14
CLAUDE.md
14
CLAUDE.md
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|||||||
|
|
||||||
## Project Overview
|
## 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.
|
**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
|
docker-compose up -d
|
||||||
|
|
||||||
# Run with custom config
|
# 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
|
# View logs
|
||||||
docker-compose logs -f
|
docker-compose logs -f
|
||||||
@@ -65,11 +65,11 @@ docker-compose logs -f
|
|||||||
docker-compose down
|
docker-compose down
|
||||||
|
|
||||||
# Pull pre-built image
|
# 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
|
# Test local Docker build
|
||||||
docker build -t ai-trader-test .
|
docker build -t ai-trader-server-test .
|
||||||
docker run --env-file .env -v $(pwd)/data:/app/data ai-trader-test
|
docker run --env-file .env -v $(pwd)/data:/app/data ai-trader-server-test
|
||||||
```
|
```
|
||||||
|
|
||||||
### Releasing Docker Images
|
### Releasing Docker Images
|
||||||
@@ -82,10 +82,10 @@ git push origin v1.0.0
|
|||||||
# GitHub Actions automatically:
|
# GitHub Actions automatically:
|
||||||
# 1. Builds Docker image
|
# 1. Builds Docker image
|
||||||
# 2. Tags with version and latest
|
# 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
|
# Verify build in Actions tab
|
||||||
# https://github.com/HKUDS/AI-Trader/actions
|
# https://github.com/Xe138/AI-Trader-Server/actions
|
||||||
```
|
```
|
||||||
|
|
||||||
### Running Trading Simulations
|
### Running Trading Simulations
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
# Base stage - dependency installation
|
# Base stage - dependency installation
|
||||||
FROM python:3.10-slim AS base
|
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
|
WORKDIR /app
|
||||||
|
|
||||||
# Install system dependencies (curl for health checks, procps for debugging)
|
# Install system dependencies (curl for health checks, procps for debugging)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Quick Start Guide
|
# 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
|
## Step 1: Clone Repository
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -62,7 +62,7 @@ docker-compose up -d
|
|||||||
|
|
||||||
This will:
|
This will:
|
||||||
- Build the Docker image (~5-10 minutes first time)
|
- 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)
|
- Start internal MCP services (math, search, trade, price)
|
||||||
- Initialize the SQLite database
|
- Initialize the SQLite database
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ This will:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# View logs
|
# View logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Wait for this message:
|
# Wait for this message:
|
||||||
# "Application startup complete"
|
# "Application startup complete"
|
||||||
@@ -261,7 +261,7 @@ curl "http://localhost:8080/results?date=2025-01-16&model=gpt-4"
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check logs
|
# Check logs
|
||||||
docker logs ai-trader
|
docker logs ai-trader-server
|
||||||
|
|
||||||
# Common issues:
|
# Common issues:
|
||||||
# - Missing API keys in .env
|
# - Missing API keys in .env
|
||||||
@@ -288,13 +288,13 @@ docker-compose up -d
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Check if container is running
|
# Check if container is running
|
||||||
docker ps | grep ai-trader
|
docker ps | grep ai-trader-server
|
||||||
|
|
||||||
# Restart service
|
# Restart service
|
||||||
docker-compose restart
|
docker-compose restart
|
||||||
|
|
||||||
# Check for errors in logs
|
# Check for errors in logs
|
||||||
docker logs ai-trader | grep -i error
|
docker logs ai-trader-server | grep -i error
|
||||||
```
|
```
|
||||||
|
|
||||||
### Job stays "pending"
|
### Job stays "pending"
|
||||||
@@ -303,7 +303,7 @@ The simulation might still be downloading price data on first run.
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Watch logs in real-time
|
# Watch logs in real-time
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Look for messages like:
|
# Look for messages like:
|
||||||
# "Downloading missing price data..."
|
# "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:
|
**Solution 2:** Manually download price data:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
cd data
|
cd data
|
||||||
python get_daily_price.py
|
python get_daily_price.py
|
||||||
python merge_jsonl.py
|
python merge_jsonl.py
|
||||||
@@ -334,7 +334,7 @@ exit
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# View logs
|
# View logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Stop service
|
# Stop service
|
||||||
docker-compose down
|
docker-compose down
|
||||||
@@ -349,10 +349,10 @@ docker-compose restart
|
|||||||
curl http://localhost:8080/health
|
curl http://localhost:8080/health
|
||||||
|
|
||||||
# Access container shell
|
# Access container shell
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
|
|
||||||
# View database
|
# 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?
|
## Need Help?
|
||||||
|
|
||||||
- Check [docs/user-guide/troubleshooting.md](docs/user-guide/troubleshooting.md)
|
- Check [docs/user-guide/troubleshooting.md](docs/user-guide/troubleshooting.md)
|
||||||
- Review logs: `docker logs ai-trader`
|
- Review logs: `docker logs ai-trader-server`
|
||||||
- Open an issue: [GitHub Issues](https://github.com/Xe138/AI-Trader/issues)
|
- Open an issue: [GitHub Issues](https://github.com/Xe138/AI-Trader-Server/issues)
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -1,6 +1,6 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
# 🚀 AI-Trader: Can AI Beat the Market?
|
# 🚀 AI-Trader-Server: REST API for AI Trading
|
||||||
|
|
||||||
[](https://python.org)
|
[](https://python.org)
|
||||||
[](LICENSE)
|
[](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
|
### Key Features
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@
|
|||||||
|
|
||||||
**2. Setup**
|
**2. Setup**
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
|
|
||||||
# Configure environment
|
# Configure environment
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
@@ -193,7 +193,7 @@ Through the MCP (Model Context Protocol) toolchain, AI agents can:
|
|||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
class AITraderClient:
|
class AITraderServerClient:
|
||||||
def __init__(self, base_url="http://localhost:8080"):
|
def __init__(self, base_url="http://localhost:8080"):
|
||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ class AITraderClient:
|
|||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
client = AITraderClient()
|
client = AITraderServerClient()
|
||||||
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
job = client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
||||||
result = client.wait_for_completion(job["job_id"])
|
result = client.wait_for_completion(job["job_id"])
|
||||||
```
|
```
|
||||||
@@ -445,7 +445,7 @@ SQLite database at `data/jobs.db` contains:
|
|||||||
|
|
||||||
Query directly:
|
Query directly:
|
||||||
```bash
|
```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;
|
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
|
## 📄 License
|
||||||
|
|
||||||
MIT License - see [LICENSE](LICENSE) for details
|
MIT License - see [LICENSE](LICENSE) for details
|
||||||
@@ -517,9 +523,9 @@ MIT License - see [LICENSE](LICENSE) for details
|
|||||||
|
|
||||||
## 🔗 Links
|
## 🔗 Links
|
||||||
|
|
||||||
- **GitHub**: https://github.com/Xe138/AI-Trader
|
- **GitHub**: https://github.com/Xe138/AI-Trader-Server
|
||||||
- **Docker Hub**: `ghcr.io/xe138/ai-trader:latest`
|
- **Docker Hub**: `ghcr.io/xe138/ai-trader-server:latest`
|
||||||
- **Issues**: https://github.com/Xe138/AI-Trader/issues
|
- **Issues**: https://github.com/Xe138/AI-Trader-Server/issues
|
||||||
- **API Docs**: http://localhost:8080/docs (when running)
|
- **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**
|
**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>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Configuration Files
|
# 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
|
## Files
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
services:
|
services:
|
||||||
# REST API server for Windmill integration
|
# REST API server for Windmill integration
|
||||||
ai-trader:
|
ai-trader-server:
|
||||||
# image: ghcr.io/xe138/ai-trader:latest
|
# image: ghcr.io/xe138/ai-trader-server:latest
|
||||||
# Uncomment to build locally instead of pulling:
|
# Uncomment to build locally instead of pulling:
|
||||||
build: .
|
build: .
|
||||||
container_name: ai-trader
|
container_name: ai-trader-server
|
||||||
volumes:
|
volumes:
|
||||||
- ${VOLUME_PATH:-.}/data:/app/data
|
- ${VOLUME_PATH:-.}/data:/app/data
|
||||||
- ${VOLUME_PATH:-.}/logs:/app/logs
|
- ${VOLUME_PATH:-.}/logs:/app/logs
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
1. **Clone repository:**
|
1. **Clone repository:**
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Configure environment:**
|
2. **Configure environment:**
|
||||||
@@ -70,13 +70,13 @@ docker-compose up
|
|||||||
|
|
||||||
**Priority order:**
|
**Priority order:**
|
||||||
1. `configs/custom_config.json` (if exists) - **Highest priority**
|
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)
|
3. `configs/default_config.json` (fallback)
|
||||||
|
|
||||||
**Advanced: Use a different config file name:**
|
**Advanced: Use a different config file name:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose run ai-trader configs/my_special_config.json
|
docker-compose run ai-trader-server configs/my_special_config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage Examples
|
## Usage Examples
|
||||||
@@ -94,7 +94,7 @@ docker-compose logs -f # Follow logs
|
|||||||
|
|
||||||
### Run with custom config
|
### Run with custom config
|
||||||
```bash
|
```bash
|
||||||
docker-compose run ai-trader configs/custom_config.json
|
docker-compose run ai-trader-server configs/custom_config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
### Stop containers
|
### Stop containers
|
||||||
@@ -156,10 +156,10 @@ docker-compose up
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Backup
|
# 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
|
# Restore
|
||||||
tar -xzf ai-trader-backup-YYYYMMDD.tar.gz
|
tar -xzf ai-trader-server-backup-YYYYMMDD.tar.gz
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using Pre-built Images
|
## Using Pre-built Images
|
||||||
@@ -167,7 +167,7 @@ tar -xzf ai-trader-backup-YYYYMMDD.tar.gz
|
|||||||
### Pull from GitHub Container Registry
|
### Pull from GitHub Container Registry
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull ghcr.io/hkuds/ai-trader:latest
|
docker pull ghcr.io/xe138/ai-trader-server:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run without Docker Compose
|
### Run without Docker Compose
|
||||||
@@ -177,12 +177,12 @@ docker run --env-file .env \
|
|||||||
-v $(pwd)/data:/app/data \
|
-v $(pwd)/data:/app/data \
|
||||||
-v $(pwd)/logs:/app/logs \
|
-v $(pwd)/logs:/app/logs \
|
||||||
-p 8000-8003:8000-8003 \
|
-p 8000-8003:8000-8003 \
|
||||||
ghcr.io/hkuds/ai-trader:latest
|
ghcr.io/xe138/ai-trader-server:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Specific version
|
### Specific version
|
||||||
```bash
|
```bash
|
||||||
docker pull ghcr.io/hkuds/ai-trader:v1.0.0
|
docker pull ghcr.io/xe138/ai-trader-server:v1.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
@@ -239,7 +239,7 @@ docker pull ghcr.io/hkuds/ai-trader:v1.0.0
|
|||||||
Run bash inside container for debugging:
|
Run bash inside container for debugging:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker-compose run --entrypoint /bin/bash ai-trader
|
docker-compose run --entrypoint /bin/bash ai-trader-server
|
||||||
```
|
```
|
||||||
|
|
||||||
### Build Multi-platform Images
|
### Build Multi-platform Images
|
||||||
@@ -247,13 +247,13 @@ docker-compose run --entrypoint /bin/bash ai-trader
|
|||||||
For ARM64 (Apple Silicon) and AMD64:
|
For ARM64 (Apple Silicon) and AMD64:
|
||||||
|
|
||||||
```bash
|
```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
|
### View Container Resource Usage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker stats ai-trader-app
|
docker stats ai-trader-server
|
||||||
```
|
```
|
||||||
|
|
||||||
### Access MCP Services Directly
|
### Access MCP Services Directly
|
||||||
@@ -295,10 +295,10 @@ cp configs/default_config.json configs/aggressive.json
|
|||||||
# Edit each config...
|
# Edit each config...
|
||||||
|
|
||||||
# Test conservative strategy
|
# Test conservative strategy
|
||||||
docker-compose run ai-trader configs/conservative.json
|
docker-compose run ai-trader-server configs/conservative.json
|
||||||
|
|
||||||
# Test aggressive strategy
|
# 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**
|
**Method 3: Temporarily switch configs**
|
||||||
|
|||||||
@@ -31,30 +31,30 @@ Tag push automatically triggers `.github/workflows/docker-release.yml`:
|
|||||||
3. ✅ Logs into GitHub Container Registry
|
3. ✅ Logs into GitHub Container Registry
|
||||||
4. ✅ Extracts version from tag
|
4. ✅ Extracts version from tag
|
||||||
5. ✅ Builds Docker image with caching
|
5. ✅ Builds Docker image with caching
|
||||||
6. ✅ Pushes to `ghcr.io/hkuds/ai-trader:VERSION`
|
6. ✅ Pushes to `ghcr.io/xe138/ai-trader-server:VERSION`
|
||||||
7. ✅ Pushes to `ghcr.io/hkuds/ai-trader:latest`
|
7. ✅ Pushes to `ghcr.io/xe138/ai-trader-server:latest`
|
||||||
|
|
||||||
### 4. Verify Build
|
### 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)
|
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
|
### 5. Test Release
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Pull released image
|
# 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
|
# Test run
|
||||||
docker run --env-file .env \
|
docker run --env-file .env \
|
||||||
-v $(pwd)/data:/app/data \
|
-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)
|
### 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`
|
2. Select tag: `v1.0.0`
|
||||||
3. Release title: `v1.0.0 - Docker Deployment Support`
|
3. Release title: `v1.0.0 - Docker Deployment Support`
|
||||||
4. Add release notes:
|
4. Add release notes:
|
||||||
@@ -67,8 +67,8 @@ This release adds full Docker support for easy deployment.
|
|||||||
### Pull and Run
|
### Pull and Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker pull 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/hkuds/ai-trader: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:
|
Or use Docker Compose:
|
||||||
@@ -137,13 +137,13 @@ If automated build fails, manual push:
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Build locally
|
# 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
|
# Login to GHCR
|
||||||
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
|
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin
|
||||||
|
|
||||||
# Push
|
# Push
|
||||||
docker push ghcr.io/hkuds/ai-trader:v1.0.0
|
docker push ghcr.io/xe138/ai-trader-server:v1.0.0
|
||||||
docker tag ghcr.io/hkuds/ai-trader:v1.0.0 ghcr.io/hkuds/ai-trader:latest
|
docker tag ghcr.io/xe138/ai-trader-server:v1.0.0 ghcr.io/xe138/ai-trader-server:latest
|
||||||
docker push ghcr.io/hkuds/ai-trader:latest
|
docker push ghcr.io/xe138/ai-trader-server:latest
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ Production Docker deployment guide.
|
|||||||
## Quick Deployment
|
## Quick Deployment
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
# Edit .env with API keys
|
# Edit .env with API keys
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
@@ -23,8 +23,8 @@ docker-compose up -d
|
|||||||
```yaml
|
```yaml
|
||||||
# docker-compose.yml
|
# docker-compose.yml
|
||||||
services:
|
services:
|
||||||
ai-trader:
|
ai-trader-server:
|
||||||
image: ghcr.io/xe138/ai-trader:latest
|
image: ghcr.io/xe138/ai-trader-server:latest
|
||||||
# ... rest of config
|
# ... rest of config
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ services:
|
|||||||
```yaml
|
```yaml
|
||||||
# docker-compose.yml
|
# docker-compose.yml
|
||||||
services:
|
services:
|
||||||
ai-trader:
|
ai-trader-server:
|
||||||
build: .
|
build: .
|
||||||
# ... rest of config
|
# ... rest of config
|
||||||
```
|
```
|
||||||
@@ -84,10 +84,10 @@ healthcheck:
|
|||||||
docker ps
|
docker ps
|
||||||
|
|
||||||
# Resource usage
|
# Resource usage
|
||||||
docker stats ai-trader
|
docker stats ai-trader-server
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ curl http://localhost:8080/health
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# View logs
|
# View logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Filter errors
|
# Filter errors
|
||||||
docker logs ai-trader 2>&1 | grep -i error
|
docker logs ai-trader-server 2>&1 | grep -i error
|
||||||
|
|
||||||
# Export logs
|
# 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
|
```bash
|
||||||
# Database size
|
# 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
|
# 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;"
|
"SELECT status, COUNT(*) FROM jobs GROUP BY status;"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,15 @@ For parallel simulations, deploy multiple instances:
|
|||||||
```yaml
|
```yaml
|
||||||
# docker-compose.yml
|
# docker-compose.yml
|
||||||
services:
|
services:
|
||||||
ai-trader-1:
|
ai-trader-server-1:
|
||||||
image: ghcr.io/xe138/ai-trader:latest
|
image: ghcr.io/xe138/ai-trader-server:latest
|
||||||
ports:
|
ports:
|
||||||
- "8081:8080"
|
- "8081:8080"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data1:/app/data
|
- ./data1:/app/data
|
||||||
|
|
||||||
ai-trader-2:
|
ai-trader-server-2:
|
||||||
image: ghcr.io/xe138/ai-trader:latest
|
image: ghcr.io/xe138/ai-trader-server:latest
|
||||||
ports:
|
ports:
|
||||||
- "8082:8080"
|
- "8082:8080"
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# Contributing to AI-Trader
|
# Contributing to AI-Trader-Server
|
||||||
|
|
||||||
Guidelines for contributing to the project.
|
Guidelines for contributing to the project.
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ Local development without Docker.
|
|||||||
### 1. Clone Repository
|
### 1. Clone Repository
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/Xe138/AI-Trader.git
|
git clone https://github.com/Xe138/AI-Trader-Server.git
|
||||||
cd AI-Trader
|
cd AI-Trader-Server
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Create Virtual Environment
|
### 2. Create Virtual Environment
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Testing Guide
|
# Testing Guide
|
||||||
|
|
||||||
Guide for testing AI-Trader during development.
|
Guide for testing AI-Trader-Server during development.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Data Formats
|
# Data Formats
|
||||||
|
|
||||||
File formats and schemas used by AI-Trader.
|
File formats and schemas used by AI-Trader-Server.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Configuration Guide
|
# 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
|
curl http://localhost:8080/health
|
||||||
|
|
||||||
# Check logs for errors
|
# Check logs for errors
|
||||||
docker logs ai-trader | grep -i error
|
docker logs ai-trader-server | grep -i error
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Integration Examples
|
# 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 aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
class AsyncAITraderClient:
|
class AsyncAITraderServerClient:
|
||||||
def __init__(self, base_url="http://localhost:8080"):
|
def __init__(self, base_url="http://localhost:8080"):
|
||||||
self.base_url = base_url
|
self.base_url = base_url
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ class AsyncAITraderClient:
|
|||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
async def main():
|
async def main():
|
||||||
client = AsyncAITraderClient()
|
client = AsyncAITraderServerClient()
|
||||||
job = await client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
job = await client.trigger_simulation("2025-01-16", models=["gpt-4"])
|
||||||
result = await client.wait_for_completion(job["job_id"])
|
result = await client.wait_for_completion(job["job_id"])
|
||||||
print(f"Simulation completed: {result['status']}")
|
print(f"Simulation completed: {result['status']}")
|
||||||
@@ -104,7 +104,7 @@ echo "Results saved to results_$DATE.json"
|
|||||||
|
|
||||||
Add to crontab:
|
Add to crontab:
|
||||||
```bash
|
```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):
|
def trigger_simulation(**context):
|
||||||
response = requests.post(
|
response = requests.post(
|
||||||
"http://ai-trader:8080/simulate/trigger",
|
"http://ai-trader-server:8080/simulate/trigger",
|
||||||
json={"start_date": "{{ ds }}", "models": ["gpt-4"]}
|
json={"start_date": "{{ ds }}", "models": ["gpt-4"]}
|
||||||
)
|
)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
@@ -128,19 +128,19 @@ def trigger_simulation(**context):
|
|||||||
|
|
||||||
def wait_for_completion(**context):
|
def wait_for_completion(**context):
|
||||||
job_id = context["task_instance"].xcom_pull(task_ids="trigger")
|
job_id = context["task_instance"].xcom_pull(task_ids="trigger")
|
||||||
|
|
||||||
while True:
|
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()
|
status = response.json()
|
||||||
|
|
||||||
if status["status"] in ["completed", "partial", "failed"]:
|
if status["status"] in ["completed", "partial", "failed"]:
|
||||||
return status
|
return status
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
|
||||||
def fetch_results(**context):
|
def fetch_results(**context):
|
||||||
job_id = context["task_instance"].xcom_pull(task_ids="trigger")
|
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()
|
return response.json()
|
||||||
|
|
||||||
default_args = {
|
default_args = {
|
||||||
@@ -152,7 +152,7 @@ default_args = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dag = DAG(
|
dag = DAG(
|
||||||
"ai_trader_simulation",
|
"ai_trader_server_simulation",
|
||||||
default_args=default_args,
|
default_args=default_args,
|
||||||
schedule_interval="0 6 * * *", # Daily at 6 AM
|
schedule_interval="0 6 * * *", # Daily at 6 AM
|
||||||
catchup=False
|
catchup=False
|
||||||
@@ -183,7 +183,7 @@ trigger_task >> wait_task >> fetch_task
|
|||||||
|
|
||||||
## Generic Workflow Automation
|
## 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`
|
1. **Trigger:** POST to `/simulate/trigger`
|
||||||
2. **Poll:** GET `/simulate/status/{job_id}` every 10-30 seconds
|
2. **Poll:** GET `/simulate/status/{job_id}` every 10-30 seconds
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Troubleshooting Guide
|
# 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
|
### Container Won't Start
|
||||||
|
|
||||||
**Symptoms:**
|
**Symptoms:**
|
||||||
- `docker ps` shows no ai-trader container
|
- `docker ps` shows no ai-trader-server container
|
||||||
- Container exits immediately after starting
|
- Container exits immediately after starting
|
||||||
|
|
||||||
**Debug:**
|
**Debug:**
|
||||||
```bash
|
```bash
|
||||||
# Check logs
|
# Check logs
|
||||||
docker logs ai-trader
|
docker logs ai-trader-server
|
||||||
|
|
||||||
# Check if container exists (stopped)
|
# Check if container exists (stopped)
|
||||||
docker ps -a | grep ai-trader
|
docker ps -a | grep ai-trader-server
|
||||||
```
|
```
|
||||||
|
|
||||||
**Common Causes & Solutions:**
|
**Common Causes & Solutions:**
|
||||||
@@ -64,10 +64,10 @@ chmod -R 755 data logs configs
|
|||||||
**Debug:**
|
**Debug:**
|
||||||
```bash
|
```bash
|
||||||
# Check if API process is running
|
# 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)
|
# 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
|
# Check configured port
|
||||||
grep API_PORT .env
|
grep API_PORT .env
|
||||||
@@ -82,7 +82,7 @@ Another service is using your configured port.
|
|||||||
# Find conflicting service
|
# Find conflicting service
|
||||||
sudo lsof -i :8080
|
sudo lsof -i :8080
|
||||||
|
|
||||||
# Change AI-Trader port
|
# Change AI-Trader-Server port
|
||||||
echo "API_PORT=8889" >> .env
|
echo "API_PORT=8889" >> .env
|
||||||
docker-compose down
|
docker-compose down
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
@@ -94,7 +94,7 @@ curl http://localhost:8889/health
|
|||||||
**If MCP services didn't start:**
|
**If MCP services didn't start:**
|
||||||
```bash
|
```bash
|
||||||
# Check MCP processes
|
# 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
|
# Should see 4 MCP services on ports 8000-8003
|
||||||
```
|
```
|
||||||
@@ -102,7 +102,7 @@ docker exec ai-trader ps aux | grep python
|
|||||||
**If database issues:**
|
**If database issues:**
|
||||||
```bash
|
```bash
|
||||||
# Check database file
|
# 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
|
# If missing, restart to recreate
|
||||||
docker-compose restart
|
docker-compose restart
|
||||||
@@ -121,13 +121,13 @@ docker-compose restart
|
|||||||
**Debug:**
|
**Debug:**
|
||||||
```bash
|
```bash
|
||||||
# Check worker logs
|
# Check worker logs
|
||||||
docker logs ai-trader | grep -i "worker\|simulation"
|
docker logs ai-trader-server | grep -i "worker\|simulation"
|
||||||
|
|
||||||
# Check database
|
# 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
|
# Check MCP service accessibility
|
||||||
docker exec ai-trader curl http://localhost:8000/health
|
docker exec ai-trader-server curl http://localhost:8000/health
|
||||||
```
|
```
|
||||||
|
|
||||||
**Solutions:**
|
**Solutions:**
|
||||||
@@ -173,7 +173,7 @@ done
|
|||||||
**Check if agent is stuck:**
|
**Check if agent is stuck:**
|
||||||
```bash
|
```bash
|
||||||
# View real-time logs
|
# View real-time logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Look for repeated errors or infinite loops
|
# Look for repeated errors or infinite loops
|
||||||
```
|
```
|
||||||
@@ -204,7 +204,7 @@ curl -X POST http://localhost:8080/simulate/trigger \
|
|||||||
**Option 2: Manually Download Data**
|
**Option 2: Manually Download Data**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
cd data
|
cd data
|
||||||
python get_daily_price.py # Downloads latest data
|
python get_daily_price.py # Downloads latest data
|
||||||
python merge_jsonl.py # Merges into database
|
python merge_jsonl.py # Merges into database
|
||||||
@@ -242,7 +242,7 @@ grep AUTO_DOWNLOAD_PRICE_DATA .env
|
|||||||
**Workaround:**
|
**Workaround:**
|
||||||
```bash
|
```bash
|
||||||
# Pre-download data in batches
|
# Pre-download data in batches
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
cd data
|
cd data
|
||||||
|
|
||||||
# Download in stages (wait 1 min between runs)
|
# 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:**
|
**Solutions:**
|
||||||
|
|
||||||
@@ -279,7 +279,7 @@ exit
|
|||||||
curl http://localhost:8080/health # Verify API is up
|
curl http://localhost:8080/health # Verify API is up
|
||||||
|
|
||||||
# Query recent jobs (need to check database)
|
# 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;"
|
"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):**
|
**Force-stop stuck job (last resort):**
|
||||||
```bash
|
```bash
|
||||||
# Update job status in database
|
# 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');"
|
"UPDATE jobs SET status='failed' WHERE status IN ('pending', 'running');"
|
||||||
|
|
||||||
# Restart service
|
# Restart service
|
||||||
@@ -386,7 +386,7 @@ docker-compose up -d
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Re-download price data
|
# Re-download price data
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
cd data
|
cd data
|
||||||
python get_daily_price.py
|
python get_daily_price.py
|
||||||
python merge_jsonl.py
|
python merge_jsonl.py
|
||||||
@@ -418,7 +418,7 @@ exit
|
|||||||
**3. MCP services overloaded**
|
**3. MCP services overloaded**
|
||||||
```bash
|
```bash
|
||||||
# Check CPU usage
|
# Check CPU usage
|
||||||
docker stats ai-trader
|
docker stats ai-trader-server
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -430,7 +430,7 @@ docker stats ai-trader
|
|||||||
**If higher:**
|
**If higher:**
|
||||||
```bash
|
```bash
|
||||||
# Check memory
|
# Check memory
|
||||||
docker stats ai-trader
|
docker stats ai-trader-server
|
||||||
|
|
||||||
# Restart if needed
|
# Restart if needed
|
||||||
docker-compose restart
|
docker-compose restart
|
||||||
@@ -442,34 +442,34 @@ docker-compose restart
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Container status
|
# Container status
|
||||||
docker ps | grep ai-trader
|
docker ps | grep ai-trader-server
|
||||||
|
|
||||||
# Real-time logs
|
# Real-time logs
|
||||||
docker logs -f ai-trader
|
docker logs -f ai-trader-server
|
||||||
|
|
||||||
# Check errors only
|
# 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
|
# Container resource usage
|
||||||
docker stats ai-trader
|
docker stats ai-trader-server
|
||||||
|
|
||||||
# Access container shell
|
# Access container shell
|
||||||
docker exec -it ai-trader bash
|
docker exec -it ai-trader-server bash
|
||||||
|
|
||||||
# Database inspection
|
# 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 * FROM jobs ORDER BY created_at DESC LIMIT 5;
|
||||||
sqlite> SELECT status, COUNT(*) FROM jobs GROUP BY status;
|
sqlite> SELECT status, COUNT(*) FROM jobs GROUP BY status;
|
||||||
sqlite> .quit
|
sqlite> .quit
|
||||||
|
|
||||||
# Check file permissions
|
# Check file permissions
|
||||||
docker exec ai-trader ls -la /app/data
|
docker exec ai-trader-server ls -la /app/data
|
||||||
|
|
||||||
# Test API connectivity
|
# Test API connectivity
|
||||||
curl -v http://localhost:8080/health
|
curl -v http://localhost:8080/health
|
||||||
|
|
||||||
# View all environment variables
|
# 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
|
1. **Check logs** for specific error messages
|
||||||
2. **Review** [API_REFERENCE.md](../../API_REFERENCE.md) for correct usage
|
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:
|
4. **Open new issue** with:
|
||||||
- Error messages from logs
|
- Error messages from logs
|
||||||
- Steps to reproduce
|
- Steps to reproduce
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# Using the API
|
# Using the API
|
||||||
|
|
||||||
Common workflows and best practices for AI-Trader API.
|
Common workflows and best practices for AI-Trader-Server API.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e # Exit on any error
|
set -e # Exit on any error
|
||||||
|
|
||||||
echo "🚀 Starting AI-Trader API Server..."
|
echo "🚀 Starting AI-Trader-Server API..."
|
||||||
|
|
||||||
# Validate required environment variables
|
# Validate required environment variables
|
||||||
echo "🔍 Validating environment variables..."
|
echo "🔍 Validating environment variables..."
|
||||||
|
|||||||
6
main.sh
6
main.sh
@@ -1,11 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# AI-Trader 主启动脚本
|
# AI-Trader-Server 主启动脚本
|
||||||
# 用于启动完整的交易环境
|
# 用于启动完整的交易环境
|
||||||
|
|
||||||
set -e # 遇到错误时退出
|
set -e # 遇到错误时退出
|
||||||
|
|
||||||
echo "🚀 Launching AI Trader Environment..."
|
echo "🚀 Launching AI-Trader-Server Environment..."
|
||||||
|
|
||||||
|
|
||||||
echo "📊 Now getting and merging price data..."
|
echo "📊 Now getting and merging price data..."
|
||||||
@@ -25,7 +25,7 @@ sleep 2
|
|||||||
echo "🤖 Now starting the main trading agent..."
|
echo "🤖 Now starting the main trading agent..."
|
||||||
python main.py configs/default_config.json
|
python main.py configs/default_config.json
|
||||||
|
|
||||||
echo "✅ AI-Trader stopped"
|
echo "✅ AI-Trader-Server stopped"
|
||||||
|
|
||||||
echo "🔄 Starting web server..."
|
echo "🔄 Starting web server..."
|
||||||
cd ./docs
|
cd ./docs
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "AI-Trader API Endpoint Testing"
|
echo "AI-Trader-Server API Endpoint Testing"
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ echo "Checking if API is accessible..."
|
|||||||
if ! curl -f "$API_BASE_URL/health" &> /dev/null; then
|
if ! curl -f "$API_BASE_URL/health" &> /dev/null; then
|
||||||
echo -e "${RED}✗${NC} API is not accessible at $API_BASE_URL"
|
echo -e "${RED}✗${NC} API is not accessible at $API_BASE_URL"
|
||||||
echo "Make sure the container is running:"
|
echo "Make sure the container is running:"
|
||||||
echo " docker-compose up -d ai-trader"
|
echo " docker-compose up -d ai-trader-server"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo -e "${GREEN}✓${NC} API is accessible"
|
echo -e "${GREEN}✓${NC} API is accessible"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
set -e # Exit on error
|
set -e # Exit on error
|
||||||
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "AI-Trader Docker Build Validation"
|
echo "AI-Trader-Server Docker Build Validation"
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ echo "Step 3: Building Docker image..."
|
|||||||
echo "This may take several minutes on first build..."
|
echo "This may take several minutes on first build..."
|
||||||
echo ""
|
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"
|
print_status 0 "Docker image built successfully"
|
||||||
else
|
else
|
||||||
print_status 1 "Docker build failed"
|
print_status 1 "Docker build failed"
|
||||||
@@ -124,11 +124,11 @@ echo ""
|
|||||||
# Step 4: Check image
|
# Step 4: Check image
|
||||||
echo "Step 4: Verifying Docker 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"
|
print_status 0 "Image size: $IMAGE_SIZE"
|
||||||
|
|
||||||
# List exposed ports
|
# 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"
|
print_status 0 "Exposed ports: $EXPOSED_PORTS"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -137,7 +137,7 @@ echo ""
|
|||||||
echo "Step 5: Testing API mode startup..."
|
echo "Step 5: Testing API mode startup..."
|
||||||
echo "Starting container in background..."
|
echo "Starting container in background..."
|
||||||
|
|
||||||
$COMPOSE_CMD up -d ai-trader
|
$COMPOSE_CMD up -d ai-trader-server
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
print_status 0 "Container started successfully"
|
print_status 0 "Container started successfully"
|
||||||
@@ -146,20 +146,20 @@ if [ $? -eq 0 ]; then
|
|||||||
sleep 10
|
sleep 10
|
||||||
|
|
||||||
# Check if container is still running
|
# 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"
|
print_status 0 "Container is running"
|
||||||
|
|
||||||
# Check logs for errors
|
# 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
|
if [ $ERROR_COUNT -gt 0 ]; then
|
||||||
print_warning "Found $ERROR_COUNT error messages in logs"
|
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
|
else
|
||||||
print_status 0 "No critical errors in logs"
|
print_status 0 "No critical errors in logs"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
print_status 1 "Container stopped unexpectedly"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -209,14 +209,14 @@ else
|
|||||||
print_warning "Diagnostics:"
|
print_warning "Diagnostics:"
|
||||||
|
|
||||||
# Check if container is still running
|
# 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"
|
echo " ✓ Container is running"
|
||||||
else
|
else
|
||||||
echo " ✗ Container has stopped"
|
echo " ✗ Container has stopped"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if port is listening
|
# 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"
|
echo " ✓ Port 8080 is listening inside container"
|
||||||
else
|
else
|
||||||
echo " ✗ Port 8080 is NOT listening inside container"
|
echo " ✗ Port 8080 is NOT listening inside container"
|
||||||
@@ -224,7 +224,7 @@ else
|
|||||||
|
|
||||||
# Try curl from inside container
|
# Try curl from inside container
|
||||||
echo " Testing 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
|
if [ $? -eq 0 ]; then
|
||||||
echo " ✓ Health endpoint works inside container: $INTERNAL_TEST"
|
echo " ✓ Health endpoint works inside container: $INTERNAL_TEST"
|
||||||
echo " ✗ Issue is with port mapping or host networking"
|
echo " ✗ Issue is with port mapping or host networking"
|
||||||
@@ -235,7 +235,7 @@ else
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Recent logs:"
|
echo "Recent logs:"
|
||||||
docker logs ai-trader 2>&1 | tail -20
|
docker logs ai-trader-server 2>&1 | tail -20
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -262,7 +262,7 @@ echo "2. Test batch mode:"
|
|||||||
echo " bash scripts/test_batch_mode.sh"
|
echo " bash scripts/test_batch_mode.sh"
|
||||||
echo ""
|
echo ""
|
||||||
echo "3. If any checks failed, review logs:"
|
echo "3. If any checks failed, review logs:"
|
||||||
echo " docker logs ai-trader"
|
echo " docker logs ai-trader-server"
|
||||||
echo ""
|
echo ""
|
||||||
echo "4. For troubleshooting, see: DOCKER_API.md"
|
echo "4. For troubleshooting, see: DOCKER_API.md"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user