mirror of
https://github.com/Xe138/AI-Trader.git
synced 2026-04-02 01:27:24 -04:00
Major architecture transformation from batch-only to API service with
database persistence for Windmill integration.
## REST API Implementation
- POST /simulate/trigger - Start simulation jobs
- GET /simulate/status/{job_id} - Monitor job progress
- GET /results - Query results with filters (job_id, date, model)
- GET /health - Service health checks
## Database Layer
- SQLite persistence with 6 tables (jobs, job_details, positions,
holdings, reasoning_logs, tool_usage)
- Foreign key constraints with cascade deletes
- Replaces JSONL file storage
## Backend Components
- JobManager: Job lifecycle management with concurrency control
- RuntimeConfigManager: Thread-safe isolated runtime configs
- ModelDayExecutor: Single model-day execution engine
- SimulationWorker: Date-sequential, model-parallel orchestration
## Testing
- 102 unit and integration tests (85% coverage)
- Database: 98% coverage
- Job manager: 98% coverage
- API endpoints: 81% coverage
- Pydantic models: 100% coverage
- TDD approach throughout
## Docker Deployment
- Dual-mode: API server (persistent) + batch (one-time)
- Health checks with 30s interval
- Volume persistence for database and logs
- Separate entrypoints for each mode
## Validation Tools
- scripts/validate_docker_build.sh - Build validation
- scripts/test_api_endpoints.sh - Complete API testing
- scripts/test_batch_mode.sh - Batch mode validation
- DOCKER_API.md - Deployment guide
- TESTING_GUIDE.md - Testing procedures
## Configuration
- API_PORT environment variable (default: 8080)
- Backwards compatible with existing configs
- FastAPI, uvicorn, pydantic>=2.0 dependencies
Co-Authored-By: AI Assistant <noreply@example.com>
44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
# =============================================================================
|
|
# AI-Trader Environment Configuration
|
|
# =============================================================================
|
|
# Copy this file to .env and fill in your actual values
|
|
# Docker Compose automatically reads .env from project root
|
|
|
|
# AI Model API Configuration
|
|
# OPENAI_API_BASE: Leave empty to use default OpenAI endpoint, or set to custom proxy URL
|
|
OPENAI_API_BASE=
|
|
OPENAI_API_KEY=your_openai_key_here # https://platform.openai.com/api-keys
|
|
|
|
# Data Source Configuration
|
|
ALPHAADVANTAGE_API_KEY=your_alphavantage_key_here # https://www.alphavantage.co/support/#api-key
|
|
JINA_API_KEY=your_jina_key_here # https://jina.ai/
|
|
|
|
# System Configuration (Docker default paths)
|
|
RUNTIME_ENV_PATH=/app/data/runtime_env.json
|
|
|
|
# MCP Service Host Ports (exposed on host machine)
|
|
# Container always uses 8000-8003 internally
|
|
# Change these if you need different ports on your host
|
|
MATH_HTTP_PORT=8000
|
|
SEARCH_HTTP_PORT=8001
|
|
TRADE_HTTP_PORT=8002
|
|
GETPRICE_HTTP_PORT=8003
|
|
|
|
# API Server Port (exposed on host machine for REST API)
|
|
# Container always uses 8080 internally
|
|
# Used for Windmill integration and external API access
|
|
API_PORT=8080
|
|
|
|
# Web Interface Host Port (exposed on host machine)
|
|
# Container always uses 8888 internally
|
|
WEB_HTTP_PORT=8888
|
|
|
|
# Agent Configuration
|
|
AGENT_MAX_STEP=30
|
|
|
|
# Data Volume Configuration
|
|
# Base directory for all persistent data (will contain data/, logs/, configs/ subdirectories)
|
|
# Use relative paths (./volumes) or absolute paths (/home/user/ai-trader-volumes)
|
|
# Defaults to current directory (.) if not set
|
|
VOLUME_PATH=.
|