Skip to content

feat: capital-temperature position sizing (shadow-default) - #12

Merged
trogers1052 merged 1 commit into
mainfrom
feat/capital-temperature-sizing
Jul 27, 2026
Merged

feat: capital-temperature position sizing (shadow-default)#12
trogers1052 merged 1 commit into
mainfrom
feat/capital-temperature-sizing

Conversation

@trogers1052

Copy link
Copy Markdown
Owner

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 in market: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 — parse capital_temperature.value (clamped 0..1; absent/malformed → 0.0 = no reduction) + get_capital_temperature().
  • service.py_apply_capital_temperature folds 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.pycapital_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 — 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 until CAPITAL_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.

Follow-ups (not here): retire risk-engine's dead parallel temperature; sentiment (Fear&Greed/put-call) is still a stub and not in the composite's weights.

🤖 Generated with Claude Code

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>
@trogers1052
trogers1052 merged commit 30b198b into main Jul 27, 2026
1 check passed
@trogers1052
trogers1052 deleted the feat/capital-temperature-sizing branch July 27, 2026 14:31
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.

1 participant