"""
Configuración centralizada para OrbiQuant SDK
"""

from pydantic import BaseModel
from typing import Optional
import os


class Config(BaseModel):
    """Configuración del SDK"""

    # URLs de servicios
    backend_url: str = "http://localhost:3000"
    ml_engine_url: str = "http://localhost:8001"
    llm_agent_url: str = "http://localhost:8003"
    trading_agents_url: str = "http://localhost:8004"
    data_service_url: str = "http://localhost:8002"

    # WebSocket
    ws_url: str = "ws://localhost:3000"

    # Timeouts
    timeout: int = 30
    retry_attempts: int = 3
    retry_delay: float = 1.0

    # Auth
    api_key: Optional[str] = None
    access_token: Optional[str] = None

    @classmethod
    def from_env(cls) -> "Config":
        """Crear configuración desde variables de entorno"""
        return cls(
            backend_url=os.getenv("ORBIQUANT_BACKEND_URL", "http://localhost:3000"),
            ml_engine_url=os.getenv("ORBIQUANT_ML_URL", "http://localhost:8001"),
            llm_agent_url=os.getenv("ORBIQUANT_LLM_URL", "http://localhost:8003"),
            trading_agents_url=os.getenv(
                "ORBIQUANT_AGENTS_URL", "http://localhost:8004"
            ),
            data_service_url=os.getenv("ORBIQUANT_DATA_URL", "http://localhost:8002"),
            ws_url=os.getenv("ORBIQUANT_WS_URL", "ws://localhost:3000"),
            timeout=int(os.getenv("ORBIQUANT_TIMEOUT", "30")),
            retry_attempts=int(os.getenv("ORBIQUANT_RETRY_ATTEMPTS", "3")),
            api_key=os.getenv("ORBIQUANT_API_KEY"),
            access_token=os.getenv("ORBIQUANT_ACCESS_TOKEN"),
        )


# Configuración por defecto
DEFAULT_CONFIG = Config()
