continuation
This commit is contained in:
parent
32e43c9243
commit
879e9b4228
42 changed files with 2607 additions and 1306 deletions
35
apps/stock/orchestrator/src/backtest/execution-engine.ts
Normal file
35
apps/stock/orchestrator/src/backtest/execution-engine.ts
Normal 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';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue