1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# 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:
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%