Bond Market Trading Strategy Tester

Bond Market Trading Strategy Tester

Build and backtest a rules-based bond trading strategy.

Entry Signal (Conditions to BUY)

The strategy will enter a long position when BOTH conditions are met.

Define your strategy and parameters, then click "Run Backtest" to see the results.

Asset: Simulated US Agg Bond ETF | Period: ${params.startYear} - ${params.endYear}

Performance Metrics

Initial Capital$${params.initialCapital.toLocaleString()}
Total Return${kpis.totalReturn}
CAGR${kpis.cagr}
Max Drawdown${kpis.maxDrawdown}
Trades${kpis.trades}

Equity Curve

Strategy Rules

BUY WHEN: Yield Curve ${strategy.yieldOp} ${strategy.yieldVal} AND Credit Spread ${strategy.spreadOp} ${strategy.spreadVal}

Trade Log (First 20 Trades)

${tradeRows}
DateActionPriceCapital
`; const { jsPDF } = window.jspdf; const canvas = await html2canvas(document.getElementById('pdf-report'), { scale: 2.5 }); const imgData = canvas.toDataURL('image/jpeg', 0.8); const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const imgHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'JPEG', 0, 0, pdfWidth, imgHeight); pdf.save('Bond-Strategy-Backtest.pdf'); pdfMessage.textContent = 'Download successful!'; } catch(e) { pdfMessage.textContent = 'Error creating PDF.'; console.error(e); } finally { loader.classList.add('hidden'); document.getElementById('downloadPdfBtn').disabled = false; } }); // --- Initial Setup --- const years = Array.from({length: 25}, (_, i) => 2000 + i); years.forEach(year => { startYearSelect.innerHTML += ``; endYearSelect.innerHTML += ``; }); tabs.forEach((tab, index) => tab.addEventListener('click', () => updateTabs(index))); nextBtn.addEventListener('click', () => { if (currentTab < tabs.length - 1) updateTabs(currentTab + 1); }); prevBtn.addEventListener('click', () => { if (currentTab > 0) updateTabs(currentTab - 1); }); updateTabs(0); });
Scroll to Top