Overall Statistics Total Trades4936Average Win0.08%Average Loss-0.07%Compounding Annual Return13.320%Drawdown20.200%Expectancy0.028Net Profit13.320%Sharpe Ratio0.532Loss Rate50%Win Rate50%Profit-Loss Ratio1.08Alpha0.877Beta-43.338Annual Standard Deviation0.267Annual Variance0.071Information Ratio0.468Tracking Error0.267Treynor Ratio-0.003Total Fees\$5403.92
```import numpy as np

### <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(2016,1,01)  #Set Start Date
self.SetEndDate(2017,1,01)    #Set End Date
self.SetCash(100000)           #Set Strategy Cash
self.UniverseSettings.Resolution = Resolution.Daily
self._changes = SecurityChanges.None
self.CoarseSymbols = 200
self.FineSymbols1  = 150
self.FineSymbols2  = 100
self.FineSymbols3  = 50
self.FineSymbols4  = 20

def CoarseSelectionFunction(self,coarse):
sortedbyDollarVolume = sorted(coarse, key = lambda x: x.DollarVolume, reverse = True)
return[x.Symbol for x in sortedbyDollarVolume[:self.CoarseSymbols]]

def FineSelectionFunction(self,fine):
sortedbyMetric1 = sorted(fine, key = lambda x: x.OperationRatios.ROIC.OneYear, reverse = False)
sortedbyMetric2 = sorted(sortedbyMetric1[:self.FineSymbols1], key = lambda x: x.ValuationRatios.EVToEBITDA, reverse = True)
sortedbyMetric3 = sorted(sortedbyMetric2[:self.FineSymbols2], key = lambda x: x.ValuationRatios.BookValuePerShare, reverse = False)
sortedbyMetric4 = sorted(sortedbyMetric3[:self.FineSymbols3], key = lambda x: x.OperationRatios.ROE.OneYear, reverse = False)
return[x.Symbol for x in sortedbyMetric4[:self.FineSymbols4]]

def OnData(self, data):

if self._changes == SecurityChanges.None: return

# liquidate removed securities
for security in self._changes.RemovedSecurities:
if security.Invested:
self.Liquidate(security.Symbol)

# we want equal allocation in each security in our universe
# 1 / 20 = 0.05 so use 0.045 to prevent insufficient funds