Hi guys, I am currently learning how to use Quantconnect by trying to build a cross-momentum equally-weighted portfolio. However, somewhere in the middle of the backtest I get the following error: Runtime Error: 'Pandas' object has no attribute 'volume' at CoarseSelectionFunction self.adv[sec.Symbol].Update(bar.close, bar.volume) ^^^^^^^^^^ in main.py: line 62 (Open Stack Trace)
I've played around with the start date, coarse filters and how many symbols i want the filtered universe to have but I couldn't pinpoint the issue. What am I doing wrong?
Mia Alissi
The error in the code is due to a syntax issue. Specifically, ensure that the attributes being accessed on the
sec
object, such asAdjustedPrice
andVolume
, are correct and available. Additionally, verify that the logic for checking if a symbol is in the dictionaryself.adv
is implemented correctly.Sources: Momentum Effect In Commodities Futures, Combining Momentum Effect With Volume, Leveraged ETFs With Systematic Risk Management, Futures Fast Trend Following, with Trend Strength, Short Term Reversal
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.
Julien
Managed to find some sort of solution by using hasattr() to solve for the cases where there is no volume attribute. There might be better solutions out there and happy to see them!
I am still not too sure why this error arose - perhaps checking first if the symbol was IPO'd more than 12 months ago could help.
Julien
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!