/// <summary> /// Generate the rolling portfolio beta to equities plot using the python libraries. /// </summary> public override string Render() { var backtestPoints = ResultsUtil.EquityPoints(_backtest); var backtestBenchmarkPoints = ResultsUtil.BenchmarkPoints(_backtest); var livePoints = ResultsUtil.EquityPoints(_live); var liveBenchmarkPoints = ResultsUtil.BenchmarkPoints(_live); var backtestSeries = new Series <DateTime, double>(backtestPoints); var backtestBenchmarkSeries = new Series <DateTime, double>(backtestBenchmarkPoints); var liveSeries = new Series <DateTime, double>(livePoints); var liveBenchmarkSeries = new Series <DateTime, double>(liveBenchmarkPoints); var base64 = ""; using (Py.GIL()) { var backtestList = new PyList(); var liveList = new PyList(); var backtestRollingBetaSixMonths = Rolling.Beta(backtestSeries, backtestBenchmarkSeries, windowSize: 22 * 6); var backtestRollingBetaTwelveMonths = Rolling.Beta(backtestSeries, backtestBenchmarkSeries, windowSize: 252); backtestList.Append(backtestRollingBetaSixMonths.Keys.ToList().ToPython()); backtestList.Append(backtestRollingBetaSixMonths.Values.ToList().ToPython()); backtestList.Append(backtestRollingBetaTwelveMonths.Keys.ToList().ToPython()); backtestList.Append(backtestRollingBetaTwelveMonths.Values.ToList().ToPython()); var liveRollingBetaSixMonths = Rolling.Beta(liveSeries, liveBenchmarkSeries, windowSize: 22 * 6); var liveRollingBetaTwelveMonths = Rolling.Beta(liveSeries, liveBenchmarkSeries, windowSize: 252); liveList.Append(liveRollingBetaSixMonths.Keys.ToList().ToPython()); liveList.Append(liveRollingBetaSixMonths.Values.ToList().ToPython()); liveList.Append(liveRollingBetaTwelveMonths.Keys.ToList().ToPython()); liveList.Append(liveRollingBetaTwelveMonths.Values.ToList().ToPython()); base64 = Charting.GetRollingBeta(backtestList, liveList); } return(base64); }