0% found this document useful (0 votes)
15 views22 pages

Computational Finance and Algorithmic Trading

The document outlines the fundamentals of algorithmic trading, including definitions of financial instruments, trading systems, and key concepts such as liquidity, market makers, and order types. It discusses the roles of buyers, sellers, and brokers in trading, as well as the importance of execution logic, risk management, and backtesting in developing effective trading strategies. The lecture also emphasizes the significance of market data protocols and order entry systems in facilitating trades within electronic exchanges.

Uploaded by

selinhurel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views22 pages

Computational Finance and Algorithmic Trading

The document outlines the fundamentals of algorithmic trading, including definitions of financial instruments, trading systems, and key concepts such as liquidity, market makers, and order types. It discusses the roles of buyers, sellers, and brokers in trading, as well as the importance of execution logic, risk management, and backtesting in developing effective trading strategies. The lecture also emphasizes the significance of market data protocols and order entry systems in facilitating trades within electronic exchanges.

Uploaded by

selinhurel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

MIS4321

Computational Finance and


Algorithmic Trading

Fall 2024
Lecture #2
Fundamentals of Algorithmic Trading
By a trade we will understand either a purchase or sale of some kind
of financial instrument.

The financial instruments include stocks (or shares), bonds,


commodities, currencies, derivatives and possibly other instruments.

The term security is used to cover any kind of financial instrument


that can be traded.

A trade can be realized by a seller offering to sell at a particular price


and a buyer willing to buy at that price. Such a buyer and seller are
matched, and a trade between them becomes possible.

Goods that are traded should possess the property of fungibility


which essentially means that two different units are exchangeable and
possess the same financial value. Cash is a fungible asset. 2
Trading Systems
The flow of information from an electronic trading exchange to
the market participants:
The trading exchange
maintains a book of
client buy orders (bids)
and client sell orders
(asks), and publishes
market data using market
data protocols to provide
the state of the book to
all market participants.

The outgoing order flow is communicated to the exchange via order


entry protocols. This, in turn, will generate further market data
flow, and so the trading information cycle continues.
3
Trading Systems
A stock exchange (or a simply an exchange) is a place where buyers
and sellers can negotiate and conduct trades.

Typically, buyers and sellers do not directly negotiate.

The brokers who negotiate among themselves on behalf of their


clients to conduct trades. Brokers earn commissions, and both buyers
and sellers become clients of brokers.
An electronic stock exchange is essentially a piece of software.
There are two basic tasks:
1. Entering orders in an order book
2. Matching buy and sell orders

Direct market access: Buyers and sellers can also obtain direct access
to the order book of a stock exchange (there is no broker). 4
Concepts in Algorithmic Trading
Liquidity: Market liquidity of a financial asset refers to the property
whereby the asset can be quickly sold or purchased without a
significant change in the price of the asset. Liquidation simply
means selling the asset for cash.

Market maker: A market maker is an entity which places limit


orders that cannot be immediately executed, i.e. it places buy orders
at prices below the current selling price and/or sell orders at prices
above the current buying price. Such orders introduce liquidity into
the market, thus a market maker is also called a liquidity provider.

Market taker: A market taker is an entity which places orders that


are immediately executed. This means that the entity places a buy
order at a price which is at or above the current selling price and/or
places a sell order at a price which is at or below the current buying
price. Such orders remove liquidity from the market and so, these 5
entities are also called liquidity takers.
Concepts in Algorithmic Trading
Maker, taker fees: Makers “create or make a market” for other
traders and bring liquidity to an exchange. Takers remove liquidity
by “taking” available orders that are filled immediately. Taker fees
are usually slightly higher than maker fees to encourage market
makers.

Bid-ask spread: The difference in the selling and buying prices of the
security in an exchange. One measure of liquidity of an asset is the
size of the bid-ask spread. If this spread is small, then the asset is
very liquid.

Market impact: The effect on the price when an entity buys or sells
an asset. Market impact is quantified by the amount in which the
price moves in the opposing direction.
6
Concepts in Algorithmic Trading
Short: A short sale (or going short) of an asset refers to the act of
sale of an asset that the seller does not possess. So, the sale has to
be made good by borrowing the asset from another entity. At a later
point of time, the seller repurchases the asset from the market and
pays back the lender. This is called covering the short position. The
seller gains if the price decreases between the time it makes the sale
and the time it buys from the market to pay back to the lender.

Long: An entity having a long (buy) position in an asset means that


the entity owns a positive amount of the asset. This is the
conventional concept of investing. An entity buys a certain amount of
the asset. If the price of the asset goes up, the entity stands to gain,
while if the price goes down, then the entity potentially loses.

7
Exchange Order Book
The exchange order book maintains all
incoming buy and sell orders placed by
clients. It tracks all attributes for incoming
orders—prices, number of contracts/shares
(amount), order types, and participant
identification.

Buy orders (or bids) are sorted from the


highest price (best price) to the lowest price
(worst price). Bids with higher prices have a
higher priority as far as matching is
concerned.

Sell orders (or asks) are sorted from the


lowest price (best price) to the highest price
(worst price). 8
Exchange Order Book
The simplest FIFO (First In First Out) algorithm uses an outomatic
rule of prioritizing orders at the same price in the order in which
they came in.
Market depth of a security refers
to the various price levels for the
security.
It is provided as a list of the price
levels and the total quantity that
is to be traded at each price
level.

It is the size of the order that is


needed to move the market
price by a specified amount. A
deep market maintains a stable
price. 9
Order Types
Market orders:
The simplest order is a market order. Such an order specifies the
quantity, but not the price. It is to be immediately fulfilled at the best
available market price.
For example, a buy market order is fulfilled at the lowest ask price
and a sell market order is fulfilled at the highest bid price.

Limit orders:
They are one step up in complexity from market orders. A limit
order specifies the quantity and the price indicating that the trade for
the quantity is to be made at the specified or better price.
A buy limit order can be fulfilled by purchasing at the specified or
lower price, while a sell limit order can be fulfilled by selling at the
specified or higher price.
The limit order is entered into the order book queue and has to wait for
matching orders. 10
Order Types
Fill or Kill (FOK): The orders are either to be filled completely or
cancelled.

Immediate or Cancel (IOC): The orders are to be executed immediately


or cancelled. Unlike FOK, partial fulfillment is allowed.

All or Nothing (AON): Either the order is filled completely or not at all.
Partial fulfillment is not allowed. Unfilled AON orders are not cancelled.

Stop Order: This is an order to transact a trade when the market price
reaches a specified price. Once the specified price is reached, the stop
order becomes a market order. So, the trade will definitely take place
even if the price changes adversely with respect to the stop order price.

Mid-Price Peg: Such an order specifies a limit price which is the


average of the best bid and the best offer prices. 11
Order Types
Market-if-Touched: Trade is to be conducted at the best available price
if the market price reaches a specified ‘if touched’ level. As soon as the
trigger price is reached, the order is treated as a market order.

One Cancels Other: This is a pair of orders for two instruments. If one
of the orders is executed, then the other order stands cancelled.

One Sends Other: This specifies a cascade of orders. If the first order is
executed, then the next one is triggered. The orders are executed
sequentially.

12
Concepts in Algorithmic Trading
Exchange market data protocols are outgoing communication
streams from the exchange to all market participants that are well-
documented for new participants to build their software applications
to subscribe, receive, decode, and check for errors and network losses.

Market data feed handlers are software applications that market


participants build with a view to interfacing with the specific
exchange market data protocol. These are able to subscribe, receive,
decode, and check for errors and network losses,

Exchange order entry protocols are how market participant software


applications send order requests (new, cancels, modifies) and how the
exchange replies to these requests.

13
Concepts in Algorithmic Trading
Order entry gateways are the market participant client applications
that communicate with the exchange matching engine over the order
entry protocols. These have to deal with order flow in a reliable
manner, sending orders to the exchange, modifying and canceling
those orders, and getting notifications when these orders are accepted,
canceled, executed, and so on.

