Market-Neutral Hedge Fund Strategy Builder (Conceptual Simulator)

Strategy Setup

$
This is used as a base for % calculations if applicable, or for scaling P&L.

Define Long & Short Legs

Long Leg

%
%
%

Short Leg

%
Strategy uses this as a short position (e.g., -100%).
%
The strategy profits if this asset underperforms or falls.
%

Costs & Risk-Free Rate

%
Applied to (LongAlloc + ShortAlloc)/2 as % of strategy capital. This is a simplification.
%
%

Market-Neutral Strategy Analysis

Strategy analysis results will appear here.

Net Market Exposure (Conceptual): ${netMarketExposure.toFixed(0)}% of notional capital.

`; const pdfBtn = document.getElementById('mnhfsb_downloadPdfButton'); if(pdfBtn) pdfBtn.style.display = 'block'; } // --- PDF Generation --- function mnhfsb_downloadPDF() { if (!mnhfsb_model.analysisResults) { alert("Please analyze strategy first."); return; } if (typeof window.jspdf === 'undefined' || typeof window.jspdf.jsPDF === 'undefined') { alert('Core PDF library (jsPDF) is not loaded.'); console.error('jsPDF library not found.'); return; } const { jsPDF: JSPDF } = window.jspdf; const doc = new JSPDF(); if (typeof doc.autoTable !== 'function') { alert('PDF Table plugin (jsPDF-AutoTable) not loaded correctly. Tables in PDF may be missing.'); console.error('doc.autoTable is not a function.'); } let y = 15; const m = 15; const cw = doc.internal.pageSize.getWidth() - (2 * m); const res = mnhfsb_model.analysisResults; const inputs = res.inputsSnapshot || mnhfsb_model; function addLine(text, size, style = 'normal', indent = 0, spacing = 2.5) { if (y > 275) { doc.addPage(); y = m; } doc.setFontSize(size); doc.setFont(undefined, style); const lines = doc.splitTextToSize(text, cw - indent); doc.text(lines, m + indent, y); y += (lines.length * (size * 0.35)) + spacing; } addLine(`Market-Neutral Strategy Analysis: ${inputs.strategyName || 'N/A'}`, 16, 'bold', 0, 5); addLine(`Approach: ${inputs.approach.replace(/_/g,' ')} | Report Date: ${new Date().toLocaleDateString()}`, 9, 'italic', 0, 5); addLine(`Notional Capital Allocated: ${mnhfsb_formatCurrency(inputs.capitalAllocated)}`, 10); // Use mnhfsb_formatCurrency y += 3; addLine("Strategy Leg Assumptions:", 12, 'bold', 0, 3); let legData = [ ["Component", "Name", "Allocation (%)", "Asset E(R) (%)", "Volatility (%)"], ["Long Leg", inputs.longLeg.name, inputs.longLeg.allocationPercent.toFixed(1), (inputs.longLeg.expReturn*100).toFixed(1), (inputs.longLeg.expVolatility*100).toFixed(1)], ["Short Leg", inputs.shortLeg.name, `-${inputs.shortLeg.allocationPercent.toFixed(1)} (Short)`, (inputs.shortLeg.assetExpReturn*100).toFixed(1), (inputs.shortLeg.expVolatility*100).toFixed(1)] ]; if (typeof doc.autoTable === 'function') { doc.autoTable({startY: y, head: [legData[0]], body: legData.slice(1), theme: 'striped', headStyles:{fillColor:[79,70,229]}, styles:{fontSize:9, cellPadding:1.2}, columnStyles:{0:{fontStyle:'bold'}}}); y = doc.lastAutoTable.finalY + 5; } else { legData.forEach(row => addLine(row.join(' | '), 9)); y+=5; } addLine(`- Correlation (Long vs Short Legs): ${inputs.correlationLS.toFixed(2)}`, 9, 'normal', 5, 3); addLine("Cost & Risk-Free Assumptions:", 12, 'bold', 0, 3); let costData = [ ["Transaction Costs (% of avg. gross exposure):", mnhfsb_formatPercent(inputs.transactionCostsPercent*100)], ["Shorting Costs (% of short leg value):", mnhfsb_formatPercent(inputs.shortingCostsPercent*100)], ["Annual Risk-Free Rate:", mnhfsb_formatPercent(inputs.riskFreeRate*100)], ]; if (typeof doc.autoTable === 'function') { doc.autoTable({startY: y, body: costData, theme: 'plain', styles:{fontSize:9, cellPadding:1.2}, columnStyles:{0:{fontStyle:'bold'}}}); y = doc.lastAutoTable.finalY + 6; } else { costData.forEach(row => addLine(`${row[0]} ${row[1]}`, 9)); y+=5; } addLine("Calculated Strategy Performance (Annualized):", 14, 'bold', 0, 4); let perfData = [ ["Gross Portfolio Expected Return:", mnhfsb_formatPercent(res.components.grossReturn)], ["Est. Total Cost Impact:", `-${mnhfsb_formatPercent(res.components.totalCostImpact)}`], [{content:"Net Portfolio Expected Return:", styles:{fontStyle:'bold'}}, {content:mnhfsb_formatPercent(res.portfolioNetReturnPercent), styles:{fontStyle:'bold'}}], ["Conceptual Portfolio Volatility:", mnhfsb_formatPercent(res.portfolioVolatilityPercent)], ["Conceptual Sharpe Ratio:", mnhfsb_formatDecimal(res.sharpeRatio)], ]; if (typeof doc.autoTable === 'function') { doc.autoTable({startY: y, body: perfData, theme: 'grid', headStyles:{fillColor:[99,102,241]}, styles:{fontSize:9, cellPadding:1.5}, columnStyles:{0:{fontStyle:'bold'}}}); y = doc.lastAutoTable.finalY + 7; } else { perfData.forEach(row => addLine(`${row[0]} ${row[1]}`, 9)); y+=5; } addLine("Note: This is a conceptual simulator based on user-defined inputs and simplified calculations. It does not constitute financial advice.", 7, 'italic'); doc.save(`${(inputs.strategyName || 'MarketNeutralStrategy').replace(/\s+/g, '_')}.pdf`); }
Scroll to Top