-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
361 lines (322 loc) · 18 KB
/
index.html
File metadata and controls
361 lines (322 loc) · 18 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bogle3 - 3-Fund Portfolio Calculator</title>
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.3/dist/cdn.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-50 text-gray-900 min-h-screen">
<div class="max-w-6xl mx-auto p-6" x-data="bogle3Data()" x-init="init()">
<div class="grid lg:grid-cols-4 gap-6">
<!-- Sidebar -->
<div class="lg:col-span-1" x-data="{ showInfo: false }">
<div class="lg:sticky lg:top-6 space-y-4">
<!-- App Name -->
<div class="flex items-center justify-between lg:block">
<div>
<h1 class="text-4xl font-bold text-blue-900 mb-1">Bogle3</h1>
<p class="text-sm text-gray-600">3-Fund Portfolio Calculator</p>
</div>
<!-- Mobile toggle -->
<button @click="showInfo = !showInfo" class="lg:hidden text-sm text-gray-500 hover:text-gray-700 flex items-center gap-1">
<span x-text="showInfo ? 'Hide' : 'Info'">Info</span>
<svg class="w-4 h-4 transition-transform" :class="showInfo ? 'rotate-180' : ''" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
</div>
<!-- Collapsible content for mobile -->
<div x-show="showInfo" x-transition class="lg:hidden space-y-6">
<!-- About -->
<div class="text-sm text-gray-600 leading-relaxed">
<h3 class="font-semibold text-gray-900 mb-2">What is this?</h3>
<p class="mb-3">A simple calculator for the <a href="https://www.bogleheads.org/wiki/Three-fund_portfolio" target="_blank" rel="noopener noreferrer" class="font-semibold text-gray-800 underline hover:text-blue-700">Bogleheads 3-Fund Portfolio</a> — a low-cost, diversified investment strategy using just three index funds:</p>
<ul class="list-disc list-outside ml-4 space-y-1 mb-3">
<li>US Total Stock Market</li>
<li>International Stock Market</li>
<li>Total Bond Market</li>
</ul>
<p>This tool helps you split your investment dollars across these three funds at your preferred allocation.</p>
</div>
<!-- Instructions -->
<div class="text-sm text-gray-600 leading-relaxed">
<h3 class="font-semibold text-gray-900 mb-2">How to use</h3>
<ol class="list-decimal list-outside ml-4 space-y-2">
<li>Enter your age to auto-set stocks/bonds, or adjust slider</li>
<li>Set International % of stocks (20-40% recommended)</li>
<li>Enter investment amount</li>
<li>Select your broker to see recommended funds</li>
<li>Purchase shares at your broker to match the dollar amounts</li>
</ol>
</div>
<!-- GitHub -->
<div class="text-sm text-gray-600 leading-relaxed">
<a href="https://github.com/narkeeso/bogle3" target="_blank" rel="noopener noreferrer" class="text-gray-800 underline hover:text-blue-700">View on GitHub</a>
</div>
</div>
<!-- Desktop only content (always visible) -->
<div class="hidden lg:block space-y-6">
<!-- About -->
<div class="text-sm text-gray-600 leading-relaxed">
<h3 class="font-semibold text-gray-900 mb-2">What is this?</h3>
<p class="mb-3">A simple calculator for the <a href="https://www.bogleheads.org/wiki/Three-fund_portfolio" target="_blank" rel="noopener noreferrer" class="font-semibold text-gray-800 underline hover:text-blue-700">Bogleheads 3-Fund Portfolio</a> — a low-cost, diversified investment strategy using just three index funds:</p>
<ul class="list-disc list-outside ml-4 space-y-1 mb-3">
<li>US Total Stock Market</li>
<li>International Stock Market</li>
<li>Total Bond Market</li>
</ul>
<p>This tool helps you split your investment dollars across these three funds at your preferred allocation.</p>
</div>
<!-- Instructions -->
<div class="text-sm text-gray-600 leading-relaxed">
<h3 class="font-semibold text-gray-900 mb-2">How to use</h3>
<ol class="list-decimal list-outside ml-4 space-y-2">
<li>Enter your age to auto-set stocks/bonds, or adjust slider</li>
<li>Set International % of stocks (20-40% recommended)</li>
<li>Enter investment amount</li>
<li>Select your broker to see recommended funds</li>
<li>Purchase shares at your broker to match the dollar amounts</li>
</ol>
</div>
<!-- GitHub -->
<div class="text-sm text-gray-600 leading-relaxed">
<a href="https://github.com/narkeeso/bogle3" target="_blank" rel="noopener noreferrer" class="text-gray-800 underline hover:text-blue-700">View on GitHub</a>
</div>
</div>
</div>
</div>
<!-- Main Calculator -->
<div class="lg:col-span-3 flex justify-center">
<div class="w-full max-w-2xl">
<!-- Allocation Sliders -->
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
<div class="flex justify-between items-center mb-4 flex-wrap gap-2">
<h2 class="text-lg font-semibold">Asset Allocation</h2>
<div class="flex items-center gap-2">
<label class="text-sm text-gray-600">Age:</label>
<input
type="number"
x-model="age"
@blur="setAllocationFromAge()"
@keydown.enter="setAllocationFromAge()"
min="18"
max="100"
class="w-16 px-2 py-1.5 h-8 border border-gray-300 rounded text-center text-sm leading-none"
placeholder="25"
>
</div>
</div>
<!-- Stocks/Bonds Split -->
<div class="mb-6 p-4 bg-gray-50 rounded-lg">
<div class="flex justify-between mb-2">
<label class="text-sm font-medium text-gray-700">Stocks vs Bonds</label>
<span class="text-sm font-semibold text-gray-900" x-text="stocksPercent + '% Stocks / ' + (100 - stocksPercent) + '% Bonds'"></span>
</div>
<input
type="range"
x-model="stocksPercent"
min="20"
max="90"
class="w-full h-3 bg-gradient-to-r from-yellow-200 to-blue-200 rounded-lg appearance-none cursor-pointer accent-blue-600"
>
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>More Bonds</span>
<span>More Stocks</span>
</div>
</div>
<!-- International % of Stocks -->
<div class="mb-4 p-4 bg-gray-50 rounded-lg">
<div class="flex justify-between mb-2">
<label class="text-sm font-medium text-gray-700">International % of Stocks</label>
<span class="text-sm font-semibold text-gray-900" x-text="intlPercentOfStocks + '%'"></span>
</div>
<input
type="range"
x-model="intlPercentOfStocks"
min="0"
max="60"
class="w-full h-3 bg-gradient-to-r from-blue-200 to-green-200 rounded-lg appearance-none cursor-pointer accent-green-600"
>
<div class="flex justify-between text-xs text-gray-500 mt-1">
<span>0% (All US)</span>
<span>20%</span>
<span>40%</span>
<span>60%</span>
</div>
<div class="text-xs text-gray-400 mt-2">
US: <span x-text="usStockPercent + '%'"></span> | International: <span x-text="intlStockPercent + '%'"></span> of total portfolio
</div>
</div>
<div class="text-right">
<button @click="resetAllocation()" class="text-xs text-gray-500 hover:text-gray-700 underline">Reset to defaults</button>
</div>
</div>
<!-- Investment Breakdown -->
<div class="bg-white rounded-lg shadow-md p-6 mb-6">
<div class="flex justify-between items-center mb-4 flex-wrap gap-2">
<h2 class="text-lg font-semibold">Investment</h2>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Amount</label>
<div class="relative">
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-500">$</span>
<input
type="number"
x-model="totalAmount"
class="w-full pl-8 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-lg"
placeholder="100"
>
</div>
</div>
<div class="flex justify-between items-center mb-4 flex-wrap gap-2">
<h3 class="font-medium text-gray-700">Breakdown</h3>
<div class="flex items-center gap-2">
<label class="text-sm text-gray-600">Broker:</label>
<select
x-model="selectedBroker"
class="px-2 h-8 border border-gray-300 rounded text-sm bg-white"
>
<option value="Vanguard">Vanguard</option>
<option value="Schwab">Schwab</option>
<option value="Fidelity">Fidelity</option>
<option value="iShares">iShares</option>
</select>
</div>
</div>
<div class="grid grid-cols-3 gap-3">
<!-- US Stock Result -->
<div class="p-3 bg-blue-50 rounded-lg text-center">
<div class="font-bold text-blue-900 text-xl mb-1" x-text="formatCurrency(usStockAmount)">$60</div>
<div class="text-sm text-blue-600 mb-1 font-mono font-bold bg-blue-100 px-2 py-1 rounded inline-block" x-text="usTicker">VTI</div>
<div class="font-medium text-blue-900 text-sm">US Stock</div>
</div>
<!-- International Stock Result -->
<div class="p-3 bg-green-50 rounded-lg text-center">
<div class="font-bold text-green-900 text-xl mb-1" x-text="formatCurrency(intlStockAmount)">$20</div>
<div class="text-sm text-green-600 mb-1 font-mono font-bold bg-green-100 px-2 py-1 rounded inline-block" x-text="intlTicker">VXUS</div>
<div class="font-medium text-green-900 text-sm">International</div>
</div>
<!-- Bond Result -->
<div class="p-3 bg-yellow-50 rounded-lg text-center">
<div class="font-bold text-yellow-900 text-xl mb-1" x-text="formatCurrency(bondAmount)">$20</div>
<div class="text-sm text-yellow-600 mb-1 font-mono font-bold bg-yellow-100 px-2 py-1 rounded inline-block" x-text="bondTicker">BND</div>
<div class="font-medium text-yellow-900 text-sm">Bonds</div>
</div>
</div>
</div><!-- /Investment Breakdown -->
</div><!-- /max-w-2xl -->
</div><!-- /main calculator -->
</div><!-- /grid -->
</div><!-- /max-w-6xl container -->
<!-- Footer - Full Width -->
<footer class="mt-8 py-6 text-center text-sm text-gray-500">
<div class="max-w-6xl mx-auto px-6">
<p>Invest at your own risk. Not financial advice.</p>
</div>
</footer>
<script>
function bogle3Data() {
const DEFAULTS = {
age: 25,
stocksPercent: 60,
intlPercentOfStocks: 25,
selectedBroker: 'Vanguard'
};
return {
totalAmount: 100,
age: DEFAULTS.age,
stocksPercent: DEFAULTS.stocksPercent,
intlPercentOfStocks: DEFAULTS.intlPercentOfStocks,
selectedBroker: DEFAULTS.selectedBroker,
brokers: {
'Vanguard': { us: 'VTI', intl: 'VXUS', bond: 'BND' },
'Schwab': { us: 'SWTSX', intl: 'SWISX', bond: 'SWAGX' },
'Fidelity': { us: 'FSKAX', intl: 'FTIHX', bond: 'FXNAX' },
'iShares': { us: 'ITOT', intl: 'IXUS', bond: 'AGG' }
},
init() {
const saved = localStorage.getItem('bogle3-allocation');
if (saved) {
try {
const data = JSON.parse(saved);
if (data.age != null) this.age = data.age;
if (data.stocksPercent != null) this.stocksPercent = data.stocksPercent;
if (data.intlPercentOfStocks != null) this.intlPercentOfStocks = data.intlPercentOfStocks;
if (data.selectedBroker != null) this.selectedBroker = data.selectedBroker;
} catch (e) {
console.error('Failed to load saved allocation:', e);
}
}
// Debounced auto-apply for age
let ageTimeout;
this.$watch('age', (val) => {
this.saveAllocation();
clearTimeout(ageTimeout);
ageTimeout = setTimeout(() => {
this.setAllocationFromAge();
}, 500);
});
this.$watch('stocksPercent', () => this.saveAllocation());
this.$watch('intlPercentOfStocks', () => this.saveAllocation());
this.$watch('selectedBroker', () => this.saveAllocation());
},
saveAllocation() {
const data = {
age: this.age,
stocksPercent: this.stocksPercent,
intlPercentOfStocks: this.intlPercentOfStocks,
selectedBroker: this.selectedBroker,
version: '2.3'
};
localStorage.setItem('bogle3-allocation', JSON.stringify(data));
},
resetAllocation() {
this.age = DEFAULTS.age;
this.stocksPercent = DEFAULTS.stocksPercent;
this.intlPercentOfStocks = DEFAULTS.intlPercentOfStocks;
this.saveAllocation();
},
get usTicker() {
return this.brokers[this.selectedBroker].us;
},
get intlTicker() {
return this.brokers[this.selectedBroker].intl;
},
get bondTicker() {
return this.brokers[this.selectedBroker].bond;
},
setAllocationFromAge() {
const ageNum = parseInt(this.age) || 40;
// Clamp between 20% and 90% stocks (must have at least some of all 3 funds)
this.stocksPercent = Math.max(20, Math.min(90, 100 - ageNum));
},
get usStockPercent() {
return Math.round(this.stocksPercent * (1 - this.intlPercentOfStocks / 100));
},
get intlStockPercent() {
return Math.round(this.stocksPercent * (this.intlPercentOfStocks / 100));
},
get usStockAmount() {
return Math.round(this.totalAmount * (this.usStockPercent / 100));
},
get intlStockAmount() {
return Math.round(this.totalAmount * (this.intlStockPercent / 100));
},
get bondAmount() {
return this.totalAmount - this.usStockAmount - this.intlStockAmount;
},
formatCurrency(amount) {
return new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 0,
maximumFractionDigits: 0
}).format(amount);
}
};
}
</script>
</body>
</html>