Changed around line 1
+ // Sample stock data
+ const stocks = [
+ { name: 'AAPL', dividend: true, lowVolatility: false, highQuality: true },
+ { name: 'MSFT', dividend: true, lowVolatility: true, highQuality: true },
+ { name: 'TSLA', dividend: false, lowVolatility: false, highQuality: false },
+ { name: 'JNJ', dividend: true, lowVolatility: true, highQuality: true },
+ { name: 'XOM', dividend: true, lowVolatility: false, highQuality: false },
+ { name: 'PG', dividend: true, lowVolatility: true, highQuality: true }
+ ];
+
+ // DOM Elements
+ const stockGrid = document.getElementById('stock-grid');
+ const analyzeButton = document.getElementById('analyze-button');
+ const resultsSection = document.getElementById('analysis-results');
+ const annualReturn = document.getElementById('annual-return');
+ const maxDrawdown = document.getElementById('max-drawdown');
+ const sharpeRatio = document.getElementById('sharpe-ratio');
+ const performanceChart = document.getElementById('performance-chart');
+
+ // Initialize stock grid
+ function renderStocks() {
+ stockGrid.innerHTML = '';
+ stocks.forEach(stock => {
+ const stockCard = document.createElement('div');
+ stockCard.className = 'stock-card';
+ stockCard.innerHTML = `
+
${stock.name} + 选择
+ `;
+ stockGrid.appendChild(stockCard);
+ });
+ }
+
+ // Analyze portfolio
+ function analyzePortfolio() {
+ // Simulate analysis results
+ annualReturn.textContent = '7.8%';
+ maxDrawdown.textContent = '-12.3%';
+ sharpeRatio.textContent = '1.2';
+
+ // Show results section
+ resultsSection.style.display = 'block';
+
+ // Chart data
+ const chartData = {
+ labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],
+ datasets: [{
+ label: '组合表现',
+ data: [100, 105, 102, 110, 115, 120],
+ borderColor: '#3498db',
+ fill: false
+ }]
+ };
+
+ // Render chart
+ new Chart(performanceChart, {
+ type: 'line',
+ data: chartData,
+ options: {
+ responsive: true,
+ maintainAspectRatio: false
+ }
+ });
+ }
+
+ // Event listeners
+ analyzeButton.addEventListener('click', analyzePortfolio);
+
+ // Initial render
+ renderStocks();