SF19 | Development of Alpha Moving Average Enhancement Strategy Based on VWAP (Volume Weighted Average Price)

 Committed to sharing quantitative strategies, training videos, Python, programmatic trading and other related content

1. Volume Weighted Average Price (VWAP algorithm)

Algorithmic trading is actually mainly used in fund companies and brokerages. For example, I have already selected stocks and want to buy them in large quantities, but it is a bit difficult to complete the operations of buying 1 million shares based on the massive orders of traders. So how to solve the problem of splitting orders at this time to prevent the impact of cost? Only relying on algorithmic trading, there are two popular algorithmic trading on the market now, the first is VWAP and the other is TWAP. But each algorithmic trading also has its disadvantages, that is, it is easy for people to see the operation method (if the strategy is relatively simple), so this needs to be continuously optimized.

 VWAP is the abbreviation of Volume Weighted Average Price, translated as Volume Weighted Average Price. The VWAP strategy is an algorithmic trading strategy that splits large orders and executes them in batches within a predetermined time period, in order to make the final average buying or selling transaction price as close as possible to the average transaction price of the entire market during that period.

The content of the VWAP policy. VWAP strategy includes macro and micro levels. To solve the problem of how to split large orders at the macro level, investors need to predict the intraday trading volume of the stock. We recommend splitting orders by two minutes. At the micro level, it is necessary to determine whether to use a limit order or a market order to issue a transaction order. Considering that VWAP is a strategy for passively tracking the average market price, we recommend using the market order method. On the one hand, it is beneficial to control the final transaction average price and market average price. On the other hand, it can improve the efficiency of entrusted transactions and avoid the risk that limit orders cannot be filled for a long time.
             
According to the traditional VWAP strategy, it is only a passive strategy, and in this strategy, the most important factors are the following: historical trading volume, future trading volume forecast, total market dynamic trading volume, time period for splitting orders (that is, In total, how many orders should be divided into how many orders and what time frequency to trade)

2. Macro order split VWAP

Suppose an investor wants to buy 1 million shares of a stock at the average market price on October 10, 2011. The macro strategy can tell investors how to split the order for 1 million shares and how many orders to place at what time of day. The common practice in the market is to place an order with equal duration, for example, place an order every 5 minutes, so that the original order of 1 million shares will be split into small orders and executed in time-sharing.

Where V is the total amount of orders before splitting. Obviously, at that time, the above formula takes the minimum value of 0, that is to say, if investors can accurately predict the ratio of the trading volume of each time period in the market to the trading volume of the day, then the investor will split the order according to this ratio and trade in time-sharing. , then the final total average transaction price will be equal to the market average transaction price. Therefore, a key to the split order strategy is the prediction of intraday volume.

But one flaw of this approach is that it predicts future volumes based on historical transactions. Therefore, they have made a dynamic improvement to the VWAP predicted volume ratio, which is to use the dynamic volume to make a prediction. For example, predict the volume of the next two minutes based on the volume of the previous two minutes.
This strategy effectively reduces transaction costs. When testing whether the VWAP strategy is effective, they introduced an indicator. Absolute value mean deviation,

Except for individual stocks, the deviation of VWAP-D from the average market price is smaller than that of VWAP-B, which is mainly due to its real-time dynamic adjustment of intraday trading volume forecast. In addition, the larger the stock market value, the smaller the volatility of its stock price and trading volume, the better the execution effect of the VWAP strategy, and the smaller the deviation from the average market price. In general, large-cap stocks are better than mid-cap stocks, and mid-cap stocks are better than small-cap stocks, but the gap between them is not obvious. This is mainly because our verification process has not yet involved the size of funds. The impact cost of large-cap stocks and small-cap stocks will widen. For a strategy, the smaller the MAPE, the better the strategy effect, and the larger the price, the higher the selling price. Of course, VWAP can also be designed as an active strategy instead of passive.

Literature source: https://www.cnblogs.com/anxbb/p/8941514.html

development ideas  

The above are the references for SF19 strategy development. Thanks to the original author for the ideas and calculation formulas. From the above we know that the use of VWAP is at the micro and macro levels. In this issue, we use the micro-level algorithm to help us realize the strategy. It is calculated by the following formula:

Volume-weighted average price, the above formula is the sum of the product of each transaction volume in N cycles * the sum of the products of each transaction price/sum of transaction volume in N cycles.

Simple Arithmetic Average (MA), Exponential Moving Average (EMA), Weighted Arithmetic Moving Average (SMA), these moving averages are calculated in different ways and have different smoothing effects, but they are only two-dimensional compositions of price and time , there is essentially no difference. The volume-weighted average price (VWAP) is different. It takes the volume, the most important factor in calculating the cost price, into account, and the obtained cost price is more convincing than other moving averages.

Strategy building:

  1. Code implementation of VWAP (Volume Weighted Average Price);
  2. Calculate the VWAP cost price for long and short periods;
  3. Calculate the phased track lines;
  4. Add take profit and stop loss;

Interpretation of pictures and texts

1. Calculation and comparison of different moving averages with the same parameters;

VWAP lines (5,15)

MA moving average (5,15)

Conclusion: Under the conditions of the same parameters (5 days, 15 days), the MA moving average is obviously sluggish in response to VWAP.

2. Alpha moving average enhancement (same parameter)

in conclusion:

This is the performance of the MA double moving average and the VWAP double moving average on the RB. The number of crossings is equal, which means that whether the trend is oscillating or not, they all generate cross signals, and the number of signals is the same. However, the VWAP moving average is obviously earlier than the MA moving average group, which means that the timing and price of the cross entry are more advantageous than the MA, so the performance obtained is better than that of the MA moving average, which is often referred to as alpha . To enhance the effect , interested friends can write a stock strategy and try it out, and there may be unexpected additional benefits.

3. Defect improvement

in conclusion: 

       No matter what kind of moving average calculation method you adopt, you cannot escape the frequent crossing of moving averages in the volatile market, which is the fate of moving average strategy. If you want to improve, you must jump out of the moving average itself and use other methods. The SF19 strategy uses phased orbital lines to filter some of the oscillating signals. Of course, there are many filtering methods. The focus of this article is VWAP. If you are interested, you can filter in other ways.

strategic performance

thread

coke

iron ore

white sugar

Shanghai Aluminum

PP

palm

thermal coal

Other platform tests:

Wenhua:

pyramid:

Provide multi-platform source code:

 

Conclusion:

Through the use of the VWAP algorithm, the SF19 strategy found that it has certain advantages for ordinary moving averages, and has an enhanced effect compared to ordinary moving averages. If you are also using moving averages as part of your strategy trading, try the VWAP algorithm. However, the moving average strategy has the disadvantage of frequent oscillating and frequent crossing, which is a congenital defect of the moving average strategy, so the orbital line filtering is used in the strategy. If you want a solid offer, you need your own wisdom to revise and upgrade. I wish you success. It's not easy to code words. Please click on the right side at the end of the article to watch and like, thank you.

This strategy is only used for learning and communication, and investors are personally responsible for the profit and loss of real trading.

Guess you like

Origin blog.csdn.net/m0_56236921/article/details/123271041