S 13, 14 & 15 - Algorithmic Trading

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 76

S 13, 14 and 15-

Algorithmic Trading

B B Chakrabarti
Professor of Finance
Algorithmic Trading
• Algorithmic trading is a method of executing orders using
automated pre-programmed trading instructions accounting
for variables such as time, price, and volume to send small
slices of the order (child orders) out to the market over time.
They were developed so that traders do not need to
constantly watch a stock and repeatedly send those slices out
manually. Popular "algos" include Percentage of Volume,
Pegged, VWAP, TWAP, Implementation shortfall, Target close.
In the twenty-first century, algorithmic trading has been
gaining traction with both retail and institutional traders.
• It is widely used by investment banks, pension funds, mutual
funds, and hedge funds because these institutional
traders need to execute large orders in markets that cannot
support all of the size at once.
B B Chakrabarti - bbc@iimcal.ac.in 2
Algorithmic Trading
• The term is also used to mean automated trading system.
Also known as black box trading, Quant or Quantitative
trading, these encompass trading strategies that are heavily
reliant on complex mathematical formulas and high-speed
computer programs.
• Such systems run strategies including market making, inter-
market spreading, arbitrage, or pure speculation such as trend
following. Many fall into the category of high-frequency
trading (HFT), which are characterized by high turnover and
high order-to-trade ratios. HFT strategies utilize computers
that make elaborate decisions to initiate orders based on
information that is received electronically, before human
traders are capable of processing the information they
observe. Algorithmic trading and HFT have resulted in a
dramatic change of the market microstructure, particularly in
the way liquidity is provided.
B B Chakrabarti - bbc@iimcal.ac.in 3
Example of Algorithmic Trading
• Royal Dutch Shell (RDS) is listed on the Amsterdam Stock
Exchange (AEX) and London Stock Exchange (LSE). We want to
build an algorithm to identify arbitrage opportunities.
• Some observations:
• AEX trades in euros while LSE trades in British pound sterling.
• Due to the one-hour time difference, AEX opens an hour
earlier than LSE followed by both exchanges trading
simultaneously for the next few hours and then trading only in
LSE during the last hour as AEX closes.
• Requirements:
• A computer program that can read current market prices.
• Price feeds from both LSE and AEX.
• A forex (foreign exchange) rate feed for GBP-EUR.
B B Chakrabarti - bbc@iimcal.ac.in 4
Example of Algorithmic Trading
• Order-placing capability that can route the order to the
correct exchange.
• Backtesting capability on historical price feeds.
• The computer program should perform the following:
• Read the incoming price feed of RDS stock from both
exchanges.
• Using the available foreign exchange rates, convert the price
of one currency to the other.
• If there is a large enough price discrepancy (discounting the
brokerage costs) leading to a profitable opportunity, then the
program should place the buy order on the lower-priced
exchange and sell the order on the higher-priced exchange.
• If the orders are executed as desired, the arbitrage profit will
follow.
B B Chakrabarti - bbc@iimcal.ac.in 5
Growth in Algorithmic Trading

B B Chakrabarti - bbc@iimcal.ac.in 6
History of Algorithmic Trading
• Computerization of the order flow in financial markets began
in the early 1970s, with some landmarks being the
introduction of the NYSE's “designated order turnaround”
system (DOT, and later SuperDOT), which routed orders
electronically to the proper trading post, which executed
them manually.
• Program trading is defined by the NYSE as an order to buy or
sell 15 or more stocks valued at over US$1 million total. In
practice this means that all program trades are entered with
the aid of a computer. In the 1980s, program trading became
widely used in trading between the S&P 500 equity and
futures markets for stock index arbitrage. The program trade
at the NYSE would be pre-programmed into a computer to
enter the order automatically into the NYSE’s electronic order
routing system.
B B Chakrabarti - bbc@iimcal.ac.in 7
History of Algorithmic Trading
• Financial markets with fully electronic execution and
similar electronic communication networks developed in the
late 1980s and 1990s. In the U.S., decimalization, which
changed the minimum tick size from 1/16 of a dollar
(US$0.0625) to US$0.01 per share in 2001, may have
encouraged algorithmic trading as it changed the market
microstructure by permitting smaller differences between the
bid and offer prices, decreasing the market-makers' trading
advantage, thus increasing market liquidity.
• This increased market liquidity led to institutional traders
splitting up orders according to computer algorithms so they
could execute orders at a better average price. These average
price benchmarks are measured and calculated by computers
by applying the time-weighted average price or more usually
by the volume-weighted average price.
B B Chakrabarti - bbc@iimcal.ac.in 8
History of Algorithmic Trading
• A further encouragement for the adoption of algorithmic
trading in the financial markets came in 2001 when a team
of IBM researchers published a paper where they showed that
in experimental laboratory versions of the electronic auctions
used in the financial markets, two algorithmic strategies
(IBM's own MGD, and Hewlett-Packard's ZIP) could
consistently out-perform human traders. MGD was a modified
version of the "GD" algorithm invented by Steven Gjerstad &
John Dickhaut in 1996/7; the ZIP algorithm had been invented
at HP by Dave Cliff (professor) in 1996. In their paper, the IBM
team wrote that the financial impact of their results showing
MGD and ZIP outperforming human traders "...might be
measured in billions of dollars annually"; the IBM paper
generated international media coverage.

