Is there an easy way to look up all the attributes linked to a QC object? In the example below I try to get the attributes of a Symbol object using `.__dict__`, which works for “normal" Python objects, but raises an error on the QC object.
Do I have to go to the docs for this? If so, is there an easy way to search up an object (such as Symbol) and get its associated attributes?
class GettingObjectAttributes(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2020, 10, 9) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddEquity("SPY", Resolution.Minute)
self.symbol = Symbol.Create("AAPL", SecurityType.Equity, Market.USA)
self.Debug(f"Symbol dict: {self.symbol.__dict__}")
def OnData(self, data: Slice):
'''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
'''
pass
AttributeError : 'Symbol' object has no attribute '__dict__'
Vladimir
Haakon Flaarønning,
You can do this using self.History(), and I prefer to do it in a research notebook.
If you are satisfied with my answer, please accept it.
Fred Painchaud
Hi Haakon,
Objects like Symbol, and all other objects coming from LEAN, are not usual Python objects. They are .NET objects, stubbed into Python via Python.NET.
The easiest way to look for all attributes of any LEAN object in Python is to use the generated documentation from the .NET source code, which is kept up to date daily here:
https://lean-api-docs.netlify.app/index.html
Fred
Haakon
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!