/// <summary> /// Generate the daily returns plot using the python libraries. /// </summary> public override string Render() { var backtestReturns = ResultsUtil.EquityPoints(_backtest); var liveReturns = ResultsUtil.EquityPoints(_live); var backtestSeries = new Series <DateTime, double>(backtestReturns.Keys, backtestReturns.Values); var liveSeries = new Series <DateTime, double>(liveReturns.Keys, liveReturns.Values); // The following two operations are equivalent to the Pandas `DataFrame.resample(...)` method var backtestResampled = backtestSeries.PercentChange().ResampleEquivalence(date => date.Date, s => s.Sum()) * 100; var liveResampled = liveSeries.PercentChange().ResampleEquivalence(date => date.Date, s => s.Sum()) * 100; var base64 = ""; using (Py.GIL()) { var backtestList = new PyList(); backtestList.Append(backtestResampled.Keys.ToList().ToPython()); backtestList.Append(backtestResampled.Values.ToList().ToPython()); var liveList = new PyList(); liveList.Append(liveResampled.Keys.ToList().ToPython()); liveList.Append(liveResampled.Values.ToList().ToPython()); base64 = Charting.GetDailyReturns(backtestList, liveList); backtestList.Dispose(); liveList.Dispose(); } return(base64); }