Maximum Drawdown and Recovery Day From a Daily PnL Series

Last updated: November 29, 2026

Quick Overview

Given a list of daily PnL values for a strategy, compute the maximum drawdown of the cumulative PnL curve, the peak and trough days that define it, and the first day the curve regains the peak (or None).

Trexquant
Coding & Algorithms
Quantitative Researcher
Trexquant
November 29, 2026
Quantitative Researcher
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given a list of daily PnL values for a strategy, compute the maximum drawdown of the cumulative PnL curve, the peak and trough days that define it, and the first day the curve regains the peak (or None).

Drawdown is one of the first numbers anyone looks at when judging a backtest. The interviewer checks a single pass solution and careful indexing around the starting equity and an unrecovered drawdown.

What the Interviewer Expects
  • Builds the cumulative equity curve starting from zero
  • Tracks running peak and the largest peak-to-trough gap in one pass
  • Returns peak, trough and recovery indices consistently
  • Handles a drawdown that starts before day 0 and one that never recovers
  • States O(n) time
Key Topics to Cover
running maximum
equity curve
drawdown
single pass
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you report drawdown as a percent of capital instead of dollars?
  • How would you find the longest drawdown duration instead of the deepest?
  • Why can max drawdown be misleading when comparing strategies with different history lengths?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Equity starts at 0 before day 0 and adds each day's PnL. Drawdown at day i is running peak minus equity. Return (max_dd, peak_idx, trough_idx, recovery_idx); peak_idx is -1 if the peak is the starti...

High-Level Design

One pass keeps the running peak and its index; whenever peak - equity beats the best so far, record it. A second short pass from the trough finds the first day equity is back at the peak level....


Submit Your Answer
Markdown supported

Related Questions