When not using the Algorithm Framework in LEAN locally, just doing self.AddData(CustomTradeBar,ticker,resolution) just works fine and you can access data within self.OnData() etc. However when using the Algorithm Framework, it doesn't seem to work with the below code:
class TrialStrat(QCAlgorithm):
def Initialize(self):
...
self.tickers = [BTCUSDT,ETHUSDT]
symbols = [self.AddData(type=CustomTradeBar, ticker=ticker, resolution=Resolution.Minute).Symbol for ticker in self.tickers]
self.SetUniverseSelection(ManualUniverseSelectionModel(symbols))
self.SetAlpha(..)
self.SetPortfolioConstruction(..)
self.SetExecution()
I couldn't find what the issue was since the same CustomTradeBar class works perfectly when used in a non-Framework QCAlgorithm instance.
What is the recommended way of adding Custom local data to the Algorithm Framework?
Nottakumasato
Added code just after self.SetUniverseSelection():
and the output is:
Louis Szeto
Hi Nottakumasato
Using AddData would serve the same function, you don't need to use universe selection anymore after that.
If it is local data files, you may just save it to the data directory in the same format as LEAN crypto data.
Best
Louis
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.
Nottakumasato
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!