Overall Statistics |
Total Trades 2 Average Win 0% Average Loss 0% Compounding Annual Return 9.617% Drawdown 7.800% Expectancy 0 Net Profit 9.562% Sharpe Ratio 0.648 Probabilistic Sharpe Ratio 32.729% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.116 Beta 1.266 Annual Standard Deviation 0.111 Annual Variance 0.012 Information Ratio -0.877 Tracking Error 0.087 Treynor Ratio 0.057 Total Fees $105.68 Estimated Strategy Capacity $26000000.00 Lowest Capacity Asset MWD 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)