compute_returns
Stress-test a linear factor model by applying fractional shocks to factors and compute portfolio returns. Specify shocks as fractional changes; the server handles absolute levels automatically.
Instructions
Run a what-if stress test on a Moment (linear) factor model — the PRIMARY tool for scenario analysis. Requires simulation_batch_id from analyze_quantitative or compute_betas. Express stresses as FRACTIONAL CHANGES of each factor's current value (shocks dict). The server translates to absolute levels using each factor's latest observed value — you don't need to look it up or do the arithmetic. Examples: • 'TLT down 8.5%' → {'TLT': -0.085}. • '50bps rate cut on DGS10 (currently 5%)' → {'DGS10': -0.10} (−50bps / 500bps of the current rate = −10%). • 'VIX doubles (to ~40 from 20)' → {'VIX': 1.00}. • 'SPY drops 20%' → {'SPY': -0.20}. Omitted factors default to no shock. Include factor_last_values_raw from the betas output in your narration so the user sees the current level next to the stressed level. Also check data_freshness_warning in betas output — if present, betas may be stale. For Flow (generative) models, use simulate_flow_scenario instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| shocks | Yes | Fractional change per factor. -0.10 = −10%, 0.25 = +25%. Uniform convention for all feature types (prices, rates, indices, volatilities). For a 50bps rate cut on a rate currently at 5%: −50bps / 500bps = -0.10. For TLT down 8.5%: -0.085. Keys must match conditioning_features. | |
| n_samples | No | Number of Monte Carlo samples (default 1000) | |
| simulation_batch_id | Yes | From analyze_quantitative or compute_betas results |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |