πŸ§ͺ Backtest v2

pick a strategy β†’ choose data (pattern / SQL / form) β†’ preview β†’ run. Ctrl+Enter to run.

⚠

1. Strategy

+
no match

fresh: Β· target:

2. Data Source

↑↓ Enter Β· Esc
quick:
snap:

snap:

πŸ’° Portfolio (all values in %, type direct)
INR

% / trade

% of equity

%

πŸ›‘οΈ SL / TP override (% from entry; blank = use strategy's own)
%
%
🏷️ order type β€” drives what happens to a position still open at end of backtest

examples: commission=1 means 1%, slippage=0.05 means 0.05%, portfolio=10 means 10% of equity

πŸ“– read-only SELECT/WITH Β· max 1000 rows

3. Run

strategy
instruments ()
date range
timeframe β€”
πŸ“Š Result
starting
final value
return
trades:
open:
wins:
losses:
win rate:
elapsed:
total pnl:
unrealized:
max DD:
best:
worst:
signals:
fills:
bars:
order type:
MIS auto square-off:
discarded @ EOD:
🌐 Plotly chart disabled

πŸ“‹ Preview

bars:
no rows match filter

πŸ’Ό Trades ()

instrumentside entry tsentry px slt1t2 exit tsexit pxreason pnlstatus

🎯 Criteria scoring

type instrument ts close score % first failed checks (βœ“/βœ—) details chart
no bars at this score threshold

πŸ• Past runs

when strategyuniversetf tradeswin%pnl run_id
no past runs yet
πŸ“„ Strategy source
⏳ loading source…

            
// ============================================================ // GLOBAL KITE CHART OPENER FUNCTION (for partials) // ============================================================ // [L1425] This function is used by HTMX partials that don't have Alpine.js context async function openKiteChartFromPartial(symbol) { try { // [L1427] Fetch Kite chart URL from backend const response = await fetch(`/api/orders/kite-chart-url/${encodeURIComponent(symbol)}`); const data = await response.json(); if (data.url) { // [L1431] Open URL in new tab window.open(data.url, '_blank', 'noopener,noreferrer'); } else { // [L1434] Show error if URL not found if (window.showNotification) { window.showNotification(`Kite chart URL not found for ${symbol}`, 'error', 5); } console.error('[KITE CHART] URL not found:', data); } } catch (e) { // [L1441] Handle fetch errors if (window.showNotification) { window.showNotification(`Error loading Kite chart: ${e.message}`, 'error', 5); } console.error('[KITE CHART] Error:', e); } } // [L1448] Make it available globally window.openKiteChartFromPartial = openKiteChartFromPartial; // ============================================================ // GLOBAL FINPLOT CHART OPENER FUNCTION (for partials) // ============================================================ // [L1450] This function is used by HTMX/Jinja2 partials that don't have Alpine.js context // It opens a native finplot desktop chart window via the backend API function openFinplotFromPartial(symbol) { // [L1453] Default finplot parameters - 5-minute candles, 200 bars const FINPLOT_DEFAULT_RESOLUTION = 5; const FINPLOT_DEFAULT_COUNTBACK = 200; // [L1456] Normalize symbol to Fyers format (finplot uses Fyers data source) // Kite uses bare symbols like "RELIANCE", but Fyers needs "NSE:RELIANCE-EQ" let fmtSymbol = symbol; if (!symbol.includes(':')) { fmtSymbol = 'NSE:' + symbol; } // [L1461] Add -EQ suffix for equity symbols (not options CE/PE or futures FUT) if (!fmtSymbol.includes('-') && !fmtSymbol.includes('CE') && !fmtSymbol.includes('PE')) { fmtSymbol = fmtSymbol + '-EQ'; } // [L1465] Build the finplot API URL const url = `/api/backtest/finplot?symbol=${encodeURIComponent(fmtSymbol)}&resolution=${FINPLOT_DEFAULT_RESOLUTION}&countback=${FINPLOT_DEFAULT_COUNTBACK}`; // [L1468] Log the action with timestamp for debugging console.log(`[L1468] ${new Date().toLocaleTimeString()} - [Finplot] Opening for ${fmtSymbol}`); // [L1470] Fire the request - backend opens native desktop window fetch(url) .then(r => r.json()) .then(data => console.log(`[L1472] ${new Date().toLocaleTimeString()} - [Finplot] Response:`, data)) .catch(err => console.error(`[L1473] ${new Date().toLocaleTimeString()} - [Finplot] Error:`, err)); } // [L1475] Make it available globally for Jinja2 partials window.openFinplotFromPartial = openFinplotFromPartial;