VWAP Reversion Bot: trading robot for Python
VWAP Reversion Bot is a mean-reversion advisor that automatically enters against the deviation of price from the volume-weighted average.
How the advisor works
The advisor tracks the deviation of price from VWAP and enters against it when the deviation exceeds one ATR, aiming for a return to the volume-weighted price. Automation catches the moment of over-extension more precisely than a human and is not tempted to "let the move run".
The approach is profitable while the market oscillates around fair value and loses in a trend, where VWAP itself shifts along with the move. An additional subtlety for a forex advisor is that volume is tick volume rather than exchange volume, which reduces the reliability of VWAP.
Parameters and metrics
| Parameter | Value |
|---|---|
| Entry threshold | 1σ from VWAP |
| Time stop | 2 hours |
| Volatility filter | off when VIX > 25 |
| Instrument | US500 |
Check on real data
The advisor's logic was run on real quotes without fitting parameters to history. The rule tested was "VWAP Reversion: return to the volume-weighted price":
- Long when price deviates more than one ATR(14) below the cumulative VWAP.
- Short when price deviates more than one ATR above VWAP.
- Exit when price returns to VWAP.
Pros and cons
- Precisely catches over-extension relative to a volume benchmark.
- The deviation threshold is normalized by ATR.
- A clear automated exit target — a return to VWAP.
- Counter-trend: loses money on a sustained price shift.
- On forex, tick volume reduces the reliability of VWAP.
- The cumulative VWAP is sluggish on a long sample.
Pitfalls
A VWAP advisor is dangerous in a trend: when price moves steadily in one direction, the accumulated VWAP is dragged after it, and counter-trend entries produce a series of losses. The owner should pair the robot with a trend filter that switches it off in a directional move. The second subtlety is forex tick volume, which makes VWAP less accurate than on an exchange.
Who it suits
For traders automating mean-reversion logic on ranging instruments who understand the limitations of volume data on forex. In a trend the advisor must be switched off.
Related methodology
Frequently asked questions
Why is VWAP better than an ordinary average for an advisor?
VWAP is weighted by volume and gravitates toward levels of real turnover, so a deviation from it is more meaningful than a deviation from a simple average. The robot uses it as a fair-value benchmark.
Why is the advisor dangerous in a trend?
In a sustained move VWAP shifts along with price, and counter-trend entries against the trend produce a series of losses. A filter that switches the robot off in a directional market is needed.
What did the backtest show?
On a calm sample the returns to VWAP triggered often and the result is positive. But this is an illustration of the mechanic: on a trending stretch the result would be different.