Compare commits

...

5 Commits

Author SHA1 Message Date
9539d63103 fix: correct YAML syntax error in docker-release workflow
Fixed line 70-71 where a literal newline in the bash script was
breaking YAML parsing. Changed from:

  TAGS="$TAGS
  ghcr.io/..."

To:

  TAGS="${TAGS}"$'\n'"ghcr.io/..."

This uses bash's ANSI-C quoting syntax to properly insert a newline
within a single YAML line, avoiding the syntax error.
2025-10-31 14:47:36 -04:00
47b9df6b82 docs: merge unreleased configuration changes into v0.3.0
Consolidated the configuration simplification changes (RUNTIME_ENV_PATH
removal, API_PORT cleanup, MCP port removal) into the v0.3.0 release
notes under the 'Changed - Configuration' section.

This ensures all v0.3.0 changes are documented together in a single
release entry rather than split across Unreleased and v0.3.0 sections.
2025-10-31 14:43:31 -04:00
d587a5f213 refactor: remove unnecessary MCP service port configuration
MCP services are completely internal to the container and accessed
only via localhost. They should not be configurable or exposed.

Changes:
- Remove MATH_HTTP_PORT, SEARCH_HTTP_PORT, TRADE_HTTP_PORT,
  GETPRICE_HTTP_PORT from docker-compose.yml environment
- Remove MCP service port mappings from docker-compose.yml
- Remove MCP port configuration from .env.example
- Update README.md to remove MCP port configuration
- Update CLAUDE.md to clarify MCP services use fixed internal ports
- Update CHANGELOG.md with these simplifications

Technical details:
- MCP services hardcode to ports 8000-8003 via os.getenv() defaults
- Services only accessed via localhost URLs within container:
  - http://localhost:8000/mcp (math)
  - http://localhost:8001/mcp (search)
  - http://localhost:8002/mcp (trade)
  - http://localhost:8003/mcp (price)
- No external access needed or desired for these services
- Only API (8080) and web dashboard (8888) should be exposed

Benefits:
- Simpler configuration (4 fewer environment variables)
- Reduced attack surface (4 fewer exposed ports)
- Clearer architecture (internal vs external services)
- Prevents accidental misconfiguration of internal services
2025-10-31 14:41:07 -04:00
c929080960 fix: remove API_PORT from container environment variables
The API_PORT variable was incorrectly included in the container's
environment section. It should only be used for host port mapping
in docker-compose.yml, not passed into the container.

Changes:
- Remove API_PORT from environment section in docker-compose.yml
- Container always uses port 8080 internally (hardcoded in entrypoint.sh)
- API_PORT in .env/.env.example only controls the host-side mapping:
  ports: "${API_PORT:-8080}:8080" (host:container)

Why this matters:
- Prevents confusion about whether API_PORT changes internal port
- Clarifies that entrypoint.sh hardcodes --port 8080
- Simplifies container environment (one less unused variable)
- More explicit about the port mapping behavior

No functional change - the container was already ignoring this variable.
2025-10-31 14:38:53 -04:00
849e7bffa2 refactor: remove unnecessary RUNTIME_ENV_PATH environment variable
Simplifies deployment configuration by removing the RUNTIME_ENV_PATH
environment variable, which is no longer needed for API mode.

Changes:
- Remove RUNTIME_ENV_PATH from docker-compose.yml
- Remove RUNTIME_ENV_PATH from .env.example
- Update CLAUDE.md to reflect API-managed runtime configs
- Update README.md to remove RUNTIME_ENV_PATH from config examples
- Update CHANGELOG.md with this simplification

Technical details:
- API mode dynamically creates isolated runtime config files via
  RuntimeConfigManager (data/runtime_env_{job_id}_{model}_{date}.json)
- tools/general_tools.py already handles missing RUNTIME_ENV_PATH
  gracefully, returning empty dict and warning on writes
- No functional impact - all tests pass without this variable set
- Reduces configuration complexity for new deployments

Breaking change: None - variable was vestigial from batch mode era
2025-10-31 14:37:00 -04:00
6 changed files with 20 additions and 53 deletions

View File

@@ -13,17 +13,6 @@ OPENAI_API_KEY=your_openai_key_here # https://platform.openai.com/api-keys
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 port 8080 internally (hardcoded in entrypoint.sh)
# This variable ONLY controls the host port mapping (host:API_PORT -> container:8080)

View File

@@ -67,8 +67,7 @@ jobs:
# Only add 'latest' tag for stable releases
if [[ "$IS_PRERELEASE" == "false" ]]; then
TAGS="$TAGS
ghcr.io/$REPO_OWNER_LOWER/ai-trader:latest"
TAGS="${TAGS}"$'\n'"ghcr.io/$REPO_OWNER_LOWER/ai-trader:latest"
echo "Tagging as both $VERSION and latest"
else
echo "Pre-release detected - tagging as $VERSION only (NOT latest)"

View File

@@ -56,11 +56,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Architecture** - Transformed from batch-only to API-first service with database persistence
- **Data Storage** - Migrated from JSONL files to SQLite relational database
- **Deployment** - Simplified to single API-only Docker service
- **Configuration** - Added configurable API_PORT environment variable (default: 8080, customizable for port conflicts)
- **Configuration** - Simplified environment variable configuration
- Added configurable API_PORT for host port mapping (default: 8080, customizable for port conflicts)
- Removed `RUNTIME_ENV_PATH` (API dynamically manages runtime configs via RuntimeConfigManager)
- Removed MCP service port configuration (MATH_HTTP_PORT, SEARCH_HTTP_PORT, TRADE_HTTP_PORT, GETPRICE_HTTP_PORT)
- MCP services use fixed internal ports (8000-8003) and are no longer exposed to host
- Container always uses port 8080 internally for API (hardcoded in entrypoint.sh)
- Only API port (8080) and web dashboard (8888) are 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
- **Dockerfile** - Added system dependencies (curl, procps) and port 8080 exposure
- **.env.example** - Enhanced API server configuration with port conflict documentation
- **.env.example** - Simplified configuration with only essential variables
- **Entrypoint** - Unified entrypoint.sh with proper signal handling (exec uvicorn)
### Technical Implementation

View File

@@ -20,8 +20,6 @@ cp .env.example .env
# Edit .env and set:
# - OPENAI_API_BASE, OPENAI_API_KEY
# - ALPHAADVANTAGE_API_KEY, JINA_API_KEY
# - RUNTIME_ENV_PATH (recommended: absolute path to runtime_env.json)
# - MCP service ports (default: 8000-8003)
# - AGENT_MAX_STEP (default: 30)
```
@@ -41,11 +39,8 @@ cd agent_tools
python start_mcp_services.py
cd ..
# Services run on ports defined in .env:
# - MATH_HTTP_PORT (default: 8000)
# - SEARCH_HTTP_PORT (default: 8001)
# - TRADE_HTTP_PORT (default: 8002)
# - GETPRICE_HTTP_PORT (default: 8003)
# MCP services use fixed internal ports (8000-8003)
# These are not exposed to the host and should not be changed
```
### Docker Deployment
@@ -163,8 +158,10 @@ bash main.sh
3. JSON config file
4. Default values (lowest)
**Runtime configuration** (`runtime_env.json` at `RUNTIME_ENV_PATH`):
- Dynamic state: `TODAY_DATE`, `SIGNATURE`, `IF_TRADE`
**Runtime configuration** (API mode only):
- Dynamically created per model-day execution via `RuntimeConfigManager`
- Isolated config files prevent concurrent execution conflicts
- Contains: `TODAY_DATE`, `SIGNATURE`, `IF_TRADE`, `JOB_ID`
- Written by `write_config_value()`, read by `get_config_value()`
### Agent System
@@ -319,9 +316,9 @@ When modifying agent behavior or adding tools:
- Check Alpha Vantage API key is valid
**Runtime Config Issues:**
- Set `RUNTIME_ENV_PATH` to absolute path in `.env`
- Ensure directory is writable
- File gets created automatically on first run
- Runtime configs are automatically managed by the API
- Configs are created per model-day execution in `data/` directory
- Ensure `data/` directory is writable
**Agent Doesn't Stop Trading:**
- Agent must output `<FINISH_SIGNAL>` within `max_steps`

View File

@@ -291,14 +291,6 @@ OPENAI_API_KEY=your_openai_key
ALPHAADVANTAGE_API_KEY=your_alpha_vantage_key
JINA_API_KEY=your_jina_api_key
# ⚙️ System Configuration
RUNTIME_ENV_PATH=./runtime_env.json # Recommended to use absolute path
# 🌐 Service Port Configuration
MATH_HTTP_PORT=8000
SEARCH_HTTP_PORT=8001
TRADE_HTTP_PORT=8002
GETPRICE_HTTP_PORT=8003
# 🧠 AI Agent Configuration
AGENT_MAX_STEP=30 # Maximum reasoning steps
```

View File

@@ -18,27 +18,10 @@ services:
- ALPHAADVANTAGE_API_KEY=${ALPHAADVANTAGE_API_KEY}
- JINA_API_KEY=${JINA_API_KEY}
# System Configuration
- RUNTIME_ENV_PATH=/app/data/runtime_env.json
# MCP Service Ports (fixed internally)
- MATH_HTTP_PORT=8000
- SEARCH_HTTP_PORT=8001
- TRADE_HTTP_PORT=8002
- GETPRICE_HTTP_PORT=8003
# API Configuration
- API_PORT=${API_PORT:-8080}
# Agent Configuration
- AGENT_MAX_STEP=${AGENT_MAX_STEP:-30}
ports:
# MCP service ports (internal)
- "${MATH_HTTP_PORT:-8000}:8000"
- "${SEARCH_HTTP_PORT:-8001}:8001"
- "${TRADE_HTTP_PORT:-8002}:8002"
- "${GETPRICE_HTTP_PORT:-8003}:8003"
# API server port (primary interface)
# API server port (primary interface for external access)
- "${API_PORT:-8080}:8080"
# Web dashboard
- "${WEB_HTTP_PORT:-8888}:8888"