Logo

Coding preview

Diverging Stocks

What this preview is

About this preview

Diverging Stocks is a easy quant coding problem on language knowledge in Cpp.

Unlock full access to getcracked

Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.

Implementing a stock divergence detector in C++

This is an easy coding problem that tests your ability to design and implement a simple event-driven monitoring system. It is representative of the kind of infrastructure code that real trading systems rely on: maintaining state across multiple entities, handling updates efficiently, and triggering alerts based on thresholds.

The core challenge is choosing the right data structures to track pairs of stocks, their most recent prices, and the relationships between them. You'll need to handle registration (with deduplication), price updates, and lookups across one-to-many relationships. The solution rewards clear logic over optimization; focus on correctness, edge cases (missing prices, duplicate pairs, multi-pair membership), and readable state management.

  • Mapping and bidirectional lookup (symbol to pairs, pair to symbols)
  • Deduplication and idempotent registration
  • Threshold-based comparison logic (strict inequality)
  • State consistency under concurrent updates