Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save quantra-go-algo/c60aff8939a4116c5b7f877157253c88 to your computer and use it in GitHub Desktop.

Select an option

Save quantra-go-algo/c60aff8939a4116c5b7f877157253c88 to your computer and use it in GitHub Desktop.
guardrailed-llm-agent — Step 1: The Control Panel: Settings (snippet 1)
# ---------- Policy mode ----------
POLICY_MODE = 'llm' # 'llm' = DeepSeek | 'rule' = deterministic baseline
# ---------- Data ----------
SYMBOL = 'AAPL'
START = '1990-01-01'
OOS_START = '2023-01-01'
# ---------- Costs ----------
COST_BPS = 0.28 # IBKR Fixed: $0.005/share + reg fees at AAPL ~$185
SLIPPAGE_BPS = 0.37 # half bid-ask ($0.01 spread) + vol-spike buffer
TC_BPS = COST_BPS + SLIPPAGE_BPS # = 0.65 bps total one-way cost
TC_BPS = COST_BPS + SLIPPAGE_BPS
# ---------- Volatility targeting ----------
USE_VOL_TARGET = True
TARGET_VOL = 0.25 # annualized target volatility
MAX_LEVERAGE = 1.0 # no leverage
# ---------- LLM exposure mapping ----------
LONG_FULL_EXP = 1.0 # LLM says LONG size 1.0 → hold 100 % of target
LONG_HALF_EXP = 0.8 # LLM says LONG size 0.5 → hold 80 %
FLAT_EXP = 0.5 # LLM says FLAT → hold 50 % (never fully exit)
# ---------- Guardrail re-entry ----------
MAX_FLAT_DAYS = 10 # force re-entry after ~2 trading weeks of zero exposure
REENTRY_SIZE = 1.0 # come back at full size to recover the drawdown faster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment