-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
54 lines (44 loc) · 2.56 KB
/
config.py
File metadata and controls
54 lines (44 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
config.py — Carga toda la configuración desde el archivo .env
Este módulo es el único que toca las variables de entorno.
El resto del código importa desde aquí.
"""
import os
from dotenv import load_dotenv
# Carga el archivo .env desde la raíz del proyecto
load_dotenv()
def _require(key: str) -> str:
"""Obtiene una variable de entorno obligatoria. Lanza error si falta."""
value = os.getenv(key)
if not value:
raise EnvironmentError(
f"❌ Falta la variable de entorno: '{key}'\n"
f" Asegúrate de copiar .env.example como .env y rellenar tus claves."
)
return value
# ── Alpaca ────────────────────────────────────────────────────────────────────
ALPACA_API_KEY = _require("ALPACA_API_KEY")
ALPACA_SECRET_KEY = _require("ALPACA_SECRET_KEY")
ALPACA_MODE = os.getenv("ALPACA_MODE", "paper") # "paper" | "live"
# URL base según el modo
ALPACA_BASE_URL = (
"https://paper-api.alpaca.markets"
if ALPACA_MODE == "paper"
else "https://api.alpaca.markets"
)
# ── Massive ───────────────────────────────────────────────────────────────────
MASSIVE_API_KEY = _require("MASSIVE_API_KEY")
MASSIVE_BASE_URL = "https://api.massive.com/v1" # Ajusta según la doc de Massive
# ── Trading ───────────────────────────────────────────────────────────────────
TRADING_SYMBOL = os.getenv("TRADING_SYMBOL", "AAPL")
MAX_CAPITAL = float(os.getenv("MAX_CAPITAL", "1000"))
RISK_PER_TRADE = float(os.getenv("RISK_PER_TRADE", "0.02")) # 2%
STOP_LOSS_PCT = float(os.getenv("STOP_LOSS_PCT", "0.03")) # 3%
TAKE_PROFIT_PCT = float(os.getenv("TAKE_PROFIT_PCT", "0.06")) # 6%
# ── Indicadores ───────────────────────────────────────────────────────────────
TIMEFRAME = os.getenv("TIMEFRAME", "15Min")
SMA_SHORT = int(os.getenv("SMA_SHORT", "10"))
SMA_LONG = int(os.getenv("SMA_LONG", "30"))
RSI_PERIOD = int(os.getenv("RSI_PERIOD", "14"))
RSI_OVERSOLD = int(os.getenv("RSI_OVERSOLD", "35"))
RSI_OVERBOUGHT = int(os.getenv("RSI_OVERBOUGHT", "65"))