Sistema de trading bot - Semanas 1-2 completadas
- Infraestructura de datos completa - Descarga desde exchanges (CCXT) - Procesamiento y limpieza de datos - Almacenamiento en PostgreSQL - Sistema anti-duplicados - Script de descarga masiva - Tests unitarios - Documentación completa
This commit is contained in:
22
main.py
22
main.py
@@ -1,10 +1,10 @@
|
||||
# main.py
|
||||
# main.py
|
||||
"""
|
||||
Punto de entrada principal del bot de trading
|
||||
Demo para Semanas 1-2: Data Pipeline + Storage
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
from datetime import datetime, timedelta
|
||||
from src.monitoring.logger import log
|
||||
@@ -14,16 +14,12 @@ from src.data.storage import StorageManager
|
||||
|
||||
def setup_environment():
|
||||
"""
|
||||
Carga variables de entorno desde config/secrets.env
|
||||
Carga variables de entorno
|
||||
"""
|
||||
# Cargar desde config/secrets.env
|
||||
project_root = Path(__file__).parent
|
||||
env_path = project_root / 'config' / 'secrets.env'
|
||||
if not env_path.exists():
|
||||
log.error(f"No se encuentra el archivo: {env_path}")
|
||||
raise FileNotFoundError(f"Archivo de configuración no encontrado: {env_path}")
|
||||
load_dotenv(env_path)
|
||||
log.info(f"Cargando configuración desde: {env_path}")
|
||||
from pathlib import Path
|
||||
env_path = Path(__file__).parent / 'config' / 'secrets.env'
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
|
||||
# Verificar variables requeridas
|
||||
required_vars = ['EXCHANGE_NAME', 'DB_HOST', 'DB_NAME', 'DB_USER', 'DB_PASSWORD']
|
||||
@@ -33,7 +29,7 @@ def setup_environment():
|
||||
log.error(f"Faltan variables de entorno: {missing_vars}")
|
||||
raise EnvironmentError(f"Variables faltantes: {missing_vars}")
|
||||
|
||||
log.success("✓ Variables de entorno cargadas correctamente")
|
||||
log.success("Variables de entorno cargadas correctamente")
|
||||
|
||||
def demo_data_pipeline():
|
||||
"""
|
||||
@@ -50,15 +46,15 @@ def demo_data_pipeline():
|
||||
exchange_name = os.getenv('EXCHANGE_NAME', 'binance')
|
||||
symbol = 'BTC/USDT'
|
||||
timeframe = '1h'
|
||||
days_back = 7
|
||||
days_back = 1
|
||||
|
||||
# 2. Inicializar componentes
|
||||
log.info("\n[1/5] Inicializando componentes...")
|
||||
|
||||
fetcher = DataFetcher(
|
||||
exchange_name=exchange_name,
|
||||
api_key=os.getenv('API_KEY'),
|
||||
api_secret=os.getenv('API_SECRET')
|
||||
api_key=os.getenv('API_KEY') if os.getenv('API_KEY') else None,
|
||||
api_secret=os.getenv('API_SECRET') if os.getenv('API_SECRET') else None
|
||||
)
|
||||
|
||||
processor = DataProcessor()
|
||||
|
||||
Reference in New Issue
Block a user