feat: capital-temperature position sizing (shadow-default) - #12
Merged
Conversation
Consume the composite capital_temperature (0..1) that context-service already publishes in market:context and use it to auto-scale BUY position size — the "is this a good environment to be a buyer at all?" gap. Nothing consumed that signal before; the risk-engine had a weaker VIX+HY-only temperature whose size reduction decision-engine discarded. - market_context: parse capital_temperature.value (clamped 0..1; absent → 0.0 = no reduction) + get_capital_temperature(). - service: _apply_capital_temperature folds temp into the tier size multiplier — temp_mult = 1 - temp*max_reduction (default 0.50), combined = tier*temp_mult, re-clamped to 2% by the existing trade-planner seam. ALWAYS logs the would-be effect; only APPLIES when capital_temperature_sizing_enabled=True. - config: capital_temperature_sizing_enabled (default False = shadow) + capital_temperature_max_reduction (0.50), mirroring feedback_accuracy_enabled. Scales SIZE (complementing the regime multiplier which scales CONFIDENCE). Ships shadow-default: logs what it would do against live signals, applies nothing until the flag flips. +12 tests; suite 880 green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Lights up the Composite Risk / Capital-Temperature Score (gap-analysis Phase B, Gap 3): auto-scale BUY position size by the composite
capital_temperature(0..1, 0=risk-on … 1=stressed) that context-service already publishes inmarket:context. This is the "don't buy into weakness" brake that was missing when MOH was bought.Why now / what was missing
The weighted composite gauge already exists in context-service — but nothing consumed it. decision-engine read only
regime/regime_confidence. A separate, weaker VIX+HY-only temperature in risk-engine computed a size reduction that decision-engine discarded (it uses risk-engine only as a pass/fail gate). So the real production sizer never saw temperature at all.Changes (decision-engine only)
market_context.py— parsecapital_temperature.value(clamped 0..1; absent/malformed → 0.0 = no reduction) +get_capital_temperature().service.py—_apply_capital_temperaturefolds temp into the tier size multiplier at the existing seam:temp_mult = 1 − temp×max_reduction(default 0.50 → full stress halves size),combined = tier × temp_mult, re-clamped to 2% by the trade planner. Always logs the would-be effect; only applies when the flag is on.config.py—capital_temperature_sizing_enabled(default False = shadow) +capital_temperature_max_reduction(0.50), mirroringfeedback_accuracy_enabled.Scales size (complementing the regime multiplier, which scales confidence — two distinct levers, deliberately not mixed).
Rollout
Ships shadow-default: against live signals it logs e.g.
capital-temperature sizing AAPL: temp=0.64 → ×0.68 (tier ×1.15 → combined ×0.78) [shadow], applying nothing untilCAPITAL_TEMPERATURE_SIZING_ENABLED=true. Real-time observability during shadow, same as the hard gate.+12 tests (parsing/clamp/absent, shadow-vs-enabled, tier combination, max_reduction, no-reader). Full suite 880 green.
🤖 Generated with Claude Code