B B Chakrabarti - bbc@iimcal.ac.in 9
History of Algorithmic Trading
• As more electronic markets opened, other algorithmic trading
strategies were introduced. These strategies are more easily
implemented by computers, because machines can react
more rapidly to temporary mispricing and examine prices
from several markets simultaneously. For example,
Chameleon (developed by BNP Paribas), Stealth (developed
by the Deutsche Bank), Sniper and Guerilla (developed
by Credit Suisse) and many others.
• This type of trading is what is driving the new demand for low
latency proximity hosting and global exchange connectivity.
Latency refers to the delay between the transmission of
information from a source and the reception of the
information at a destination. Latency corresponds to about
3.3 milliseconds per 1,000 kilometers of optical fiber.
B B Chakrabarti - bbc@iimcal.ac.in 10
High Frequency Trading (HFT)
• HFT is a subset of algorithmic trading and, in turn, HFT
includes Ultra HFT trading. Algorithms essentially work as
middlemen between buyers and sellers, with HFT and Ultra
HFT being a way for traders to capitalize on infinitesimal price
discrepancies that might exist only for a minuscule period.
• Large sized-orders, usually made by pension funds or
insurance companies, can have a severe impact on stock price
levels. AT aims to reduce that price impact by splitting large
orders into many small-sized orders, thereby offering traders
some price advantage.
• The algorithms dynamically control the schedule of sending
orders to the market. These algorithms read real-time high-
speed data feeds, detect trading signals, identify appropriate
price levels and then place trade orders once they identify a
suitable opportunity. B B Chakrabarti - bbc@iimcal.ac.in 11
High Frequency Trading (HFT)
• HFT is an extension of algorithmic trading. It manages small-
sized trade orders to be sent to the market at high speeds,
often in milliseconds or microseconds.
• These orders are managed by high-speed algorithms which
replicate the role of a market maker. HFT algorithms typically
involve two-sided order placements (buy-low and sell-high) in
an attempt to benefit from bid-ask spreads. HFT algorithms
also try to “sense” any pending large-size orders by sending
multiple small-sized orders and analyzing the patterns and
time taken in trade execution. If they sense an opportunity,
HFT algorithms then try to capitalize on large pending orders
by adjusting prices to fill them and make profits.
• Ultra HFT is a further specialized stream of HFT. By paying an
additional exchange fee, trading firms get access to pending
orders a split-second before the rest of the market does.
B B Chakrabarti - bbc@iimcal.ac.in 12
Profit Potential from HFT
• A research paper published in The Quarterly Journal of
Economics (Nov 2015) provides the following example.
• The authors reveal what HFT algorithms aim to detect and
capitalize upon. The enclosed graphs show tick-by-tick price
movements of E-mini S&P 500 futures (ES) and SPDR S&P 500
ETFs (SPY) at different time frequencies.
• The deeper that one zooms into the graphs, the greater price
differences can be found between two securities that at first
glance look perfectly correlated.
• Two graphs are attached – one at hourly interval and the
other at 250 milliseconds.
• Please note that the axis for both instruments is different. The
price differentials are significant, although appearing at the
same horizontal levels.
B B Chakrabarti - bbc@iimcal.ac.in 13
Graph – Hourly Interval

B B Chakrabarti - bbc@iimcal.ac.in 14
Graph – 250 milliseconds Interval

B B Chakrabarti - bbc@iimcal.ac.in 15
AT - Advantages
• Lower commissions – Commission only for execution and
order management and not for research and advice
• Reduced transaction costs - Computers are better equipped,
faster, more consistent to react to changing market conditions
resulting in decreased market impact cost, less timing risk and
higher percentage of completed orders.
• Access and Speed - Algorithms provide fast and efficient
access to different markets and dark pool. AT uses co-location
with low latency connections.
• Algorithms are written beforehand so you can execute the
instructions automatically. The speed is so fast that as a
human being, it would be difficult to notice. You can scan and
execute multiple indicators at a very fast speed that is difficult
to spot. This enables trades to be analyzed and executed
faster and provide better opportunities.
B B Chakrabarti - bbc@iimcal.ac.in 16
AT - Advantages
• Accuracy - Use of computers in trading would help in reducing
some mistakes that may ordinary be associated with carrying
out that same activity manually. Human emotions play a huge
role in trading but with algorithmic, there is no room for that.
Humans often get carried away with their susceptible
emotions that often leads to making irrational decisions. It
helps you remove any errors before you can start trading in
the live market. Manual trading leaves a lot of room to get
carried away by greed and overwhelming by fear.
• To trade accurately, algo trading lets you backtest. It’s a huge
task for traders to know the pattern of trading system that
works properly and the technique that doesn’t work for them.
AT would enable you to do backtest of the systems that failed
and worked.
B B Chakrabarti - bbc@iimcal.ac.in 17
AT - Advantages
• Control – Buy-side traders have full control over orders. They
determine the venues (displayed/ dark), order submission
rules (market / limit order), order quantities, wait and refresh
times and match investment objectives with market
conditions. Traders can cancel or modify the trading
instructions almost instantaneously.
• Minimum information leakage – Buy-side trader specifies the
trading instructions by choosing the algorithm and its
parameters. Broker does not know the trading parameters or
intentions.
• Competition – AT has seen competition from various market
participants like exchanges, brokers, order and execution
management software firms, sell-side broker dealers and
others leading to better execution services and lower costs.
B B Chakrabarti - bbc@iimcal.ac.in 18
AT - Disadvantages
• Users can become complacent and use the same algorithm
regardless of the order characteristics and market conditions.
Users need to continuously test and evaluate algorithms for
effectiveness.
• Algorithms perform as they are specified. So, they may
provide sub-par performance in case of rise of unplanned
events.
• Too many algos and too many names. Some algos like VWAP
etc. are fairly descriptive and consistent across brokers. But an
algo such as Tarzan is not descriptive and does not provide
insights into how it trades. Investors have to understand
hundreds of algorithms and keep track of the changes in these
codebases.

B B Chakrabarti - bbc@iimcal.ac.in 19
Market Microstructure
• Trading venues:
• Displayed market – It is an exchange that displays order book
information including bid / offer prices, volume of trading and
depth of book. Investors can see how many shares are
available in each price increment, compute expected
transaction prices for a specified no. of shares, expected wait
time for a limit order etc.
• Dark pool – It is a crossing network or other types of matching
system that does not display order information. Customers
enter buy or sell orders into the dark pool, which are executed
only if there is a match.
• Advantage – no information leakage. Disadvantage – no prior
knowledge of order execution.
• Example – Liquidnet, Bids Trading, Level ATS.
B B Chakrabarti - bbc@iimcal.ac.in 20
Market Microstructure
• Types of orders:
• Market order – Buy or sell at the best available market price.
• Limit order – Buy or sell at the specified limit price or better
• Marketable limit order - A limit order that the broker can
execute immediately when it is submitted by a trader (buyer
or seller).
• Colocation: This implies that exchanges provide colocation
facility by renting out computer / server space next to their
matching engines. Traders can thus have same fast access and
are not disadvantaged.
• Direct market access (DMA): Using DMA, investment
companies (also known as buy side firms) and other
private traders use the IT infrastructure of sell side firms such
as investment banks and the market access that those firms
possess. B B Chakrabarti - bbc@iimcal.ac.in 21
Algorithms – Single stock algorithm
1) Single stock algorithm – These interact with the market
based on user specified settings and will take advantage of
favourable market conditions only when it is in the best
interest of the order and the investor.
Ex. – X is currently manually trading a stock on Robinhood
(U.S.-based financial services company offering mobile app,
which allows individuals to invest in public companies and
ETFs listed on U.S. stock exchanges without paying
commission) and would like to automate the process.
The stock is range-bound between $0.12 and $0.19. X would
like to pick it up between $.12 and $.14 (up to 100% of the
portfolio) and sell between $.15 and $.19. (up to 100% of the
portfolio) B B Chakrabarti - bbc@iimcal.ac.in 22
Algorithms - VWAP
• 2) VWAP (Volume weighted average price) –
VWAP is calculated through the following steps:
• 1. For each period, calculate the typical price, which is equal
to the sum of the high, low, and close price divided by three
[(H+L+C)/3]. One bar or candlestick is equal to one period.
What this period is set at is up to the trader’s discretion (e.g.,
5-minute, 30-minute, etc.).
• 2. Take the typical price (TP) and multiply by the volume (V),
giving a value TP*V.
• 3. Keep a running tabulation of the TP*V totals as well as a
running tally of volume totals. These are additive and
aggregate over the course of the day.
• 4. VWAP is calculated by the formula: cumulative TP*V /
cumulative volume
B B Chakrabarti - bbc@iimcal.ac.in 23
• This calculation, when run on every period, will produce a
Algorithms - VWAP
• VWAP, being an intraday indicator, is best for short-term
traders who take trades usually lasting just minutes to hours.
• Trading rules will be as follows:
• Long Trades
• Moving VWAP needs to be positively sloped
• Derivative oscillator (https://www.daytrading.com/derivative-
oscillator) above zero
• Short Trades
• Moving VWAP needs to be negatively sloped
• Derivative oscillator below zero
• Trade Exits
• Either one of these two criteria invalid.

B B Chakrabarti - bbc@iimcal.ac.in 24
Algorithms – VWAP Example

B B Chakrabarti - bbc@iimcal.ac.in 25
Algorithms - TWAP
• 3) TWAP (Time-weighted average price) – This strategy
attempts to execute an order to achieve the TWAP or better. A
TWAP strategy underpins more sophisticated ways of buying
and selling than simply executing orders en masse: for
example, dumping a huge number of shares in one block is
likely to affect market perceptions, with an adverse effect on
the price. High-volume traders use TWAP to execute orders
over a specific time so that they trade to keep the price close
to that which reflects the true market price.
• Traders follow a constant participation rate throughout the
day. In NSE equity market, a full day order will trade
approximately 1/375 th. of the order in each one minute
bucket (NSE operates from 9-15 am to 3-30 pm).
• It is a static strategy and will remain constant throughout the
day. B B Chakrabarti - bbc@iimcal.ac.in 26
Algorithms - POV
• 4) POV (Percentage of volume) – Also called volume inline or
participation Rate, it is a simple strategy which executes the
order quantity as percentage of trade volume of the stock in a
given time interval.
• Example: “Be 10% of volume”- Buy 100,000 shares at
%Volume of 10 and not exceeding the price of 125.20 until
order completed or market closed.
• Strategy Parameters:
• Start Time: Orders are not sent to market before Start Time.
• End Time: All open orders are completed before End Time
irrespective of the market impact
• %Volume: The strategy automatically adjusts the participation
rate to limit it to the percentage of stocks total traded volume.
Example, if the stock trades 100,000 shares in one minute and
%Volume is 10, the strategy will trade 10,000 shares in the
same minute. B B Chakrabarti - bbc@iimcal.ac.in 27
Algorithms - POV
• Reference Price: A given price which the strategy will try to
better in execution.
• When & Why to chose POV:
a) When executing large orders in a given time window
b) When the trader is satisfied with current & expected market
price (POV executes close to market price)
c) To execute close to the market price, the strategy may use a
predictive algo to decide the next order quantity and price
d) To minimize the market impact by not executing large
volume too quickly
• This strategy does not guarantee completion of orders in case
market volumes are low. One way to guarantee is to predict a
minimum POV rate and adjust in real time to ensure order
completion by the designated end time.
B B Chakrabarti - bbc@iimcal.ac.in 28
Algorithms – Arrival Price
• 5) Arrival Price - This strategy is designed to achieve or
outperform the bid/ask midpoint price at the time the order is
submitted, taking into account the user-assigned level of
market risk which defines the pace of the execution, and the
user-defined target percent of volume.
• This is a cost minimization strategy using optimization by
balancing the trade-off between cost and risk.
• The Arrival Price algo is designed to keep hidden orders that
will impact a high percentage of the average daily volume.
The pace of execution is determined by the user-assigned
level of risk aversion and the user-defined target percent of
average daily volume. Market impact can be lessened by
assigning lesser urgency, which is likely to lengthen the
duration of the order.
B B Chakrabarti - bbc@iimcal.ac.in 29
Arrival Price Algo Screen

B B Chakrabarti - bbc@iimcal.ac.in 30
Algorithms – Arrival Price
• Algo parameters:
• Max Percentage – 1 to 50% of the average daily volume.
• Urgency/Risk Aversion - select from the most aggressive Get
Done to the least aggressive Passive. This value determines
the pace at which the order will be executed. High urgency
may result in greater market impact.
• Start time/End time - The algo will stop at the designated end
time regardless of whether the entire quantity has filled
unless you check Allow trading past end time.
• Allow trading past end time - if checked, the algo will attempt
completion by the specified end time, but will continue to
work past the end time to execute any unfilled portion.
• Attempt completion by EOD - if checked your order will be
execute by the end of day if possible.
B B Chakrabarti - bbc@iimcal.ac.in 31
Algorithms – Implementation Shortfall
• 6) Implementation Shortfall (IS) - IS is the difference between the
price at which trader wants to execute order versus the average
traded price actually achieved. The reference price provided by
trader is used as a benchmark.
• IS is similar to the Arrival price algo in many ways. But while the
Arrival price algo is constant, the IS algo uses a second level of
adaptation based on market volumes and prices.
• IS algo is used when trader wants to limit the market impact cost
and also take advantage of favorable price movements
• The strategy calculates optimal time horizon to execute the trade
using stock’s historical volume profile, liquidity and volatility.
Example: the strategy will try to completely execute the order in
short time span when A) the stock has high volatility, B) low bid-ask
spread C) low momentum
• After calculating optimal trading time, the strategy may decrease
participation rate when prices move against the benchmark price
B B Chakrabarti - bbc@iimcal.ac.in 32
and increase when prices move in favor of benchmark price.
Algorithms – Basket Algorithm
• 7) Basket algorithm – Also known as portfolio algorithm. This
manages the trade-off between cost and total basket risk
(portfolio standard deviation) based on a user specified risk
aversion. It adapts to the changing market conditions. For ex.
– It may choose not to accelerate trading in an order even
when faced with available liquidity and favorable prices.
• Important basket trading constraints are cash balancing, self
financing, minimum and maximum participation rate.
• Its main purpose is to automatically build portfolio designed
by trader, but inside trading algorithms may vary depending
on needs. Common mechanism implemented is stop loss -
when price of any traded asset exceeds boundaries defined
by Stop Loss Prices, it alarms supervisor trader and (if ordered
to do this) may stop trading. All these features make this
strategy perfect tool to achieve long term investment plans.
B B Chakrabarti - bbc@iimcal.ac.in 33
Algorithms – Momentum Investing
• 8) Momentum Investing - One of the most basic and common
algorithmic trading systems followed by investors is a
momentum investing strategy. This type of investing looks for
the market trend to move significantly in one direction on
high volume. This trading system can either be very simple or
significantly difficult.
• A simple momentum investing strategy might invest in the five
best performing shares in an index that is based on a 12-
month performance.
• A more difficult strategy may blend momentum over time,
making use of both relative (buy winners) and absolute
momentum (buy in bull market and sell under bear).
• Furthermore, using this system enables investors to rebalance
momentum systems weekly, monthly, quarterly, or even
yearly. B B Chakrabarti - bbc@iimcal.ac.in 34
Algorithms – Trend Following
• 9) Trend Following Strategies: The most common algorithmic
trading strategies follow trends in moving averages, channel
breakouts, price level movements and related technical
indicators. These are the easiest and simplest strategies to
implement through algorithmic trading because these
strategies do not involve making any predictions or price
forecasts.
• Trades are initiated based on the occurrence of desirable
trends, which are easy and straightforward to implement
through algorithms without getting into the complexity of
predictive analysis.
• Some common technical indicators are price, volume, MACD
(moving average convergence divergence), RSI (relative
strength index) etc.
B B Chakrabarti - bbc@iimcal.ac.in 35
Algorithms – Trend Following
• Example: Commodity: soybean oil
• Trading approach: long and short alternately.
• Entrance: When the 50 period simple moving average (SMA)
crosses over the 100 period SMA, go long when the market
opens. The crossover suggests that the trend has recently
turned up.
• Exit: Exit long and go short the next day when 100 period SMA
crosses over 50 period SMA. The crossover suggests that the
trend has turned down.
• Stop loss: Set a stop loss based on maximum loss acceptable.
For example, if the recent, say 10-day, average true range is
0.5% of current market price, stop loss could be set at 4x0.5%
= 2%. Conventional wisdom on stop losses set the risk per
trade anywhere between 1%-5% of capital for a single trade;
this risk varies from one trader
B B Chakrabarti to another.
- bbc@iimcal.ac.in 36
Algorithms – Factor-Based Investing
• 10) Factor-Based Investing – This strategy is used by investors
to choose securities on attributes that are related to higher
returns, based on historical data.
• There are two main types of factors that have driven returns
of stocks, bonds, and other assets: macroeconomic factors
and style factors. The former captures broad risks across asset
classes while the latter aims to explain returns and risks
within asset classes.
• Noteworthy factors include market capitalization, momentum,
earnings momentum, beta, and free cash flow. Many financial
investors will combine these factors using a static weighing
system, or a dynamic allocation.
• Factor investing, from a theoretical standpoint, is designed to
enhance diversification, generate above-market returns and
manage risk. B B Chakrabarti - bbc@iimcal.ac.in 37
Algorithms – ETF Rotation
• 11) ETF Rotation Strategies - Many investors are interested in
investing and diversifying their portfolio in various global and
local sectors, but are often unsure of where to start. Sector
rotation is a strategy used by investors whereby they hold
an overweight position in strong sectors and underweight
positions in weaker sectors. Exchange-traded funds (ETFs) that
concentrate on specific industry sectors offer investors a
straightforward way to participate in the rotation of an
industry sector.
• The strategy is to rotate into ETFs with strong momentum to
maximize return. These strategies can also move capital into
uncorrelated ETFs to control risk when there are volatile
market conditions.
• Investors use these strategies to take full advantage of
patterns and trends uncovered by quantitative research, in
B B Chakrabarti - bbc@iimcal.ac.in 38
addition to the low fees charged by ETFs.
Algorithms – Smart Beta
• 12) Smart Beta – Smart beta investing combines the benefits
of passive investing and the advantages of active investing.
• The goal of smart beta is to obtain alpha, lower risk or
increase diversification at a cost lower than traditional active
management and marginally higher than straight index
investing. It seeks the best construction of an optimally
diversified portfolio.
• In effect, smart beta is a combination of EMH and value
investing. The smart beta investment approach applies to
popular asset classes, such as equities and FICC.
• Smart beta strategies seek to passively follow indices, while
also considering alternative weighting schemes such as
volatility, liquidity, quality, value, size and momentum. That's
because smart beta strategies are implemented like typical
index strategies in that the index rules are set and
transparent. B B Chakrabarti - bbc@iimcal.ac.in 39
Algorithms – Smart Beta
• These funds don’t track standard indices, such as the S&P
500 or the Nasdaq 100 Index, but instead, focus on areas of
the market that offer an opportunity for exploitation.
• Smart beta emphasizes capturing investment factors or
market inefficiencies in a rules-based and transparent way.
• Example –
• The Vanguard Value Index Fund ETF Shares ETF (VTV) tracks
the CRSP US Large Cap Value Index. Its benchmark determines
value using several fundamental ratios including price-to-book
(P/B), forward P/E, historical P/E, dividend-to-price and price-
to-sales. The fund has $77.25 billion in AUM as of April 2019.

B B Chakrabarti - bbc@iimcal.ac.in 40
Algorithms – Sentiment Analysis
• 13) Sentiment Analysis - Sentiment analysis trading strategy is
determined by crowd reactions, as investors stay up-to-date
on recent and relevant news and purchase stocks to predict
the crowd’s reactions.
• Sentiment Analysis or Opinion Mining refers to the use of NLP,
text analysis and computational linguistics to determine
subjective information or the emotional state of the
writer/subject/topic. It is commonly used in reviews which
save businesses a lot of time from manually reading
comments.
• The goal of this strategy is to take large quantities of
unstructured data, like newspaper articles, reports, social
posts, videos, blog posts. Many advisors and investors utilize
this strategy to capture short-term price changes and obtain
quick benefits.
B B Chakrabarti - bbc@iimcal.ac.in 41
Algorithms – Statistical Arbitrage
• 14) Statistical arbitrage strategy - Statistical arbitrage
comprise a set of quantitatively driven trading strategies.
These strategies try to exploit relative price movements
across thousands of financial instruments by analyzing the
price differences and the price patterns. Investors use this
strategy to generate higher-than-usual profits.
• Example - Buying a dual listed stock at a lower price in one
market and simultaneously selling it at a higher price in
another market offers the price differential as risk-free profit
or arbitrage.
• The same operation can be replicated for stocks versus
futures instruments, as price differentials do exist from time
to time.
• Implementing an algorithm to identify such price differentials
and placing the orders allows profitable opportunities in
efficient manner. B B Chakrabarti - bbc@iimcal.ac.in 42
Algorithms – Index Fund Rebalancing
• 15) Index Fund Rebalancing: Index funds have defined
methods / periods of rebalancing to bring their holdings to
par with their respective benchmark indices.
• This creates profitable opportunities for algorithmic traders,
who capitalize on expected trades that offer 20-80 basis
points profits depending upon the number of stocks in the
index fund, just prior to index fund rebalancing.
• Such trades are initiated via algorithmic trading systems for
timely execution and best prices.
• Some balancing techniques include calendar rebalancing,
percentage-of-portfolio rebalancing, constant proportion
portfolio insurance (CPPI) rebalancing etc.

B B Chakrabarti - bbc@iimcal.ac.in 43
Algorithms – Mathematical Model Based
Strategies
• 16) Mathematical Model Based Strategies: A lot of proven
mathematical models, like the delta-neutral trading strategy,
allow trading on combination of options and its underlying
security, where trades are placed to offset positive and
negative deltas so that the portfolio delta is maintained at
zero.
• A delta-neutral portfolio evens out the response to market
movements within a small range to bring the net change of
the position to zero.
• But if the portfolio has positive gamma, it will earn money
when the asset price surges in either direction. And if the
gamma is negative, it will earn profits if the asset prices
remain stable and range bound.
• Options traders use delta neutral strategies to profit either
from implied volatilityB Bor from- bbc@iimcal.ac.in
Chakrabarti time decay of the options. 44
Algorithms – Mean Reversion
• 17) Mean Reversion (Trading range): This strategy is based on
the idea that the high and low prices of an asset are a
temporary phenomenon that revert to their mean value
periodically.
• Mean reversion is the assumption that an asset price will tend
to move to the average price over time.
• Using mean reversion in stock price analysis involves both
identifying the trading range for a stock and computing the
average price using analytical techniques taking into account
considerations such as earnings, etc.
• When the current market price is less than the average price,
the stock is considered attractive for purchase, with the
expectation that the price will rise. When the current market
price is above the average price, the market price is expected
to fall. In other words, deviations from the average price are
expected to revert to Bthe average.
B Chakrabarti - bbc@iimcal.ac.in 45
Algorithms – Pairs Trading
• 18) Pairs trading - A pairs trade is a trading strategy that
involves matching a long position with a short position in two
stocks with a high correlation.
• A pairs trade strategy is best deployed when a trader
identifies a correlation discrepancy. Relying on the historical
notion that the two securities will maintain a specified
correlation, the pairs trade can be deployed when this
correlation falters.
• When pairs from the trade deviate, an investor would seek to
take a dollar matched the long position in the
underperforming security and sell short the outperforming
security. If the securities return to their historical correlation,
a profit is made from the convergence of the prices.
• Most pairs trades will require a correlation of 0.80, which can
be challenging to identify.
B B Chakrabarti - bbc@iimcal.ac.in 46
HFT Strategies
1) Statistical arbitrage – explained earlier
2) Triangular arbitrage - Triangular arbitrage exploits mispricing
across at least three foreign exchange (FX) rates.
• Consider the scenario where you initially hold xi dollars. If you
sell these dollars to buy euros, convert these euros to pounds,
and finally convert these pounds into xf dollars then you will
realize a profit if xf > xi. If the intermediate rate does not exist
you can calculate the synthetic cross rate to complete the
exchange.
• In highly liquid markets, such opportunities should be limited
and if they were to exist you would expect to find the
difference xf−xi to be very small. Given this restriction, when
such discrepancies are identified the differential between the
identified and execution price becomes extremely important.
B B Chakrabarti - bbc@iimcal.ac.in 47
HFT Strategies

B B Chakrabarti - bbc@iimcal.ac.in 48
HFT Strategies
3) Liquidity Trading –
• Liquidity trading is the HFT strategy which mimics the role of
the traditional market maker. Liquidity traders, or scalpers,
attempt to make the spread (buy the bid, sell the ask) in order
to capture the spread gain. Such efforts allow for profit even if
the bid or ask do not move at all. The key idea is to establish
and liquidate positions extremely quickly.
4) Market-Neutral Arbitrage –
• The trader is aiming to use insights about stocks which are
expected to outperform and those expected to underperform
the market. Achieving market neutrality from an investment
perspective usually involves commitments of equal amounts
of capital to over- and underperforming stocks. The key idea
here is to neutralize the portfolio against broad market
moves, achieved by the offset of long positions’ higher price
sensitivity by short positions’ lower price sensitivity
B B Chakrabarti - bbc@iimcal.ac.in 49
HFT Strategies
5) Index / Exchange Traded Fund Arbitrage –
• Index arbitrage is driven by relative mispricing of constituent
securities. An index or exchange traded fund (ETF) is
comprised of a basket of securities with the prevailing price of
index / ETF being, usually, a weighted average of the
constituent securities. If the relative prices between
constituents and their index/ETF trackers diverge an arbitrage
opportunity exists.
6) Merger Arbitrage / Risk Arbitrage –
• This usually involves buying the stock that is being acquired
and shorting the stock of the acquirer aiming to capture the
offer premium which always persists after an announcement
of intention. This premium reflects the risk inherent to the
deal, hence risk arbitrage, and is the difference between the
offered consideration and the target price.
B B Chakrabarti - bbc@iimcal.ac.in 50
HFT Strategies
• The long-short positions reflect the spread between the
offered consideration and the target price through the merger
period.
• If the merger is successful the target stock price will converge
to the offered consideration, thus the arbitrageurs will earn
initial spreads from the day the long-short positions were
taken.
• Predicting merger success is the most important factor for
merger arbitrageurs

B B Chakrabarti - bbc@iimcal.ac.in 51
Algo Trading Software – Key Features
• Availability of Market and Company Data: All trading algorithms
are designed to act on real-time market data and price quotes. A
few programs are also customized to account for
company fundamentals data like EPS and P/E ratios. Any
algorithmic trading software should have a real-time
market data feed, as well as a company data feed. It should be
available as a build-in into the system or should have a provision
to easily integrate from alternate sources.
• Connectivity to Various Markets: Traders looking to work across
multiple markets should note that each exchange might provide
its data feed in a different format, like TCP/IP, Multicast, or a FIX.
Your software should be able to accept feeds of different
formats. Another option is to go with third-party data vendors
like Bloomberg and Reuters, which aggregate market data from
different exchanges and provide it in a uniform format to end
clients. The algorithmic trading software should be able to
process these aggregated feeds as needed.
B B Chakrabarti - bbc@iimcal.ac.in 52
Algo Trading Software – Key Features
• Latency: This is the most important factor for algorithm
trading. Latency is the time-delay introduced in the
movement of data points from one application to the other.
• Consider the following sequence of events.
Exchange −0.2→ Vendor −0.3→ Trader screen −0.1→ Trading
software −0.3→ Analysis and Order placement −0.2→ Broker
−0.3→ Exchange (Total time = 1.4 seconds)
• In today’s dynamic trading world, the original price quote
would have changed multiple times within this 1.4 second
period. This delay could make or break your algorithmic
trading venture.
• To reduce latency, eliminate data vendor and broker with
DMA to eliminate 0.6 seconds, improve trading algo to reduce
0.6 seconds to a lower value.
B B Chakrabarti - bbc@iimcal.ac.in 53
Algo Trading Software – Key Features
• Configurability and Customization: Most algorithmic trading
software offers standard built-in trade algorithms, such as
those based on a crossover of the 50-day MA with the 200-
day MA. A trader may like to experiment by switching to
the 20-day MA with the 100-day MA. Unless the software
offers such customization of parameters, the trader may be
constrained by the built-ins fixed functionality. Whether
buying or building, the trading software should have a high
degree of customization and configurability.
• Functionality to Write Custom Programs: Matlab, Python,
C++, JAVA, and Perl are the common programming languages
used to write trading software. Most trading software sold by
third-party vendors offers the ability to write your own
custom programs within it. This allows a trader to experiment
and try any trading concept. Software that offers coding in the
programming language of your
B B Chakrabarti choice is obviously preferred. 54
- bbc@iimcal.ac.in
Algo Trading Software – Key Features
• Backtesting Feature on Historical Data: Backtesting
simulation involves testing a trading strategy on historical
data. It assesses the strategy’s practicality and profitability on
past data, certifying it for success (or failure or any needed
changes). This mandatory feature also needs to be
accompanied by availability of historical data, on which the
backtesting can be performed.
• Integration With Trading Interface: Algorithmic trading
software places trades automatically based on the occurrence
of a desired criteria. The software should have the necessary
connectivity to the broker(s) network for placing the trade or
a direct connectivity to the exchange to send the trade orders.

B B Chakrabarti - bbc@iimcal.ac.in 55
Algo Trading Software – Key Features
• Plug-n-Play Integration: A trader may be simultaneously using
a Bloomberg terminal for price analysis, a broker’s terminal
for placing trades, and a Matlab program for trend analysis.
Depending upon individual needs, the algorithmic trading
software should have easy plug-n-play integration and
available APIs across such commonly used trading tools. This
ensures scalability, as well as integration.
• Platform-Independent Programming: A few programming
languages need dedicated platforms. For example, certain
versions of C++ may run only on select operating systems,
while Perl may run across all operating systems. While
building or buying trading software, preference should be
given to trading software that is platform-independent and
supports platform-independent languages. You never know
how your trading will evolve a few months down the line.
B B Chakrabarti - bbc@iimcal.ac.in 56
Algo Trading Software – Build or Buy
• Purchasing ready-made software offers quick and timely
access, while building your own allows full flexibility to
customize it to your needs.
• The automated trading software is often costly to purchase
and may be full of loopholes, which, if ignored, may lead to
losses. The high cost of the software may also eat into the
realistic profit potential from your algorithmic trading
venture.
• On the other hand, building algorithmic trading software on
your own takes time, effort and a deep knowledge, and it still
may not be foolproof.
• Algo trading is dominated by large trading firms, such as
hedge funds, investment banks, and proprietary trading firms,
who can build their own proprietary trading software.
• Quants can also develop trading software on their own.
B B Chakrabarti - bbc@iimcal.ac.in 57
Algorithmic Analysis Tools
• Pre-Trade analysis – This provides investors with the
necessary data to make informed trading decisions on both
the macro- and micro-levels.
• Pre-trade data includes current prices and quotes, liquidity
and risk statistics, momentum and an account of recent
trading activity.
• The analysis provided liquidity summaries, cost and risk
estimates, trading difficulty, short term alpha etc. to decide
whether algo trading can be successfully implemented.
• Intraday analysis – This is used to monitor performance
during trading and can be used to evaluate market conditions
and make revisions to the algorithms.
• The systems commonly provide in real time the number of
shares executed, the realized costs, the price movement since
B B Chakrabarti - bbc@iimcal.ac.in 58
Algorithmic Analysis Tools
trading began, expected market impact cost, timing risk for the
remaining shares and expected market conditions etc.
• Post-trade analysis – This is a two-part process consisting of
cost measurement and performance analysis.
• Cost is measured as the difference between the actual
realized execution price and the specified benchmark price.
• Algorithmic performance is analyzed to assess the ability of
the algorithm to adhere to the prescribed strategy, its ability
to achieve fair and reasonable prices, and determine if the
algorithm deviates from the specified strategy in an
appropriate manner.

B B Chakrabarti - bbc@iimcal.ac.in 59
AT Transaction Cost Analysis
• Transaction cost - The total cost of a security transaction after
commissions, taxes, and other expenses. Understanding
exactly what transaction costs are and why they arise is the
first and fundamental step when dealing with TCA.
Transaction costs have nine components, usually categorized
as implicit or explicit.
• Transaction Cost Analysis (TCA) provides pre and posttrade
analysis to decrease the transaction cost of an order by
finding optimal trade timing and quantity.
• Explicit transaction costs –
• Brokerage commissions, market fees, clearing and settlement
costs, and taxes/stamp duties are explicit costs. They are said
to be explicit because they do not depend on the trading
strategy and trade price.
B B Chakrabarti - bbc@iimcal.ac.in 60
AT Transaction Cost Analysis
• Brokerage commissions are paid to intermediaries for
executing trades. They can be expressed on a per share basis
or based on a total transaction value, most of the time in basis
points and subject to volume discount.
• Market fees are paid to trading venues for executing trades
on their platforms. They are usually bundled into brokerage
commissions for investors. These fees vary. On average, higher
volume markets have the lowest costs.
• Clearing and settlement costs are related to the process
whereby the ownership of securities is transferred finally and
irrevocably from one investor to another. When the trading
venue owns the clearing and settlement system, these costs,
which are a fixed and visible transaction cost component, are
usually included in market fees.

B B Chakrabarti - bbc@iimcal.ac.in 61
AT Transaction Cost Analysis
• Taxes/stamp duties are visible and variable transaction cost
components. They are visible because tax rates or specific
stamp duties are known in advance but variable because they
often vary by type of return or trade.
• In theory, explicit costs could be determined before the
execution of the trade.
• Implicit Transaction Costs
• Implicit costs are the transaction costs that cannot be known
in advance because they are included in the trade price. They
are strongly related to the trading strategy and, as variable
costs, provide opportunities to improve the quality of
execution. These implicit costs are spread, market impact and
opportunity costs.

B B Chakrabarti - bbc@iimcal.ac.in 62
AT Transaction Cost Analysis
• Spread - This component is compensation for the costs
incurred by the liquidity provider. When taking liquidity (by
buying at the best ask or selling at the best bid), we pay the
spread. The spread represents the implicit cost of a round-trip
for a small trade and, as such, may be measured from market
data by the simple difference between the best ask and best
bid quotes
• Market impact – It is the price to pay for consuming the
liquidity available on the market beyond the best quote: to
complete their “large” orders, buyers must pay premium
prices and sellers must offer discounts. In other words, market
impact is the price shift that is due to the trade size. Its main
determinants are the trade size and the market liquidity
available at the time of the trade.

B B Chakrabarti - bbc@iimcal.ac.in 63
AT Transaction Cost Analysis
• Opportunity costs - The decision to trade and the actual trade
do not usually take place at the same time. Market prices can
move for or against the proposed trade. The costs related to
price fluctuation during the time required to act on an
investment decision are opportunity costs. They arise when
prices move between the time the trading decision is made
and the time the order is executed.
• Transaction Cost Analysis (TCA) provides pre and post trade
analysis to decrease the transaction cost of an order by
finding optimal trade timing and quantity. TCA helps investors
to pick the right strategy among several automated trading
services provided by financial institutions.
• Goal of TCA – To determine the appropriate trading strategy
that will result in Best Execution, which provides the highest
likelihood of achieving the investment objective of the fund.
B B Chakrabarti - bbc@iimcal.ac.in 64
AT Decision Making Framework
• The algorithmic decision making framework is about traders
instructing the algorithm to behave in a manner consistent
with the investment objectives of the fund. This consists of:
1) Select Benchmark Price
2) Specify Trading Goal (Best Execution Strategy)
3) Specify Adaptation Tactic
A) Select Benchmark Price
• Investors need to first select their benchmark price. This could
be the current price which is also known as the arrival price, a
historical price such as the previous day’s closing price, or a
future price such as the closing price on the trade day.
• The arrival price benchmark is often selected by fundamental
managers. These are managers who determine what to buy
and what to sell based on company balance sheets and long-
term growth expectations. These managers may also use a
combination of quantitative and fundamental information. 65
B B Chakrabarti - bbc@iimcal.ac.in
AT Decision Making Framework
• Quantitative managers who run optimization models may
select a historical price as their benchmark if this represents
the price used in the optimization process. Many quant
managers would run optimizers after the close incorporating
the closing price on the day. Optimizers determine the mix of
stocks to hold in the portfolio and the corresponding trade list
for the next morning. These orders are then submitted to the
market at the open the next day.
• Index managers often select the closing price of the trade day
to be their benchmark because this is the price that will be
used to value the fund. Any transaction that is different from
this price will cause the actual value of the fund to differ from
the index benchmark price. In order to avoid incremental
tracking error and potential subpar performance, index
managers often seek to achieve the closing price on the day.
B B Chakrabarti - bbc@iimcal.ac.in 66
Comparison of Benchmark Prices

B B Chakrabarti - bbc@iimcal.ac.in 67
AT Decision Making Framework
B) Specify Trading Goal (Best Execution Strategy)
• Select the trading goal so that it is consistent with the
underlying investment objective.
• Minimize Cost
• This aims to find the least-cost trading strategy. Investors may
seek to find the strategy that minimizes market impact cost. If
investors have an alpha or momentum expectation over the
trading horizon, they will seek to minimize the combination of
market impact cost and price appreciation cost.
• Minimize Cost with Risk Constraint
• Minimize cost for a specified quantity of risk. The risk
constraint is often specified by the portfolio manager or by
firm mandate that will not allow risk to exceed the specified
level.
B B Chakrabarti - bbc@iimcal.ac.in 68
AT Decision Making Framework
• Minimize Risk with Cost Constraint
• A portfolio manager’s preferred investment stock is LMK with
an expected return of 10% and the next most attractive stock
is RLK with an expected return of 9.5%. The manager
determines that shares can be purchased at a cost of 50 bps
(0.50%). Purchasing any more shares of LMK will cause the
cost to be greater than the incremental return of 50 bps and
the manager would be better off investing some portion of
the dollars in the second most attractive stock. Therefore, the
manager decides to transact the shares using a strategy that
will minimize risk for a cost of 50 bps.
• Balance Trade-off between Cost and Risk
• This is used by investors with a certain level of risk aversion
defined by the parameter λ.

B B Chakrabarti - bbc@iimcal.ac.in 69
AT Decision Making Framework
• Risk adverse investors will set λ to be high to avoid market
exposure and risk neutral investors set λ to be small. Setting
lambda to be zero is equivalent to the first criterion—
minimize cost—since the risk term would be ignored.
• Price Improvement
• This is used by investors wishing to maximize the probability
that they will execute more favorably than a specified cost.
Usually, this is the goal of participants seeking to maximize
short-term returns or exploit a pricing discrepancy.
C) Specify Adaptation Tactic
• The third step in the algorithmic decision making process is to
specify how the algorithm is to adapt to changing market
conditions. We discuss three strategies: targeted cost,
aggressive-in-the-money (AIM), and passive-in-the-money
(PIM) strategies.
B B Chakrabarti - bbc@iimcal.ac.in 70
AT Decision Making Framework
• Projected (Target) Cost Adaptation Tactic
• At the beginning of trading the projected cost is equal to the
initial cost estimate. But after trading begins the projected
cost will be comprised of four components: realized cost,
momentum cost, remaining market impact cost, and alpha
trend cost.
• Realized Cost: the actual cost of the traded shares.
• Momentum Cost: the price movement in the stock from the
time trading began to the current time. This price movement
results in either a sunk cost or savings to the investor.
• Remaining Market Impact cost: This is the expected price
impact that will result from trading the unexecuted shares in
the current market environment (liquidity and volatility) and
with the current trading rate.

B B Chakrabarti - bbc@iimcal.ac.in 71
AT Decision Making Framework
• Alpha Trend: the cost that will result due to the alpha trend
over the trading horizon.
• The projected cost adaptation tactic will minimize the
squared difference between the projected cost and original
cost from the best execution strategy. This tactic will always
revise the strategy to put us back on track to get as close as
we can to the original expected trading cost.
• Aggressive-in-the-Money (AIM) Adaptation Tactic
• This tactic maximizes the probability that the actual cost will
be less than the original cost from the best execution strategy.
This optimization is equivalent to maximizing the Sharpe Ratio
of the trade where performance (return) is measured as the
difference between original cost and projected cost.

B B Chakrabarti - bbc@iimcal.ac.in 72
AT Decision Making Framework
• Passive-in-the-Money (PIM) Adaptation Tactic
• This is a price-based scaling tactic intended to limit the
potential losses and high costs in times of adverse price
movement. It allows investors to better participate in gains to
share in gains in times of favorable price movement.
• The PIM adaptation tactic minimizes potential bad outliers
and increases chances of achieving the good outliers.

B B Chakrabarti - bbc@iimcal.ac.in 73
AlgoTrading in India
• In the US and other developed markets, High Frequency
Trading and Algorithmic trading accounts estimated 70% or
more of equities market share. It accounts for almost 30%
trades on BSE and 50% trades on NSE.
• On April 3rd 2008, SEBI allowed Direct Market Access facility
which allows buying or selling of orders by institutional clients
without manual intervention by brokers. DMA enables clients
to access the exchange trading system through brokers’
infrastructure but without manual intervention.
• It was expected that this change would result in greater
transparency, increased liquidity, lower impact costs for large
orders, better audit trails and better use of hedging and
arbitrage opportunities.
AlgoTrading in India
• National Stock Exchange (NSE) offered additional 54 co-
location server ‘racks’ on lease to broking firms from June
2010 in an effort to improve the speed in trading.
• Some NSE initiatives to help Algo trading:
• Co-location facilities: Reduce the time taken for orders to
reach the exchange. A reduction in half millisecond is a big
improvement in HFT trading strategies.
• Tick by tick data: Create order book of any depth using tick by
tick data
• Normal Vs Bucket feed: Subscribe to only a few instruments
for which you require the data
• High Capacity Interactive Lines: Send up to 400 messages
every second to exchange
AlgoTrading in India
• Smart Order Routing: Implement systems which can pick any
of the multiple exchanges to send order at more favorable
price
• New membership categories: Alpha category memberships
available at NSE for focused proprietary trading with limited
clientele
• With several amendments over the years in rules and
processes, India provides a good opportunity for HFT traders
due to a number of factors such as co-location facilities and
sophisticated technology at both the major exchanges; a
smart order routing system; and stock exchanges that are
well-established and liquid.

You might also like