feat: wavelets simulation

This commit is contained in:
OpenSquared
2026-07-20 21:43:35 +02:00
parent 28f7c77103
commit 52890f4d1d
4 changed files with 96 additions and 28 deletions

View File

@@ -481,6 +481,8 @@ export function runOptimizationGrid(
// lookback x wavelet combo) sequentially — deliberately not parallel, so the
// backend isn't hammered with concurrent CPU-heavy CWT requests. The cheap part
// (grid of trigger configs per fetched series) runs entirely in-browser.
export type WaveletDateRange = { startDate: string; endDate?: string } | null
export async function runFullOptimization(
instruments: string[], lookbacks: number[], wavelets: string[], period: string, levels: number,
bandsToTest: number[], kindsToTest: WaveletTriggerKind[], modesToTest: WaveletPositionMode[],
@@ -489,6 +491,7 @@ export async function runFullOptimization(
onBatchResults: (results: WaveletOptimizationResult[]) => void,
method: 'cwt' | 'ssq' = 'cwt',
filterBandIndex: number | null = null,
dateRange: WaveletDateRange = null,
): Promise<void> {
const combos: { symbol: string; lookback: number; wavelet: string }[] = []
for (const symbol of instruments) {
@@ -504,7 +507,10 @@ export async function runFullOptimization(
onProgress(i, combos.length, `${symbol} @ ${lookback}j (${wavelet})`, failures)
try {
const { data: rolling } = await api.get('/wavelet/rolling', {
params: { symbol, period, levels, wavelet, lookback, step: 1, method },
params: {
symbol, levels, wavelet, lookback, step: 1, method,
...(dateRange ? { start_date: dateRange.startDate, end_date: dateRange.endDate } : { period }),
},
})
onBatchResults(runOptimizationGrid(symbol, lookback, wavelet, rolling, bandsToTest, kindsToTest, modesToTest, exitVariants, filterBandIndex))
} catch (error) {