Exploring Liquidity Aggregation Algorithm to Calculate Volume for a Given VWAP Spread


Published on

We develop a liquidity aggregation algorithm from a mathematical model based around volume-weighted average price (VWAP) calculations taking into consideration market depth.

Published in: Business, Economy & Finance
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Exploring Liquidity Aggregation Algorithm to Calculate Volume for a Given VWAP Spread

  1. 1. Exploring Liquidity Aggregation Algorithm to Calculate Volume for a Given VWAP Spread A winning liquidity aggregation strategy requires the ability to both tabulate potential profitability on bid/ask spreads and to accumulate maximum liquidity (volume) available as part of market depth. Executive Summary There are special purpose trading tools available in the market that can be used for liquidity aggre- gation, especially where voluminous positions must be hedged as a result of adverse moves in security prices. The latest trading tools have developed several sophisticated features that can be leveraged when a trader hedges positions within a very truncated time span that creates minimal price movement in the ladder. One of those fundamental features is to acquire a position based on the user-entered spread using volume-weighted average price (VWAP) calculation. This white paper covers the algorithmic aspects used to calculate the available VWAP volume for a given spread, including: • What is VWAP? The elaborated problem statement of the algorithm. • Simplified case study to find the solution. • Formation of generic mathematical models. • Deriving the algorithm from mathematical models. What Is VWAP? In finance, VWAP is the ratio of the value traded of a particular security to the total volume traded over a particular time horizon. In our problem statement, however, we will consider the market depth of a pricing ladder to constitute the volume weighted average. It is a measure of the average price a security traded at over the trading time span. Let’s understand the problem statement with reference to the example in Figure 1 (next page) of a ladder of EURUSD bid/ask prices. Simplified Case Study to Find Solution Figure 1 provides a problem statement based on the market depth of the ask side of a ladder — where the prices are sorted in ascending order (i.e., best ask being the least price a trader can afford for buying the security). If the trader agrees to pay $1.274730 and expects to hedge as much volume as possible, then without VWAP the available volume in the illustrated ladder would be 23M (Price: $1.273957) + 16M (Price: $1.274730) = 39M. However, our target is to maximize the volume that can be hedged in this scenario. Hence, the idea here is to afford some volume from an expensive lot at the cost of the price that is saved when acquiring cheaper lots in the ladder. So, if we take the best two prices in the ladder (price: $1.273957, volume: 23M and price: • Cognizant 20-20 Insights cognizant 20-20 insights | march 2014
  2. 2. 2 $1.274730, volume: 16M), then the VWAP becomes (1.273957*23 + 1.274730*16)/(23+16) = $1.274274. This price is less than what the trader can afford ($1.274957). Hence, we take the next best prices in the ladder until we reach the VWAP price mentioned by the trader. After taking the third-best price in the ladder (price: $1.273957, volume: 23M, price: $1.274730, volume: 16M, price: $1.275502, volume: 41M), our VWAP becomes = (1.273957*23 + 1.274730*16 + 1.275502*41) / (23+16+41) = $1.274903. Interestingly, we have afforded a price in the ladder that is individually greater than the target price set by the trader (ladder price: $1.275502, trader quote: $1.274957), but the effective price (VWAP) is less, so we can afford the next price in the ladder. While taking the fourth price in the ladder, we see that if we afford 3M of $1.277048, then our VWAP becomes = (1.273957*23 + 1.274730*16 + 1.275502*41 + 1.277048*3) / (23+16+41+3) = $1.274981, which is greater than the trader quote, whereas if we take 2M of $1.277048, then our VWAP becomes = (1.273957*23 + 1.274730*16 + 1.275502*41 + 1.277048*3) / (23+16+41+3) = $1.274956, which is just less than the trader quote. Hence, if we go by VWAP, we can afford a volume of 82M with a VWAP of $1.274956. In the next section, we will derive an algebraic model to identify the way to determine the VWAP volume. Formation of Generic Mathematical Model The following steps are critical for deriving the algorithmic model used above: • Consider generic values in market depth (V1:P1, V2:P2,…Vn:Pn). Here, V1 is the volume at the 1st position in the ladder, and P1 is the correspond- ing price. • There can be Max 1 lot (Min 0 lot) in market depth where volume will split to support a given VWAP. Let’s say it is Vx — Px. So the market depth becomes V1 — P1 V2 — P2 ... Vx — Px ... Vn — Pn • Let’s assume that the required volume from the Vx — Px lot is Vr. Then total money spent will become : V1*P1+V2*P2+….+Vr*Px = Sum(Vi*Pi) + Px*Vr where i varies from 1 to (x-1). • Let’s assume that the VWAP given is Pv (89.2 in the above case). Then, total money spent will be = (V1+V2+…Vx-1+Vr)*Pv = (Sum(Vi)+Vr)*Pv where i varies from 1 to (x-1). • Equating both sides gives us: Sum(Vi*Pi) + Px*Vr where i varies from 1 to (x-1) = (V1+V2+…Vx- 1+Vr)*Pv=(Sum(Vi)+Vr)*Pv where i varies from 1 to (x-1) Or, cognizant 20-20 insights Figure 1 As the ladder above shows, Best Ask is 1.273957 with a volume of 23M. Market depth is 1.27473 with volume 16M, 1.275502 with volume 41M, 1.277048 with volume 8M, and so on. Let’s as- sume that a trader wishes to hedge his position, and he agrees to afford a spread of 10 pips from the Best Ask. Hence, he can afford a price of 1.274957 and he is expecting to hedge an infinite volume (or as much as possible). We will try to find out technically how much will he be able to hedge (assuming that no other trader is present in the market at this point in time to acquire any similar position in the same ladder).
  3. 3. 3cognizant 20-20 insights Vr*Px — Vr*Pv = Sum(Vi)*Pv - Sum(Vi*Pi) Or, Vr*(Px-Pv)= Sum(Vi)*Pv - Sum(Vi*Pi) Or, Vr = {Sum(Vi)*Pv - Sum(Vi*Pi)}/ (Px-Pv) So, the total volume that can be technically availed is — Sum(Vi) + Vr where i varies from 1 to (x-1), and value of Vr is -: { Sum(Vi)*Pv - Sum(Vi*Pi)}/ (Px-Pv) Deriving the Algorithm from a Mathematical Model The basic steps of the algorithm include: • Assumptions: For the ask side of the ladder, prices are sorted in ascending order. >> Every price with its volume will be called a lot in the algorithm. >> Algorithm for ASK is shown below; algorithm for BID will be exactly same as that of ASK; only the comparator signs will be reversed (all greater than will become less than and vice-versa). >> Input to the algorithm is a set of lots and the VWAP price is quoted by the trader (Pv). >> Output to the algorithm will be the volume and effective VWAP achieved. • Algorithm: Initialize below variables: >> totalPriceMultipliedByVol = 0 >> totalVol = 0 >> For every lot in the ladder execute the below steps (start a for loop): »» Take the price of the lot, multiply with the volume available (let’s say Vi). Store it in a variable (e.g., X). »» If (totalPriceMultipliedByVol + X<Pv*( totalVol*Vi)), then totalVol = totalVol + Vi and totalPriceMultipliedByVol = totalPri- ceMultipliedByVol + X. »» Then this is the lot that will be split. Store this lot (Px:Vx); break the loop. >> Beyond the loop, check on whether Px:Vx is found. If it is not found, then that means we can consume the entire ladder. Hence, in that case the effective VWAP will be to- talPriceMultipliedByVol/totalVol, and VWAP volume will be totalVol. >> If Px:Vx is found, then: »» VWAP volume (totalVol + VV), where VV= (totalVol*Pv — totalPriceMultiplied- ByVol)/(Px — Pv). »» Effective VWAP = (totalPriceMultiplied- ByVol + VV*Px)/(VV + totalVol). Benefits of Volume Calculation Based on VWAP If we hedge our position with a given price, we will end up with the cumulative volume of those lots where the individual lot prices are either less than or equal to the given quote. Whereas, if we go with volume acquisition based on the VWAP algorithm, we can afford a few lots that have indi- vidual prices above the given quote, thus generat- ing more volume. In our example, for example, we could get a cumu- lative volume of 39M (23M with price 1.273957, 16M with price 1.274730), whereas with appli- cation of VWAP algorithm we could hedge our position with 82M of volume. One noteworthy point here is that the VWAP algorithm is useful only when we wish to acquire more volume within a given spread of price. Hence, specifically for liquidity aggregation purposes, volume calculation based on VWAP prices is certainly effective. Within the currency trading (FX) domain (FX ladder), the VWAP algorithm is more popular and frequently used, because of the existence of numerous exchange venues (like EBS, Reuters, HotSpot, 360T, etc.) that provide huge liquidity for many currencies. Hence, even usage of a virtual order book (VOB) along with the VWAP algorithm is very effective in liquidity aggregation.
  4. 4. About Cognizant Cognizant (NASDAQ: CTSH) is a leading provider of information technology, consulting, and business process out- sourcing services, dedicated to helping the world’s leading companies build stronger businesses. Headquartered in Teaneck, New Jersey (U.S.), Cognizant combines a passion for client satisfaction, technology innovation, deep industry and business process expertise, and a global, collaborative workforce that embodies the future of work. With over 50 delivery centers worldwide and approximately 171,400 employees as of December 31, 2013, Cognizant is a member of the NASDAQ-100, the S&P 500, the Forbes Global 2000, and the Fortune 500 and is ranked among the top performing and fastest growing companies in the world. Visit us online at www.cognizant.com or follow us on Twitter: Cognizant. World Headquarters 500 Frank W. Burr Blvd. Teaneck, NJ 07666 USA Phone: +1 201 801 0233 Fax: +1 201 801 0243 Toll Free: +1 888 937 3277 Email: inquiry@cognizant.com European Headquarters 1 Kingdom Street Paddington Central London W2 6BD Phone: +44 (0) 20 7297 7600 Fax: +44 (0) 20 7121 0102 Email: infouk@cognizant.com India Operations Headquarters #5/535, Old Mahabalipuram Road Okkiyam Pettai, Thoraipakkam Chennai, 600 096 India Phone: +91 (0) 44 4209 6000 Fax: +91 (0) 44 4209 6060 Email: inquiryindia@cognizant.com ­­© Copyright 2014, Cognizant. All rights reserved. No part of this document may be reproduced, stored in a retrieval system, transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the express written permission from Cognizant. The information contained herein is subject to change without notice. All other trademarks mentioned herein are the property of their respective owners. About the Author Nishit Kumar Ghosh is a Project Manager who leads Cognizant’s Wealth Management Team at one of the company’s major banking clients. He has a decade of experience in techno-functional roles in market risk domain, FX front-office trading algorithm development, wealth management and low-latency pro- gramming. Nishit has worked in Europe and APAC regions delivering transformational projects for large financial institutions. He can be reached at Nishitk.Ghosh@cognizant.com.