Open Positions: A buy side execution is called having a long


position, while a sell side execution is called having a short position.
When we have no position at all, this is referred to as being flat.

Volume Weighted Average Price (VWAP): Multiple buy executions,


or multiple sell executions for different amounts and prices, cause the
overall position price to be the volume weighted average of the
execution prices and quantities.
14
Concepts in Algorithmic Trading
Unrealized profit and loss (PnL): Open positions are marked to
market to get a sense of what the unrealized Profit and Loss (PnL) of
the position is.

Realized PnL: Profit or loss is realized when an open position is


closed, meaning you sell to close a long position and you buy to close
a short position.

Market data subscription : These components are responsible for


interacting with the feed handler components that publish normalized
data. This data can be delivered over a network or locally using a
variety of Inter-Process Communication (IPC) mechanisms from
the feed handlers.

15
Concepts in Algorithmic Trading
Signals: Once limit order books are built, every time they are updated
due to new incoming market data information, we build signals using
the new information.
Signals are called by various names—signals, indicators, predictors,
calculators, features, alpha, and so on.
A trading signal is a well-defined piece of intelligence that is derived
from incoming market data information, limit order books or trade
information that allows a trading strategy to get a statistical edge
(advantage).

Signal aggregators: Often, a lot of algorithmic trading systems


combine a lot of different kinds of signals in order to gain a bigger
edge than individual signals provide. The approach is to essentially
combine different signals that have different predictive
abilities/advantages under different market conditions.
16
Concepts in Algorithmic Trading
Execution logic
A key component of algorithmic trading is quickly and efficiently
managing orders based on signals in order to gain an edge over the
competition. It is important to react to changing market data, changing
signal values in a fast but intelligent manner. Oftentimes, speed and
sophistication are two competing goals, and good execution logic
will try to balance the two objectives in an optimal manner.

Slippage is defined as the difference in the expected price of a


trade and the price at which the trade is actually executed. This
can happen for predominantly two reasons:
1. If the order reaches the exchange later than expected (latency), then it might end
up either not executing at all, or executing at a worse price than you might
expect.
2. If the order is very large such that it executes at multiple prices, then the VWAP
of the entire execution may be significantly different from the market price
observed when the order was sent. 17
Concepts in Algorithmic Trading
Fees are another issue with executing orders efficiently. Typically,
there are exchange fees and broker fees proportional to the size of
the orders and the total volume traded.

Position and PnL management


All algorithmic trading strategies need to track and manage their
positions and PnLs effectively. Depending on the actual trading
strategy, this can be complex.

For more sophisticated trading strategies, such as pairs trading, you


have to track positions and PnLs on multiple instruments.

18
Concepts in Algorithmic Trading
Risk management
Good risk management is one of the cornerstones of algorithmic
trading. Bad risk management practices can turn potential profitable
strategies into non-profitable ones.

There is an even bigger risk of violating rules and regulations at


trading exchanges that can often lead to legal actions and huge
penalties.

Finally, one of the biggest risks with high- speed automated


algorithmic trading is that poorly programmed computer software
is prone to bugs and errors.

19
Concepts in Algorithmic Trading
Backtesting

When researching an automated trading strategy for expected


behavior, a key component in a good algorithmic trading research
system is a good backtester.

A backtester is used to simulate automated trading strategy


behavior and retrieve statistics on expected PnLs, expected risk
exposure, and other metrics based on historically recorded market
data.

The basic idea is to answer the question: given historical data, what
kind of performance would a specific trading strategy have?

20
Building Trading Strategies
Building a trading strategy takes time and goes through numerous
steps:

1. You need an original idea (a money-making strategy).

2. Once we get the idea, we need data to validate the idea. There are
many tools that we can use, to get trading data.

3. You will then need to use a large amount of historical data to


backtest your trading strategy assuming this rule: what worked
in the past will work in the future.

21
Next week

• Trading strategies

Thank you for your participation J

22

You might also like