Problem 45860. Algorithmic Trading - 2 (optimize Calmar Ratio)
This is the second of a series of problems on quant trading. It builds on earlier problem 45776 <https://www.mathworks.com/matlabcentral/cody/problems/45776-algorithmic-trading-1-optimize-trading-strategy-simple-case>
Goal
- Maximize the Calmar Ratio over the test period, calculated on daily returns, defined as C = CAGR/MDD, were MDD is the Maximum Drawdown of the return series, defined as the maximum relative drop from a peak (always positive).
- Max Drawdown can be calculated by MDD = -min((1+cR)./(1+cummax(cR))-1), where cR=cumprod(R+1)-1 is the cumulative compound return over time, mR=cummax(cR) is the historical maximum cumulative compound return over time, and R = D.*(S(1:n-1)>t) is the daily return of the investment strategy
You are given
- P, a [n x 1] vector of daily prices of the traded security, at market open (always positive)
- S, a [n x 1] vector of trading signals, calculated just ahead of market open (can take any real value)
- These will serve both as training and test set
Your function should return
- t, a scalar threshold that determines this simple trading strategy: invest all the available funds in the security when S>t, stay in cash otherwise
Hints
- The Calmar Ratio is a risk-weighted return metric. The optimal t also maximizes log(C) or, more simply maximizes sum(log(1+D.*(S(1:n-1)>t)))-cummax(cumsum(log(R+1)))
Solution Stats
Problem Comments
-
2 Comments
jmac
on 22 Nov 2020
Test suite fixed.
Michael Sisco
on 19 Jan 2023
Test suite is broken again.
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems
-
101484 Solvers
-
Determine whether a vector is monotonically increasing
20804 Solvers
-
13282 Solvers
-
28 Solvers
-
Algorithmic Trading - 4 (two thresholds)
2 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!