# Cadence configuration # Copy this file to .env and fill in your values. # Never commit .env to version control. # --- Kalshi API credentials (required for live trading) --- # # Kalshi uses RSA-PSS signed requests. When you create an API key pair at # https://kalshi.com/account/api-keys, Kalshi gives you: # 1. An API key ID (short string) # 2. A private key PEM file (downloaded once - keep it safe!) # # Put the PEM file somewhere on your machine and reference its path below. KALSHI_API_KEY_ID= KALSHI_PRIVATE_KEY_PATH=/path/to/your/kalshi_private_key.pem # Alternative: email/password login (gets a 24h JWT, less preferred) # KALSHI_EMAIL= # KALSHI_PASSWORD= # --- Risk management (all values in cents) --- # Starting equity in cents. If CADENCE_SYNC_BALANCE=true, this is overridden # by your actual Kalshi cash balance on startup. CADENCE_EQUITY=5000 # Automatically sync equity from Kalshi on every scan. CADENCE_SYNC_BALANCE=true # Kill switch: halt all trading at this % drawdown from the reference. # Set to 0 to disable drawdown kill switch entirely (rely on per-trade # and daily loss limits instead). CADENCE_MAX_DRAWDOWN_PCT=10 # What to measure drawdown against: # session_start (default): today's opening balance. Resets at midnight # or when you click "Reset Daily P&L" on the dashboard. Safer when # your Kalshi account has existing positions whose value fluctuates # independently of Cadence's trades. # peak: all-time high-water mark. Strict mode. Peak grows on gains # but never shrinks, so any dip from an all-time high triggers. # Only use this if Cadence is the sole trader on this account. CADENCE_DRAWDOWN_REFERENCE=session_start # --- Daily loss limit (flat cents and/or % of daily starting balance) --- # You can set either, both, or neither. If both are set, the MORE # RESTRICTIVE (smaller) one wins at any given moment. CADENCE_DAILY_LOSS_LIMIT=2000 # Flat cents cap # CADENCE_DAILY_LOSS_LIMIT_PCT=5 # Dynamic: 5% of today's starting balance # --- Per-trade cost limit (flat cents and/or % of current equity) --- # Same rule: both set → smaller wins. # Using the % limit makes your trade size trail your equity automatically. CADENCE_MAX_PER_TRADE=500 # Flat cents cap # CADENCE_MAX_PER_TRADE_PCT=2 # Dynamic: 2% of current equity # Max total exposure across all open positions in cents CADENCE_MAX_EXPOSURE=10000 # Pause trading after N consecutive losses CADENCE_MAX_CONSECUTIVE_LOSSES=5 # Minimum NET profit in cents for a trade to execute. # IMPORTANT: must exceed the expected partial-fill unwind cost! # If one leg of an arb fills and the other doesn't, we have to sell the # filled leg at the bid price, losing the bid-ask spread (~2c per leg) # plus taker fees (~2c per leg). That's ~6c worst-case per binary arb. # Default: 3c (middle ground between safety and catching real opps). # Raise to 5c+ for stricter safety, lower to 2c if you're confident # your partial-fill unwind is reliable. CADENCE_MIN_PROFIT=3 # --- Scanner / Executor --- # Contracts per leg when auto-executing CADENCE_CONTRACTS=1 # Seconds between scans CADENCE_INTERVAL=15 # Allow multi-outcome arbitrage (buy-all-YES / buy-all-NO across an event). # Multi-leg arbs have more partial fill risk than binary arbs because any # one leg failing to fill leaves you with naked directional exposure. # Disabled by default — only enable once you've tested with dry-run and # are confident in the unwind path. CADENCE_ALLOW_MULTI_LEG=false # Optional cap on how many markets to pull per scan. Kalshi has tens of # thousands of open markets across series (weather, crypto, stocks, etc.). # A full scan can take a minute or two. Set this to scan only the first N # markets each cycle. Leave blank to scan everything. # CADENCE_MAX_MARKETS=10000 # --- Dashboard --- CADENCE_PORT=8050 # Persist risk state across restarts CADENCE_STATE_FILE=risk_state.json # --- Telegram notifications (optional) --- # # Get these by: # 1. Message @BotFather on Telegram, send /newbot, follow prompts -> TOKEN # 2. Send /start to your new bot (in Telegram) # 3. Visit https://api.telegram.org/bot/getUpdates in your browser # and find the "chat":{"id": ...} value in the JSON response # # With these set, Cadence will send you: # - Startup / shutdown messages # - Every successful trade (with event, profit, detail) # - Partial fills + unwinds # - Kill switch activations (always) # - Scanner errors (deduped so repeated errors don't spam) # - Periodic hourly status (equity, P&L, drawdown, exposure) # # Test the setup by hitting POST http://localhost:8050/api/telegram/test # once the dashboard is running. # CADENCE_TELEGRAM_BOT_TOKEN=123456:ABC-your-bot-token # CADENCE_TELEGRAM_CHAT_ID=987654321 # CADENCE_TELEGRAM_STATUS_INTERVAL=3600 # seconds between status updates (default 1h) # Opt-in: let the bot RECEIVE commands from you (not just send). # With commands enabled you can message the bot things like: # /status /positions /decisions /config /help # /kill /resume /reset # /scanner_start /scanner_stop # /exec_start (dry run) /exec_stop # /exec_live (requires confirmation reply) # Only messages from CADENCE_TELEGRAM_CHAT_ID are accepted — anything else # is silently dropped. # CADENCE_TELEGRAM_COMMANDS_ENABLED=false