Overall Statistics |
Total Trades 576 Average Win 2.63% Average Loss -1.27% Compounding Annual Return 16.573% Drawdown 20.200% Expectancy 0.379 Net Profit 254.162% Sharpe Ratio 0.941 Loss Rate 55% Win Rate 45% Profit-Loss Ratio 2.07 Alpha 0.118 Beta 2.573 Annual Standard Deviation 0.18 Annual Variance 0.033 Information Ratio 0.83 Tracking Error 0.18 Treynor Ratio 0.066 Total Fees $969.31 |
import numpy as np from datetime import timedelta, datetime ### <summary> ### Basic template algorithm simply initializes the date range and cash. This is a skeleton ### framework you can use for designing an algorithm. ### </summary> 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(2010, 1, 1) #Set Start Date self.SetEndDate(2018,4,1) #Set End Date self.SetCash(100000) #Set Strategy Cash # Find more symbols here: http://quantconnect.com/data self.symbol = 'GOOGL' self.AddEquity(self.symbol, Resolution.Daily) self.ha = self.HeikinAshi(self.symbol, Resolution.Daily) self.Schedule.On(self.DateRules.EveryDay(self.symbol), self.TimeRules.AfterMarketOpen(self.symbol, -1), Action(self.BeforeMarketOpen)) def BeforeMarketOpen(self): if not self.ha.IsReady: return position = self.Portfolio[self.symbol].Quantity if self.ha.CurrentBar.Close > self.ha.CurrentBar.Open: self.SetHoldings(self.symbol, 1) if position >= 0 and self.ha.CurrentBar.Close < self.ha.CurrentBar.Open: self.Liquidate(self.symbol) def OnData(self, data): pass