Overall Statistics |
Total Trades 48 Average Win 0% Average Loss 0% Compounding Annual Return -77.725% Drawdown 12.100% Expectancy 0 Net Profit -11.974% Sharpe Ratio -5.039 Probabilistic Sharpe Ratio 0.000% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha -0.707 Beta -0.071 Annual Standard Deviation 0.14 Annual Variance 0.02 Information Ratio -3.888 Tracking Error 0.182 Treynor Ratio 9.922 Total Fees $173.85 |
from Execution.ImmediateExecutionModel import ImmediateExecutionModel from Portfolio.EqualWeightingPortfolioConstructionModel import EqualWeightingPortfolioConstructionModel class NetNet(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetEndDate(2020, 1, 31) self.SetCash(100000) # Set Strategy Cash self.SetAlpha(NetNetAlpha()) self.SetExecution(ImmediateExecutionModel()) self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(lambda time: None)) self.Settings.RebalancePortfolioOnInsightChanges = False self.Settings.RebalancePortfolioOnSecurityChanges = True self.SetUniverseSelection(FineFundamentalUniverseSelectionModel(self.CoarseSelectionFunction, self.FineSelectionFunction, None, None)) self.UniverseSettings.Resolution = Resolution.Daily self.SetSecurityInitializer(lambda x: x.SetDataNormalizationMode(DataNormalizationMode.Raw)) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' # if not self.Portfolio.Invested: # self.SetHoldings("SPY", 1) # on 15 Jan, filter for securities with fundamental data def CoarseSelectionFunction(self, coarse): if self.Time.month == 1 and self.Time.day == 15: filtered = [ x.Symbol for x in coarse if x.HasFundamentalData and x.Price > 1 and x.DollarVolume > 1e5] return filtered else: return Universe.Unchanged # on 15 Jan, filter first for securities with shares and then filter a second time for net net stocks def FineSelectionFunction(self, fine): # filtered = [ x.Symbol for x in fine if (x.FinancialStatements.BalanceSheet.CurrentAssets.ThreeMonths - x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths) > 0 ] filtered = [ x for x in fine if x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths > 0 and (x.FinancialStatements.BalanceSheet.CurrentAssets.ThreeMonths - x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths) > 0] filtered2 = [ x.Symbol for x in filtered if (x.Price / ((x.FinancialStatements.BalanceSheet.CurrentAssets.ThreeMonths - x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths) / x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths)) <= 0.66 ] return filtered2 class NetNetAlpha(AlphaModel): def __init__(self): pass # self.lastMonth = -1 def OnSecuritiesChanged(self, algorithm, changes): pass def Update(self, algorithm, data): insights = [] if algorithm.Time.month == 1 and algorithm.Time.day == 15: for security in algorithm.ActiveSecurities.Values: # price = security.Price # currentAssets = security.Fundamentals.FinancialStatements.BalanceSheet.CurrentAssets.ThreeMonths # totalLiabilities = security.Fundamentals.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths # shares = security.Fundamentals.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths # if ( price / ( (currentAssets - totalLiabilities) / shares ) <= 0.66 ): # insights.append(Insight.Price(security.Symbol, timedelta(days = 366), InsightDirection.Up)) insights.append(Insight.Price(security.Symbol, timedelta(days=366), InsightDirection.Up)) return insights else: return insights