KatInterview

Build a Return-Forecasting Pipeline with Sentiment and Price Signals

Machine LearningModel answer
HardModel answerMachine Learningtime-seriesfeature-engineeringbacktesting

Last updated

Design an end-to-end ML system that predicts next-day stock returns from news sentiment and price data, covering features, model choice, backtesting, and drift monitoring.

Background

You are building a daily signal generation system for a large-cap equity universe. For each stock on each trading day, you have access to:

  • Intraday news headlines with per-article sentiment scores and relevance scores, timestamped throughout the day
  • Daily OHLC price data and trading volume
  • Index membership records indicating which stocks belong to which benchmarks on each date

Your task is to predict the one-day forward return for each stock:

y = (Close(t+1) - Close(t)) / Close(t)

The predicted scores will feed a market-neutral long/short portfolio: long the top-ranked stocks, short the bottom-ranked ones, with dollar and beta neutrality enforced at execution.

What You Are Asked to Do

Write a structured response covering all four areas below. Be concrete — name specific techniques, justify trade-offs, and flag failure modes.

1. Data Construction and Feature Engineering

How do you build a training dataset from these inputs without leaking future information? Describe your point-in-time construction strategy for handling irregular intraday sentiment timestamps. Then list and explain at least three features you would derive from the raw data.

2. Model Selection

Given that daily equity returns are extremely noisy (realistic out-of-sample R² is often below 0.5%), what baseline model would you start with and what more advanced model would you graduate to? Justify each choice in terms of the signal-to-noise characteristics of the problem.

3. Offline Evaluation

Describe a rigorous backtesting procedure. Specifically, explain why standard K-fold cross-validation is inappropriate here and what you would use instead. List the metrics you would track at both the prediction level and the simulated portfolio level.

4. Production Monitoring and Retraining

Once deployed, how would you detect that the sentiment signal is degrading? Describe your drift detection approach and your fallback strategy when the model stops performing.

Constraints and Assumptions

  • The universe contains 5,000+ liquid stocks
  • Sentiment articles arrive at irregular times during the trading day; you have a fixed decision cutoff (e.g., 15:45 ET) after which any news belongs to the following day's features
  • Primary training objective is to minimize MSE, but a positive daily Information Coefficient (IC) — Spearman rank correlation between predictions and realized returns — is required to validate signal quality
  • Survivorship bias must be addressed: assume some stocks in your historical data were later delisted

Hints

Hint 1

Before designing any features, nail down your timing convention: exactly which information is observable at the decision cutoff on day t? Draw a timeline from market open to the next morning's trade execution and mark where each data source lands.

Hint 2

Standard K-fold randomly shuffles rows, but stock returns on the same calendar date share the same market shock — test rows from March 3rd will leak regime information to training rows from the same day. Think about how to split on time *and* prevent adjacent-window overlap.

Hint 3

MSE and IC can point in opposite directions: a model that predicts near-zero for every stock minimizes MSE but has zero IC. How do you train for one objective while selecting models based on the other?