Overall Statistics
Total Trades
466
Average Win
0.17%
Average Loss
-0.13%
Compounding Annual Return
17.567%
Drawdown
32.900%
Expectancy
0.099
Net Profit
17.619%
Sharpe Ratio
0.636
Probabilistic Sharpe Ratio
32.302%
Loss Rate
52%
Win Rate
48%
Profit-Loss Ratio
1.30
Alpha
0.247
Beta
-0.221
Annual Standard Deviation
0.317
Annual Variance
0.101
Information Ratio
-0.002
Tracking Error
0.483
Treynor Ratio
-0.911
Total Fees
$466.05
Estimated Strategy Capacity
$42000000.00
Lowest Capacity Asset
AGO SY2SA4YZ4UW5
from AlphaModel import *

class VerticalTachyonRegulators(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetEndDate(2021, 1, 1)
        self.SetCash(100000)
        
        # Execution model
        self.SetExecution(ImmediateExecutionModel())
        
        # Portfolio construction model
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(rebalance=timedelta(weeks=13)))
        
        # Risk model
        self.SetRiskManagement(NullRiskManagementModel())
        
        # Universe selection
        self.num_coarse = 500
        self.rebalanceTime = datetime.min
        self.UniverseSettings.Resolution = Resolution.Daily
        self.AddUniverse(self.CoarseSelectionFunction, self.FineSelectionFunction)
        
        self.sectors = set([MorningstarSectorCode.FinancialServices, MorningstarSectorCode.RealEstate, MorningstarSectorCode.Healthcare, MorningstarSectorCode.Utilities, MorningstarSectorCode.Technology])
        self.period = timedelta(weeks=13)
        
        # Alpha Model
        self.AddAlpha(FundamentalFactorAlphaModel(self.period, self.sectors))
    

    def CoarseSelectionFunction(self, coarse):
        # If not time to rebalance, keep the same universe
        if self.Time <= self.rebalanceTime: 
            return Universe.Unchanged
        
        self.rebalanceTime = self.Time + self.period
        
        # Select only those with fundamental data and a sufficiently large price
        # Sort by top dollar volume: most liquid to least liquid
        selected = sorted([x for x in coarse if x.HasFundamentalData and x.Price > 5],
                            key = lambda x: x.DollarVolume, reverse=True)
        
        return [x.Symbol for x in selected[:self.num_coarse]]


    def FineSelectionFunction(self, fine):
        # Filter the fine data for equities that IPO'd more than 5 years ago in given sector
        filtered_fine = [x.Symbol for x in fine if x.SecurityReference.IPODate + timedelta(365*5) < self.Time
                                    and x.AssetClassification.MorningstarSectorCode  in self.sectors
                                    and x.OperationRatios.ROE.Value > 0
                                    and x.OperationRatios.NetMargin.Value > 0
                                    and x.ValuationRatios.PERatio > 0]
                
        return filtered_fine