Files
matitos 2ca5032e7e Notification upgrades: lifecycle, configurable levels, summaries
- NOTIFY_LEVELS chooses which event levels are sent (default trade,error).
- NOTIFY_LIFECYCLE sends explicit start/stop messages; the kill switch always
  notifies at error level.
- SUMMARY_INTERVAL_MINUTES sends a periodic portfolio summary (equity, per
  strategy P&L, allocation, halted state) via a background task started with
  the run and stopped on stop/kill/shutdown.
- Wires the new vars plus the go-live vars through both compose files and the
  deploy workflow. Adds tests.
2026-09-22 13:18:02 +00:00

78 lines
2.4 KiB
Bash

# --- Core ---
APP_NAME=Crypto Trader
ENV=dev
# API host/port
HOST=0.0.0.0
PORT=8000
# --- Persistence ---
# SQLite by default. Point at Postgres with e.g.
# postgresql+psycopg://user:pass@localhost:5432/trader
DATABASE_URL=sqlite:///./data/trader.db
# --- Trading defaults ---
# paper = simulated fills against live market data (safe default)
# live = real orders via the exchange
MODE=paper
EXCHANGE=binance
SYMBOL=BTC/USDT
TIMEFRAME=5m
# How often the engine polls for new candles, in seconds
POLL_INTERVAL=5
# Candles fetched per tick and kept for indicators
CANDLE_LIMIT=200
# Paper broker
STARTING_BALANCE=10000
FEE_BPS=10
SLIPPAGE_BPS=5
# --- Exchange credentials (only needed for MODE=live) ---
EXCHANGE_API_KEY=
EXCHANGE_API_SECRET=
# Set true for testnet/sandbox where supported
EXCHANGE_SANDBOX=false
# --- Go-live gate (required for MODE=live) ---
# Live trading only starts when this is exactly "I UNDERSTAND THE RISK".
# Setting MODE=live alone is intentionally not enough.
LIVE_CONFIRMATION=
# Refuse to start live below this account size (quote currency).
MIN_LIVE_BALANCE=100
# --- Risk controls (0 disables a limit) ---
# Halt + flatten if the day's loss reaches this amount in quote currency
MAX_DAILY_LOSS=0
# Halt + flatten if equity falls this percent from its peak
MAX_DRAWDOWN_PCT=0
# Cap a single position at this fraction of equity (1.0 = all-in)
MAX_POSITION_PCT=1.0
# Max new entries per UTC day (0 = unlimited)
MAX_TRADES_PER_DAY=0
# --- API token (optional) ---
# When set, /api and the /api/ws live feed require this token. The frontend
# nginx injects it server-side, so the browser never sees it. Leave empty for
# no token; the app works fully without it. (The Traefik Basic auth still
# guards the UI in the deployed stack.)
API_TOKEN=
API_TOKEN_HEADER=X-API-Token
# --- Notifications (optional) ---
# Telegram: message @BotFather to create a bot, then get the chat id from
# https://api.telegram.org/bot<token>/getUpdates after messaging the bot.
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
# Generic webhook: receives POST {"level": "...", "text": "..."}
NOTIFY_WEBHOOK_URL=
# Event levels to notify on (comma separated): trade, error, warning, info.
NOTIFY_LEVELS=trade,error
# Send explicit start/stop messages.
NOTIFY_LIFECYCLE=true
# Periodic portfolio summary every N minutes (0 disables).
SUMMARY_INTERVAL_MINUTES=0
# --- Web ---
# Comma separated list, or * in dev
CORS_ORIGINS=*