Overall Statistics
Total Trades
227
Average Win
0.20%
Average Loss
-0.12%
Compounding Annual Return
449.861%
Drawdown
2.200%
Expectancy
1.040
Net Profit
16.118%
Sharpe Ratio
13.028
Probabilistic Sharpe Ratio
96.033%
Loss Rate
24%
Win Rate
76%
Profit-Loss Ratio
1.68
Alpha
3.599
Beta
-0.421
Annual Standard Deviation
0.242
Annual Variance
0.058
Information Ratio
6.327
Tracking Error
0.328
Treynor Ratio
-7.476
Total Fees
$319.31
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(2019,2 ,1)
        self.SetCash(100000)
        self.AddUniverseSelection(LiquidValueUniverseSelectionModel())
        self.UniverseSettings.Resolution = Resolution.Daily
        
        self.AddAlpha(ConstantAlphaModel(InsightType.Price, InsightDirection.Up, timedelta(days=1), None, None))
        self.SetExecution(ImmediateExecutionModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())


class LiquidValueUniverseSelectionModel(FundamentalUniverseSelectionModel):

    def __init__(self):
        super().__init__(True, None, None)

    def SelectCoarse(self,algorithm, coarse):
        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)
        universe = sortedByYields[: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)