Skip to content

feat(regime): add volatility weighted targets#660

Merged
brndnmtthws merged 3 commits intomainfrom
brndnmtthws/feat/volatility-weight
Apr 30, 2026
Merged

feat(regime): add volatility weighted targets#660
brndnmtthws merged 3 commits intomainfrom
brndnmtthws/feat/volatility-weight

Conversation

@brndnmtthws
Copy link
Copy Markdown
Owner

Haiku

Quiet weights breathe slow
Storms trim risk, calm lets it rise
Bands hold churn at bay

Summary

Adds optional volatility-weighted target sizing for regime rebalance symbols. The regime engine can now compute an effective target weight from realized volatility, clamp it between configured bounds, smooth it from previously persisted state, and use that effective weight for target value and share calculations.

User Impact

Operators can let high-risk sleeves such as TQQQ scale down during high-volatility periods and scale back up in calmer regimes without renormalizing other symbols. This changes regime rebalancing from fixed configured weights to dynamic effective weights for symbols that opt into the new configuration.

Root Cause

Regime rebalancing previously treated configured portfolio weights as static targets. That made TQQQ exposure insensitive to changing realized volatility, so the bot could not reduce or increase that sleeve based on recent risk conditions.

Fix

Introduces portfolio.symbols.<symbol>.volatility_weight with target volatility, lookback, min/max weight, rebalance band, and smoothing factors. The regime engine resolves effective weights before target-share calculations, records volatility weight state for later smoothing, displays volatility-adjusted targets in the summary, and falls back to static weights when historical data is invalid or insufficient.

Validation

  • uv run pytest
  • uv run ruff check thetagang tests
  • uv run ruff format --check thetagang tests
  • uv run ty check
  • Pre-commit hooks during commit

@brndnmtthws brndnmtthws marked this pull request as ready for review April 30, 2026 12:31
Copilot AI review requested due to automatic review settings April 30, 2026 12:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional volatility-weighted target sizing mechanism to the regime rebalance engine, allowing per-symbol effective target weights to adjust based on realized volatility (with clamping, smoothing, and persistence).

Changes:

  • Introduces per-symbol volatility-weight config (volatility_weight) in the config model.
  • Computes volatility-adjusted effective target weights during regime rebalance and uses them for target value/share calculations, with optional smoothing from persisted state.
  • Adds tests covering scaling, smoothing, band behavior, fallback conditions, and config parsing.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
thetagang/strategies/regime_engine.py Computes effective weights from realized vol, applies them to target sizing, augments summary output, and persists state.
thetagang/config_models.py Adds SymbolConfig.VolatilityWeight and a volatility_weight field on SymbolConfig.
tests/test_regime_rebalance.py Adds extensive async tests for volatility-weight behavior, persistence, and fallbacks.
tests/test_legacy_config.py Updates Polyfactory model factory to account for the new volatility_weight field.
tests/test_config_new.py Adds config parsing/validation tests for the new volatility_weight section.

Comment thread thetagang/strategies/regime_engine.py Outdated
Comment thread thetagang/strategies/regime_engine.py
@brndnmtthws brndnmtthws merged commit bb5bc00 into main Apr 30, 2026
11 checks passed
@brndnmtthws brndnmtthws deleted the brndnmtthws/feat/volatility-weight branch April 30, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants