VWAP in python

Does anyone know how to get a VWAP indicator to work in a python algo?

Below is the only way I've tried that doesn't give an error. This also never seems to have a value other than 0.0, and it is never marked as IsReady. Any ideas what I'm doing wrong?

For the symbol, I'm pulling tick data (forex), and I'm also consolidating the data into hourly bars.

Thanks in advance!

self.vwap = VolumeWeightedAveragePriceIndicator(self.symbol, 20)
Update Backtest

The VWAP indicator should be updated with the TradeBar. For forex symbol, the available bar data is the QuoteBar. The only way to construct the VWAP indicator is updating the indicator with manually constructed TradeBar data. The TradeBar can be constructed with 

TradeBar( DateTime time, Symbol symbol, decimal open, decimal high, decimal low, decimal close,decimal volume)

However, for forex symbol, there is no volume data but the calculation formula of VWAP indicator needs Volume data. Therefore, all the volume would be zero and the VWAP indicator will be zero for the whole backtest.  (For the attached example, if assume the volume has value like 100, the indicator value won't be zero). We don't have forex volume at this time. 


Update Backtest


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.


This discussion is closed