24 internal sealed
class RollingSharpeReportElement : ChartReportElement
32 private int _tradingDaysPerYear;
42 public RollingSharpeReportElement(
string name,
string key,
BacktestResult backtest,
LiveResult live,
int tradingDaysPerYear)
48 _tradingDaysPerYear = tradingDaysPerYear;
54 public override string Render()
56 var backtestPoints = ResultsUtil.EquityPoints(_backtest);
57 var livePoints = ResultsUtil.EquityPoints(_live);
59 var backtestSeries =
new Series<DateTime, double>(backtestPoints);
60 var liveSeries =
new Series<DateTime, double>(livePoints);
62 var backtestRollingSharpeSixMonths = Rolling.Sharpe(backtestSeries, 6, _tradingDaysPerYear).DropMissing();
63 var backtestRollingSharpeTwelveMonths = Rolling.Sharpe(backtestSeries, 12, _tradingDaysPerYear).DropMissing();
64 var liveRollingSharpeSixMonths = Rolling.Sharpe(liveSeries, 6, _tradingDaysPerYear).DropMissing();
65 var liveRollingSharpeTwelveMonths = Rolling.Sharpe(liveSeries, 12, _tradingDaysPerYear).DropMissing();
70 var backtestList =
new PyList();
71 var liveList =
new PyList();
73 backtestList.Append(backtestRollingSharpeSixMonths.Keys.ToList().ToPython());
74 backtestList.Append(backtestRollingSharpeSixMonths.Values.ToList().ToPython());
75 backtestList.Append(backtestRollingSharpeTwelveMonths.Keys.ToList().ToPython());
76 backtestList.Append(backtestRollingSharpeTwelveMonths.Values.ToList().ToPython());
78 liveList.Append(liveRollingSharpeSixMonths.Keys.ToList().ToPython());
79 liveList.Append(liveRollingSharpeSixMonths.Values.ToList().ToPython());
80 liveList.Append(liveRollingSharpeTwelveMonths.Keys.ToList().ToPython());
81 liveList.Append(liveRollingSharpeTwelveMonths.Values.ToList().ToPython());
83 base64 = Charting.GetRollingSharpeRatio(backtestList, liveList);