Quant Memo
Coding/●●●●●

Compute maximum run-up in one pass

Asked at Citadel, Jump Trading

Maximum run-up is the largest percentage gain from a running trough to a subsequent peak of an equity curve, the upside twin of maximum drawdown:

MRU=maxijEjEiEi\text{MRU} = \max_{i \le j} \frac{E_j - E_i}{E_i}

where EiE_i is the equity at time ii (assume all values positive).

equity = [100, 80, 130, 90, 150]
-> 0.875         # trough 80 up to peak 150

Return the maximum run-up as a fraction, in O(n)O(n) time and O(1)O(1) space. The naive all-pairs scan is O(n2)O(n^2).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions