I need to do some calculation once the warmpup period is finished. To get the list of securities I use self.GetWarmupHistoryRequests() in OnWarmupFinished() method.
But I end up with different secutirties that I originally added.
# region imports
from AlgorithmImports import *
# endregion
class GeekyLightBrownOwl(QCAlgorithm):
def Initialize(self):
self.SetTimeZone("UTC")
self.SetStartDate(2022, 1, 2)
self.SetEndDate(2022, 1, 4)
self.SetAccountCurrency("BUSD")
self.SetCash("BUSD", 100_000.00)
self.SetBrokerageModel(BrokerageName.Binance, AccountType.Margin)
for s in ["AVABUSD", "BNBBUSD"]:
self.AddCrypto(s, Resolution.Minute)
self.SetWarmUp(5)
def OnWarmupFinished(self):
slices = self.History(self.GetWarmupHistoryRequests())
for s in slices:
for v in s.Values:
self.Debug(v)
In the log file, I'm getting 2 other securities which were not added in the algorithm.
BNBBUSD: O: 527.3 H: 527.6 L: 527 C: 527.3 V: 195.646AVABUSD: O: 1.863 H: 1.863 L: 1.863 C: 1.863 V: 0USDCBUSD 18N: O: 1 H: 1 L: 1 C: 1 V: 30661.61BTCBUSD 18N: O: 47691.18 H: 47772.5 L: 47660.92 C: 47732.53 V: 26.26728
any help would be much appreciated,
thank you
Fred Painchaud
Hi Milad,
OnWarmupFinished is not designed to do what you are trying to do. It is called right before the end of warmup. It is the last thing executed during warm up.
You do not have active securities yet at that time.
Check out the attached backtest.
Note also that in Python, History does not return slices but Pandas DataFrames.
Fred
Milad Resketi
Thank you for your reply Fred Painchaud.
Even when you use the OnData() method, still you get the same behavior.
I figured out how to resolve the issue. Based the brokergage model lean automattically sets a benchmark asset, the Cash.EnsureCurrencyDataFeed() method ensures that the required data are properlly fed into lean, so there wouldn't be any interruption when calculating the benchmark value, this leads to
So to fix the issue I only had to set the benchmark asset as one of the symbols already added to the algorithm.
Milad Resketi
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!