Overall Statistics |
Total Trades 1 Average Win 0% Average Loss 0% Compounding Annual Return -4.497% Drawdown 14.000% Expectancy 0 Net Profit -4.473% Sharpe Ratio -0.293 Probabilistic Sharpe Ratio 6.024% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.109 Beta 0.554 Annual Standard Deviation 0.093 Annual Variance 0.009 Information Ratio -1.929 Tracking Error 0.091 Treynor Ratio -0.049 Total Fees $74.65 Estimated Strategy Capacity $38000000.00 Lowest Capacity Asset XON R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class SquareGreenRhinoceros(QCAlgorithm): def Initialize(self): self.SetStartDate(2017, 1, 1) # Set Start Date self.SetEndDate(2018, 1, 1) # Set Start Date self.SetCash(1000000) # Set Strategy Cash ms = self.AddEquity("MS", Resolution.Daily).Symbol xom = self.AddEquity("XOM", Resolution.Daily).Symbol spy = self.AddEquity("SPY", Resolution.Daily).Symbol self.series = {} self.InitChart('MS') self.InitChart('XOM') self.InitChart('SPY') self.ind = {} self.InitIndicators(ms.Value, 5) self.InitIndicators(xom.Value, 5) self.InitIndicators(spy.Value, 5) def InitChart(self, name): chart = Chart(name + ' Stats') self.AddChart(chart) self.series[name + ' SharpRatio'] = Series(name + ' SharpRatio', SeriesType.Line, 'r/v', Color.Blue) # The log return are in reality the logarithmic of compound returns # which by logarithmic propieties end up being the substraction # of the logarithm on current price minus price on day cero for a given period self.series[name + ' Log Return'] = Series(name + ' Log Return', SeriesType.Line, '', Color.Green) self.series[name + ' STD'] = Series(name + ' STD', SeriesType.Line, '', Color.Red) chart.AddSeries(self.series[name + ' SharpRatio']) chart.AddSeries(self.series[name + ' Log Return']) chart.AddSeries(self.series[name + ' STD']) def InitIndicators(self, symbol, period): # Create indicators self.ind[symbol+'_logr'] = LogReturn(symbol+'_logr',period) self.RegisterIndicator(symbol, self.ind[symbol+'_logr'], Resolution.Daily) self.ind[symbol+'_sr'] = SharpeRatio(symbol+'_sr',period, 0) self.RegisterIndicator(symbol, self.ind[symbol+'_sr'], Resolution.Daily) self.ind[symbol+'_std'] = StandardDeviation(symbol+'_std',period) self.RegisterIndicator(symbol, self.ind[symbol+'_std'], Resolution.Daily) self.logr = self.LOGR(symbol, 1) def OnData(self, data: Slice): if not self.Portfolio.Invested: self.SetHoldings("MS", self.GetParameter('w_ms')) self.SetHoldings("XOM", self.GetParameter('w_xom')) self.SetHoldings("SPY", self.GetParameter('w_spy')) self.PlotPoints('MS') self.PlotPoints('XOM') self.PlotPoints('SPY') def PlotPoints(self, symbol): self.series[symbol + ' Log Return'].AddPoint(self.Time,self.ind[symbol+'_logr'].Current.Value) self.series[symbol + ' SharpRatio'].AddPoint(self.Time,self.ind[symbol+'_sr'].Current.Value) self.series[symbol + ' STD'].AddPoint(self.Time,self.ind[symbol+'_std'].Current.Value)