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
0
Tracking Error
0
Treynor Ratio
0
Total Fees
$0.00
from datetime import timedelta
from QuantConnect.Data.UniverseSelection import *
from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel

class NadionUncoupledPrism(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2020,1 ,1)
        self.SetCash(100000)
        self.AddUniverseSelection(LiquidValueUniverseSelectionModel())
        self.UniverseSettings.Resolution = Resolution.Daily

class LiquidValueUniverseSelectionModel(FundamentalUniverseSelectionModel):

    def __init__(self):
        super().__init__(True, None, None)
        self.lastMonth = -1

    def SelectCoarse(self,algorithm, coarse):
        
        if self.lastMonth == algorithm.Time.month:
            return Universe.Unchanged
        self.lastMonth = algorithm.Time.month
        
        sortedByDollarVolume = sorted([x for x in coarse if x.HasFundamentalData], \
        key=lambda x: x.DollarVolume, reverse=True)
        return [x.Symbol for x in sortedByDollarVolume[:100]]
        
    def SelectFine(self, algorithm, fine):
        #sortedByYields = sorted(fine, key=lambda f: f.ValuationRatios.EarningYield, reverse=True)
        filteredByYields = [f.Symbol for f in fine if f.ValuationRatios.EarningYield > 7]
        universe = filteredByYields[:10]
        return [f.Symbol for f in universe]
        
    def OnSecuritiesChanged(self, changes):
        
        self.changes = changes
        
        for security in self.changes.RemovedSecurities:
            if security.Invested:
                self.Liquidate(security.Symbol)
                
        for security in self.changes.AddedSecurities:
            if not security.Invested:
                self.SetHoldings(security.Symbol, .10)