We use optional cookies for analytics and affiliate attribution. Essential cookies and marketing measurement are always on. Read our privacy policy

We just launched our Black Friday sale. You can use code BF2026 to get 25% off all subscriptions, valid until Nov 30th. There is a limit of 100 redemptions.

Logo

Diverging Stocks

What this preview is

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

Difficulty
Easy
Topic
Language Knowledge
Discipline
Quant development
Language
Cpp

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

Unlock full access to getcracked

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