- 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
63 lines
2 KiB
TypeScript
63 lines
2 KiB
TypeScript
import { smaStrategySelectionSchema } from '@stock-bot/stock-config/strategy';
|
|
import { createDatasetV2 } from '../../apps/stock/orchestrator/src/data/historical-dataset-v2';
|
|
import { nativeReplayFixture } from './native-replay';
|
|
|
|
/** Reviewed oracle: buy ten at next open 5, sell ten at next open 2; fees 0.70. */
|
|
export function canonicalSmaFixture(
|
|
owners = ['A'],
|
|
options: {
|
|
tradeStartStep?: number;
|
|
volume?: number;
|
|
opens?: number[];
|
|
closes?: number[];
|
|
availabilitySteps?: number[];
|
|
} = {}
|
|
) {
|
|
const fixture = nativeReplayFixture(7, 1, owners);
|
|
const { calendars, series, executionSeries, bounds, universe, corporateActions } =
|
|
fixture.dataset.manifest;
|
|
const closes = options.closes ?? [3, 2, 1, 4, 5, 1, 1];
|
|
const opens = options.opens ?? [3, 3, 2, 1, 5, 5, 2];
|
|
const dataset = createDatasetV2({
|
|
metadata: {
|
|
calendars,
|
|
series,
|
|
executionSeries,
|
|
bounds: {
|
|
...bounds,
|
|
tradeStart: fixture.start + (options.tradeStartStep ?? 1) * fixture.minute,
|
|
},
|
|
universe,
|
|
corporateActions,
|
|
},
|
|
bars: fixture.dataset.bars.map((bar, index) => {
|
|
const open = opens[index]!,
|
|
close = closes[index]!;
|
|
return {
|
|
seriesId: bar.seriesId,
|
|
timestamp: bar.intervalStart,
|
|
availableAt:
|
|
fixture.start + (options.availabilitySteps?.[index] ?? index + 1) * fixture.minute,
|
|
sourceSequence: bar.sourceSequence,
|
|
open,
|
|
close,
|
|
high: Math.max(open, close),
|
|
low: Math.min(open, close),
|
|
volume: options.volume ?? 1000,
|
|
};
|
|
}),
|
|
});
|
|
const selections = owners.map(ownerId =>
|
|
smaStrategySelectionSchema.parse({
|
|
ownerId,
|
|
strategyId: 'sma',
|
|
strategyVersion: 'sma-crossover-long-only/v1',
|
|
seed: 42,
|
|
instrumentId: 'X0.US',
|
|
seriesId: 'X0.US:1m',
|
|
ownerBudget: '40',
|
|
parameters: { fastPeriod: 2, slowPeriod: 3 },
|
|
})
|
|
);
|
|
return { ...fixture, dataset, selections };
|
|
}
|