| 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.017 Tracking Error 0.109 Treynor Ratio 0 Total Fees $0.00 |
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())
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.date == 15:
filtered = [ x.Symbol for x in coarse if x.HasFundamentalData ]
return filtered
else:
return Universe.Unchanged
# on 15 Jan, filter for securities with price above 1000
def FineSelectionFunction(self, fine):
if self.Time.month == 1 and self.Time.date == 15:
filtered = [ x.Symbol for x in fine if x.Price > 1000 ]
# filtered = [ x.Symbol for x in fine if ( (x.FinancialStatements.BalanceSheet.CurrentAssets.ThreeMonths > x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths) and (x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths > 0)) ]
# filtered = [ x.Symbol for x in filtered if x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths ]
# filtered = [ x.Symbol for x in filtered if x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.OneMonth ]
# filtered = [ x.Symbol for x in filtered if (x.Price / ((x.FinancialStatements.BalanceSheet.CurrentAssets.OneMonth - x.FinancialStatements.BalanceSheet.TotalLiabilitiesAsReported.ThreeMonths) / x.FinancialStatements.BalanceSheet.OrdinarySharesNumber.ThreeMonths)) <= 0.66]
return filtered
else:
return Universe.Unchanged
class NetNetAlpha(AlphaModel):
def __init__(self):
pass
# self.lastMonth = -1
def OnSecuritiesChanged(self, algorithm, changes):
pass
def Update(self, algorithm, data):
insights = []
if self.Time.month == 1 and self.Time.date == 15:
# if algorithm.Time.month == 1 and algorithm.Time.date == 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