Lars Kestner modified his formula twice, in 2003 (WL7 is using this revision) and in 2013:
Coding Lars Kestner’s K-Ratio in Excel
https://thesystematictrader.com/coding-lars-kestners-k-ratio-in-excel/
Coding Lars Kestner’s K-Ratio in Excel
https://thesystematictrader.com/coding-lars-kestners-k-ratio-in-excel/
Rename
I tried to come up with the 2013 version using two different approaches to coding it. The numbers returned are perfectly in line and neither matches the numbers from the referenced article. We will stick with the tried and true 2003 version and even be in agreement with a competitor software to help its users migrate to WL 😂
Understand
Vince
Vince
Lars' K-Ratio (2013, compounded) and
Lars' K-Ratio (2013, additive)
are both available as a formula metric in the Formula Scorecard which is part of the finatic.ScoreCard extension.
For example, K-Ratio (2013, compunded) is implemented by this formula:
This means the metric is
1. normalized with respect to the length of the equity curve and
2. annualized
Earlier versions of Lars' K-Ratio fail in both respects.
Remark: The formulas for Formula Scorecard are user-editable at runtime, so you can implement your own variations easily.
Lars' K-Ratio (2013, additive)
are both available as a formula metric in the Formula Scorecard which is part of the finatic.ScoreCard extension.
For example, K-Ratio (2013, compunded) is implemented by this formula:
CODE:
var r = LinearRegression(EquityCurve.Select(d => Log(d))); double slope = r.Item2; double se_slope = r.Item5; double rawK = slope / se_slope; double K = rawK * Sqrt(252) / EquityCurve.Count; return K;
This means the metric is
1. normalized with respect to the length of the equity curve and
2. annualized
Earlier versions of Lars' K-Ratio fail in both respects.
Remark: The formulas for Formula Scorecard are user-editable at runtime, so you can implement your own variations easily.
@Eugene: I'd consider this #FeatureRequest as implemented rather than declined...
@DrKoch: agreed. Marked as completed. Thanks!
Here's one of my stashes, not sure why it didn't work:
Here's one of my stashes, not sure why it didn't work:
CODE:
internal double GetKRatio(TimeSeries eq, int firstBar, int lastBar) { int numObservations = lastBar + 1 - firstBar; //The number of observations in a year is 4 for quarterly data, 12 for monthly data and 252 for daily data. HistoryScale scale = eq.DetermineScale(); int numInYear = scale == HistoryScale.Quarterly ? 4 : scale == HistoryScale.Monthly ? 12 : scale == HistoryScale.Weekly ? 52 : scale == HistoryScale.Daily ? 252 : 0; double Result = -1; if ((numObservations < 2) || (eq[firstBar] <= 0) || numInYear == 0) Result = 0; var _slope = LRSlope.Value(lastBar, eq, numObservations); var _sd = StdError.Series(eq, numObservations)[lastBar]; if (_sd > 0) Result = (_slope / _sd) * (Math.Sqrt(numInYear) / (double)numObservations); return Result; }
Your Response
Post
Edit Post
Login is required