- ago
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/
2
1,542
Solved
5 Replies

Reply

Bookmark

Sort
- ago
#1
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 😂
0
- ago
#2
Understand

Vince
0
- ago
#3
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:

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.
0
Best Answer
- ago
#4
@Eugene: I'd consider this #FeatureRequest as implemented rather than declined...
0
- ago
#5
@DrKoch: agreed. Marked as completed. Thanks!

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; }
0

Reply

Bookmark

Sort