continuation

This commit is contained in:
Boki 2026-10-20 16:57:59 -04:00
parent 32e43c9243
commit 879e9b4228
42 changed files with 2607 additions and 1306 deletions

View file

@ -0,0 +1,35 @@
import type { EventEmitter } from 'node:events';
import type { BacktestConfig } from '../types';
import type { NativeBacktestResult } from './native-result';
import type { BacktestResult } from './typescript-result';
/** The runner depends on execution capabilities, not backend implementations. */
export interface BacktestExecutionEngine extends Pick<EventEmitter, 'on' | 'off'> {
runBacktest(config: BacktestConfig): Promise<BacktestResult | NativeBacktestResult>;
stopBacktest(): Promise<void>;
pauseBacktest(): Promise<void>;
resumeBacktest(): Promise<void>;
setSpeedMultiplier(speed: number | null): void;
getStatus(): {
isRunning: boolean;
isPaused: boolean;
progress: number;
currentTime: number;
};
shutdown(): Promise<void>;
}
/** Cancellation has no result when a native worker is forcibly stopped. */
export class BacktestCancelledError extends Error {
constructor() {
super('Backtest cancelled');
this.name = 'BacktestCancelledError';
}
}
export class BacktestTimeoutError extends Error {
constructor(timeoutMs: number) {
super(`Native backtest exceeded its ${timeoutMs}ms execution deadline`);
this.name = 'BacktestTimeoutError';
}
}