feat(research): cut over canonical runtime and enforce agent budgets
This commit is contained in:
parent
ab08db82fd
commit
bbf0dd4453
103 changed files with 6138 additions and 3112 deletions
|
|
@ -3,7 +3,7 @@ import { z } from 'zod';
|
|||
import { defined } from '@stock-bot/invariants';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { parseBacktestRequest } from '../../backtest/BacktestRunner';
|
||||
import { BacktestCancelledError } from '../../backtest/execution-engine';
|
||||
import { BacktestCancelledError, LEGACY_EXECUTION_RETIRED } from '../../backtest/execution-engine';
|
||||
import { BacktestConflictError } from '../../backtest/run-repository';
|
||||
import type { OrchestratorServices as IServiceContainer } from '../../types';
|
||||
|
||||
|
|
@ -239,60 +239,8 @@ export function createBacktestRoutes(container: IServiceContainer): Hono {
|
|||
return new Response(stream);
|
||||
});
|
||||
|
||||
// Validate backtest configuration
|
||||
app.post('/validate', async c => {
|
||||
try {
|
||||
const body = await c.req.json();
|
||||
const config = parseBacktestRequest(body);
|
||||
|
||||
// Additional validation logic
|
||||
const validation = {
|
||||
valid: true,
|
||||
warnings: [] as string[],
|
||||
estimatedDuration: 0,
|
||||
};
|
||||
|
||||
// Check data availability
|
||||
const startDate = new Date(config.startDate);
|
||||
const endDate = new Date(config.endDate);
|
||||
const days = (endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24);
|
||||
|
||||
if (days > 365) {
|
||||
validation.warnings.push('Large date range may take significant time to process');
|
||||
}
|
||||
|
||||
if (config.symbols.length > 100) {
|
||||
validation.warnings.push('Large number of symbols may impact performance');
|
||||
}
|
||||
|
||||
// Estimate duration (simplified)
|
||||
validation.estimatedDuration = days * config.symbols.length * 0.1; // seconds
|
||||
|
||||
return c.json(validation);
|
||||
} catch (error) {
|
||||
if (error instanceof BacktestConflictError) {
|
||||
return c.json({ error: error.message }, 409);
|
||||
}
|
||||
if (error instanceof z.ZodError) {
|
||||
return c.json(
|
||||
{
|
||||
valid: false,
|
||||
error: 'Invalid configuration',
|
||||
details: error.errors,
|
||||
},
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
return c.json(
|
||||
{
|
||||
valid: false,
|
||||
error: error instanceof Error ? error.message : 'Validation failed',
|
||||
},
|
||||
500
|
||||
);
|
||||
}
|
||||
});
|
||||
// The old route cannot approve unversioned strategies or mutable provider inputs.
|
||||
app.post('/validate', c => c.json({ valid: false, error: LEGACY_EXECUTION_RETIRED }, 409));
|
||||
|
||||
return app;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue