Insightful thread on Algo trading in India by Prathamesh Godbole
Algo trading is broadly of 3 types- execution, market making, directional Execution algorithms are the ones used by large traders to get the best possible price for their orders.
Instead of a trader manually putting in orders, an algorithm does the optimization of when and how to make these trades. Why do you need an algorithm at all instead of a human trader? Say you’re buying 10 lots of Nifty, you don’t need an algorithm. Just hit a market order.
You’ll get a fill. But what if you need to execute an order for 1000 lots of nifty? Exchange doesnt even let you punch in a single order of 1000 lots at one go. Moreover, if you put in a market order for hundreds of lots, you’ll impact the price drastically.
You want to buy with the least possible price impact, so you slice your order into smaller bits. There are 2 main parts of execution algos -
- The macro router
- micro router
Macro router - this is the overall algorithm that decides how to execute this order. There are several popular algos that are used
- market participation
this is the simplest. The VWAP, or volume weighed average price, is the average price where trades happened. if 100 shares traded at rs 500, and 200 shares at 501, the vwap will be (100x500 + 200x501)/300 = 500.66.
The algorithm calculates what percentage of the volume was executed over the course of the day in each time slot of say 15minutes. Dividing the day into 25 chunks of 15mins, we get a distribution say 5% of volume in first slot, 20% in 2nd, 1% in third and so on.
The same percent of your order’s volume is executed in those time slots at the market price. So in times of high volume, you execute more, in times of low volume, you execute less. As a result, your average price over the day is close to vwap.
time weighed average price. As the name suggests, this executes uniformly over the course of the day. If you have 20 time slots and 200 shares, it will execute 10 shares in each. this is great for liquid stocks.
Market participation -
here, you want to be a % of the total traded volume. Say 20% at most. This means you want to trade more only when there is volume happening. If traded volume is thin, you will not execute either.
At 20%, for every 100 shares that trade, you’ll send an order for 20. Till further trades happen, dont trade. Why do this? For low volume shares, blindly executing twap or vwap will impact the price severely, so you limit yourself to be a fraction of the total volume.
as the name suggests, this algorithm is like an iceberg- shows a tip above the surface but has a large quantity hidden. Typically, this will float small buy/sell limit orders at the top of the order book, and when filled, keep adding more until finished.
It may also have a limit price where it will aggressively buy till price is below limit. Once price crosses above the limit, it stops buying actively and floats a limit price at the bid. If the bid comes down, it will lower its own bid automatically.
Note: You will likely see cases where there is a bid at some price x. as soon as you put your order, someone puts an order one tick higher- its probably this algo, or a market maker
As a variant of iceberg, the algo could also keep buying directly until the limit price, without floating any order on the order book, staying hidden. you’ll see the price rise till some value repeatedly and drop then repeat.
There are many variants and customizations possible but these are broad categories. Now comes the 2nd piece- the micro router. this sits one level below the macro router that slices the parent order into chunks.
In India we have only 2 equity exchanges- NSE,BSE. In US, you have exchanges, dark pools, and a dozen others The micro router chooses the best venue to route the order from the algo. It also decides whether to use limit/market order, and what % of order qty to display 10-100%
if you want the fastest execution, exchanges give you racks for colocation- you put your servers right at the exchange for a fee. This reduces the time taken to get data and react to it by milliseconds- but against other algorithms, those few milliseconds are everything.
Normally, the data you get from your broker terminal or data vendor is a UDP data feed, with one tick per second roughly. True tick by tick data requires colocation, and could be hundreds or thousands of ticks per second.
This is impossible to distribute on standard internet and your machine lacks the capacity to handle it. If you’re doing HFT, without colo you’re out of the race.
What are your thoughts on this?