Code Room
Vibe codingHardvc-g270
Subject Ai code reviewLevel Senior–Staff~20 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

An AI built this stock-signal backtest validation using k-fold CV. Backtest Sharpe is excellent; live trading loses money. Explain the leakage the shuffle introduces.

python
from sklearn.model_selection import cross_val_score, KFold # df sorted by date; features include rolling returnsX = df[feature_cols].valuesy = df['next_day_up'].valueskf = KFold(n_splits=5, shuffle=True, random_state=0)score = cross_val_score(clf, X, y, cv=kf).mean()print('CV accuracy:', score)
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.