import { BackwardIcon, ForwardIcon, PauseIcon, PlayIcon, StopIcon, } from '@heroicons/react/24/solid'; import { useState } from 'react'; import { at } from '@stock-bot/invariants'; import type { Run } from '../services/backtestApiV2'; interface RunControlsProps { run: Run; onPause: () => void; onResume: () => void; onCancel: () => void; onSpeedChange: (speed: number) => void; } export function RunControls({ run, onPause, onResume, onCancel, onSpeedChange }: RunControlsProps) { const [speedMultiplier, setSpeedMultiplier] = useState(run.speedMultiplier ?? 1000); const handleSpeedChange = (speed: number) => { setSpeedMultiplier(speed); onSpeedChange(speed); }; const speedOptions = [ { value: 0.1, label: '0.1x' }, { value: 0.5, label: '0.5x' }, { value: 1, label: '1x' }, { value: 2, label: '2x' }, { value: 5, label: '5x' }, { value: 10, label: '10x' }, { value: 50, label: '50x' }, { value: 100, label: '100x' }, { value: 1000, label: 'Max' }, ]; const formatDate = (date?: string) => { if (!date) { return '-'; } return new Date(date).toLocaleString(); }; const formatDuration = () => { if (!run.startedAt) { return '00:00'; } const start = new Date(run.startedAt).getTime(); const current = Date.now(); const duration = current - start; const seconds = Math.floor(duration / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); if (hours > 0) { return `${hours.toString().padStart(2, '0')}:${(minutes % 60).toString().padStart(2, '0')}:${(seconds % 60).toString().padStart(2, '0')}`; } else { return `${minutes.toString().padStart(2, '0')}:${(seconds % 60).toString().padStart(2, '0')}`; } }; return (

Run Control

{/* Progress Bar */}
Progress {run.progress.toFixed(1)}%
{/* Control Buttons */}
{run.status === 'running' ? ( ) : run.status === 'paused' ? ( ) : null} {(run.status === 'running' || run.status === 'paused') && ( )}
{/* Speed Control */} {run.status === 'running' && (
)} {/* Run Info */}
Status: {run.status.charAt(0).toUpperCase() + run.status.slice(1)}
Duration: {formatDuration()}
{run.currentSimulationDate && (
Current Date: {formatDate(run.currentSimulationDate)}
)} {run.error && (
Error: {run.error}
)}
); }