I'm trying to access a property of MorningStar in my Universe Selection.
However, I get the following error:
Runtime Error: TypeError : Cannot get managed object
at
x.FinancialStatements.BalanceSheet.OrdinarySharesNumber >= MIN_SHARE_COUNT
File "main.py" in main.py:line 39
TypeError : Cannot get managed object
The entire code is as follows:
from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel
class RedGhhost(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2021, 1, 29)
self.SetCash(100000)
self.AddUniverseSelection(UniverseModule())
self.UniverseSettings.Resolution = Resolution.Daily
class UniverseModule(FundamentalUniverseSelectionModel):
def __init__(self, filterFineData = True, universeSettings = None):
super().__init__(filterFineData, universeSettings)
self.averages = {}
'''
Filter by price
'''
def SelectCoarse(self, algorithm, coarse):
return [
x.Symbol for x in coarse if (
x.Price > 10
and x.HasFundamentalData
)
]
'''
Filter by min market cap and share count
'''
def SelectFine(self, algorithm, fine):
MIN_MKT_CAP = 1 * 10 ^ 9
MIN_SHARE_COUNT = 1 * 10 ^ 9
MAX_BARS_BACK = 200
initialFilter = [
x.Symbol for x in fine if (
x.FinancialStatements.BalanceSheet.OrdinarySharesNumber >= MIN_SHARE_COUNT
and x.MarketCap >= MIN_MKT_CAP
)
]
for x in initialFilter:
history = algorithm.History(x, MAX_BARS_BACK, Resolution.Daily)
if x not in self.averages:
self.averages[x] = SymbolData(x, history)
avg = self.averages[cf.Symbol]
avg.update(cf.EndTime, cf.AdjustedPrice)
upTrending = list(filter(lambda x: x.isUptrend, self.averages.values()))
finalSymbols = [x.symbol for x in upTrending]
return finalSymbols
class SymbolData(object):
def __init__(self, symbol, history):
self.symbol = symbol
self.longTerm = ExponentialMovingAverage(200)
self.mediumTerm = ExponentialMovingAverage(100)
self.isUptrend = False
for time, row in history.iterrows():
self.longTerm.Update(time, row.close)
self.mediumTerm.Update(time, row.close)
def update(self, time, value):
self.longTerm.Update(time, value)
self.mediumTerm.Update(time, value)
longTerm = self.longTerm.Current.Value
mediumTerm = self.mediumTerm.Current.Value
self.isUptrend = (
mediumTerm > longTerm
)
I don't see any actual example in the Documentation on how exactly one can access MorningStar fundamentals; clearly I'm doing it the wrong way.
Please help.