Articles related to algorithmic trading and software tools aiding automated investment operations.
Volume-Weighted Average Price known as VWAP is one the most basic and commonly used market indicators by traders around the world. In a book “Algorithmic & Trading DMA” we can read about VWAP that “As a benchmark, it rapidly became ubiquitous since it gives a fair reflection of market conditions throughout the day and is simple to calculate. This led to algorithms that tracked the VWAP benchmark becoming extremely popular.”
Calculation of VWAP it’s relatively simple and it can be done even on piece of paper for small amount of data. In mathematical approach VWAP is represented by equation below:
where P is the price of i-th trade and V is the size related to i-th trade. In fact it takes five steps to calculate your first VWAP. First, only if we use intraday data for examination, we need to calculate typical price for our intervals. Then multiply the price by period’s volume and create running total of these values for future trades. Fourthly we create cumulative volume and in the end we divide cumulative multiplication of price and volume by running total of volume to obtain VWAP. Even simpler, VWAP is a turnover divided by total volume.
Let’s take a look at example results calculated using these five steps on 1-minute interval intraday Morgan Stanley’s data.
|Time||Close||High||Low||Open||Volume||Typical Price||Price*Volume||Total PV||Total Volume||VWAP|
All calculations are pretty straightforward, but let us take a look at one interesting element. When you look at typical prices more than half of them (7/11) is below the last VWAP At the same time mean equals 38.917. So where does the difference come from? Volume is the culprit. In our case, period with higher typical price also has bigger Volume, thus bigger market impact and VWAP calculations indicate that.
Intraday or tick
The most classical VWAP approach is based on tick-by-tick data. But as the market grows and frequency of trades increases more resources are required to keep all calculations up-to-date. Nowadays it is nothing extraordinary for stock to have over hundred trades per minute (true or false?). When multiplied by minutes in a trading day and number of stocks it develops into numbers that might cause some performance troubles.
With help arrives intraday data, i.e. tick-by-tick data aggregated in time periods e.g. 1-minute, 5-minute or 15-minute that contains close, high, low and open price. As in VWAP calculations only one price is required we have to somehow average available prices. For this task exist typical price:
Also there is a second version of typical price that includes Open Price and it’s divided by 4.
Most likely we can point out two different strategies of reading VWAP. First one used especially by short-term traders relies on waiting for VWAP to cross above the market price and then enter long position as they interpret price to be bullish. On the other hand are Institutions looking to sell at this moment because they consider it as good opportunity for that day’s price.
When the price goes below VWAP value, the trend seems to be down. Institutions recognize it as good moment to buy, but short-term trader will look to short that stock.
Surely it’s basic approach to VWAP interpretation. For your strategy you would like to scrutinize e.g. influence of price deviation from VWAP value. You should consider that VWAP behaves differently based on period of trading day. It’s because of VWAP cumulative nature. VWAP value is very sensitive for price changes at the beginning of day, but insensitive at the end of trading day.
VWAP is surely commonly used between traders with strategies described above, but on the market there is a bunch of various indicators like VWAP that can suggest when to buy or sell shares. But there is other side of the fence.
Let’s say you want to buy 5 million shares of Morgan Stanley that is 37% of average daily volume in 2014. You cannot buy them at once, because that will impact significantly the market and the market will start to go against you. What you want to do is split the order in small pieces and execute them without impacting the market. Doing it by hand would be backbreaking, that’s what trading application has been made for.
Using trading application and VWAP Strategy, utilizing historical minute intraday files, you can easily generate average volume period profiles that will steadily buy proper number of shares without impacting the market.
Improve your VWAP
As we mentioned in previous paragraph there is a way to improve VWAP performance by creating volume profiles based on historical data. According to Kissel, Malamut and Glantz optimal trading strategy to meet VWAP benchmark can obtained by using equation:
where X is the total volume traded, is percentage of daily volume traded and is target quantity for each j-th period. Hence, VWAP can be calculated as below:
where is the average price level in each period.
VWAP is really simple indicator although it can be interpreted in various ways depending on goal and approach of the trader. It is mainly used by mutual and pension funds, but also by short-term traders. Aside from buying/selling small amount of shares, VWAP might be used as strategy for trading huge number of shares without impacting the market. “Simplicity leads to popularity.”
- Berkowitz, S., D. Logue, and E. Noser. “The Total Cost of Transactions on the NYSE.”Journal of Finance,41 (1988), pp.97-112.
- H. Kent Baker, Greg Filbeck. “Portfolio Theory of Management” (2013) , pp.421
- Barry Johnson “Algorithmic & Trading DMA – An introduction to direct access trading strategies” (2010), pp. 123-126
|We have just released beta of Empirica – Algorithmic Trading Paltform for retail investors! It’s lifetime free for development, testing and optimizing of trading algorithms.
Our development team (exactly this team who implemented the entire system) also provides full support in algorithms development as well as connectivity to brokers. If you need help just contact us.
Among many features what is unique is our exchange simulation where you can influence market conditions under which you test your algorithms. No others software offers such a realistic level of simulation.
In paid versions we offer the execution of algorithms in robust server side architecture.
We strive for your feedback!
Empirica Trading Platform – http://empirica.io
Empirica has successfuly finished the implementation of its Algorithmic Trading Platform in one of the largest brokerage houses in Poland.
Brokerage house will use our software to:
- aid its internal trading operations, like market making of derivatives on Warsaw Stock Exchange
- offer functionalities of our platform to its institutional clients, which will be able to build, test and execute their own algorithmic trading strategies
Implementation included connecting of our software system directly to the system of Warsaw Stock Exchange (Universal Trading Platform delivered by NYSE Technologies), as well as the integration with transaction systems of brokerage house. Additionally we have fulfilled and successfuly passed tests regarding the highest security, stability and performance requirements.
This implementation is an important milestone for our system. The usage by team of market makers is a proof that our system is capable of performing high-throughput and low latency operations on level required by most sophisticated traders on the capital marketets.
Next implementations of our Algorithmic Trading Platform by customers don’t stop us from developing the platform itself. Working agile requires us to keep the pace in short and frequent iterations, which in case of product means frequent releases, keeping the whole product line stable.
A few iterations that we planned in our 1.3.4 release, code named by our developers ‘The Firebolt’, will include among others:
– even faster real-time replication of all server-side components in master-slave mode (for deployment in larger institutions)
– extended client side backtesting capabilities
– sophisticated charting of backtesting results and statistics
– multiscreen mode of client side application
– additional web-based server-side module for administration & management
For those curious about the release name and unfamiliar with Harry Potter, Firebolt is:
“The state-of-the-art racing broom. The Firebolt has unsurpassable balance and pinpoint precision. Aerodynamic perfection.”
—Harry Potter: Quidditch World Cup
“The Firebolt has an acceleration of 150 miles an hour in ten seconds and incorporates an unbreakable Braking Charm. Price upon request.”
—Harry reads about the features of the Firebolt.
Speed, precision, balance, perfection. These are the words that describe our software, therefore choosing the code name was kind of obvious :).
The Firebolt broom
High Frequency Trading, known also as HFT, is a technology of market strategies execution. HFT is defined by technically simple and time costless algorithms that run on appropriate software optimized for data structures, level of memory usage and processor use, as well as suitable hardware, co-location and ultra low-latency data feeds.
Although HFT exists on the market for over 20 years, it has became one of the hottest topic during past few years. It is caused by several factors, such as May 6, 2010, “Flash crash”, latest poor situation on the market and Michael Lewis book – “Flash Boys”. Let’s look where all that fuss comes from.
Among other things, the advantage over other market participants and ability to detect market inefficiencies is the reason why so many people critics HFT so much. Most common charges put on the table are:
- Front Running – HFT companies use early access to incoming quotes to buy shares before other investors and then turn around and sell him just bought shares with slightly bigger price.
- Quote Stuffing – Way of market manipulation by quick sending and withdrawing large number of orders. Because of speed of operations, it creates a false impression of the situation on the market that leads other participants to executing against phantom orders. Then there is nothing else to do, but to exploit favorable prices by HFT investors.
- Spoofing – Another method for market manipulation by placing orders and then cancelling them for price increase/decrease. It is based on placing big order on the market to bait other investors, and when the market starts to react, quickly cancel it. Then new price allows to gain some profit by HFT investor.
But that’s just a tip of the iceberg. It can be often heard that there is lack of proper HFT regulations, exist false belief that there are Dark Pools without any regulations where HFT companies can hide their activity, and there is still active argument if HFT brings liquidity to the market or just useless volume.
Bill Laswell once said “People are afraid of things they don’t understand. They don’t know how to relate. It threatens their security, their existence, their career, image.” That phrase perfectly fits to what is happening now on High Frequency Trading topic. When people would like to take a closer look on how exchanges work, probably, they would be less sceptic to High Frequency Trading.
Thus, on most, maybe even on all, exchanges exist two mechanism which can efficiently handle problem of quote stuffing and spoofing. First of them is limitation of number of messages per second that can be send from one client. For example on New York Stock Exchange there is a limit of 1000 messages/sec, so it means that if HFT company burst whole 1000 of messages in first half of the period, in second half it cannot send any message, so it’s cut out of the market. Other limitation used by exchanges is a limit of messages per trade. It hits even harder in quote stuffing and spoofing. In most of the cases limit is around 500 messages per trade and if someone exceed it then he should be prepared for fines. On top of it company that frequently break limits could be banned from exchange for some time.
If we talk about front running, first thing we have to know is a fact that front running, in the dictionary meaning, is illegal action, and there are big fines for caught market participants who use it. Front running is using informations about new orders before they will go to the order book. Let’s say Broker gets new order with price limit to process, but before putting it to exchange, he will buy all available shares at better price than limit and then he execute client’s new order at limit getting extra profit. That’s highly not allowed and that’s not what HFT companies do.
All they do is tracking data feed, analyzing quotes, trades, statistics and basing on that information they try to predict what is going to happen in next seconds. Of course, they have advantage due to latency on data feed and so on, because of co-location, better connection and algorithms, but it’s still fair.
HFT companies have to play on the same rules as other market participants, so they don’t have any special permits letting them do things not allowed for others. Same with Dark Pools, specially that they are regularly controlled by Finance Regulators.
First, we have to know that suppliers of liquidity, i.e. Market Makers and some investors use HFT. They place orders on both sides of the book, and all the time are exposed to sudden market movement against them. The sooner such investors will be able to respond to changes in the market, the more he will be willing to place orders and will accept the narrower spreads. For market makers the greatest threat is the inability to quickly respond to the changing market situation and the fact that someone else could realize their late orders.
System performance in this case is a risk management tool. Investments in the infrastructure, both a software and hardware (including co-location), are able to improve their situation in terms of risk profile. The increase in speed is then long-term positive qualitative impact on the entire market, because it leads to narrowing of the spread between bids and offers – that is, reduce the transaction costs for other market participants, and increase of the liquidity of the instruments.
HFT AND MARKET QUALITY
In April of 2012. IIROC (Investment Industry Regulatory Organization of Canada), the Canadian regulatory body, has changed fee structure based so far only on the volume of transactions, adding the tariffs and fees that also take into account the number of sent messages (new orders, modifications and cancellations). In result, introducing new fees made trading in the high frequencies more difficult. It was very clearly illustrated by data from the Canadian market.
Directly in the following months these fees caused a decrease in the number of messages sent by market participants by 30% and hit, as you might guess, precisely the institutions that use high-frequency trading, including market makers. The consequence for the whole market was increase in the average bid-ask spread by 9%.
NO PLACE FOR MISTAKES
When people talk about HFT, both enthusiast and critics, it is not rare to hear that HFT is risk free. Well, on the face of it, after analyzing how HFT works you would possibly agree with it, but there is a dangerous side of HFT that can be not so obvious and people often forgot about it. HFT algorithms works great if the code is well written, but what would happen if someone would run wrong, badly tested or incompatible code on a real market?
We don’t have to guess it, because it happened once and it failed spectacularly, it was a “Knightmare”. Week before unfortunate 1st of August Knight Capital started to upload new version of its proprietary software to eight of their servers. However Knight’s technicians didn’t copy the new code to one of eight servers. When the market started at 9:30 AM and all 8 server was run, the horror has begun. Old incompatible code messed up with the new one and Knight Capital initiated to lose over $170,000 every second.
It was going for 45 minutes before someone managed to turn off the system. For this period Knight Capital lost around $460 million and became bankrupt. That was valuable lesson for all market participants that there is no place for mistakes in HFT ecosystem, because even you can gain a lot of money fast, you can lose more even faster.
HFT is a natural result of the evolution of financial markets and the development of technology. Companies that invest their own money in technology in order to take advantage of market inefficiencies deserve to profit like any other market participant.
HFT is not as black as is painted.
Aldridge, Irene (2013), High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems, 2nd edition, Wiley,
Empirica’s Algorithmic Trading Platform has successfully passed the XDP protocol communication certification, issued by the Warsaw Stock Exchange.
From now on Empirica is officially listed as the ISV (Independent Software Vendor) for the Warsaw Stock Exchange.
WSE uses Universal Trading Platform delivered by NYSE Technologies. The same system is used by many other European and world stock exchanges. Fulfilment of technical criteria of Warsaw Stock Exchange makes certification for those markets only a formality for our platform.
On the first of July 2014 large polish economic magazine Puls Biznesu published an article “The age of robots comes to Warsaw Stock Exchange’. Article is quoting, among others, Empirica’s representatives speaking on the topic of the growth of algorithmic trading in Poland. Excerpts below.
‘Popularization of algorithmic trading on conferences like this one is step in good direction, says Michal Rozanski CEO of Empirica, a company which delivers Algorithmic Trading Platform. Expert says that computers will never replace a human in all the tasks. First and the foremost machines are taking over the processes that human traders had to perform manually. ‘I am sure that the development of algorithmic trading will not change the soul of the markets. It will not change to the race of engineers. It is and always has been the race on new, better ideas.’ says Michal Rozanski.
In his opinion both small and big investors will benefit. ‘Appliance of algorithmic trading tools increases liquidity and descreases bid/ask spreads which in turn decreases transaction cost born by all investors’ adds expert.
Michal Rozanski stresses that appliance of algorithmic trading does not limit to transactions with shortt time horizon, e.g. counted in miliseconds. Each trader can designs algorithms adjusted for it’s own requirements. ‘Let’s imagine an investor who would like to open a large position on KGHM shares or futures on WIG20. To make it happen it’s best to divde the order to tens or hundreds of smaller orders, which allows to hide her intentions from other market participants. Investor remains anonymous and minimizes market impact of her large order.’ explains Michal Rozanski.
‘I am convinced that development of algorithmic trading can be a breakthrough moment in the history of our market, as long as we will treat the matter seriously and deliberately. On Wall Street share of algorithms in total turnover is estimated at 50%, in Europe at 40%, and in Poland still at below 20%. ‘ says Adam Maciejewski, CEO of Warsaw Stock Exchange.
Link to article…
Algorithmic trading workshop took place on 27th of July 2013 as a part of the second conference held by economic magazine ‘Puls Biznesu’ and Warsaw Stock Exchange.
Michał Różański, representing Empirica, held workshop on the practical aspects of selecting tools for algorithmic trading by financial institutions. He stressed and covered in detail, especially one aspect of algorithmic trading which is from our practical experience constantly undervalued – namely proper testing of algorithms.
Very interesting was also a lecture of Emil Lewandowski who showed an algorithm which was able to detect a flash crash an hour before it actually happened. Algorithm was implemented, backtested, executed and presented to all the participants our Algorithmic Trading Platform. It was indeed very interesting example of application of algorithmic trading!
Among other guest were representatives from IBM, Sungard, List and M10.
Link to event:
For news on cryptocurrencies, algorithmic trading, liquidity, market making, arbitrage, bitcoin, ethereum, crypto exchanges, quantitative cryptocurrency strategies, blockchain and algorithmic trading software.
© Copyright 2010-2019
Empirica, the vendor of
Cryptocurrency Marekt Making & Trading Software