@@ -200,6 +200,18 @@ export function generateMockHindcast(n = 6): HindcastResponse {
200200 return null ;
201201 } ) ;
202202
203+ // Scoring for predictions with enough realized data
204+ const nRealized = realizedPrices . filter ( ( v ) => v != null ) . length ;
205+ const dirLabels = [ "LONG" , "SHORT" , "NEUTRAL" ] as const ;
206+ const sigDir = dirLabels [ Math . floor ( rand ( ) * 3 ) ] ;
207+ const dirCorrect = rand ( ) > 0.4 ;
208+ const coverageOuter = + ( 0.5 + rand ( ) * 0.4 ) . toFixed ( 4 ) ;
209+ const coverageInner = + ( 0.3 + rand ( ) * 0.3 ) . toFixed ( 4 ) ;
210+ const bestRmse = + ( 0.5 + rand ( ) * 3 ) . toFixed ( 2 ) ;
211+ const trackDur = Math . floor ( 3 + rand ( ) * 10 ) ;
212+ const verdict = coverageOuter >= 0.7 && dirCorrect ? "PASS" as const
213+ : coverageOuter >= 0.5 || dirCorrect ? "PARTIAL" as const : "FAIL" as const ;
214+
203215 predictions . push ( {
204216 timestamp : new Date ( predTime ) . toISOString ( ) ,
205217 last_close : round ( price ) ,
@@ -208,10 +220,39 @@ export function generateMockHindcast(n = 6): HindcastResponse {
208220 sample_paths : samplePaths ,
209221 realized_prices : realizedPrices ,
210222 bars_elapsed : barsElapsed ,
223+ scoring : nRealized >= 3 ? {
224+ coverage_p10_p90 : coverageOuter ,
225+ coverage_p25_p75 : coverageInner ,
226+ direction_correct : dirCorrect ,
227+ median_rmse_pts : + ( 1 + rand ( ) * 5 ) . toFixed ( 2 ) ,
228+ best_paths : [ {
229+ path_index : Math . floor ( rand ( ) * 30 ) ,
230+ path_values : samplePaths [ Math . floor ( rand ( ) * 30 ) ] ,
231+ rmse_pts : bestRmse ,
232+ tracking_duration_bars : trackDur ,
233+ tracking_threshold_pts : 2.0 ,
234+ deviations : realizedPrices
235+ . filter ( ( v ) : v is number => v != null )
236+ . map ( ( ) => + ( ( rand ( ) - 0.5 ) * 3 ) . toFixed ( 2 ) ) ,
237+ } ] ,
238+ verdict,
239+ signal_direction : sigDir ,
240+ expected_return_pts : + ( ( rand ( ) - 0.5 ) * 8 ) . toFixed ( 2 ) ,
241+ realized_return_pts : + ( ( rand ( ) - 0.5 ) * 10 ) . toFixed ( 2 ) ,
242+ } : null ,
211243 } ) ;
212244 }
213245
214- return { predictions } ;
246+ return {
247+ predictions,
248+ rolling_accuracy : {
249+ n_evaluated : predictions . length ,
250+ coverage_p10_p90 : 0.78 ,
251+ coverage_p25_p75 : 0.46 ,
252+ direction_hit_rate : 0.58 ,
253+ mean_tracking_rmse_pts : 1.9 ,
254+ } ,
255+ } ;
215256}
216257
217258export function generateMockHistory ( ) : HistoryResponse {
0 commit comments