Strategy: ${strategy}
Option: ${optionType} | Strike: $${strikePrice} | Qty: ${quantity}
Premium Collected: $${premium.toFixed(2)}
Total Cost: $${totalCost.toFixed(2)}
Max Gain: $${maxGain.toFixed(2)}
Max Loss: $${Math.abs(maxLoss).toFixed(2)}
`; document.getElementById("resultDisplay").innerHTML = resultHTML; showTab(2); }; window.resetSimulator = function () { document.getElementById("strategy").selectedIndex = 0; document.getElementById("ticker").value = ''; document.getElementById("stockPrice").value = ''; document.getElementById("expiry").value = ''; document.getElementById("optionType").selectedIndex = 0; document.getElementById("strikePrice").value = ''; document.getElementById("quantity").value = ''; document.getElementById("resultDisplay").innerHTML = ''; showTab(0); }; // Working PDF generation document.getElementById("downloadBtn").addEventListener("click", function () { const resultText = document.getElementById("resultDisplay").innerText; if (!resultText.trim()) { alert("Nothing to export."); return; } const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFontSize(14); doc.text("Advanced Options Trading Simulation", 20, 20); doc.setFontSize(11); const lines = doc.splitTextToSize(resultText, 180); doc.text(lines, 20, 40); doc.save("options_simulation.pdf"); }); });