Perps-Terminal / backend /config.py
Naufal Arhab
fix(audit): resolve multi-pass backend calculations, exchange guards, AI/UI state, and chart bugs
80df99b
Raw History Blame Contribute Delete
1.56 kB
"""
Configuration settings loaded from environment variables.
Copy .env.example to .env and fill in your API keys.
"""
import os
from pathlib import Path
from dotenv import load_dotenv
# Load .env from backend folder or current working directory
_env_path = Path(__file__).resolve().parent / ".env"
if _env_path.exists():
load_dotenv(dotenv_path=_env_path)
else:
load_dotenv()
# --- Exchange API Keys (read-only keys are sufficient) ---
BINANCE_API_KEY: str = os.getenv("BINANCE_API_KEY", "")
BINANCE_SECRET: str = os.getenv("BINANCE_SECRET", "")
BYBIT_API_KEY: str = os.getenv("BYBIT_API_KEY", "")
BYBIT_SECRET: str = os.getenv("BYBIT_SECRET", "")
# --- App settings ---
UPDATE_INTERVAL: int = int(os.getenv("UPDATE_INTERVAL", "60")) # seconds between data refreshes
DATABASE_URL: str = os.getenv("DATABASE_URL", "")
# --- Exchange base URLs & Proxy ---
BINANCE_FUTURES_BASE_URL: str = os.getenv("BINANCE_BASE_URL", "https://fapi.binance.com")
BYBIT_BASE_URL: str = os.getenv("BYBIT_BASE_URL", "https://api.bybit.biz")
PROXY_URL: str = os.getenv("PROXY_URL", os.getenv("HTTPS_PROXY", os.getenv("HTTP_PROXY", "")))
# --- API Security ---
PERPS_API_TOKEN: str = os.getenv("PERPS_API_TOKEN", "").strip()
CRON_SECRET: str = os.getenv("CRON_SECRET", "").strip()
# --- CORS ---
raw_cors = os.getenv("CORS_ORIGINS", "*")
CORS_ORIGINS: list[str] = ["*"] if raw_cors == "*" else [c.strip() for c in raw_cors.split(",") if c.strip()]
# --- Signal thresholds ---
SIGNAL_LONG_THRESHOLD: int = 3
SIGNAL_SHORT_THRESHOLD: int = -3
MAX_CONVICTION: int = 10