- Remove ~44k LOC of dead code, legacy v1 TS simulator/strategy stack, event-bus, analytics FastAPI prototype, legacy calculation archives, and unused deps (data-ingestion provider API handlers untouched) - Extract @stock-bot/di/http-security and isolate @stock-bot/browser to data-ingestion via ServiceContainerBuilder.withRegistrations() - Harden @stock-bot/mongodb read-only proxies, flatten @stock-bot/postgres with unified master+research migrations, and fix @stock-bot/config EnvLoader, ServiceApplication worker lifecycle, NamespacedCache.clear(), and BatchProcessor error propagation - Flatten workspace root (remove apps/stock/package.json) and collapse orchestrator re-export shims - Pin all Docker image versions, add shm_size/nofile/RAM caps and docker-compose.quant.yml, fix 05-add-visible-column.sql view recreation, and decouple dev/QA Compose project names for side-by-side execution - Update PLATFORM-PLAN, DATA-CONTRACTS (bars_1m PARTITION BY MONTH, Rust bulk ETL, DuckDB limits), MILESTONES, and servers docs
44 lines
2.2 KiB
TypeScript
44 lines
2.2 KiB
TypeScript
import { expect, test } from 'bun:test';
|
|
import { builtinStrategySelectionSchema } from '@stock-bot/stock-config/strategy';
|
|
import { canonicalRegimeSelection } from '../fixtures/canonical-regime-research';
|
|
|
|
test('canonical mean-reversion selection requires its exact version and explicit compatible parameters', () => {
|
|
const selection = canonicalRegimeSelection();
|
|
for (const alias of ['mean_reversion', 'mean-reversion', ' Mean Reversion ']) {
|
|
expect(builtinStrategySelectionSchema.parse({ ...selection, strategyId: alias })).toEqual(
|
|
selection
|
|
);
|
|
}
|
|
const { maxVolatility: _ceiling, ...missing } = selection.parameters;
|
|
for (const patch of [
|
|
{ strategyId: 'sma' },
|
|
{ strategyVersion: 'mean-reversion/v2' },
|
|
{ strategyVersion: 'mean-reversion-regime-long-only/v2' },
|
|
{ ownerBudget: '0' },
|
|
{ ownerBudget: '-1' },
|
|
{ ownerBudget: 'invalid' },
|
|
{ parameters: missing },
|
|
{ parameters: {} },
|
|
{ parameters: { ...selection.parameters, lookbackPeriod: 1 } },
|
|
{ parameters: { ...selection.parameters, trendPeriod: 2 } },
|
|
{ parameters: { ...selection.parameters, momentumPeriod: 0 } },
|
|
{ parameters: { ...selection.parameters, volatilityPeriod: 1 } },
|
|
{ parameters: { ...selection.parameters, entryZScore: 0 } },
|
|
{ parameters: { ...selection.parameters, exitZScore: 1 } },
|
|
{ parameters: { ...selection.parameters, minTrendReturn: -1 } },
|
|
{ parameters: { ...selection.parameters, minMomentumReturn: -1 } },
|
|
{ parameters: { ...selection.parameters, maxVolatility: Infinity } },
|
|
{ parameters: { ...selection.parameters, maxVolatility: -0.01 } },
|
|
{ parameters: { ...selection.parameters, minNotionalVolume: '-1' } },
|
|
{ parameters: { ...selection.parameters, minNotionalVolume: 'invalid' } },
|
|
{ parameters: { ...selection.parameters, regimeFilter: 'fitted' } },
|
|
{ parameters: { ...selection.parameters, rsiOversold: 30 } },
|
|
{ parameters: { ...selection.parameters, quantity: 10 } },
|
|
{ parameters: { ...selection.parameters, maxPositionQuantity: '99999' } },
|
|
{ initialState: {} },
|
|
{ source: 'return buy()' },
|
|
{ decide: () => ({}) },
|
|
]) {
|
|
expect(() => builtinStrategySelectionSchema.parse({ ...selection, ...patch })).toThrow();
|
|
}
|
|
});
|