Overall Statistics
Total Trades
825
Average Win
0.89%
Average Loss
-0.99%
Compounding Annual Return
21.446%
Drawdown
45.500%
Expectancy
0.274
Net Profit
167.591%
Sharpe Ratio
0.68
Probabilistic Sharpe Ratio
15.530%
Loss Rate
33%
Win Rate
67%
Profit-Loss Ratio
0.90
Alpha
0.089
Beta
1.166
Annual Standard Deviation
0.278
Annual Variance
0.077
Information Ratio
0.513
Tracking Error
0.201
Treynor Ratio
0.162
Total Fees
$1254.47
Estimated Strategy Capacity
$7500000.00
Lowest Capacity Asset
MRO R735QTJ8XC9X
# top dollar volume top MAR(History) universe

from AlgorithmImports import *

#

# -------------------------------------------------------
N_DV = 50; N_MOM = 10; FAST = 50; SLOW = 200; LEV = 1.00; 
# -------------------------------------------------------

class UglyBrownDolphin(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2017, 5, 25)
        self.SetEndDate(2022, 6, 16)
        self.SetCash(100000) 
        self.UniverseSettings.Resolution = Resolution.Minute
        self.AddUniverse(self.CoarseSelectionFunction)   
        self.selectedSymbols = []
        self.universeMonth = -1


    def CoarseSelectionFunction(self, universe):
        if self.Time.month == self.universeMonth:
            return self.selectedSymbols
        
        stocks = [x for x in universe if (x.HasFundamentalData)]
        price_above_10 =  [x for x in stocks if (x.Price > 10)]

        dollar_volume = sorted(price_above_10, key = lambda c: c.DollarVolume, reverse=True)
        dollar_volume_top = [c.Symbol for c in dollar_volume[:N_DV]]
        
        hist = self.History(dollar_volume_top, SLOW, Resolution.Daily)
        C = hist['close'].unstack(level = 0)
        mar = C[-FAST:].mean() / C[-SLOW:].mean() 
        top_mar = mar.sort_values(ascending = False)[:N_MOM]
        
        self.selectedSymbols = [self.Symbol(str(x)) for x in top_mar.index]
        self.Plot("Universe", "top_dv_top_mar_symbols", len(self.selectedSymbols))  

        return self.selectedSymbols
        
    
    def OnData(self, data):
        if self.Time.month == self.universeMonth: return
        if not (self.Time.hour == 10 and self.Time.minute == 1): return

        for sec in self.Portfolio.Keys:
            if sec not in self.selectedSymbols:
                self.Liquidate(sec)
                    
        for sec in self.selectedSymbols:
            self.SetHoldings(sec, LEV/len(self.selectedSymbols))
            
        self.universeMonth = self.Time.month