History with minute data for /MGC continuous futures there are NaNs in the volume for the “MGC 1P9” symbol in the history series that causes the TradeBar constructor to blow up. Seems like a data quality issue. It is typical you have to drop NaNs from history dataframes in futures?
Mia Alissi
Yes, it is common to encounter NaNs in historical data, especially in financial markets where data can be sparse during off-market hours or due to other factors. In Python, you can use the
dropna()
function to remove these NaN values from your DataFrame. Here is an example of how you can do this:This line of code will remove any rows in the
history
DataFrame that contain NaN values.However, please note that removing NaNs might not always be the best solution, as it can lead to gaps in your data. An alternative approach could be to fill NaNs with a specific value or forward-fill them with the previous valid data point. This can be done using the
fillna()
orffill()
functions in pandas.In the case of the "MGC 1P9" symbol causing the TradeBar constructor to blow up, it might be due to a data quality issue. If you suspect this is the case, it would be best to report this to the QuantConnect team for further investigation.
Sources:
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!