I am confused about the implementation of VolumeWeightedAveragePriceIndicator. I am using it on 1 minute data and using the Reset() method at specific times in the day. The “period” is not making sense to me; it seems to automatically reset itself every set “period”. The behavior should be that the VWAP first report is after “periods” then continues to accumulate until a Reset() is called. The image below is of a trading day with period set to 5; clearly the VWAP is not accumulating past 5 points. What am I missing?
Mia Alissi
The Volume Weighted Average Price (VWAP) Indicator is calculated by adding up the dollars traded for every transaction (price multiplied by the number of shares traded) and then dividing by the total shares traded for the day. The "period" parameter in the VWAP method refers to the number of bars over which the VWAP is computed.
In the case of using 1-minute data with a period of 5, the VWAP is calculated over the last 5 minutes. If you call the Reset() method, it will clear the internal state of the VWAP indicator, and it will start calculating the VWAP over the next 5 minutes.
If you want the VWAP to accumulate over the entire day, you should not call the Reset() method. The VWAP will then be calculated over all the 1-minute bars of the day.
Here is an example of how to use the VWAP indicator in Python:
In this example, the VWAP is calculated over the last 5 minutes. If you want the VWAP to accumulate over the entire day, you should set the period to the number of minutes in a trading day (e.g., 390 for a typical US equity market day from 9:30 AM to 4:00 PM).
Please note that the VWAP indicator is designed to be used with trade bar data, and it may not work correctly if you use it with other types of data.
For more information, you can refer to the QuantConnect documentation on the VWAP indicator.
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
So, debugging my code based on the above recommendation, the indicator is not ready until the day end. The period has to be done before IsReady evaluates as True. So, 390 the day is over before it is True.
Mia Alissi
The
IsReady
property of an indicator becomesTrue
when the indicator has enough data to produce a valid output. For the VWAP indicator, this means that it needs to have data for the number of periods specified when creating the indicator.If you set the period to 390 (the number of minutes in a typical US equity market day), the
IsReady
property will indeed becomeTrue
only at the end of the day. This is because the VWAP indicator needs to have data for the entire day to calculate the VWAP.If you want the VWAP indicator to be ready before the end of the day, you need to set the period to a smaller number. For example, if you set the period to 60, the
IsReady
property will becomeTrue
after the first hour of trading.Here is an example of how to use the VWAP indicator with a period of 60 minutes in Python:
In this example, the
IsReady
property will becomeTrue
after the first hour of trading, and the VWAP will be calculated over the last 60 minutes.For more information, you can refer to the QuantConnect documentation on the VWAP indicator.
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.
FemtoTrader
https://www.quantconnect.com/docs/v2/writing-algorithms/indicators/supported-indicators/volume-weighted-average-price-indicator
link is now broken (404 error)
Marc Daoust
FemtoTrader;
I found the “Volume Weighted Average Price Indicator” under “Intraday VWAP” in the new (V2) documentation:
That page contains links to more info on “Intraday VWAP”, but 404 to “VolumeWeightedAveragePriceIndicator”It appears this content is auto-generated using the source code & comments. It needs to be updated before re-generating this documentation page.
Maybe Louis Szeto can help figure out the changes required?
FYI: The link to the V1 documentation for “VWAP” and “Intraday VWAP” (underneath VWAP), with a brief description and their parameters:
Limited in details as links simply point to the top of the same page.
Louis Szeto
Hi all
Both indicators have the same helper method abstraction VWAP. If you're including a period argument, you get VolumeWeightedMovingAverage indicator. Otherwise, you'll get IntradayVwap indicator.
It is correct that the indicator value is accurate only when it is “IsReady”, so make sure you warm up the indicator properly after reset.
Best
Louis
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!