Computational Finance and Algorithmic Trading
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
19
Concepts in Algorithmic Trading
Backtesting
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:
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.
21
Next week
• Trading strategies
22