class MomentumScalperV3(QCAlgorithm):
def initialize(self):
ticker = "MSFT"
equity = self.add_equity(ticker, Resolution.SECOND, extended_market_hours=False, fill_forward=True)
symbol = equity.symbol
self.symbol_cache.append(symbol)
symbol_properties = self.symbol_properties_database.get_symbol_properties(symbol.id.market, symbol, SecurityType.EQUITY, 'USD')
security_exchange_hours = self.market_hours_database.get_exchange_hours(symbol.id.market, symbol, SecurityType.EQUITY)
# Add PolygonLiveData (bars with VWAP)
polygon_live = self.add_data(PolygonLiveData, ticker, properties=symbol_properties, exchange_hours=security_exchange_hours, resolution=Resolution.SECOND, fill_forward=True)
polygon_live_symbol = polygon_live.symbol
# Cache mapping between equity symbol and polygon symbol (both use same ticker)
if not hasattr(self, 'polygon_symbol_cache'):
self.polygon_symbol_cache = {}
self.polygon_symbol_cache[symbol] = polygon_live_symbol
def on_data(self, data: Slice):
if hasattr(algorithm, 'polygon_symbol_cache') and symbol in algorithm.polygon_symbol_cache:
dfadfdafda
try:
All Gold
I'm really struggling to get this to work.
I am focused on getting a backtest to work current. I want to import custom data alongside add_equity. It's second's resolution, via Polygon, and so this returns a json with many entries. I am having difficulty returning the custom data appropriately, and accessing its slice in on_data. I have tried UnfoldingCollections, as well as CSV and JSON format. I have tried using yield instead of returning a BaseDataCollection as well.
Could someone please assist me in getting this to return data properly? Thank you.
All Gold
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!