Exemplo n.º 1
0
        /// <summary>
        /// Generate the rolling sharpe using the python libraries.
        /// </summary>
        public override string Render()
        {
            var backtestPoints = ResultsUtil.EquityPoints(_backtest);
            var livePoints     = ResultsUtil.EquityPoints(_live);

            var backtestRollingSharpe = Rolling.Sharpe(new Series <DateTime, double>(backtestPoints), 6).DropMissing();
            var liveRollingSharpe     = Rolling.Sharpe(new Series <DateTime, double>(livePoints), 6).DropMissing();

            var base64 = "";

            using (Py.GIL())
            {
                var backtestList = new PyList();
                var liveList     = new PyList();

                backtestList.Append(backtestRollingSharpe.Keys.ToList().ToPython());
                backtestList.Append(backtestRollingSharpe.Values.ToList().ToPython());

                liveList.Append(liveRollingSharpe.Keys.ToList().ToPython());
                liveList.Append(liveRollingSharpe.Values.ToList().ToPython());

                base64 = Charting.GetRollingSharpeRatio(backtestList, liveList);
            }

            return(base64);
        }