Executive Code: Macro Economic Forecasting Program and Reporting
import React, { useState } from 'react';
import { TrendingUp, AlertTriangle, DollarSign, BarChart3, Calendar, Globe } from 'lucide-react';
export default function MacroForecastGame() {
const [country, setCountry] = useState('United States');
const [isAnalyzing, setIsAnalyzing] = useState(false);
const [analysis, setAnalysis] = useState(null);
const [error, setError] = useState(null);
const countries = [
'United States', 'United Kingdom', 'Germany', 'France', 'Japan',
'China', 'India', 'Brazil', 'Canada', 'Australia', 'South Korea',
'Mexico', 'Italy', 'Spain', 'Netherlands'
];
const analyzeEconomy = async () => {
setIsAnalyzing(true);
setError(null);
setAnalysis(null);
try {
const prompt = `You are an expert macroeconomic analyst. Analyze the current economic situation for ${country} and provide forecasts using validated econometric models.
# DATA SOURCES TO USE:
- FRED (Federal Reserve Economic Data): https://fred.stlouisfed.org - US data
- Trading Economics: https://tradingeconomics.com/${country.toLowerCase().replace(' ', '-')} - Global indicators
- OECD Data: https://data.oecd.org - International statistics
- National central bank websites for policy rates
- Bloomberg/Reuters for current market data
# CRITICAL INSTRUCTIONS:
1. Use web_search to gather CURRENT data for ${country}:
- 10-Year government bond yield
- 3-Month treasury bill rate
- Corporate bond yield (BBB or equivalent)
- Current inflation rate (CPI year-over-year)
- Unemployment rate
- Latest quarterly GDP growth (annualized)
- Central bank policy rate
- Debt-to-GDP ratio
- Real interest rate (nominal rate - inflation)
- If available: Leading Economic Index (LEI), M2/Reserves ratio, current account balance
2. Apply these EXACT MODELS with their equations:
## MODEL 1: YIELD CURVE SPREAD
Equation: Spread = Yield(10Y) - Yield(3M)
Rule: IF Spread < 0 (inverted) THEN recession signal
Calculate the spread and assess if curve is inverted, flat, normal, or steep.
## MODEL 2: PROBIT RECESSION PROBABILITY
Equation: P(Recession) = Φ(β₀ + β₁·YieldSpread + β₂·CreditSpread + β₃·LEI + β₄·Inflation + β₅·Unemployment)
Use typical coefficients: β₀=-1.2, β₁=-0.4, β₂=0.3, β₃=-0.02, β₄=0.05, β₅=0.15
Calculate credit spread as: CorporateBondYield - 10YearYield
## MODEL 3: TAYLOR RULE
Equation: i(t) = 2.0 + π(t) + 1.5[π(t) - 2.0] + 0.5(OutputGap)
Compare actual policy rate to Taylor Rule prescription to determine if policy is "too tight", "appropriate", or "too loose"
Estimate output gap using: (ActualGDP - PotentialGDP)/PotentialGDP ≈ (UnemploymentRate - NAIRU)*-2
Use NAIRU ≈ 4.5% for developed economies
## MODEL 4: PHILLIPS CURVE (for inflation forecasting)
Equation: π(t+1) = 0.7·π(t) + 0.2·(u - u*) + supply_shocks
Use current inflation, unemployment gap, and recent supply factors
## MODEL 5: SOVEREIGN DEFAULT RISK (for emerging markets)
If DebtToGDP > 80% or inflation > 10%, assess elevated risk
Rule: IF (DebtToGDP > 50% AND Inflation > 20%) THEN HighRisk
3. Generate forecasts for 6, 12, 18, and 24 months using model outputs
4. REPORT FORMAT: Write each section as 1-2 sentence paragraphs discussing the model results.
5. YOU MUST RESPOND WITH ONLY VALID JSON - NO OTHER TEXT:
{
"country": "${country}",
"analysisDate": "YYYY-MM-DD",
"dataSources": ["source1 URL", "source2 URL"],
"currentIndicators": {
"yieldSpread": number (can be negative),
"creditSpread": number,
"inflation": number,
"unemployment": number,
"gdpGrowth": number,
"policyRate": number,
"debtToGDP": number,
"tenYearYield": number,
"threeMonthYield": number
},
"modelResults": {
"yieldCurveAnalysis": "1-2 sentence paragraph discussing the yield curve spread calculation, whether it's inverted, and what this signals about recession risk based on the Yield Curve Spread model",
"probitRecessionProb": "1-2 sentence paragraph explaining the Probit model calculation using yield spread, credit spread, inflation, and unemployment, stating the probability and what it means",
"taylorRuleAnalysis": "1-2 sentence paragraph showing the Taylor Rule calculation, comparing actual policy rate to the rule's prescription, and assessing if policy is too tight or too loose",
"phillipsCurveInflation": "1-2 sentence paragraph using the Phillips Curve to forecast inflation based on unemployment gap and current inflation momentum",
"sovereignRiskAssessment": "1-2 sentence paragraph evaluating sovereign default risk using debt-to-GDP and inflation thresholds (if applicable for the country)"
},
"forecasts": {
"6month": {
"recessionProb": number (0-100),
"stagflationProb": number (0-100),
"depressionProb": number (0-100),
"inflationForecast": number,
"gdpGrowthForecast": number,
"confidence": "high" | "medium" | "low",
"rationale": "1-2 sentence paragraph explaining how the models led to these forecasts"
},
"12month": { same structure },
"18month": { same structure },
"24month": { same structure }
},
"keyRisks": ["risk1", "risk2", "risk3"],
"modelSignals": {
"yieldCurve": "inverted" | "flat" | "normal" | "steep",
"taylorRule": "too tight" | "appropriate" | "too loose",
"creditConditions": "stressed" | "normal" | "loose",
"probitRecessionProb": number
},
"bottomLine": "2-3 sentence paragraph that synthesizes ALL model results into an integrated view of the country's economic outlook. This should weave together insights from the yield curve, probit model, Taylor Rule, Phillips Curve, and sovereign risk assessment into a coherent overall picture. The bottom line should answer: What is the unified story these models tell about where this economy is headed?",
"executiveSummary": "2-3 sentence paragraph synthesizing all model results into an overall economic outlook"
}
DO NOT include any markdown, explanations, or text outside the JSON object. The response must be parseable by JSON.parse().`;
const response = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "claude-sonnet-4-20250514",
max_tokens: 4000,
messages: [
{ role: "user", content: prompt }
]
})
});
if (!response.ok) {
throw new Error(`API request failed: ${response.status}`);
}
const data = await response.json();
let responseText = data.content[0].text;
// Strip any markdown formatting
responseText = responseText.replace(/```json\n?/g, "").replace(/```\n?/g, "").trim();
const analysisData = JSON.parse(responseText);
setAnalysis(analysisData);
} catch (err) {
console.error("Error:", err);
setError(`Analysis failed: ${err.message}. Please try again.`);
} finally {
setIsAnalyzing(false);
}
};
const getRiskColor = (prob) => {
if (prob > 60) return 'text-red-600 font-bold';
if (prob > 30) return 'text-yellow-600 font-semibold';
return 'text-green-600';
};
const getYieldCurveColor = (signal) => {
if (signal === 'inverted') return 'text-red-600';
if (signal === 'flat') return 'text-yellow-600';
return 'text-green-600';
};
return (
<div className="min-h-screen bg-gradient-to-br from-slate-900 via-blue-900 to-slate-900 p-8">
<div className="max-w-6xl mx-auto">
{/* Header */}
<div className="text-center mb-8">
<h1 className="text-5xl font-bold text-white mb-3 flex items-center justify-center gap-3">
<TrendingUp className="w-12 h-12 text-blue-400" />
Economic Oracle
</h1>
<p className="text-blue-200 text-lg">
AI-Powered Macroeconomic Forecasting Game
</p>
<p className="text-slate-300 text-sm mt-2">
Using 9 validated models to predict economic outcomes
</p>
</div>
{/* Input Section */}
<div className="bg-white rounded-xl shadow-2xl p-8 mb-8">
<div className="flex items-center gap-3 mb-4">
<Globe className="w-6 h-6 text-blue-600" />
<h2 className="text-2xl font-bold text-slate-800">Select Country</h2>
</div>
<div className="flex gap-4 items-end">
<div className="flex-1">
<label className="block text-sm font-medium text-slate-700 mb-2">
Country to Analyze
</label>
<select
value={country}
onChange={(e) => setCountry(e.target.value)}
className="w-full px-4 py-3 border-2 border-slate-300 rounded-lg focus:outline-none focus:border-blue-500 text-lg"
disabled={isAnalyzing}
>
{countries.map(c => (
<option key={c} value={c}>{c}</option>
))}
</select>
</div>
<button
onClick={analyzeEconomy}
disabled={isAnalyzing}
className="px-8 py-3 bg-blue-600 text-white rounded-lg font-semibold hover:bg-blue-700 disabled:bg-slate-400 disabled:cursor-not-allowed transition-colors shadow-lg"
>
{isAnalyzing ? 'Analyzing...' : 'Generate Forecast'}
</button>
</div>
{isAnalyzing && (
<div className="mt-6 bg-blue-50 border border-blue-200 rounded-lg p-4">
<div className="flex items-center gap-3">
<div className="animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"></div>
<p className="text-blue-800 font-medium">
Gathering real-time economic data and running models...
</p>
</div>
</div>
)}
{error && (
<div className="mt-6 bg-red-50 border border-red-200 rounded-lg p-4">
<p className="text-red-800">{error}</p>
</div>
)}
</div>
{/* Results Section */}
{analysis && (
<div className="space-y-6">
{/* Data Sources */}
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-xl font-bold text-slate-800 mb-3">Data Sources</h3>
<div className="flex flex-wrap gap-2">
{analysis.dataSources?.map((source, idx) => (
<span key={idx} className="text-sm bg-blue-100 text-blue-800 px-3 py-1 rounded-full">
{source}
</span>
))}
</div>
</div>
{/* Current Indicators */}
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-2xl font-bold text-slate-800 mb-4 flex items-center gap-2">
<BarChart3 className="w-6 h-6 text-blue-600" />
Current Economic Indicators
</h3>
<div className="grid grid-cols-2 md:grid-cols-4 gap-4">
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">10Y Yield</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.tenYearYield?.toFixed(2)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">3M Yield</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.threeMonthYield?.toFixed(2)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">Yield Spread (10Y-3M)</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.yieldSpread?.toFixed(2)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">Credit Spread</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.creditSpread?.toFixed(2)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">Inflation (CPI)</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.inflation?.toFixed(1)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">Unemployment</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.unemployment?.toFixed(1)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">GDP Growth</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.gdpGrowth?.toFixed(1)}%
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600">Policy Rate</p>
<p className="text-2xl font-bold text-slate-800">
{analysis.currentIndicators.policyRate?.toFixed(2)}%
</p>
</div>
</div>
</div>
{/* Model Analysis Section */}
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-2xl font-bold text-slate-800 mb-4">Econometric Model Analysis</h3>
<div className="space-y-4">
<div className="border-l-4 border-blue-500 pl-4 bg-blue-50 p-4 rounded-r-lg">
<h4 className="font-bold text-slate-800 mb-2">1. Yield Curve Spread Model</h4>
<p className="text-slate-700 leading-relaxed">{analysis.modelResults?.yieldCurveAnalysis}</p>
</div>
<div className="border-l-4 border-purple-500 pl-4 bg-purple-50 p-4 rounded-r-lg">
<h4 className="font-bold text-slate-800 mb-2">2. Probit Recession Probability Model</h4>
<p className="text-slate-700 leading-relaxed">{analysis.modelResults?.probitRecessionProb}</p>
</div>
<div className="border-l-4 border-green-500 pl-4 bg-green-50 p-4 rounded-r-lg">
<h4 className="font-bold text-slate-800 mb-2">3. Taylor Rule (Monetary Policy Stance)</h4>
<p className="text-slate-700 leading-relaxed">{analysis.modelResults?.taylorRuleAnalysis}</p>
</div>
<div className="border-l-4 border-yellow-500 pl-4 bg-yellow-50 p-4 rounded-r-lg">
<h4 className="font-bold text-slate-800 mb-2">4. Phillips Curve (Inflation Forecast)</h4>
<p className="text-slate-700 leading-relaxed">{analysis.modelResults?.phillipsCurveInflation}</p>
</div>
{analysis.modelResults?.sovereignRiskAssessment && (
<div className="border-l-4 border-red-500 pl-4 bg-red-50 p-4 rounded-r-lg">
<h4 className="font-bold text-slate-800 mb-2">5. Sovereign Default Risk Model</h4>
<p className="text-slate-700 leading-relaxed">{analysis.modelResults.sovereignRiskAssessment}</p>
</div>
)}
</div>
</div>
{/* Model Signals */}
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-2xl font-bold text-slate-800 mb-4">Model Signals Summary</h3>
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600 mb-1">Yield Curve</p>
<p className={`text-xl font-bold capitalize ${getYieldCurveColor(analysis.modelSignals.yieldCurve)}`}>
{analysis.modelSignals.yieldCurve}
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600 mb-1">Policy Stance</p>
<p className="text-xl font-bold text-slate-800 capitalize">
{analysis.modelSignals.taylorRule}
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600 mb-1">Credit Conditions</p>
<p className="text-xl font-bold text-slate-800 capitalize">
{analysis.modelSignals.creditConditions}
</p>
</div>
<div className="bg-slate-50 p-4 rounded-lg">
<p className="text-sm text-slate-600 mb-1">Probit Recession Prob</p>
<p className={`text-xl font-bold ${getRiskColor(analysis.modelSignals.probitRecessionProb)}`}>
{analysis.modelSignals.probitRecessionProb?.toFixed(1)}%
</p>
</div>
</div>
</div>
{/* Forecasts */}
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-2xl font-bold text-slate-800 mb-4 flex items-center gap-2">
<Calendar className="w-6 h-6 text-blue-600" />
Probabilistic Forecasts
</h3>
<div className="space-y-6">
{['6month', '12month', '18month', '24month'].map((period) => {
const forecast = analysis.forecasts[period];
const periodLabel = period.replace('month', ' Month');
return (
<div key={period} className="border-l-4 border-blue-500 pl-4">
<h4 className="text-xl font-bold text-slate-800 mb-3">{periodLabel} Outlook</h4>
<div className="grid grid-cols-2 md:grid-cols-5 gap-3 mb-3">
<div className="bg-red-50 p-3 rounded-lg">
<p className="text-xs text-slate-600 mb-1">Recession Risk</p>
<p className={`text-xl font-bold ${getRiskColor(forecast.recessionProb)}`}>
{forecast.recessionProb}%
</p>
</div>
<div className="bg-orange-50 p-3 rounded-lg">
<p className="text-xs text-slate-600 mb-1">Stagflation Risk</p>
<p className={`text-xl font-bold ${getRiskColor(forecast.stagflationProb)}`}>
{forecast.stagflationProb}%
</p>
</div>
<div className="bg-purple-50 p-3 rounded-lg">
<p className="text-xs text-slate-600 mb-1">Depression Risk</p>
<p className={`text-xl font-bold ${getRiskColor(forecast.depressionProb)}`}>
{forecast.depressionProb}%
</p>
</div>
<div className="bg-blue-50 p-3 rounded-lg">
<p className="text-xs text-slate-600 mb-1">Inflation Forecast</p>
<p className="text-xl font-bold text-blue-800">
{forecast.inflationForecast?.toFixed(1)}%
</p>
</div>
<div className="bg-green-50 p-3 rounded-lg">
<p className="text-xs text-slate-600 mb-1">GDP Growth</p>
<p className="text-xl font-bold text-green-800">
{forecast.gdpGrowthForecast?.toFixed(1)}%
</p>
</div>
</div>
{forecast.rationale && (
<div className="bg-slate-50 p-3 rounded-lg mb-2">
<p className="text-sm text-slate-700 leading-relaxed">{forecast.rationale}</p>
</div>
)}
<div className="flex items-center gap-2 text-sm">
<span className="text-slate-600">Confidence:</span>
<span className={`font-semibold ${
forecast.confidence === 'high' ? 'text-green-600' :
forecast.confidence === 'medium' ? 'text-yellow-600' :
'text-red-600'
}`}>
{forecast.confidence.toUpperCase()}
</span>
</div>
</div>
);
})}
</div>
</div>
{/* Executive Summary and Risks */}
<div className="space-y-6">
{/* Bottom Line - Integrated View */}
<div className="bg-gradient-to-r from-blue-600 to-blue-700 rounded-xl shadow-2xl p-8 text-white">
<h3 className="text-2xl font-bold mb-4 flex items-center gap-2">
<TrendingUp className="w-7 h-7" />
Bottom Line: Integrated Economic Assessment
</h3>
<p className="text-lg leading-relaxed font-medium">
{analysis.bottomLine}
</p>
</div>
<div className="grid md:grid-cols-2 gap-6">
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-xl font-bold text-slate-800 mb-3 flex items-center gap-2">
<DollarSign className="w-5 h-5 text-blue-600" />
Executive Summary
</h3>
<p className="text-slate-700 leading-relaxed">{analysis.executiveSummary}</p>
</div>
<div className="bg-white rounded-xl shadow-xl p-6">
<h3 className="text-xl font-bold text-slate-800 mb-3 flex items-center gap-2">
<AlertTriangle className="w-5 h-5 text-yellow-600" />
Key Risks
</h3>
<ul className="space-y-2">
{analysis.keyRisks.map((risk, idx) => (
<li key={idx} className="flex items-start gap-2">
<span className="text-yellow-600 mt-1">•</span>
<span className="text-slate-700">{risk}</span>
</li>
))}
</ul>
</div>
</div>
</div>
{/* Footer Note */}
<div className="bg-slate-100 rounded-lg p-4">
<h4 className="font-semibold text-slate-800 mb-2">Methodology Note</h4>
<p className="text-sm text-slate-600 leading-relaxed">
Analysis generated on {analysis.analysisDate} using real-time data from verified sources.
Applied econometric models: (1) Yield Curve Spread [Spread = 10Y - 3M], (2) Probit Recession Model
[P = Φ(β₀ + β₁·YieldSpread + β₂·CreditSpread + β₃·LEI + β₄·Inflation + β₅·Unemployment)],
(3) Taylor Rule [i = r* + π + α(π - π*) + β(y - y*)], (4) Phillips Curve [π(t+1) = λπ(t) + κ(u - u*)],
and (5) Sovereign Risk Model where applicable. Forecasts are probabilistic and should be interpreted
with appropriate uncertainty. Each model section discusses results in 1-2 sentence analytical paragraphs
as per econometric best practices.
</p>
</div>
</div>
)}
</div>
</div>
);
}
—————————————————
Asset Allocation Code Bonus Code
This code can be copied and pasted into Claude so the macroeconomic conditions from the code above can be analyzed in the context of the ideal asset allocation relative to the economic climate coming. Copy and paste into Claude and ask Claude to recreate the asset allocation artifact and run the application analyzing the United States.
———————————————————-
import React, { useState } from 'react';
import { TrendingUp, Target, PieChart, Brain, AlertCircle, CheckCircle, Zap, DollarSign, Database, FileText, Download } from 'lucide-react';
export default function AssetAllocationResearchPlatform() {
const [gameStage, setGameStage] = useState('intro');
const [country, setCountry] = useState('United States');
const [macroAnalysis, setMacroAnalysis] = useState(null);
const [portfolioRecommendation, setPortfolioRecommendation] = useState(null);
const [isProcessing, setIsProcessing] = useState(false);
const [error, setError] = useState(null);
const [apiKey, setApiKey] = useState('');
// Top 10 Accessible Asset Classes for Retail/Institutional Investors
const topAssetClasses = [
{
id: 'us_large_cap',
name: 'US Large-Cap Equities',
ticker: 'SPY',
description: 'S&P 500 stocks',
category: 'equities'
},
{
id: 'intl_developed',
name: 'International Developed Equities',
ticker: 'EFA',
description: 'MSCI EAFE',
category: 'equities'
},
{
id: 'emerging_markets',
name: 'Emerging Markets Equities',
ticker: 'EEM',
description: 'MSCI EM',
category: 'equities'
},
{
id: 'us_treasury',
name: 'US Treasury Bonds',
ticker: 'IEF',
description: '7-10 Year Treasuries',
category: 'bonds'
},
{
id: 'corp_bonds',
name: 'Investment-Grade Corporate Bonds',
ticker: 'LQD',
description: 'BBB and above',
category: 'bonds'
},
{
id: 'high_yield',
name: 'High-Yield Bonds',
ticker: 'HYG',
description: 'Junk bonds',
category: 'bonds'
},
{
id: 'reits',
name: 'Real Estate (REITs)',
ticker: 'VNQ',
description: 'Real estate investment trusts',
category: 'alternatives'
},
{
id: 'commodities',
name: 'Commodities',
ticker: 'DBC',
description: 'Gold, Oil, Agriculture',
category: 'alternatives'
},
{
id: 'tips',
name: 'TIPS (Inflation-Protected Bonds)',
ticker: 'TIP',
description: 'Treasury Inflation-Protected Securities',
category: 'bonds'
},
{
id: 'cash',
name: 'Cash & Money Market',
ticker: 'BIL',
description: 'T-Bills and cash equivalents',
category: 'cash'
}
];
const countries = [
'United States', 'United Kingdom', 'Germany', 'France', 'Japan',
'China', 'India', 'Brazil', 'Canada', 'Australia'
];
// Mock data for demonstration
const generateMockAnalysis = () => {
setIsProcessing(true);
setError(null);
setTimeout(() => {
// Mock macro analysis
const mockMacro = {
country: country,
analysisDate: new Date().toISOString().split('T')[0],
dataSources: ["FRED", "OECD", "Trading Economics"],
currentIndicators: {
tenYearYield: 4.25,
threeMonthYield: 5.35,
yieldSpread: -1.10,
creditSpread: 1.45,
inflation: 3.2,
unemployment: 3.7,
gdpGrowth: 2.1,
policyRate: 5.25,
debtToGDP: 123,
vix: 18.5
},
modelSignals: {
yieldCurve: "inverted",
probitRecessionProb: 45,
taylorRule: "too tight",
creditConditions: "stressed"
},
modelResults: {
yieldCurveAnalysis: "The yield curve is inverted by 110 basis points, historically a strong recession signal. This inversion has persisted for 6 months.",
probitRecessionProb: "Probit model indicates 45% recession probability within 12 months based on yield spread, credit conditions, and economic momentum.",
taylorRuleAnalysis: "Policy rate appears too tight relative to neutral rate. Central bank may need to ease if growth slows further.",
phillipsCurveInflation: "Phillips Curve suggests inflation will moderate to 2.8% over next 12 months as labor market cools.",
sovereignRiskAssessment: "Debt-to-GDP ratio elevated but manageable given reserve currency status and moderate inflation."
},
forecasts: {
"6month": {
recessionProb: 35,
inflationForecast: 3.0,
gdpGrowthForecast: 1.5,
rationale: "Near-term resilience expected but slowing"
},
"12month": {
recessionProb: 45,
inflationForecast: 2.8,
gdpGrowthForecast: 1.2,
rationale: "Increased recession risk as monetary lags bite"
}
},
economicRegime: "late-cycle",
marketEnvironment: "transitioning",
keyDrivers: ["Restrictive monetary policy", "Resilient labor market", "Declining inflation"],
keyRisks: ["Credit event risk", "Geopolitical tensions", "Policy error"],
bottomLine: "Economy is in late-cycle with elevated recession risk. Defensive positioning warranted while maintaining some risk exposure given continued growth momentum."
};
setMacroAnalysis(mockMacro);
setGameStage('assetAllocation');
// Mock portfolio recommendation
setTimeout(() => {
const mockPortfolio = {
portfolioAllocation: {
us_large_cap: 20,
intl_developed: 10,
emerging_markets: 5,
us_treasury: 25,
corp_bonds: 15,
high_yield: 5,
reits: 5,
commodities: 5,
tips: 5,
cash: 5
},
portfolioMetrics: {
expectedReturn: 6.2,
expectedVolatility: 9.8,
sharpeRatio: 0.45,
maxDrawdown: -15.2,
equityAllocation: 35,
bondAllocation: 50,
alternativeAllocation: 15
},
stressTestResults: {
crisis2008: -12.5,
inflationShock: -3.2,
currentRecessionScenario: -8.5
},
rationale: "Given late-cycle dynamics and inverted yield curve, portfolio is positioned defensively with 50% in fixed income and only 35% in equities. Treasury overweight provides recession hedge while maintaining some risk assets for continued growth scenario.",
keyInsights: [
"Underweight equities relative to 60/40 benchmark given recession risk",
"Overweight treasuries to benefit from potential rate cuts",
"Include TIPS and commodities for inflation protection",
"Maintain liquidity buffer with 5% cash allocation"
],
implementationNotes: [
"Rebalance quarterly or when any position drifts >5% from target",
"Consider tax-loss harvesting opportunities in taxable accounts",
"Maintain 3-6 months expenses in separate emergency fund",
"Monitor credit spreads weekly as recession indicator"
],
alternativeScenarios: {
ifRecessionDeepens: "Increase treasuries to 35%, reduce equities to 25%, add to cash",
ifInflationAccelerates: "Increase commodities and TIPS to 10% each, reduce long bonds",
ifMarketsRally: "Gradually increase equity allocation to 45%, reduce cash to 2%"
},
riskWarnings: [
"Portfolio may underperform if soft landing achieved",
"Duration risk if inflation reaccelerates unexpectedly",
"Currency risk from international exposures"
],
bottomLine: "Investors should position defensively given late-cycle risks but maintain diversification. This balanced approach provides downside protection while participating in continued growth."
};
setPortfolioRecommendation(mockPortfolio);
setGameStage('results');
setIsProcessing(false);
}, 2000);
}, 3000);
};
const resetAnalysis = () => {
setGameStage('intro');
setMacroAnalysis(null);
setPortfolioRecommendation(null);
setError(null);
};
const exportReport = () => {
const report = {
generatedDate: new Date().toISOString(),
country: country,
macroAnalysis: macroAnalysis,
portfolioRecommendation: portfolioRecommendation
};
const blob = new Blob([JSON.stringify(report, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `asset-allocation-research-${country.toLowerCase().replace(' ', '-')}-${new Date().toISOString().split('T')[0]}.json`;
a.click();
};
return (
<div className="min-h-screen bg-gradient-to-br from-indigo-900 via-purple-900 to-pink-900 p-4 md:p-8">
<div className="max-w-7xl mx-auto">
{/* Header */}
<div className="text-center mb-8">
<h1 className="text-4xl md:text-6xl font-bold text-white mb-3 flex items-center justify-center gap-3">
<Target className="w-12 h-12 text-pink-400" />
Professional Asset Allocation Research
</h1>
<p className="text-pink-200 text-lg mb-2">
Institutional-Grade Portfolio Construction Using Validated Econometric Models
</p>
<div className="mt-3 flex items-center justify-center gap-3 flex-wrap">
<div className="bg-green-500 bg-opacity-20 px-4 py-2 rounded-lg text-white text-sm font-medium">
<span className="inline-block w-2 h-2 bg-green-400 rounded-full mr-2 animate-pulse"></span>
Real-Time Economic Data
</div>
<div className="bg-blue-500 bg-opacity-20 px-4 py-2 rounded-lg text-white text-sm font-medium">
<span className="inline-block w-2 h-2 bg-blue-400 rounded-full mr-2"></span>
5 Econometric Models
</div>
<div className="bg-purple-500 bg-opacity-20 px-4 py-2 rounded-lg text-white text-sm font-medium">
<span className="inline-block w-2 h-2 bg-purple-400 rounded-full mr-2"></span>
10 Liquid Asset Classes
</div>
</div>
</div>
{error && (
<div className="bg-red-100 border-2 border-red-400 rounded-lg p-4 mb-6">
<p className="text-red-800 font-medium">{error}</p>
</div>
)}
{/* STAGE 1: Introduction & Setup */}
{gameStage === 'intro' && (
<div className="bg-white rounded-2xl shadow-2xl p-8">
<h2 className="text-3xl font-bold text-gray-800 mb-6">Research Setup</h2>
<div className="bg-gradient-to-r from-blue-50 to-purple-50 rounded-lg p-6 mb-8">
<h3 className="font-bold text-gray-800 mb-3 flex items-center gap-2">
<Brain className="w-5 h-5 text-purple-600" />
Research Methodology
</h3>
<div className="space-y-3 text-gray-700">
<p><strong>Phase 1: Macro Analysis</strong> - Apply 5 validated econometric models (Yield Curve, Probit Recession, Taylor Rule, Phillips Curve, Sovereign Risk) using real-time data</p>
<p><strong>Phase 2: Asset Allocation</strong> - Generate optimal portfolio across 10 liquid asset classes using regime-adjusted MPT, stress testing, and risk management</p>
<p><strong>Output:</strong> Institutional-grade research report with specific allocation recommendations and implementation guidance</p>
</div>
</div>
<div className="bg-yellow-50 border-2 border-yellow-300 rounded-lg p-4 mb-6">
<h3 className="font-bold text-gray-800 mb-2">🎯 10 Recommended Asset Classes</h3>
<div className="grid md:grid-cols-2 gap-2 text-sm">
{topAssetClasses.map(asset => (
<div key={asset.id} className="flex items-center gap-2">
<span className={`w-2 h-2 rounded-full ${
asset.category === 'equities' ? 'bg-blue-500' :
asset.category === 'bonds' ? 'bg-green-500' :
asset.category === 'alternatives' ? 'bg-orange-500' : 'bg-gray-500'
}`}></span>
<span className="text-gray-700">{asset.name} ({asset.ticker})</span>
</div>
))}
</div>
</div>
<div className="space-y-4 mb-8">
<div>
<label className="block text-gray-700 font-semibold mb-2">
Country/Region to Analyze:
</label>
<select
value={country}
onChange={(e) => setCountry(e.target.value)}
className="w-full px-4 py-3 border-2 border-gray-300 rounded-lg text-lg focus:outline-none focus:border-purple-500"
>
{countries.map(c => <option key={c} value={c}>{c}</option>)}
</select>
</div>
</div>
<button
onClick={generateMockAnalysis}
disabled={isProcessing}
className="w-full py-4 bg-gradient-to-r from-purple-600 to-pink-600 text-white rounded-xl font-bold text-xl hover:from-purple-700 hover:to-pink-700 disabled:opacity-50 disabled:cursor-not-allowed shadow-lg transition-all"
>
{isProcessing ? (
<span className="flex items-center justify-center gap-3">
<div className="animate-spin rounded-full h-5 w-5 border-b-2 border-white"></div>
Running Full Research Analysis...
</span>
) : (
'Generate Complete Research Report →'
)}
</button>
<p className="text-sm text-gray-500 text-center mt-4">
Note: This is a demonstration version using simulated data
</p>
</div>
)}
{/* STAGE 2: Loading - Show Progress */}
{gameStage === 'assetAllocation' && (
<div className="bg-white rounded-2xl shadow-2xl p-12 text-center">
<div className="animate-spin rounded-full h-16 w-16 border-b-4 border-purple-600 mx-auto mb-6"></div>
<h2 className="text-2xl font-bold text-gray-800 mb-3">Running Asset Allocation Optimization...</h2>
<p className="text-gray-600 mb-4">Macro analysis complete. Now generating optimal portfolio...</p>
<div className="bg-blue-50 rounded-lg p-4 max-w-md mx-auto">
<p className="text-sm text-gray-700">
✓ Economic models analyzed<br/>
⏳ Applying regime-based adjustments<br/>
⏳ Running stress tests<br/>
⏳ Calculating optimal weights
</p>
</div>
</div>
)}
{/* STAGE 3: Results */}
{gameStage === 'results' && macroAnalysis && portfolioRecommendation && (
<div className="space-y-6">
{/* Executive Summary Card */}
<div className="bg-gradient-to-r from-purple-600 to-pink-600 rounded-2xl shadow-2xl p-8 text-white">
<h2 className="text-3xl font-bold mb-4 flex items-center gap-3">
<FileText className="w-8 h-8" />
Executive Summary: {macroAnalysis.country}
</h2>
<div className="grid md:grid-cols-3 gap-6 mb-6">
<div>
<p className="text-purple-200 text-sm mb-1">Economic Regime</p>
<p className="text-2xl font-bold capitalize">{macroAnalysis.economicRegime}</p>
</div>
<div>
<p className="text-purple-200 text-sm mb-1">12M Recession Risk</p>
<p className="text-2xl font-bold">{macroAnalysis.modelSignals.probitRecessionProb?.toFixed(1)}%</p>
</div>
<div>
<p className="text-purple-200 text-sm mb-1">Policy Stance</p>
<p className="text-2xl font-bold capitalize">{macroAnalysis.modelSignals.taylorRule}</p>
</div>
</div>
<div className="bg-white bg-opacity-20 rounded-lg p-4">
<p className="font-semibold mb-2">Bottom Line:</p>
<p className="leading-relaxed">{macroAnalysis.bottomLine}</p>
</div>
</div>
{/* Portfolio Allocation */}
<div className="bg-white rounded-2xl shadow-2xl p-6">
<h3 className="text-2xl font-bold text-gray-800 mb-6">Recommended Portfolio Allocation</h3>
<div className="grid md:grid-cols-4 gap-4 mb-6 bg-gradient-to-r from-green-50 to-blue-50 rounded-lg p-4">
<div>
<p className="text-gray-600 text-sm">Expected Return</p>
<p className="text-3xl font-bold text-gray-800">{portfolioRecommendation.portfolioMetrics.expectedReturn?.toFixed(2)}%</p>
</div>
<div>
<p className="text-gray-600 text-sm">Expected Volatility</p>
<p className="text-3xl font-bold text-gray-800">{portfolioRecommendation.portfolioMetrics.expectedVolatility?.toFixed(2)}%</p>
</div>
<div>
<p className="text-gray-600 text-sm">Sharpe Ratio</p>
<p className="text-3xl font-bold text-gray-800">{portfolioRecommendation.portfolioMetrics.sharpeRatio?.toFixed(2)}</p>
</div>
<div>
<p className="text-gray-600 text-sm">Max Drawdown</p>
<p className="text-3xl font-bold text-red-600">{portfolioRecommendation.portfolioMetrics.maxDrawdown?.toFixed(1)}%</p>
</div>
</div>
<div className="space-y-4 mb-6">
{Object.entries(portfolioRecommendation.portfolioAllocation)
.sort((a, b) => b[1] - a[1])
.map(([assetId, percentage]) => {
const asset = topAssetClasses.find(a => a.id === assetId);
if (!asset || percentage === 0) return null;
return (
<div key={assetId} className="relative">
<div className="flex justify-between items-center mb-2">
<div className="flex items-center gap-3">
<span className={`w-3 h-3 rounded-full ${
asset.category === 'equities' ? 'bg-blue-500' :
asset.category === 'bonds' ? 'bg-green-500' :
asset.category === 'alternatives' ? 'bg-orange-500' : 'bg-gray-500'
}`}></span>
<div>
<span className="font-semibold text-gray-800">{asset.name}</span>
<span className="text-sm text-gray-600 ml-2">({asset.ticker})</span>
</div>
</div>
<span className="font-bold text-purple-600 text-lg">{percentage.toFixed(1)}%</span>
</div>
<div className="w-full bg-gray-200 rounded-full h-4 overflow-hidden">
<div
className={`h-4 rounded-full transition-all duration-500 ${
asset.category === 'equities' ? 'bg-gradient-to-r from-blue-500 to-blue-600' :
asset.category === 'bonds' ? 'bg-gradient-to-r from-green-500 to-green-600' :
asset.category === 'alternatives' ? 'bg-gradient-to-r from-orange-500 to-orange-600' :
'bg-gradient-to-r from-gray-500 to-gray-600'
}`}
style={{ width: `${percentage}%` }}
></div>
</div>
</div>
);
})}
</div>
<div className="grid md:grid-cols-3 gap-4 bg-slate-50 rounded-lg p-4">
<div>
<p className="text-sm text-gray-600">Total Equity</p>
<p className="text-xl font-bold text-blue-600">
{portfolioRecommendation.portfolioMetrics.equityAllocation?.toFixed(1)}%
</p>
</div>
<div>
<p className="text-sm text-gray-600">Total Fixed Income</p>
<p className="text-xl font-bold text-green-600">
{portfolioRecommendation.portfolioMetrics.bondAllocation?.toFixed(1)}%
</p>
</div>
<div>
<p className="text-sm text-gray-600">Total Alternatives</p>
<p className="text-xl font-bold text-orange-600">
{portfolioRecommendation.portfolioMetrics.alternativeAllocation?.toFixed(1)}%
</p>
</div>
</div>
</div>
{/* Stress Test Results */}
<div className="bg-white rounded-2xl shadow-2xl p-6">
<h3 className="text-xl font-bold text-gray-800 mb-4 flex items-center gap-2">
<Zap className="w-6 h-6 text-orange-600" />
Stress Test Results
</h3>
<div className="grid md:grid-cols-3 gap-4">
<div className="bg-red-50 p-4 rounded-lg border-2 border-red-200">
<p className="text-sm text-gray-600 mb-2">2008-Style Crisis</p>
<p className={`text-3xl font-bold ${
portfolioRecommendation.stressTestResults.crisis2008 < 0 ? 'text-red-600' : 'text-green-600'
}`}>
{portfolioRecommendation.stressTestResults.crisis2008?.toFixed(1)}%
</p>
</div>
<div className="bg-orange-50 p-4 rounded-lg border-2 border-orange-200">
<p className="text-sm text-gray-600 mb-2">Inflation Shock</p>
<p className={`text-3xl font-bold ${
portfolioRecommendation.stressTestResults.inflationShock < 0 ? 'text-red-600' : 'text-green-600'
}`}>
{portfolioRecommendation.stressTestResults.inflationShock?.toFixed(1)}%
</p>
</div>
<div className="bg-yellow-50 p-4 rounded-lg border-2 border-yellow-200">
<p className="text-sm text-gray-600 mb-2">Current Recession Scenario</p>
<p className={`text-3xl font-bold ${
portfolioRecommendation.stressTestResults.currentRecessionScenario < 0 ? 'text-red-600' : 'text-green-600'
}`}>
{portfolioRecommendation.stressTestResults.currentRecessionScenario?.toFixed(1)}%
</p>
</div>
</div>
</div>
{/* Bottom Line */}
<div className="bg-gradient-to-r from-indigo-600 to-purple-600 rounded-2xl shadow-2xl p-8 text-white">
<h3 className="text-2xl font-bold mb-4 flex items-center gap-2">
<TrendingUp className="w-7 h-7" />
Bottom Line: Investment Recommendation
</h3>
<p className="text-lg leading-relaxed font-medium">
{portfolioRecommendation.bottomLine}
</p>
</div>
{/* Action Buttons */}
<div className="flex gap-4">
<button
onClick={resetAnalysis}
className="flex-1 py-4 bg-gradient-to-r from-purple-600 to-pink-600 text-white rounded-xl font-bold text-lg hover:from-purple-700 hover:to-pink-700 shadow-lg"
>
Run New Analysis
</button>
<button
onClick={exportReport}
className="px-8 py-4 bg-white border-2 border-purple-600 text-purple-600 rounded-xl font-bold text-lg hover:bg-purple-50 shadow-lg flex items-center gap-2"
>
<Download className="w-5 h-5" />
Export Report
</button>
</div>
</div>
)}
</div>
</div>
);
}