I keep running into error after error loading history of futures data and keep getting the error below for MicroCrudeOilWTI and MicroGold but not on MicroSP500EMini or MicroDow30EMini. This is super frustrating as there seems to be inconsistent indexes from history between them. Tried numerous iterations of different ways to get history. Any and all help would be appreciated.
During the algorithm initialization, the following exception has occurred: Trying to dynamically access a method that does not exist throws a TypeError exception. To prevent the exception, ensure each parameter type matches those required by the 'datetime.timedelta'>) method. Please checkout the API documentation. at __init__ tradeBar = TradeBar(tTime in baseMTSymInd.py: line 291
if DailyTF:
hist = algorithm.History(self.symbol, self.nHist , Resolution.Daily, extendedMarketHours= True)
TDelt = timedelta(days=1)
else:
hist = algorithm.History(self.symbol, self.nHist , Resolution.Minute, extendedMarketHours= True)
TDelt = timedelta(minutes=inTRes)
if algorithm.Securities[self.symbol.Value].Type == 5:
hist = hist.droplevel([0, 1], axis=0)
for index, row in hist.iterrows():
tTime = index
tradeBar = TradeBar(tTime, self.symbol, row.open, row.high, row.low, row.close, row.volume, TDelt)
Mia Alissi
Based on the error message you provided, it seems like the issue is related to the way you're trying to access the historical data. The error message suggests that there's a mismatch between the parameters you're providing and the ones expected by the method.
In the code you provided, you're trying to create a
TradeBar
object using data from the historical dataframe. However, the error message suggests that the parameters you're providing to theTradeBar
constructor don't match the expected types.Here's the line of code that seems to be causing the issue:
The
TradeBar
constructor expects the following parameters:datetime, symbol, open, high, low, close, volume, period
. The error message suggests that one or more of these parameters are not of the expected type.One potential issue could be with the
tTime
variable. You're settingtTime
toindex
, which is the index of the current row in thehist
dataframe. If the index of this dataframe is not adatetime
object, this could be causing the issue.You could try converting the index to a
datetime
object before using it to create theTradeBar
:If this doesn't solve the issue, I would recommend checking the types of all the variables you're passing to the
TradeBar
constructor to make sure they match the expected types.Also, please make sure to check the QuantConnect API documentation for more information on how to use the
History
method and theTradeBar
class.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.
Michael Dehring
All types are verified before calling TradeBar constructor and still get the error
Ashutosh
Hello,
I tried a simple backtest but did not get any error.
It would be helpful if you could attach the code for debugging.
The error usually occurs when there is a mismatch of function signature values. This could also happen if one of the function parameters feed in nan values.
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.
Michael Dehring
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!