- 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
117 lines
3.8 KiB
TypeScript
117 lines
3.8 KiB
TypeScript
import type { ReplayConfig } from '@stock-bot/stock-config/canonical-replay';
|
|
import { createDatasetV2 } from '../../apps/stock/orchestrator/src/data/historical-dataset-v2';
|
|
|
|
/** Retained synthetic sessions, raw executable bars, explicit availability. */
|
|
export function nativeReplayFixture(barsPerAsset = 3, assets = 1, owners = ['A']) {
|
|
const start = Date.parse('2024-01-01T09:00:00Z'),
|
|
minute = 60000,
|
|
day = 86400000;
|
|
const at = (step: number) => start + Math.floor(step / 600) * day + (step % 600) * minute;
|
|
const end = at(barsPerAsset - 1) + minute;
|
|
const instruments = Array.from({ length: assets }, (_, i) => `X${i}.US`);
|
|
const calendar = {
|
|
id: 'fixture-calendar',
|
|
venue: 'TEST',
|
|
timeZone: 'UTC',
|
|
revision: '1',
|
|
source: 'synthetic',
|
|
startDate: '2024-01-01',
|
|
endDate: new Date(end + day).toISOString().slice(0, 10),
|
|
sessions: Array.from({ length: Math.ceil(barsPerAsset / 600) }, (_, i) => ({
|
|
date: new Date(start + i * day).toISOString().slice(0, 10),
|
|
open: start + i * day,
|
|
close: start + i * day + 600 * minute,
|
|
})),
|
|
};
|
|
const dataset = createDatasetV2({
|
|
metadata: {
|
|
calendars: [calendar],
|
|
series: instruments.map(instrumentId => ({
|
|
id: `${instrumentId}:1m`,
|
|
instrumentId,
|
|
interval: '1m',
|
|
calendarId: calendar.id,
|
|
venue: calendar.venue,
|
|
source: { provider: 'synthetic', revision: 'f07-v1' },
|
|
timestamp: 'interval-start',
|
|
availability: 'explicit',
|
|
adjustment: 'raw',
|
|
})),
|
|
executionSeries: instruments.map(instrumentId => ({
|
|
instrumentId,
|
|
seriesId: `${instrumentId}:1m`,
|
|
})),
|
|
bounds: { warmupStart: start, tradeStart: start + minute, tradeEnd: end },
|
|
universe: {
|
|
selection: 'point-in-time',
|
|
asOf: start,
|
|
revision: '1',
|
|
instrumentIds: instruments,
|
|
},
|
|
corporateActions: instruments.map(instrumentId => ({
|
|
instrumentId,
|
|
status: 'action-free',
|
|
start,
|
|
end,
|
|
revision: '1',
|
|
actions: [],
|
|
})),
|
|
},
|
|
bars: instruments.flatMap(instrumentId =>
|
|
Array.from({ length: barsPerAsset }, (_, step) => ({
|
|
seriesId: `${instrumentId}:1m`,
|
|
timestamp: at(step),
|
|
availableAt: at(step) + minute,
|
|
sourceSequence: step,
|
|
open: 10 + (step % 20) * 2,
|
|
high: 11 + (step % 20) * 2,
|
|
low: 10 + (step % 20) * 2,
|
|
close: 11 + (step % 20) * 2,
|
|
volume: 1000,
|
|
}))
|
|
),
|
|
});
|
|
const config: ReplayConfig = {
|
|
matching: {
|
|
risk: {
|
|
ledger: {
|
|
version: 1,
|
|
sessionId: 'f07-fixture',
|
|
accountId: 'research-only',
|
|
baseCurrency: 'USD',
|
|
reserveOwnerId: 'reserve',
|
|
ownerIds: owners,
|
|
initialCapital: '10000',
|
|
riskSession: {
|
|
calendarId: 'account',
|
|
calendarRevision: '1',
|
|
sessionId: 'risk',
|
|
startsAt: start,
|
|
},
|
|
},
|
|
feeRate: '0.01',
|
|
maxOrderQuantity: '1000000',
|
|
maxPositionQuantity: '1000000',
|
|
maxSymbolExposure: '1000000',
|
|
maxGrossExposure: '1000000',
|
|
maxDailyLoss: '1000000',
|
|
maxDrawdownAmount: '1000000',
|
|
maxMarkAgeMs: day * 2,
|
|
},
|
|
owners: owners.map(ownerId => ({ ownerId, mode: 'Target' })),
|
|
series: instruments.map(instrumentId => ({
|
|
instrumentId,
|
|
seriesId: `${instrumentId}:1m`,
|
|
mode: 'Open',
|
|
})),
|
|
halfSpreadRate: '0',
|
|
slippageRate: '0',
|
|
latencyMs: 0,
|
|
},
|
|
participation_rate: '1',
|
|
cadence: owners.map(owner_id => ({ owner_id, series_ids: instruments.map(id => `${id}:1m`) })),
|
|
allow_exploratory: false,
|
|
risk_boundaries: [],
|
|
};
|
|
return { dataset, config, start, minute, instruments };
|
|
}
|