Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-1.857
Tracking Error
0.113
Treynor Ratio
0
Total Fees
$0.00
class NadionOptimizedEngine(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 11, 15)
        
        self.tsla = Symbol.Create("TSLA", SecurityType.Equity, Market.USA)
        
        self.SetUniverseSelection(FineFundamentalUniverseSelectionModel(self.CoarseSelectionFunction, self.FineSelectionFunction, None, None))

    
    def CoarseSelectionFunction(self, coarse):
        sortedByDollarVolume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)[:5]
        return [ x.Symbol for x in sortedByDollarVolume ] + [self.tsla]
    
    def FineSelectionFunction(self, fine):
        
        tsla_pe = None
        for f in fine:
            self.Log(f"PE of {f.Symbol}: {f.ValuationRatios.PERatio}")
            if f.Symbol == self.tsla:
                tsla_pe = f.ValuationRatios.PERatio
        if tsla_pe is None:
            return []
        
        return [f.Symbol for f in fine if f.Symbol != self.tsla and f.ValuationRatios.PERatio > tsla_pe]