Hi there,
I wanted to experiment playing with Volume in an algorythm with crypto and created the symple algo attached. However, when I try to get the Volume in the OnData block (line 54: _Volume = data[_Ticker].Volume;) and plot it on a graph, I get the following error:
Runtime Error: 'QuantConnect.Data.Market.QuoteBar' does not contain a definition for 'Volume'
I guess this is because cryptos are of the QuoteBar data type which does not include volumes. But is there a way to get crypto data as TradeBar that include volumes?
If not, then what happen when you use indicators that use volume in their calculation? I have tested AccumulationDistribution for example and it does split out a result while I would expect it to crash if no volumes where available (you can comment line 54 and run the algo to check).
Many thanks for your help!
Yiyun Wu
Hi Pi..R,
When access crypto attributes by slice you need to indicate wether you want to access TradeBar or QuoteBar, since it has both. What's more, we access the data directly from the Slice var bar = data[_Ticker];  it gets the QuoteBar since it has higher precedence. It will be fine if you make a change of the code as below:
Â
_Close = data.Bars[_Ticker].Close; _Open = data.Bars[_Ticker].Open; _Low = data.Bars[_Ticker].Low; _High = data.Bars[_Ticker].High; _Volume = data.Bars[_Ticker].Volume;
Here is the detailed information of using crypto data. To see the detail of how to access data by slice, please take a look at here.
Hope this helps!
Pi..R
Thank you very much Yiyun! I read the documentation several times but somhow missed that... super helpful, thanks again and sorry for the very beginner question.
Pi..R
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!