back Β·

unsaved changes

Loading strategy…

Human-readable name shown in dropdowns + the strategy list.

Plain text. No markdown rendering (yet).

// ============================================================ // 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;