Overall Statistics
Total Trades
1042
Average Win
0.07%
Average Loss
-0.02%
Compounding Annual Return
74.020%
Drawdown
4.000%
Expectancy
0.788
Net Profit
14.811%
Sharpe Ratio
4.447
Probabilistic Sharpe Ratio
92.116%
Loss Rate
58%
Win Rate
42%
Profit-Loss Ratio
3.23
Alpha
0.639
Beta
-0.087
Annual Standard Deviation
0.138
Annual Variance
0.019
Information Ratio
1.805
Tracking Error
0.194
Treynor Ratio
-7.05
Total Fees
$1105.02
Estimated Strategy Capacity
$13000.00
Lowest Capacity Asset
SENEB R735QTJ8XC9X
class UglyRedOrangeChinchilla(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 12, 1)  
        self.SetEndDate(2021, 3, 1) 
        self.SetCash(100000)  
        self.SetBenchmark("SPY")
        self.num_fine = 10
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverseSelection(
            FineFundamentalUniverseSelectionModel(self.SelectCoarse, 
                                                    self.SelectFine))
            
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
    
    def SelectCoarse(self, coarse):
        hasFundamentalData = [c for c in coarse if c.HasFundamentalData]
        filteredByPrice = [p.Symbol for p in hasFundamentalData if p.Price > 10]
        
        return filteredByPrice

    def SelectFine(self, fine):
        filter_sector = [f for f in fine if f.AssetClassification.MorningstarSectorCode == MorningstarSectorCode.ConsumerDefensive]
        sortedByFactor = sorted(filter_sector, 
                            key=lambda f: f.ValuationRatios.FCFYield, 
                            reverse=True)
        self.forLong = [f.Symbol for f in sortedByFactor[:self.num_fine]]
        self.forShort = [f.Symbol for f in sortedByFactor[-self.num_fine:]]
        return self.forShort + self.forLong
    
    def OnData(self, slice):
        insights = []
        
        for kvp in self.Portfolio:
            holding = kvp.Value
            symbol = holding.Symbol
            if holding.Invested and symbol not in self.forLong and symbol not in self.forShort:
                insights.append(Insight(symbol, timedelta(1), InsightType.Price, InsightDirection.Flat, None, None))
        
        [insights.append(Insight.Price(symbol, timedelta(1), InsightDirection.Up)) for symbol in self.forLong]
        [insights.append(Insight.Price(symbol, timedelta(1), InsightDirection.Down)) for symbol in self.forShort]
        self.EmitInsights(insights)