ML Engine Updates: - Updated BTCUSD with Polygon API data (2024-2025): 215,699 new records - Re-trained all ML models: Attention (R²: 0.223), Base, Metamodel (87.3% confidence) - Backtest results: +176.71R profit with aggressive_filter strategy Documentation Consolidation: - Created docs/99-analisis/_MAP.md index with 13 new analysis documents - Consolidated inventories: removed duplicates from orchestration/inventarios/ - Updated ML_INVENTORY.yml with BTCUSD metrics and training results - Added execution reports: FASE11-BTCUSD, correction issues, alignment validation Architecture & Integration: - Updated all module documentation with NEXUS v3.4 frontmatter - Fixed _MAP.md indexes across all folders - Updated orchestration plans and traces Files: 229 changed, 5064 insertions(+), 1872 deletions(-) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
202 lines
5.8 KiB
TypeScript
202 lines
5.8 KiB
TypeScript
/**
|
|
* Configuración centralizada para Trading Platform Trading Platform
|
|
*
|
|
* Este archivo define todas las URLs, puertos y configuraciones
|
|
* que deben ser compartidas entre servicios.
|
|
*/
|
|
|
|
// ============================================================================
|
|
// Service URLs
|
|
// ============================================================================
|
|
|
|
export const SERVICES = {
|
|
BACKEND: {
|
|
name: 'backend',
|
|
port: 3000,
|
|
url: process.env.BACKEND_URL || 'http://localhost:3000',
|
|
healthPath: '/health',
|
|
},
|
|
ML_ENGINE: {
|
|
name: 'ml-engine',
|
|
port: 8001,
|
|
url: process.env.ML_ENGINE_URL || 'http://localhost:8001',
|
|
healthPath: '/health',
|
|
},
|
|
DATA_SERVICE: {
|
|
name: 'data-service',
|
|
port: 8002,
|
|
url: process.env.DATA_SERVICE_URL || 'http://localhost:8002',
|
|
healthPath: '/health',
|
|
},
|
|
LLM_AGENT: {
|
|
name: 'llm-agent',
|
|
port: 8003,
|
|
url: process.env.LLM_AGENT_URL || 'http://localhost:8003',
|
|
healthPath: '/health',
|
|
},
|
|
TRADING_AGENTS: {
|
|
name: 'trading-agents',
|
|
port: 8004,
|
|
url: process.env.TRADING_AGENTS_URL || 'http://localhost:8004',
|
|
healthPath: '/health',
|
|
},
|
|
FRONTEND: {
|
|
name: 'frontend',
|
|
port: 5173,
|
|
url: process.env.FRONTEND_URL || 'http://localhost:5173',
|
|
},
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Database
|
|
// ============================================================================
|
|
|
|
export const DATABASE = {
|
|
host: process.env.DB_HOST || 'localhost',
|
|
port: parseInt(process.env.DB_PORT || '5432'),
|
|
name: process.env.DB_NAME || 'trading',
|
|
user: process.env.DB_USER || 'trading',
|
|
password: process.env.DB_PASSWORD || '',
|
|
ssl: process.env.DB_SSL === 'true',
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Redis
|
|
// ============================================================================
|
|
|
|
export const REDIS = {
|
|
host: process.env.REDIS_HOST || 'localhost',
|
|
port: parseInt(process.env.REDIS_PORT || '6379'),
|
|
password: process.env.REDIS_PASSWORD || '',
|
|
db: parseInt(process.env.REDIS_DB || '0'),
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// External APIs
|
|
// ============================================================================
|
|
|
|
export const EXTERNAL_APIS = {
|
|
BINANCE: {
|
|
apiUrl: process.env.BINANCE_API_URL || 'https://api.binance.com',
|
|
wsUrl: process.env.BINANCE_WS_URL || 'wss://stream.binance.com:9443',
|
|
testnetApiUrl: 'https://testnet.binance.vision',
|
|
testnetWsUrl: 'wss://testnet.binance.vision',
|
|
},
|
|
STRIPE: {
|
|
apiUrl: 'https://api.stripe.com',
|
|
webhookPath: '/webhooks/stripe',
|
|
},
|
|
OLLAMA: {
|
|
url: process.env.OLLAMA_URL || 'http://localhost:11434',
|
|
model: process.env.OLLAMA_MODEL || 'llama3',
|
|
},
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// API Versioning
|
|
// ============================================================================
|
|
|
|
export const API = {
|
|
version: 'v1',
|
|
basePath: '/api/v1',
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Timeouts & Retries
|
|
// ============================================================================
|
|
|
|
export const TIMEOUTS = {
|
|
default: 30000,
|
|
ml: 60000,
|
|
llm: 120000,
|
|
trading: 10000,
|
|
} as const;
|
|
|
|
export const RETRIES = {
|
|
attempts: 3,
|
|
delay: 1000,
|
|
backoffMultiplier: 2,
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// WebSocket Channels
|
|
// ============================================================================
|
|
|
|
export const WS_CHANNELS = {
|
|
TICKER: 'ticker',
|
|
ORDERBOOK: 'orderbook',
|
|
TRADES: 'trades',
|
|
CANDLES: 'candles',
|
|
SIGNALS: 'signals',
|
|
ORDERS: 'orders',
|
|
POSITIONS: 'positions',
|
|
NOTIFICATIONS: 'notifications',
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Trading Constants
|
|
// ============================================================================
|
|
|
|
export const TRADING = {
|
|
defaultLeverage: 1,
|
|
maxLeverage: 100,
|
|
minOrderSize: 0.001,
|
|
maxOrderSize: 1000000,
|
|
supportedTimeframes: ['1m', '5m', '15m', '1h', '4h', '1d', '1w'] as const,
|
|
supportedOrderTypes: ['market', 'limit', 'stop_loss', 'take_profit'] as const,
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Agent Profiles
|
|
// ============================================================================
|
|
|
|
export const AGENT_PROFILES = {
|
|
ATLAS: {
|
|
name: 'Atlas',
|
|
profile: 'conservative',
|
|
maxDrawdown: 0.05,
|
|
targetMonthly: 0.03,
|
|
riskPerTrade: 0.01,
|
|
},
|
|
ORION: {
|
|
name: 'Orion',
|
|
profile: 'moderate',
|
|
maxDrawdown: 0.10,
|
|
targetMonthly: 0.07,
|
|
riskPerTrade: 0.02,
|
|
},
|
|
NOVA: {
|
|
name: 'Nova',
|
|
profile: 'aggressive',
|
|
maxDrawdown: 0.20,
|
|
targetMonthly: 0.15,
|
|
riskPerTrade: 0.03,
|
|
},
|
|
} as const;
|
|
|
|
// ============================================================================
|
|
// Helper Functions
|
|
// ============================================================================
|
|
|
|
export function getServiceUrl(serviceName: keyof typeof SERVICES): string {
|
|
return SERVICES[serviceName].url;
|
|
}
|
|
|
|
export function buildApiUrl(serviceName: keyof typeof SERVICES, path: string): string {
|
|
const baseUrl = getServiceUrl(serviceName);
|
|
const cleanPath = path.startsWith('/') ? path : `/${path}`;
|
|
return `${baseUrl}${API.basePath}${cleanPath}`;
|
|
}
|
|
|
|
export function getDatabaseUrl(): string {
|
|
const { user, password, host, port, name, ssl } = DATABASE;
|
|
const sslParam = ssl ? '?sslmode=require' : '';
|
|
return `postgresql://${user}:${password}@${host}:${port}/${name}${sslParam}`;
|
|
}
|
|
|
|
export function getRedisUrl(): string {
|
|
const { host, port, password, db } = REDIS;
|
|
const auth = password ? `:${password}@` : '';
|
|
return `redis://${auth}${host}:${port}/${db}`;
|
|
}
|