# region imports
from AlgorithmImports import *
from QuantConnect.DataSource import *# endregion
class HipsterFluorescentYellowOwl(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2023, 8, 15)
self.SetStartDate(2023, 8, 17)
# Requesting data
self.AddUniverse(self.SelectCoarse, self.SelectFine)
self.UniverseSettings.Resolution = Resolution.Daily
# Coarse filter: get list of symbols with biggest dollar volume
def SelectCoarse(self, coarse):
selected = [c for c in coarse if c.HasFundamentalData]
sorted_by_dollar_volume = sorted(selected, key=lambda c: c.DollarVolume, reverse=True)
return [ c.Symbol for c in sorted_by_dollar_volume[:10000] ]
# Fine filter: filter to only 10 regional banks via MorningstarIndustryCode
def SelectFine(self, fine):
filtered_by_class = [f for f in fine if f.AssetClassification.MorningstarIndustryCode == MorningstarIndustryCode.BanksRegional]
return [ f.Symbol for f in filtered_by_class[:self.10] ]
# DATA EVENT HANDLER
def OnData(self, data: Slice):
for security in self._changes.AddedSecurities:
#self.Plot(???) # here I have no clue how to get the fundamental data from morningstar
#Event fired each time the we add/remove securities from the data feed
def OnSecuritiesChanged(self, changes):
self._changes = changes
Mia Alissi
Hello,
To access the fundamental data in your
OnData
method, you can use theFundamentals
property of theSecurity
objects in your algorithm. Here is an example of how you can do it:Please note that the
Fundamentals
property provides access to the most recent fundamental data for the security. If you need historical fundamental data, you would need to use theGetFundamental
method in the Research Environment.Also, keep in mind that the fundamental data is only updated once per day at midnight New York time. Therefore, if you're using a higher resolution for your algorithm, the fundamental data will remain the same throughout the day.
For more information, you can refer to the QuantConnect Documentation.
I hope this helps! Let me know if you have any other questions.
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.
Paulduring
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!