Overall Statistics
Total Trades
858
Average Win
0.44%
Average Loss
-0.55%
Compounding Annual Return
-33.553%
Drawdown
43.200%
Expectancy
-0.170
Net Profit
-33.553%
Sharpe Ratio
-1.146
Loss Rate
54%
Win Rate
46%
Profit-Loss Ratio
0.80
Alpha
-0.108
Beta
-12.447
Annual Standard Deviation
0.308
Annual Variance
0.095
Information Ratio
-1.21
Tracking Error
0.308
Treynor Ratio
0.028
Total Fees
$2972.58
class CoarseFundamentalTop5Algorithm(QCAlgorithm):

    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(2014,1,1)    #Set Start Date
        self.SetEndDate(2015,1,1)      #Set End Date
        self.SetCash(50000)            #Set Strategy Cash

        # what resolution should the data *added* to the universe be?
        self.UniverseSettings.Resolution = Resolution.Daily

        # this add universe method accepts a single parameter that is a function that
        # accepts an IEnumerable<CoarseFundamental> and returns IEnumerable<Symbol>
        self.AddUniverse(self.CoarseSelectionFunction)

        self.__numberOfSymbols = 5
        self._changes = None


    # sort the data by daily dollar volume and take the top 'NumberOfSymbols'
    def CoarseSelectionFunction(self, coarse):
        # sort descending by daily dollar volume
        sortedByVolume = sorted(coarse, key=lambda x: x.Volume, reverse=True)
        # return the symbol objects of the top entries from our sorted collection
        return [ x.Symbol for x in sortedByVolume[:self.__numberOfSymbols] ]


    def OnData(self, data):

        pass
        # if we have no changes, do nothing
        if self._changes == None: return

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

        # we want 20% allocation in each security in our universe
        for security in self._changes.AddedSecurities:
            self.SetHoldings(security.Symbol, 0.2)

        self._changes = None;


    # this event fires whenever we have changes to our universe
    def OnSecuritiesChanged(self, changes):
        self.Debug(changes)
        self._changes = changes

    def OnOrderEvent(self, fill):
        pass