mollendorff-forge 10.0.0-beta.8

Battle-tested financial math for AI. 173 Excel-compatible functions validated against Gnumeric & R. MCP integration, Monte Carlo, Decision Trees, Real Options.
Documentation
# Bootstrap Resampling Example
# =============================
# Run with: forge bootstrap examples/bootstrap.yaml
#
# This example calculates confidence intervals for portfolio returns
# using non-parametric bootstrap resampling.
#
# Why bootstrap?
# - No assumption about distribution shape
# - Works with small samples
# - Validated against R's boot package
#
# Process:
# 1. Take historical returns (12 months)
# 2. Resample with replacement 10,000 times
# 3. Calculate statistic (mean, median, etc.) for each resample
# 4. Use distribution of statistics for confidence intervals

_forge_version: "5.0.0"

# ─────────────────────────────────────────────────────────────────────────────
# Bootstrap Configuration
# ─────────────────────────────────────────────────────────────────────────────
bootstrap:
  iterations: 10000
  confidence_levels: [0.90, 0.95, 0.99]
  seed: 42  # For reproducibility

  # Historical monthly returns (12 months)
  data:
    - 0.052   # Jan: +5.2%
    - -0.018  # Feb: -1.8%
    - 0.031   # Mar: +3.1%
    - 0.045   # Apr: +4.5%
    - -0.027  # May: -2.7%
    - 0.068   # Jun: +6.8%
    - 0.023   # Jul: +2.3%
    - -0.041  # Aug: -4.1%
    - 0.037   # Sep: +3.7%
    - 0.055   # Oct: +5.5%
    - -0.012  # Nov: -1.2%
    - 0.082   # Dec: +8.2%

  # What to calculate
  statistics:
    - type: mean
      name: "Average Monthly Return"

    - type: median
      name: "Median Monthly Return"

    - type: std
      name: "Return Volatility"

    - type: percentile
      percentile: 5
      name: "5th Percentile (VaR proxy)"

# ─────────────────────────────────────────────────────────────────────────────
# Portfolio Context
# ─────────────────────────────────────────────────────────────────────────────
portfolio:
  name:
    value: "Growth Portfolio"
    formula: null

  initial_value:
    value: 1000000
    formula: null

  # Annualized return (simple)
  annual_return:
    value: null
    formula: "=0.0295 * 12"  # Sample mean * 12

  # Projected value after 1 year
  projected_value:
    value: null
    formula: "=initial_value * (1 + annual_return)"

# ─────────────────────────────────────────────────────────────────────────────
# Expected Output:
# ─────────────────────────────────────────────────────────────────────────────
# Sample Statistics:
#   Mean:   2.95% monthly
#   Median: 3.40% monthly
#   Std:    3.74% monthly
#
# Bootstrap Results (10,000 iterations):
#
# Average Monthly Return:
#   Bootstrap Mean: 2.95%
#   Bootstrap SE:   1.08%
#   90% CI: [1.17%, 4.73%]
#   95% CI: [0.82%, 5.08%]
#   99% CI: [0.15%, 5.75%]
#
# Median Monthly Return:
#   Bootstrap Mean: 3.40%
#   Bootstrap SE:   1.25%
#   95% CI: [0.70%, 5.35%]
#
# Return Volatility (Std):
#   Bootstrap Mean: 3.74%
#   Bootstrap SE:   0.82%
#   95% CI: [2.45%, 5.48%]
#
# 5th Percentile (VaR proxy):
#   Bootstrap Mean: -3.20%
#   95% CI: [-4.10%, -1.80%]
#
# Interpretation:
# - We are 95% confident the true mean return is between 0.82% and 5.08%
# - Monthly VaR(5%) is approximately -3.2% (5% chance of losing 3.2%+)
# - Volatility estimate has uncertainty: could be 2.5% to 5.5%