🔧 CRITICAL FIX: Price Data Sync & Position Monitor Enhancement

Fixed major price data sync issues:
- Removed hardcoded price (77.63) from position monitor
- Added real-time oracle data instead of stale TWAP pricing
- Implemented cache-busting headers for fresh data
- Updated fallback prices to current market levels

- Real-time P&L tracking with trend indicators (📈📉➡️)
- Enhanced stop loss proximity alerts with color-coded risk levels
- Analysis progress indicators during automation cycles
- Performance metrics (runtime, cycles, trades, errors)
- Fresh data validation and improved error handling

- Price accuracy: 77.63 → 84.47 (matches Drift UI)
- P&L accuracy: -.91 → -.59 (correct calculation)
- Risk assessment: CRITICAL → MEDIUM (proper evaluation)
- Stop loss distance: 0.91% → 4.8% (safe distance)

- CLI monitor script with 8-second updates
- Web dashboard component (PositionMonitor.tsx)
- Real-time automation status tracking
- Database and error monitoring improvements

This fixes the automation showing false emergency alerts when
position was actually performing normally.
This commit is contained in:
mindesbunister
2025-07-25 23:33:06 +02:00
parent 08f9a9b541
commit 9b6a393e06
18 changed files with 6783 additions and 361 deletions

View File

@@ -1,3 +1,5 @@
version: '2.4'
services:
app:
container_name: trader_dev
@@ -30,6 +32,8 @@ services:
- SCREENSHOT_PARALLEL_SESSIONS=false
- SCREENSHOT_MAX_WORKERS=1
- BROWSER_POOL_SIZE=1
# Disable aggressive cleanup during development
- DISABLE_AUTO_CLEANUP=true
# Load environment variables from .env file
env_file:
@@ -48,6 +52,8 @@ services:
- ./lib:/app/lib:cached
- ./components:/app/components:cached
- ./package.json:/app/package.json:ro
# Mount root JavaScript files for Enhanced Risk Manager
- ./start-enhanced-risk-manager.js:/app/start-enhanced-risk-manager.js:ro
# Port mapping for development
ports:
@@ -58,8 +64,51 @@ services:
# Faster health check for development
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3000/ || exit 1"]
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000/ || exit 1"]
interval: 10s
timeout: 5s
retries: 2
start_period: 15s
# Enhanced Risk Manager as separate service
risk_manager:
container_name: enhanced_risk_manager
build:
context: .
dockerfile: Dockerfile
args:
- BUILDKIT_INLINE_CACHE=1
- NODE_VERSION=20.11.1
- PNPM_VERSION=8.15.1
# Override entrypoint and command to run Enhanced Risk Manager directly
entrypoint: []
command: ["node", "start-enhanced-risk-manager.js"]
# Enhanced Risk Manager environment
environment:
- NODE_ENV=development
- DOCKER_ENV=true
- DATABASE_URL=file:./prisma/dev.db
- TZ=Europe/Berlin
# Load environment variables from .env file
env_file:
- .env
# Enhanced Risk Manager volumes
volumes:
- ./lib:/app/lib:cached
- ./prisma:/app/prisma:cached
- ./start-enhanced-risk-manager.js:/app/start-enhanced-risk-manager.js:ro
# Working directory
working_dir: /app
# Depends on the main app being healthy
depends_on:
app:
condition: service_healthy
# Restart policy
restart: unless-stopped