export function investorTypeQuiz(form: FormTs) {
form.setTitle(() => '💰 What Type of Investor Are You?');
// ========== STATE ==========
type InvestorType = 'conservative' | 'moderate' | 'growth' | 'aggressive' | 'speculative';
const scores = form.state<Record<InvestorType, number>>({
conservative: 0,
moderate: 0,
growth: 0,
aggressive: 0,
speculative: 0
});
// ========== SCORING FUNCTIONS ==========
const updateScore = (type: InvestorType, points: number) => {
scores.update(current => ({
...current,
[type]: (current[type] || 0) + points
}));
};
const getTopType = (): InvestorType => {
const s = scores();
const entries = Object.entries(s) as [InvestorType, number][];
const sorted = entries.sort((a, b) => b[1] - a[1]);
return sorted[0]?.[0] || 'moderate';
};
const getSecondaryType = (): InvestorType => {
const s = scores();
const top = getTopType();
const entries = Object.entries(s) as [InvestorType, number][];
const filtered = entries.filter(e => e[0] !== top);
const sorted = filtered.sort((a, b) => b[1] - a[1]);
return sorted[0]?.[0] || 'moderate';
};
type TypeInfo = {
emoji: string;
title: string;
tagline: string;
description: string;
allocation: string;
riskLevel: string;
timeHorizon: string;
};
const typeInfo: Record<InvestorType, TypeInfo> = {
conservative: {
emoji: '🛡️',
title: 'The Guardian',
tagline: 'Safety First, Always',
description: 'You prioritize capital preservation above all else. Sleep well at night knowing your investments are secure.',
allocation: '70-80% Bonds, 20-30% Stocks',
riskLevel: 'Low',
timeHorizon: 'Short to Medium (1-5 years)'
},
moderate: {
emoji: '⚖️',
title: 'The Balancer',
tagline: 'Steady and Sensible',
description: 'You seek a balanced approach, accepting some risk for better returns while maintaining stability.',
allocation: '40-60% Stocks, 40-60% Bonds',
riskLevel: 'Moderate',
timeHorizon: 'Medium (5-10 years)'
},
growth: {
emoji: '📈',
title: 'The Builder',
tagline: 'Growing Wealth Steadily',
description: 'You focus on long-term growth, comfortable with market volatility for higher potential returns.',
allocation: '70-80% Stocks, 20-30% Bonds',
riskLevel: 'Moderate-High',
timeHorizon: 'Long (10-20 years)'
},
aggressive: {
emoji: '🚀',
title: 'The Accelerator',
tagline: 'Maximum Growth Potential',
description: 'You pursue maximum returns and can handle significant volatility. Time is on your side.',
allocation: '90-100% Stocks, 0-10% Bonds',
riskLevel: 'High',
timeHorizon: 'Very Long (20+ years)'
},
speculative: {
emoji: '🎯',
title: 'The Opportunist',
tagline: 'High Risk, High Reward',
description: 'You actively seek asymmetric opportunities - crypto, startups, options. You understand most will fail but some will soar.',
allocation: 'Varies: Crypto, Startups, Options',
riskLevel: 'Very High',
timeHorizon: 'Varies by opportunity'
}
};
const getTypeInfo = (type: InvestorType): TypeInfo => typeInfo[type];
// ========== COMPLETION SCREEN ==========
form.configureCompletionScreen({
type: 'text',
title: () => `${getTypeInfo(getTopType()).emoji} You're ${getTypeInfo(getTopType()).title}!`,
message: () => `${getTypeInfo(getTopType()).description} Check your email for your complete investor profile and personalized portfolio recommendations.`
});
// ========== PAGES ==========
const pages = form.addPages('quiz-pages', { heightMode: 'current-page' });
// ========== PAGE 1: Risk Tolerance ==========
const page1 = pages.addPage('risk-tolerance', { mobileBreakpoint: 500 });
page1.addRow(row => {
row.addTextPanel('header1', {
label: 'Step 1 of 5: Risk Tolerance',
computedValue: () => 'How do you handle investment risk?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page1.addSpacer({ height: '24px' });
page1.addRow(row => {
row.addRadioButton('marketDrop', {
label: 'Your portfolio drops 20% in a month. What do you do?',
options: [
{ id: 'sell', name: '🛡️ Sell everything - I can\'t handle this' },
{ id: 'some', name: '⚖️ Sell some to reduce exposure' },
{ id: 'hold', name: '📈 Hold and wait for recovery' },
{ id: 'buy', name: '🚀 Buy more - great opportunity!' },
{ id: 'double', name: '🎯 Double down aggressively' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'sell') updateScore('conservative', 5);
else if (v === 'some') updateScore('moderate', 5);
else if (v === 'hold') updateScore('growth', 5);
else if (v === 'buy') updateScore('aggressive', 5);
else if (v === 'double') updateScore('speculative', 5);
}
});
});
page1.addRow(row => {
row.addRatingScale('volatility', {
label: 'How comfortable are you with investment volatility?',
preset: 'custom',
min: 1,
max: 5,
lowLabel: 'Very uncomfortable',
highLabel: 'Very comfortable',
onValueChange: (v) => {
if (v === 1) updateScore('conservative', 4);
else if (v === 2) updateScore('moderate', 4);
else if (v === 3) updateScore('growth', 4);
else if (v === 4) updateScore('aggressive', 4);
else if (v === 5) updateScore('speculative', 4);
}
});
});
// ========== PAGE 2: Time Horizon ==========
const page2 = pages.addPage('time-horizon', { mobileBreakpoint: 500 });
page2.addRow(row => {
row.addTextPanel('header2', {
label: 'Step 2 of 5: Time Horizon',
computedValue: () => 'When will you need this money?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page2.addSpacer({ height: '24px' });
page2.addRow(row => {
row.addRadioButton('timeline', {
label: 'When do you plan to use these investments?',
options: [
{ id: 'short', name: 'Within 1-3 years' },
{ id: 'medium', name: '3-7 years' },
{ id: 'long', name: '7-15 years' },
{ id: 'verylong', name: '15-25 years' },
{ id: 'retirement', name: '25+ years (retirement)' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'short') updateScore('conservative', 5);
else if (v === 'medium') updateScore('moderate', 5);
else if (v === 'long') updateScore('growth', 5);
else if (v === 'verylong') updateScore('aggressive', 5);
else if (v === 'retirement') updateScore('aggressive', 3);
}
});
});
page2.addRow(row => {
row.addRadioButton('age', {
label: 'What\'s your age range?',
options: [
{ id: 'young', name: '18-30 years old' },
{ id: 'earlycareer', name: '31-40 years old' },
{ id: 'midcareer', name: '41-50 years old' },
{ id: 'preretire', name: '51-60 years old' },
{ id: 'retire', name: '60+ years old' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'young') { updateScore('aggressive', 3); updateScore('speculative', 2); }
else if (v === 'earlycareer') updateScore('growth', 4);
else if (v === 'midcareer') updateScore('moderate', 4);
else if (v === 'preretire') { updateScore('moderate', 3); updateScore('conservative', 2); }
else if (v === 'retire') updateScore('conservative', 5);
}
});
});
// ========== PAGE 3: Goals ==========
const page3 = pages.addPage('goals', { mobileBreakpoint: 500 });
page3.addRow(row => {
row.addTextPanel('header3', {
label: 'Step 3 of 5: Investment Goals',
computedValue: () => 'What are you investing for?',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page3.addSpacer({ height: '24px' });
page3.addRow(row => {
row.addRadioButton('primaryGoal', {
label: 'What\'s your primary investment goal?',
options: [
{ id: 'preserve', name: '🛡️ Preserve capital and beat inflation' },
{ id: 'income', name: '⚖️ Generate steady income (dividends)' },
{ id: 'grow', name: '📈 Grow wealth for future goals' },
{ id: 'maximize', name: '🚀 Maximize long-term returns' },
{ id: 'moonshot', name: '🎯 Find the next 10x opportunity' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'preserve') updateScore('conservative', 5);
else if (v === 'income') updateScore('moderate', 5);
else if (v === 'grow') updateScore('growth', 5);
else if (v === 'maximize') updateScore('aggressive', 5);
else if (v === 'moonshot') updateScore('speculative', 5);
}
});
});
page3.addRow(row => {
row.addSuggestionChips('interests', {
label: 'What investment types interest you? (Select all)',
suggestions: [
{ id: 'bonds', name: '🏛️ Bonds' },
{ id: 'index', name: '📊 Index Funds' },
{ id: 'stocks', name: '📈 Individual Stocks' },
{ id: 'realestate', name: '🏠 Real Estate' },
{ id: 'crypto', name: '₿ Cryptocurrency' },
{ id: 'startups', name: '🚀 Startups/VC' }
],
onValueChange: (v) => {
const picks = v || [];
if (picks.includes('bonds')) updateScore('conservative', 2);
if (picks.includes('index')) updateScore('moderate', 2);
if (picks.includes('stocks')) updateScore('growth', 2);
if (picks.includes('realestate')) updateScore('growth', 1);
if (picks.includes('crypto')) updateScore('speculative', 3);
if (picks.includes('startups')) updateScore('speculative', 3);
}
});
});
// ========== PAGE 4: Experience ==========
const page4 = pages.addPage('experience', { mobileBreakpoint: 500 });
page4.addRow(row => {
row.addTextPanel('header4', {
label: 'Step 4 of 5: Investment Experience',
computedValue: () => 'Tell us about your investing background',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page4.addSpacer({ height: '24px' });
page4.addRow(row => {
row.addRadioButton('experience', {
label: 'How would you describe your investing experience?',
options: [
{ id: 'none', name: 'Beginner - just starting out' },
{ id: 'some', name: 'Some experience - invested for a few years' },
{ id: 'intermediate', name: 'Intermediate - comfortable with markets' },
{ id: 'advanced', name: 'Advanced - active investor' },
{ id: 'expert', name: 'Expert - professional/full-time' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'none') updateScore('conservative', 3);
else if (v === 'some') updateScore('moderate', 3);
else if (v === 'intermediate') updateScore('growth', 3);
else if (v === 'advanced') updateScore('aggressive', 3);
else if (v === 'expert') updateScore('speculative', 2);
}
});
});
page4.addRow(row => {
row.addRadioButton('lossExperience', {
label: 'Have you experienced significant investment losses?',
options: [
{ id: 'no', name: 'No, and I want to avoid them' },
{ id: 'small', name: 'Small losses - it was uncomfortable' },
{ id: 'medium', name: 'Yes, but I learned from them' },
{ id: 'large', name: 'Yes, large losses - I recovered and continue' }
],
orientation: 'vertical',
onValueChange: (v) => {
if (v === 'no') updateScore('conservative', 3);
else if (v === 'small') updateScore('moderate', 3);
else if (v === 'medium') updateScore('growth', 3);
else if (v === 'large') updateScore('aggressive', 3);
}
});
});
// ========== PAGE 5: Results ==========
const page5 = pages.addPage('results', { mobileBreakpoint: 500 });
page5.addRow(row => {
row.addTextPanel('header5', {
label: 'Step 5 of 5: Your Investor Profile',
computedValue: () => 'Discover your investing personality',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page5.addSpacer({ height: '24px' });
page5.addRow(row => {
row.addTextPanel('mainResult', {
label: '',
computedValue: () => {
const info = getTypeInfo(getTopType());
return `${info.emoji} You're ${info.title}!`;
},
customStyles: {
fontSize: '32px',
fontWeight: 'bold',
textAlign: 'center',
padding: '20px',
borderRadius: '12px',
color: '#059669',
background: '#ecfdf5'
}
});
});
page5.addRow(row => {
row.addTextPanel('tagline', {
label: '',
computedValue: () => getTypeInfo(getTopType()).tagline,
customStyles: { textAlign: 'center', fontStyle: 'italic', fontSize: '18px', padding: '10px' }
});
});
page5.addRow(row => {
row.addTextPanel('description', {
label: '',
computedValue: () => getTypeInfo(getTopType()).description,
customStyles: { textAlign: 'center', padding: '15px', background: '#f9fafb', borderRadius: '8px' }
});
});
const detailsSection = page5.addSubform('allocationDetails', {
title: '📊 Your Recommended Allocation (click to expand)',
isCollapsible: true,
customStyles: { background: '#f9fafb', borderRadius: '8px', marginTop: '20px' }
});
detailsSection.addRow(row => {
row.addTextPanel('allocation', {
label: '💼 Suggested Allocation',
computedValue: () => getTypeInfo(getTopType()).allocation
});
});
detailsSection.addRow(row => {
row.addTextPanel('risk', {
label: '⚠️ Risk Level',
computedValue: () => getTypeInfo(getTopType()).riskLevel
});
});
detailsSection.addRow(row => {
row.addTextPanel('horizon', {
label: '⏱️ Ideal Time Horizon',
computedValue: () => getTypeInfo(getTopType()).timeHorizon
});
});
page5.addRow(row => {
row.addTextPanel('secondary', {
label: '',
computedValue: () => {
const secondary = getSecondaryType();
const info = getTypeInfo(secondary);
return `Your secondary type is ${info.emoji} ${info.title}`;
},
customStyles: { textAlign: 'center', fontStyle: 'italic', padding: '15px', marginTop: '10px' }
});
});
// ========== PAGE 6: Lead Capture ==========
const page6 = pages.addPage('lead-capture', { mobileBreakpoint: 500 });
page6.addRow(row => {
row.addTextPanel('header6', {
label: 'Get Your Complete Investor Profile',
computedValue: () => 'Receive personalized portfolio recommendations',
customStyles: { fontSize: '0.9rem', color: '#6b7280', marginBottom: '1rem' }
});
});
page6.addSpacer({ height: '24px' });
page6.addRow(row => {
row.addTextbox('name', { label: 'Your Name', isRequired: true, placeholder: 'John Smith' }, '1fr');
row.addEmail('email', { label: 'Email', isRequired: true, placeholder: 'john@email.com' }, '1fr');
});
page6.addRow(row => {
row.addDropdown('investmentAmount', {
label: 'Approximate investment amount',
options: [
{ id: 'starter', name: 'Under $10,000' },
{ id: 'growing', name: '$10,000 - $50,000' },
{ id: 'substantial', name: '$50,000 - $250,000' },
{ id: 'significant', name: '$250,000 - $1M' },
{ id: 'hnw', name: 'Over $1M' }
]
}, '1fr');
row.addEmpty('1fr');
});
page6.addRow(row => {
row.addCheckboxList('consent', {
options: [
{ id: 'report', name: '📄 Send me my investor profile report', isRequired: true },
{ id: 'portfolio', name: '💼 Include sample portfolio allocations' },
{ id: 'advisor', name: '📞 Connect me with a financial advisor' }
],
defaultValue: ['report'],
orientation: 'vertical'
});
});
// ========== SUBMIT BUTTON ==========
form.configureSubmitButton({
label: () => `💰 Get My ${getTypeInfo(getTopType()).title} Profile`
});
// ========== PDF REPORT ==========
form.configurePdf('investor-profile', pdf => {
pdf.configure({
filename: 'investor-type-profile.pdf',
pageSize: 'A4',
allowUserDownload: true,
downloadButtonLabel: '💰 Download Investor Profile',
header: {
title: 'Your Investor Profile',
subtitle: 'Personalized Investment Analysis'
},
footer: {
text: 'For educational purposes only. Consult a financial advisor.',
showPageNumbers: true
}
});
const topType = getTopType();
const info = getTypeInfo(topType);
pdf.addSection('Your Investor Type', section => {
section.addRow(row => {
row.addField('Profile', `${info.emoji} ${info.title}`);
row.addField('Risk Level', info.riskLevel);
});
section.addText(info.description);
});
pdf.addSection('Recommended Allocation', section => {
section.addRow(row => {
row.addField('Suggested Mix', info.allocation);
});
section.addRow(row => {
row.addField('Time Horizon', info.timeHorizon);
});
});
pdf.addPageBreak();
pdf.addSection('Getting Started', section => {
section.addText('1. Start with low-cost index funds to build your core portfolio');
section.addText('2. Diversify across asset classes and geographies');
section.addText('3. Rebalance annually to maintain your target allocation');
section.addText('4. Consider tax-advantaged accounts (401k, IRA)');
section.addText('5. Review and adjust as your goals change');
});
pdf.addSection('Disclaimer', section => {
section.addText('This quiz is for educational and entertainment purposes only. It does not constitute financial advice. Please consult with a qualified financial advisor before making investment decisions.');
});
});
form.configureSubmitBehavior({ sendToServer: true });
}