Share backtest request contracts and isolate stored result mapping
This commit is contained in:
parent
007e35c747
commit
420c47704e
21 changed files with 777 additions and 244 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { Hono } from 'hono';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { isBacktestRequestError } from '@stock-bot/stock-config/backtest';
|
||||
import { BacktestService } from '../services/backtest.service';
|
||||
|
||||
const logger = getLogger('backtest-routes');
|
||||
|
|
@ -33,7 +33,7 @@ export function createBacktestRoutes(container: IServiceContainer) {
|
|||
return c.json(backtest, 201);
|
||||
} catch (error) {
|
||||
logger.error('Failed to create backtest', { error });
|
||||
if (error instanceof HistoricalDataRequestError) {
|
||||
if (isBacktestRequestError(error)) {
|
||||
return c.json({ error: error.message }, 400);
|
||||
}
|
||||
return c.json({ error: 'Failed to create backtest' }, 500);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Hono } from 'hono';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import { getLogger } from '@stock-bot/logger';
|
||||
import { HistoricalDataRequestError } from '@stock-bot/types';
|
||||
import { isBacktestRequestError } from '@stock-bot/stock-config/backtest';
|
||||
import { BacktestServiceV2 } from '../services/backtest-v2.service';
|
||||
|
||||
const logger = getLogger('backtests-v2-routes');
|
||||
|
|
@ -44,7 +44,7 @@ export function createBacktestV2Routes(container: IServiceContainer) {
|
|||
return c.json(backtest, 201);
|
||||
} catch (error) {
|
||||
logger.error('Failed to create backtest', error);
|
||||
if (error instanceof HistoricalDataRequestError) {
|
||||
if (isBacktestRequestError(error)) {
|
||||
return c.json({ error: error.message }, 400);
|
||||
}
|
||||
return c.json({ error: 'Failed to create backtest' }, 500);
|
||||
|
|
@ -61,7 +61,7 @@ export function createBacktestV2Routes(container: IServiceContainer) {
|
|||
return c.json(backtest);
|
||||
} catch (error) {
|
||||
logger.error('Failed to update backtest', error);
|
||||
if (error instanceof HistoricalDataRequestError) {
|
||||
if (isBacktestRequestError(error)) {
|
||||
return c.json({ error: error.message }, 400);
|
||||
}
|
||||
return c.json({ error: 'Failed to update backtest' }, 500);
|
||||
|
|
@ -100,7 +100,7 @@ export function createBacktestV2Routes(container: IServiceContainer) {
|
|||
return c.json(run, 202);
|
||||
} catch (error) {
|
||||
logger.error('Failed to create run', error);
|
||||
if (error instanceof HistoricalDataRequestError) {
|
||||
if (isBacktestRequestError(error)) {
|
||||
return c.json({ error: error.message }, 400);
|
||||
}
|
||||
return c.json({ error: 'Failed to create run' }, 500);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue