-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecision-tree.html
More file actions
555 lines (536 loc) · 32.4 KB
/
Copy pathdecision-tree.html
File metadata and controls
555 lines (536 loc) · 32.4 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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Investment Decision Tree — Should You Buy, Hold, or Sell? | KeepRule Tools</title>
<meta name="description" content="Free investment decision tool. Walk through an interactive decision tree to determine whether to buy, hold, or sell any stock. Based on Buffett's investing principles.">
<meta name="keywords" content="should I buy this stock, investment decision tool, buy hold sell decision, stock analysis framework, Warren Buffett decision making">
<link rel="canonical" href="https://henu-wang.github.io/keeprule-tools/decision-tree.html">
<meta property="og:title" content="Investment Decision Tree — Should You Buy, Hold, or Sell?">
<meta property="og:description" content="Walk through an interactive decision framework used by the world's best investors. Get a buy, hold, or sell recommendation.">
<meta property="og:type" content="website">
<meta name="twitter:card" content="summary_large_image">
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
background: #0a0e17;
color: #e0e0e0;
min-height: 100vh;
}
.nav { padding: 16px 20px; border-bottom: 1px solid rgba(99,179,237,0.1); }
.nav a { color: #63b3ed; text-decoration: none; font-size: 0.9rem; }
.nav a:hover { text-decoration: underline; }
.container { max-width: 720px; margin: 0 auto; padding: 40px 20px 60px; }
h1 {
font-size: 2rem;
font-weight: 700;
background: linear-gradient(135deg, #b794f6, #63b3ed);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 8px;
}
.subtitle { color: #94a3b8; font-size: 1.05rem; margin-bottom: 12px; line-height: 1.5; }
.stock-input-row {
display: flex;
gap: 12px;
margin-bottom: 32px;
align-items: center;
}
.stock-input-row input {
flex: 1;
padding: 12px 16px;
background: #0d1117;
border: 1px solid rgba(99,179,237,0.2);
border-radius: 10px;
color: #e0e0e0;
font-size: 1rem;
outline: none;
}
.stock-input-row input:focus { border-color: #63b3ed; }
.stock-input-row input::placeholder { color: #4a5568; }
.path-breadcrumb {
display: flex;
flex-wrap: wrap;
gap: 6px;
margin-bottom: 20px;
min-height: 28px;
}
.path-step {
font-size: 0.75rem;
padding: 4px 10px;
background: rgba(183,148,246,0.1);
border: 1px solid rgba(183,148,246,0.2);
border-radius: 12px;
color: #b794f6;
}
.node-card {
background: linear-gradient(145deg, #131825, #1a2035);
border: 1px solid rgba(99,179,237,0.12);
border-radius: 14px;
padding: 28px 24px;
margin-bottom: 20px;
animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.node-step { color: #64748b; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.node-question { font-size: 1.2rem; color: #f0f0f0; font-weight: 600; margin-bottom: 8px; line-height: 1.45; }
.node-context { color: #94a3b8; font-size: 0.9rem; margin-bottom: 20px; line-height: 1.5; }
.node-options { display: flex; flex-direction: column; gap: 10px; }
.node-opt {
padding: 14px 18px;
background: #0d1117;
border: 1px solid rgba(99,179,237,0.15);
border-radius: 10px;
color: #e0e0e0;
cursor: pointer;
font-size: 0.95rem;
text-align: left;
transition: all 0.2s;
display: flex;
align-items: center;
gap: 10px;
}
.node-opt:hover { border-color: #b794f6; background: rgba(183,148,246,0.06); }
.node-opt .opt-icon { font-size: 1.1rem; }
.back-btn {
background: none;
border: 1px solid rgba(99,179,237,0.2);
color: #94a3b8;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
font-size: 0.85rem;
margin-top: 12px;
transition: all 0.2s;
}
.back-btn:hover { border-color: #63b3ed; color: #63b3ed; }
/* Result */
.result-card {
text-align: center;
padding: 36px 24px;
background: linear-gradient(145deg, #131825, #1a2035);
border: 1px solid rgba(99,179,237,0.12);
border-radius: 16px;
margin-bottom: 24px;
animation: fadeIn 0.4s ease;
}
.result-icon { font-size: 3rem; margin-bottom: 12px; }
.result-action { font-size: 2rem; font-weight: 800; margin-bottom: 8px; }
.result-buy { color: #68d391; }
.result-hold { color: #63b3ed; }
.result-sell { color: #fc8181; }
.result-avoid { color: #f6ad55; }
.result-desc { color: #94a3b8; font-size: 1rem; line-height: 1.5; max-width: 500px; margin: 0 auto; }
.principle-card {
background: linear-gradient(145deg, #131825, #1a2035);
border: 1px solid rgba(99,179,237,0.12);
border-radius: 12px;
padding: 20px;
margin-bottom: 12px;
}
.principle-card h3 { font-size: 0.95rem; color: #f0f0f0; margin-bottom: 8px; }
.principle-card p { color: #94a3b8; font-size: 0.9rem; line-height: 1.55; }
.principle-card .pq {
margin-top: 10px;
padding: 10px 14px;
background: rgba(183,148,246,0.06);
border-left: 3px solid #b794f6;
border-radius: 0 8px 8px 0;
font-style: italic;
color: #b0bec5;
font-size: 0.85rem;
}
.path-summary {
background: rgba(183,148,246,0.06);
border: 1px solid rgba(183,148,246,0.15);
border-radius: 12px;
padding: 16px 20px;
margin-bottom: 20px;
}
.path-summary h3 { font-size: 0.9rem; color: #b794f6; margin-bottom: 10px; }
.path-summary .step-item {
font-size: 0.85rem;
color: #94a3b8;
padding: 4px 0;
display: flex;
gap: 8px;
}
.path-summary .step-q { color: #e0e0e0; }
.share-row { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.share-btn {
padding: 8px 20px; border-radius: 8px; border: 1px solid rgba(99,179,237,0.2);
background: rgba(99,179,237,0.08); color: #63b3ed; cursor: pointer; font-size: 0.85rem; transition: all 0.2s;
}
.share-btn:hover { background: rgba(99,179,237,0.15); }
.cta-box {
text-align: center; padding: 28px;
background: linear-gradient(135deg, rgba(183,148,246,0.08), rgba(99,179,237,0.08));
border: 1px solid rgba(183,148,246,0.15); border-radius: 14px; margin-top: 32px;
}
.cta-box h3 { color: #e0e0e0; margin-bottom: 8px; }
.cta-box p { color: #94a3b8; font-size: 0.9rem; margin-bottom: 14px; }
.cta-link {
display: inline-block; padding: 10px 28px;
background: linear-gradient(135deg, #b794f6, #63b3ed);
color: #0a0e17; font-weight: 600; border-radius: 8px; text-decoration: none;
}
@media (max-width: 600px) { h1 { font-size: 1.5rem; } }
</style>
</head>
<body>
<div class="nav">
<a href="index.html">← All Tools</a>
</div>
<div class="container">
<h1>Investment Decision Tree</h1>
<p class="subtitle">Walk through a structured decision framework inspired by the world's greatest investors. Each question narrows your path to a clear recommendation.</p>
<div class="stock-input-row">
<input type="text" id="stock-name" placeholder="What stock are you evaluating? (e.g. Apple, AAPL)" maxlength="50">
</div>
<div class="path-breadcrumb" id="breadcrumb"></div>
<div id="tree-container"></div>
<div id="result-container" style="display:none;"></div>
</div>
<script>
// Decision tree structure
const tree = {
id: 'start',
step: 'Step 1: Understanding',
question: 'Do you understand this business?',
context: 'Buffett\'s first filter: Can you explain in simple terms how this company makes money? Do you understand its products, customers, and competitive dynamics?',
options: [
{
text: 'Yes, I understand the business well',
icon: '✓',
pathLabel: 'Understand business',
next: {
id: 'moat',
step: 'Step 2: Competitive Moat',
question: 'Does this company have a durable competitive advantage?',
context: 'A moat protects a business from competition. Think: brand power (Coca-Cola), network effects (Visa), switching costs (Microsoft), cost advantages (Costco).',
options: [
{
text: 'Yes — strong and durable moat',
icon: '🏰',
pathLabel: 'Strong moat',
next: {
id: 'mgmt',
step: 'Step 3: Management Quality',
question: 'Is the management honest, competent, and shareholder-friendly?',
context: 'Look for managers who think like owners: rational capital allocation, honest communication, aligned incentives, and a track record of integrity.',
options: [
{
text: 'Yes — trustworthy and capable management',
icon: '✓',
pathLabel: 'Good management',
next: {
id: 'financials',
step: 'Step 4: Financial Health',
question: 'Are the financials strong? (Consistent earnings, low debt, high ROE)',
context: 'Buffett looks for consistent earnings growth, return on equity above 15%, manageable debt levels, and strong free cash flow generation.',
options: [
{
text: 'Yes — strong and consistent financials',
icon: '✓',
pathLabel: 'Strong financials',
next: {
id: 'valuation',
step: 'Step 5: Valuation',
question: 'Is the current price below your estimate of intrinsic value?',
context: 'The margin of safety is crucial. Buffett wants to buy dollar bills for 50-70 cents. Compare the price to your estimate of what the business is worth.',
options: [
{
text: 'Yes — significant margin of safety exists',
icon: '💰',
pathLabel: 'Undervalued',
result: 'BUY'
},
{
text: 'Fair price — close to intrinsic value',
icon: '⚖',
pathLabel: 'Fair value',
result: 'HOLD_FAIR'
},
{
text: 'No — appears overvalued',
icon: '📈',
pathLabel: 'Overvalued',
result: 'WAIT'
}
]
}
},
{
text: 'Mixed — some concerns about financials',
icon: '⚠',
pathLabel: 'Mixed financials',
next: {
id: 'fin_temp',
step: 'Step 4b: Nature of Weakness',
question: 'Are the financial issues temporary or structural?',
context: 'A temporary setback (one bad quarter, industry cycle) is very different from a structural decline (shrinking market, losing competitive position).',
options: [
{ text: 'Temporary — I see a clear path to recovery', icon: '🔄', pathLabel: 'Temporary issue', result: 'RESEARCH_MORE' },
{ text: 'Structural — fundamental deterioration', icon: '📉', pathLabel: 'Structural issue', result: 'AVOID' }
]
}
},
{
text: 'No — weak or deteriorating financials',
icon: '❌',
pathLabel: 'Weak financials',
result: 'AVOID'
}
]
}
},
{
text: 'Uncertain — I have doubts about management',
icon: '❓',
pathLabel: 'Uncertain management',
result: 'AVOID_MGMT'
},
{
text: 'No — management concerns',
icon: '❌',
pathLabel: 'Bad management',
result: 'SELL_MGMT'
}
]
}
},
{
text: 'Narrow or weakening moat',
icon: '⚠',
pathLabel: 'Weak moat',
result: 'AVOID_MOAT'
},
{
text: 'No moat — commodity business',
icon: '❌',
pathLabel: 'No moat',
result: 'SELL_COMMODITY'
}
]
}
},
{
text: 'Somewhat — I know the basics',
icon: '🤔',
pathLabel: 'Partial understanding',
result: 'STUDY_FIRST'
},
{
text: 'No — it\'s outside my circle of competence',
icon: '❌',
pathLabel: 'Don\'t understand',
result: 'PASS'
}
]
};
const results = {
BUY: {
action: 'BUY', cls: 'result-buy', icon: '✅',
desc: 'This checks all of Buffett\'s boxes: understandable business, strong moat, good management, solid financials, and available at a discount. This is a classic Buffett-style investment.',
principles: [
{ title: 'Margin of Safety', text: 'You\'ve identified a gap between price and value. This is your protection against errors in judgment and unforeseen events.', quote: '"The three most important words in investing are: margin of safety." — Benjamin Graham' },
{ title: 'Quality at a Discount', text: 'A wonderful business at a fair price beats a fair business at a wonderful price every time. You\'ve found the ideal combination.', quote: '"It\'s far better to buy a wonderful company at a fair price than a fair company at a wonderful price." — Warren Buffett' }
]
},
HOLD_FAIR: {
action: 'HOLD', cls: 'result-hold', icon: '📊',
desc: 'This is a high-quality business at a fair price. If you already own it, hold. If you don\'t own it, consider a small position or wait for a better entry point.',
principles: [
{ title: 'Fair Price for Quality', text: 'Buffett evolved from buying cheap mediocre businesses to paying fair prices for wonderful ones. This business passes the quality test.', quote: '"It\'s far better to buy a wonderful company at a fair price than a fair company at a wonderful price." — Warren Buffett' },
{ title: 'Patience', text: 'If the business is truly wonderful, time is your friend. Even at fair value, compounding by a great business creates wealth over decades.', quote: '"Our favorite holding period is forever." — Warren Buffett' }
]
},
WAIT: {
action: 'WAIT FOR BETTER PRICE', cls: 'result-hold', icon: '⏳',
desc: 'The business is excellent, but the price doesn\'t offer adequate margin of safety. Add it to your watchlist and be ready when Mr. Market offers a better deal.',
principles: [
{ title: 'Discipline Over FOMO', text: 'The hardest thing in investing is watching a great business go up while waiting for a better price. But discipline is what separates great investors from good ones.', quote: '"The stock market is designed to transfer money from the active to the patient." — Warren Buffett' },
{ title: 'Wonderful Business, Wrong Price', text: 'Keep this on your radar. Market corrections, earnings misses, or sector rotations often create temporary discounts in excellent businesses.', quote: '"Opportunities come infrequently. When it rains gold, put out the bucket, not the thimble." — Warren Buffett' }
]
},
RESEARCH_MORE: {
action: 'RESEARCH MORE', cls: 'result-hold', icon: '🔍',
desc: 'There\'s potential here, but financial concerns need resolution. Dig deeper into the temporary weakness before committing capital.',
principles: [
{ title: 'Temporary vs Permanent', text: 'Some of Buffett\'s best investments came from buying great businesses during temporary setbacks. But make sure the setback truly is temporary.', quote: '"The best thing that happens to us is when a great company gets into temporary trouble... We want to buy them when they\'re on the operating table." — Warren Buffett' }
]
},
AVOID: {
action: 'AVOID', cls: 'result-avoid', icon: '🚫',
desc: 'The fundamentals don\'t support an investment. Financial weakness combined with structural issues is a recipe for permanent capital loss.',
principles: [
{ title: 'Rule #1 and #2', text: 'Avoiding losses is more important than capturing gains. A 50% loss requires a 100% gain just to break even.', quote: '"Rule No. 1: Never lose money. Rule No. 2: Never forget Rule No. 1." — Warren Buffett' }
]
},
AVOID_MGMT: {
action: 'AVOID', cls: 'result-avoid', icon: '⚠',
desc: 'When you have doubts about management integrity or competence, it\'s better to pass. There are thousands of stocks — find one where you trust the people running it.',
principles: [
{ title: 'Trust Is Non-Negotiable', text: 'Buffett places enormous weight on management character. No amount of financial attractiveness compensates for untrustworthy leadership.', quote: '"In looking for people to hire, you look for three qualities: integrity, intelligence, and energy. And if they don\'t have the first, the other two will kill you." — Warren Buffett' }
]
},
SELL_MGMT: {
action: 'SELL', cls: 'result-sell', icon: '🚨',
desc: 'Management concerns are a serious red flag. If you own this stock, consider selling. Bad management can destroy even great businesses.',
principles: [
{ title: 'When Management Fails', text: 'A jockey matters. Even a great horse can lose with a bad rider. Management that is dishonest, incompetent, or misaligned with shareholders is a reason to exit.', quote: '"When a management with a reputation for brilliance tackles a business with a reputation for bad economics, it is the reputation of the business that remains intact." — Warren Buffett' }
]
},
AVOID_MOAT: {
action: 'AVOID', cls: 'result-avoid', icon: '⚠',
desc: 'Without a strong competitive advantage, a business will struggle to maintain profitability over time. Competition will erode returns.',
principles: [
{ title: 'No Moat, No Investment', text: 'A business without a moat is like a castle without walls. It may thrive today, but competitors will eventually break through.', quote: '"In business, I look for economic castles protected by unbreachable moats." — Warren Buffett' }
]
},
SELL_COMMODITY: {
action: 'SELL', cls: 'result-sell', icon: '📉',
desc: 'Commodity businesses without differentiation are at the mercy of supply/demand cycles. These are typically poor long-term investments.',
principles: [
{ title: 'Avoid Commodity Hell', text: 'In commodity businesses, the low-cost producer wins and everyone else suffers. Unless this is the lowest-cost operator, expect mediocre returns.', quote: '"The key to investing is determining the competitive advantage of any given company and, above all, the durability of that advantage." — Warren Buffett' }
]
},
STUDY_FIRST: {
action: 'STUDY FIRST', cls: 'result-hold', icon: '📚',
desc: 'You need deeper understanding before investing. Spend time reading annual reports, understanding the industry, and building conviction before putting money at risk.',
principles: [
{ title: 'Circle of Competence', text: 'Buffett only invests in businesses he thoroughly understands. Expanding your circle takes time, but it\'s time well spent.', quote: '"Risk comes from not knowing what you\'re doing." — Warren Buffett' },
{ title: 'Do Your Homework', text: 'Read the last 5 years of annual reports. Understand the competitive landscape. Know what could go wrong. Only then are you ready to invest.', quote: '"I insist on a lot of time being spent, almost every day, to just sit and think." — Warren Buffett' }
]
},
PASS: {
action: 'PASS', cls: 'result-avoid', icon: '🚷',
desc: 'This is outside your circle of competence. That\'s not a weakness — it\'s wisdom. Focus on businesses you understand deeply.',
principles: [
{ title: 'Stay in Your Circle', text: 'Buffett has passed on countless great businesses (like Amazon and Google) because they were outside his circle. He didn\'t need them to build enormous wealth.', quote: '"What counts for most people in investing is not how much they know, but rather how realistically they define what they don\'t know." — Warren Buffett' }
]
}
};
let path = [];
let currentNode = tree;
function getStockName() {
return document.getElementById('stock-name').value.trim() || 'this stock';
}
function renderNode(node) {
const container = document.getElementById('tree-container');
const q = node.question.replace('this company', getStockName()).replace('this business', getStockName());
container.innerHTML = `
<div class="node-card">
<div class="node-step">${node.step}</div>
<div class="node-question">${q}</div>
<div class="node-context">${node.context}</div>
<div class="node-options">
${node.options.map((o, i) => `
<button class="node-opt" onclick="selectOption(${i})">
<span class="opt-icon">${o.icon}</span>
<span>${o.text}</span>
</button>
`).join('')}
</div>
${path.length > 0 ? '<button class="back-btn" onclick="goBack()">← Go back</button>' : ''}
</div>`;
}
function renderBreadcrumb() {
const bc = document.getElementById('breadcrumb');
bc.innerHTML = path.map(p => `<span class="path-step">${p.label}</span>`).join('');
}
function selectOption(idx) {
const opt = currentNode.options[idx];
path.push({ label: opt.pathLabel, question: currentNode.question, answer: opt.text });
renderBreadcrumb();
if (opt.result) {
showResult(opt.result);
} else if (opt.next) {
currentNode = opt.next;
renderNode(currentNode);
}
}
function goBack() {
if (path.length === 0) return;
path.pop();
renderBreadcrumb();
// Replay from start
currentNode = tree;
for (const p of path) {
const opt = currentNode.options.find(o => o.pathLabel === p.label);
if (opt && opt.next) currentNode = opt.next;
}
renderNode(currentNode);
document.getElementById('result-container').style.display = 'none';
document.getElementById('tree-container').style.display = 'block';
}
function showResult(key) {
const r = results[key];
const stock = getStockName();
document.getElementById('tree-container').style.display = 'none';
const rc = document.getElementById('result-container');
rc.style.display = 'block';
const pathHtml = path.map((p, i) => `
<div class="step-item">
<span style="color:#b794f6;">${i+1}.</span>
<span><span class="step-q">${p.question}</span> → ${p.answer}</span>
</div>`).join('');
const principlesHtml = r.principles.map(p => `
<div class="principle-card">
<h3>${p.title}</h3>
<p>${p.text}</p>
<div class="pq">${p.quote}</div>
</div>`).join('');
rc.innerHTML = `
<div class="result-card">
<div class="result-icon">${r.icon}</div>
<div class="result-action ${r.cls}">${r.action}</div>
<div class="result-desc">${r.desc.replace('This', stock === 'this stock' ? 'This' : stock)}</div>
</div>
<div class="path-summary">
<h3>Your Decision Path for ${stock}</h3>
${pathHtml}
</div>
${principlesHtml}
<div class="share-row">
<button class="share-btn" onclick="shareTwitter('${r.action}')">Share on X / Twitter</button>
<button class="share-btn" onclick="copyResult('${r.action}')">Copy Results</button>
<button class="share-btn" onclick="restart()">Evaluate Another Stock</button>
</div>
<div class="cta-box">
<h3>Go Deeper with Investment Principles</h3>
<p>KeepRule organizes Buffett's, Munger's, and Graham's investment decision frameworks into actionable rules for every scenario.</p>
<a class="cta-link" href="https://keeprule.com/scenarios/evaluating-stocks?utm_source=tools&utm_medium=decision-tree&utm_campaign=result" target="_blank" rel="noopener">Explore Stock Evaluation Principles</a>
</div>`;
window._shareResult = { action: r.action, stock };
}
function shareTwitter(action) {
const s = window._shareResult;
const text = `I used the KeepRule Investment Decision Tree to evaluate ${s.stock}. Result: ${s.action}. Walk through the framework yourself:`;
const url = 'https://henu-wang.github.io/keeprule-tools/decision-tree.html';
window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}&url=${encodeURIComponent(url)}`, '_blank');
}
function copyResult(action) {
const s = window._shareResult;
const pathText = path.map((p, i) => `${i+1}. ${p.question} -> ${p.answer}`).join('\n');
const text = `Investment Decision: ${s.action} for ${s.stock}\n\nDecision Path:\n${pathText}\n\nTry it: https://henu-wang.github.io/keeprule-tools/decision-tree.html`;
navigator.clipboard.writeText(text).then(() => alert('Results copied!')).catch(() => alert('Copy failed'));
}
function restart() {
path = [];
currentNode = tree;
document.getElementById('stock-name').value = '';
document.getElementById('result-container').style.display = 'none';
document.getElementById('tree-container').style.display = 'block';
renderBreadcrumb();
renderNode(currentNode);
window.scrollTo(0, 0);
}
// Init
renderNode(tree);
</script>
</body>
</html>