Overall Statistics |
Total Trades 50 Average Win 2.77% Average Loss -2.39% Compounding Annual Return 8.019% Drawdown 15.700% Expectancy 0.381 Net Profit 23.924% Sharpe Ratio 0.649 Loss Rate 36% Win Rate 64% Profit-Loss Ratio 1.16 Alpha 0.213 Beta -6.39 Annual Standard Deviation 0.132 Annual Variance 0.017 Information Ratio 0.498 Tracking Error 0.132 Treynor Ratio -0.013 Total Fees $875.41 |
from QuantConnect.Indicators import * class BasicTemplateAlgorithm(QCAlgorithm): '''Basic template algorithm simply initializes the date range and cash''' def Initialize(self): '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.''' self.SetStartDate(2015,9,1) #Set Start Date self.SetEndDate(2018,5,15) #Set End Date self.SetCash(100000) #Set Strategy Cash # Find more symbols here: http://quantconnect.com/data self.AddEquity("PFE", Resolution.Daily) self.BollingerBand = self.BB("PFE",20,2,MovingAverageType.Simple,Resolution.Daily) self.Strength = self.RSI("PFE",14,MovingAverageType.Simple,Resolution.Daily) self.SetWarmUp(20) self.SetBenchmark("SPY") def OnData(self, data): rsi = self.Strength.Current.Value lower = self.BollingerBand.LowerBand.Current.Value upper = self.BollingerBand.UpperBand.Current.Value middle = self.BollingerBand.MiddleBand.Current.Value current = data["PFE"].Close #need to check when to go long if not self.Portfolio.Invested: if current < lower and rsi < 40: self.SetHoldings("PFE", 1) if current > upper and rsi > 60: self.SetHoldings("PFE", -1) if self.Portfolio.Invested: if self.Portfolio["PFE"].IsLong: if current > middle: self.Liquidate("PFE") if self.Portfolio["PFE"].IsShort: if current < middle: self.Liquidate("PFE")