The document provides an overview of algorithmic trading, including definitions, common components, and considerations for developing algorithmic trading strategies. It discusses the basic schema for algorithmic trading, including acquiring market data, analyzing the data, establishing conditions to trigger trades, and executing trades. It also covers related topics like risk management, portfolio management, data handling, and post-trade analysis. Additionally, it discusses different types of algorithmic trading strategies and considerations for backtesting strategies.
2. Algorithmic trading consists of the automated buying and selling
of financial instruments (stocks, bonds and futures). Essentially It
requires a network connection to an electronic exchange, broker
or counterparty, and means of programmatically buying, selling
and performing other tasks related to trading, such as monitoring
price action and market exposure.
What is Algorithmic
Trading (or Algo)?
What will be covered in these slides ?
Who uses Algorithms
- Basic Algo definitions
- Terminology used
- Defining the perfect algorithm
How to start with Algo
- Basic considerations
- Skills to master
- Reality over imagination
Backtesting
- Basic considerations
- Main drivers
- Real problem identification
3. Who is interested to Algo-Trading?
Algo-Trading for investors: Pros and Cons
The Schema for Algo-trading:
• A method to acquire data (“read some price data”), noting that this in itself could be quite
a complex standalone algorithm and requires connection to a source of market data, usually
in real time.
• Some analysis of that data (“calculate its mean and standard deviation”).
• A means of checking if some condition has been fulfilled based on the previous analysis (“if
the most recent price is above its mean and the standard deviation is less than some
threshold”).
• Execution of the trading logic, which again can be quite a complex standalone algorithm
requiring a means of communicating with a broker or exchange, managing that
communication link and keeping track of orders and fills.
Other common components of such system include:
• Risk management modules, for example position sizing calculations, exposure tracking and
adjustment, and tools to track a system’s performance and behaviour.
• Portfolio management tools, which are somewhat related to the above.
• Data handling and storage.
• Post-trade reconciliation and analysis.
Remove the Human factor
Allows backtesting of
strategies
Demanding learning
process
The term «algorithmic trading» can actually have a slightly different meaning,
particularly in an institutional setting. Indeed, algorithmic trading can refer to the
automated splitting of a large order to get the best execution possible. Such
algorithms typically split up a large order into smaller pieces and send the pieces to
market in a way that optmizes the overall cost of the transaction.
When a large transaction has to be processed, without a proper liquidity valuation,
the price of the stock will dramatically increase (or decrease). By entering the
position gradually, in line with the capacity of the stock to absorb the order, the
overall cost of the transaction is reduced.
The market
Set of instruction involved in algo
trading
No need to watch the screen all day
Cross skills implemented
Hardware tools
Retail investors:
For investors is typically used to
automate the trades accordigly to
the developed strategy.
This is the case in which once a
strategy is set, the trader let the
algorithm do the job.
Institutions:
For ECN - is typically used by Market
Makers to disseminate and match
orders with their network of
counterparties.
For Dark Pools - is more like a private
execution venue where liquidity is
provided by the participants of the
dark pool, away from the exchange.
Terminology:
4. Technical Analysis Quantitative Trading High Frequency Trading
Defining the algorithm for different classes:
The type of algorithmic trading that most retail investors focus on, seeks to identify opportunities to profit by buying low and selling higher.
This is the signal-based type of algorithmic trading, this try to trigger the purchase after an event is occurred. Within this broad category,
there are different sub-classes of trading algorithm. While there is no one accepted nomenclature for the classes, they can generally be
described as follows:
• Analysis of patterns on price and volume to predict
future market movement. (assuming that exist
repeating patterns in the price action of a market.)
• Strategies based on indicators (price / volume) like the
Relative Strength Index (RSI) and Moving Average
Convergence Divergence (MACD). It also includes a
suite of trend lines, support and resistance lines,
formations like ‘flag’ and ‘pennant’ and patterns like
‘head and shoulders’.
• There is a catalog of candlestick patterns like
‘engulfing bear’ that based on historical data try to
predict the future direction of the market.
• On the more esoteric end of the spectrum, we have
things like Elliot Wave and Fibonacci Retracement
• Quantitative trading is based on mathematical or
statistical models of market behavior. Examples are
the cross-sectional momentum strategy and the mean-
reversion strategy.
• Another is a cointegrating pairs model, in which we
select a pair of securities that can be combined such
that together they form a mean-reverting series.
• Quantitative models can be based on fundamental
data by using tools to automatically process the news
releases and company filings.
• A subset of quantitative trading in an increasing
interest trend is the one linked to Machine Learnig and
artificial intelligence.
• High Frequency Trading (HFT) is relatively new, by
definition must be algorithmic since it occurs on the
scale of microseconds – or less.
• No human could engage in HFT without the support of
computers. While HFT is generally signal based – that
is, something occurs to trigger a buy or sell signal –
speed and latency are generally more important than
the actual signal itself.
• The implication of this is that co-location of the
algorithm either in the exchange or as close as
possible is a prerequisite, and code must be optimized
for speed and usually written in a low level language
like C++. This results in barriers that are simply too
high for DIY traders, and indeed for many trading
firms.
5. What does it take to succeed in Algo Trading ?
Where to start?
While reading these slides you have already started the process. However, these
slides will serve as trigger guidance to trigger new algo traders to learn more. This
section will provide answers for tipical questions when learning something new:
Learning the theoretical underpinnings is important – so start reading. To
become proficient at algorithmic trading, you absolutely must put the theory
into practice.
This is a theme that you will see repeated throughout these slides;
emphasizing the practical is my strongest message when it comes to
succeeding in this field. Having said that, in order to succeed in algorithmic
trading, one typically needs to have knowledge and skills that span a number
of disciplines. This includes both technical and soft skills.
Individuals looking to set up their own algorithmic trading business will need to
be across many if not all of the topics on the right; while if you are looking to
build or be a part of a team, you may not need to be personally across all of
these, so long as they are covered by other team members.
Active doing is crucial:
Statistics is crucial when managing risk to measuring performance and making decisions
about allocating to particular strategies. Here are some specific examples of using statistics in
algorithmic trading to illustrate just how vital this skill is:
• Statistical tests can provide insight into what sort of underlying process describes a market
at a particular time.
• Correlation of portfolio components can be used to manage risk.
• Regression analysis;
• Statistics can provide insight into whether a particular approach is outperforming due to
taking on higher risk, or if it exploits a genuine source of alpha.
Statistics
To do any serious algorithmic trading, you absolutely must be able to program, as it is this skill
that enables efficient research. Accept that coding skills are prerequisite. The most known
languages:
Programmming
This sort of risk management attempts to quantify the risk of loss and determine the optimal
allocation approach for a strategy or portfolio of strategies.
• Allocation strategies: Kelly allocation and Mean-Variance Optimization (MVO);
• The Value-at-Risk (VaR);
• The System Parameter Permutation, or SPP ;
Risk Management
Finance Related
Computer Science
Python C ++ Java Matlab R
Study Practice
6. Expectations Frequency of Trading Infrastructure
Important Practical Matters:
Bear in mind that this is a very difficult path to deal with, due to the complexity of the arguments related to algo trading, in order to develop
strategies and really build up something you will need time and effort. First of all, you should master at least one of those skills previously
mentioned, then you can start to implement those skills in other context.
• This is not a way to become a millionare in just one
day – Hedge funds have 3-year compounded annual
return of just under 30%. You are not SMARTER !!!
• There may exist market phenomena that can generate
returns that are significant compared to the position
sizing of a retail account, but which are not capable of
carrying the trades of a larger fund.
• The amount of gains is tangled up with the amount of
risk you are willing to take. Thinking about reward in
terms of risk rather than in isolation will lead you to
much more sensible expectations.
• Swing Traders: are those who sets a lower frequency
of trading and hold a trade for weeks or months.
• Day Traders: holds positions for 2 days or less
• Intra-day Traders holds posistions within the day,
meaning that they open trades as soon as the market
open and close them before the closing day.
• High frequency trading generally refers to systems with
holding periods on the order of milliseconds to
seconds.
• Access to a strong (APIs) through a broker or through
a protocol, namely FIX, or Financial Information
Exchange.
• HFTs are not accessible by a retail investor who is
able to program due to restrictions on liquidity amount
and infrastructure complexity.
• For retail algo traders, a normal computer is enough to
process their algos, in order to perform algorithms 24h
a day, knowledge of warehouse servers is needed.
• Computer specifications and algorithms implemented
needs to be set out properly in order to be more
efficient.
7. Backtesting – Measuring the results
Traditional approach:
• Choose one strategy
• Implement the strategy for a
period of time.
• Take notes of the results and
grasp the pitfalls
Algo approach:
• Choose one or more strategies
• Set the timeseries in which you
want to perform the backtest
• Understand the variables that
affects the most the strategy and
rewrite the algorithm properly.
Slow Dynamic
• Slippage
• Commissions
• Swaps
Trading conditions
Simulation
vs
Reality
Backtesting requires that your trading algorithm’s performance be simulated using historical market
data, and the profit and loss of the resulting trades aggregated. Dealing with these two problems
requires that we consider:
Requirements for a good Backtest
• The Timeframe used for the analysis heavily influence
Granularity
• Sample of data discrepancies
Sample of data
Accuracy main drivers
Simulation accuracy Time frame employed
• Entry levels
• Exits
• Volume
• Market volatility
• Market liquidity
• Order type
• Execution Lathency
Influencing factors:
• Broker pricing
• Missing data
• On the traded product
• Data source
Where can be
found:
8. Look-Ahead Bias or Peeking Bias Curve-Fitting Bias or over-Optimization Bias Data-Mining Bias or Selection Bias
Development methodology:
In addition to simulation accuracy, the experimental methodology itself can compromise the results of our simulations. Many of these biases are
subtle yet profound: they can and will very easily creep into a trading strategy research and development process and can have disastrous effects on
live performance. Accounting for these biases is critical and needs to be considered at every stage of the development process. For now, I will walk
through and explain the various biases that can creep in and their effect on a trading strategy.
• This form of bias is introduced by allowing future
knowledge to affect trade decisions. That is, trade
decisions are affected by knowledge that would not
have been available at the time the trade decision was
taken.
• A common example is executing an intra-day trade on
the basis of the day’s closing price, when that closing
price is not actually known until the end of the day.
• Another bias example is when we use a parameter
which has been estimated and then retrospectively
apply it to the beginning of the next run of the
simulation.
• Portfolio optimization parameters are particularly prone
to this bias.
• Data mining bias is another significant source of over-
estimated model performance.
• It is reconducible to the selection of a sample, once a
strategy has been tested, it is unlikely that the same
strategy works with other instruments or time frames
• It is impossible to solve the problem, a strategy must
work dependently with his framework.
• This is the bias that allows us to create magical backtests that
produce annual returns on the order of hundreds of percent.
Such backtests are of course completely useless for any
practical trading purpose.
• Regression models on more data will produce a cut of noise
and of course a curve-fitting shape.
• The more the sample embed the noise in the sample the more
the trading results will be of no value due to an always
increasing curve