Week6 AlgoritmicTrading EN
Week6 AlgoritmicTrading EN
Week 6
1
Agenda
Introduction to Algorithmic Trading
Strategies and Techniques
Backtesting and Simulation Techniques for Trading
Coding Example
2
What is the Stock Market?
4
5
What is Algorithmic Trading
❑ Definition: It is a computer software that operates based on the
main parameters set by an investment firm or a client of the
investment firm, producing orders to be automatically sent to
trading platforms in response to market information.
6
How Does It Work?
Y
When the 50-day moving average of
stock X rises above the 200-day
Buy 50 shares of
moving average stock X!
❑ Automatic Monitoring
❑ Order Execution Based on Conditions
❑ Elimination of the Need for Manual Tracking
❑ Automatic Evaluation of Trading Opportunities 7
Market Structure and a HEALTHY
Trading Ecosystem
8
Key Highlights
Algorithmic trading uses process- and rule-based computational formulas to execute trades.
Algorithmic trading has grown significantly since the early 1980s and is used for various purposes.
While it offers advantages such as faster execution times and reduced costs, algorithmic trading
can also exacerbate the negative aspects of the market, leading to flash crashes and immediate
loss of liquidity.
9
Key Components of Algorithmic
Trading
• Data Analysis
Analysis of historical and real-time data for
market signals.
Data such as price movements, volume, and
volatility.
• Trading Strategies
Technical analysis, fundamental analysis,
statistical arbitrage, machine learning.
Example: Moving average crossover strategies.
• Order Execution
Automated trading based on signals.
Placing orders based on price, volume, or time.
10
Computer-Based Trading by Investors -
Algorithmic Trading
Traditional
Algorithms are designed Algorithmic Smart
Trading
to help reduce the total How Order
Routing
cost of executing an
investment decision made
independently of the When Where
trading process.
11
History: 1. ANCIENT MARKET
NASDAQ OMX 12
History: 2. ELECTRONIC MARKET
NASDAQ OMX 13
History: 3. ELECTRONIC MARKET WITH API
NASDAQ OMX 14
History: 4. HFT MARKET
NASDAQ OMX 15
HFT
High-Frequency Trading (HFT):
➢ HFT is a type of algorithmic trading that is extremely
fast, short-term, and typically occurs within milliseconds
or even microseconds.
16
HFT
17
NASDAQ Yesterday/Today Algorithmic Trading Review
▪ The organizational structure of a market directly affects the diversity of trader
types.
▪ In 2009, prior to GENIUM INET, Stockholm was a fragmented, electronic, but high-
latency market.
▪ Today, the Stockholm market is fragmented, electronic, low-latency, and still has
traditional traders.
▪ In contrast, on NASDAQ today, traditional traders have almost entirely
disappeared.
18
HFT
NASDAQ OMX 19
HFT
NASDAQ OMX 20
Data Structures
21
Hardware
22
OPERATING SYSTEM
23
Technical Requirements for Algorithmic Trading
✓ Knowledge of Computer Programming or Trading Software:
Programming knowledge sufficient to program the required trading
strategy, programmers, and/or ready-made trading software.
✓ Access to Market Data Feeds: Access to real-time market data feeds for
the algorithm to monitor opportunities.
Performance Metrics
Sharpe Ratio:
A performance metric that measures the return earned per unit of risk.
A high Sharpe ratio indicates a strong risk-return profile for the strategy.
Maximum Drawdown:
Represents the percentage loss from a strategy’s highest value to its lowest value.
Indicates how much loss the strategy may incur in the worst-case scenario.
Volatility:
Measures how much the return varies over time.
High volatility indicates that the strategy is riskier, while low volatility shows a more stable
performance.
26
Types of Algorithmic Trading
Algorithms used in financial transactions are rules or instructions designed to make trading
decisions automatically. They range from simple single-stock algorithms to more complex
black-box algorithms, and they analyze market conditions, price movements, and other
financial data to execute trades at optimal times for the highest profit margin with the least
cost.
▪ Arrival Price Algorithms: Preserve Order Price and Minimize Market Impact
▪ Basket Algorithms: Portfolio Management and Risk Control
▪ Implementation Shortfall Algorithms: Minimize the Difference Between Decision Price
and Execution Price
▪ Percentage of Volume Algorithms: Order Management Based on Market Volume
▪ Single-Stock Algorithms: Optimization for a Single Security
▪ Volume Weighted Average Price (VWAP): Execute Trades at the Volume-Weighted
Average Price
▪ Time Weighted Average Price (TWAP): Price Averaging Based on Trade Duration
▪ Risk-Aversion Parameter: Investor's Risk Tolerance and Trading Aggressiveness
27
Types of Algorithmic Trading
Black Box Algorithms
These algorithms operate differently from the ones mentioned above and are at the center of
discussions about the use of artificial intelligence (AI) in the financial world. Black box
algorithms do not consist of pre-set executable rules for specific strategies; instead, they
derive their name from being a family of algorithms with hidden and unexplainable inner
mechanisms.
While other algorithms follow pre-defined execution rules (e.g., trading at a specific volume or
price), black box algorithms are characterized by a goal-oriented approach. Designers set the
goal, and specific rules and algorithms are chosen to reach it. However, black box systems
independently determine the best way to achieve that goal based on market conditions and
external events, while designers only set the targets.
28
Advantages of Algorithmic Trading
Best Execution: Transactions are usually carried out at the best possible prices.
Speed: Executes trades faster than humans.
Accuracy: Reduces manual errors.
Efficiency: Operates 24/7.
Emotionless Decision-Making: Prevents emotional decisions.
Backtesting: Provides the ability to test various scenarios in real-world
conditions.
29
Attention!
30
Disadvantages of Algorithmic Trading
1. Latency Risk: Sudden price changes can make it difficult for other investors to adjust
their trades accordingly.
Delay in trade execution speed, i.e., the time difference in executing a trade.
6. Regulation
Importance: Algorithmic trading relies on high speeds and low latency.
Algorithmic trading is subject to various legal requirements and regulations.
Risk: If trades are not executed quickly, opportunities may be missed, or
unexpected losses may occur. Challenge: Compliance is complex and time-consuming.
2. Black Swan Events Importance: Algorithms that fail to comply with regulations may face legal
penalties.
Unexpected and difficult-to-predict events that cause sudden and significant
market changes. 7. High Capital Costs
Characteristics: Algorithmic trading is based on historical data and Developing and maintaining algorithmic trading systems is costly.
mathematical models; however, black swan events cannot be predicted by
these models. Expenses: Software, data feeds, server, and internet infrastructure require
continuous payments.
Examples: 2008 financial crisis, COVID-19 pandemic, May 6, 2010, when the
Dow Jones dropped 1,000 points and then recovered. Risk: High capital costs can reduce profitability, especially for small
investors.
Risk: Such events can create situations that algorithms cannot foresee, leading
to significant losses. 8. Limited Customization
3. Flash Crash Risk Algorithmic trading systems are based on predefined rules and instructions.
A sudden sharp market drop, followed by a rapid price recovery. Risk: It may be difficult for investors to flexibly customize the system
according to their specific needs or preferences.
Cause: Algorithms triggering sequential trades and a reduction in market
liquidity. Importance: Limited control over trades can negatively impact
performance.
Risk: Sudden price movements may cause substantial losses for other investors
due to the swift reaction of algorithms. 9. Lack of Human Judgment
4. Dependence on Technology Algorithmic trading relies entirely on mathematical models and historical
data.
Algorithmic trading relies on technologies like computer programs and high-
speed internet connections. Risk: It does not consider subjective and qualitative factors that may
influence market movements.
Risk: Technical failures, internet outages, or programming errors can disrupt
the trading process and lead to losses. Disadvantage: This can be restrictive for investors who prefer an intuitive or
instinctual approach.
5. Market Impact
35
Integration of Artificial Intelligence in Algorithmic Trading
Example Applications: LSTM, Reinforcement Learning
LSTM (Long Short-Term Memory): LSTM is a type of recurrent neural network used for analyzing sequential
data, especially financial time series data. It is commonly applied in stock price prediction, trend tracking,
and time series analysis.
Reinforcement Learning: Reinforcement learning is a type of learning where an agent improves itself based
on the outcomes of its actions in a given environment. It is used for optimizing algo-trading strategies,
portfolio management, and enabling trading algorithms to self-improve.
Risk Management: AI-Based Risk Analysis and Portfolio Optimization
AI-Based Risk Analysis: AI algorithms can process large amounts of data to identify and analyze financial
risks. By performing quick analysis of market fluctuations and unexpected events, they help minimize risks.
Portfolio Optimization: AI algorithms aim to maximize returns and balance risks by maintaining an optimal
distribution of assets within a portfolio. With machine learning and deep learning techniques, portfolio
management becomes more efficient and flexible.
Future Developments: AI and Quantum Computing in Trading
AI and Quantum Computing: Quantum computing offers processing power beyond that of classical
computers, enabling much more complex computations in a short time.
Promising Applications: Combined with AI, quantum computing allows for faster and more complex
analyses in algorithmic trading.
Potential Impact on Trading: It is anticipated that quantum algorithms, especially due to their speed in
solving complex optimization problems, will be used in trading strategies. Quantum computing’s ability to
process vast amounts of data instantly could provide a competitive advantage in trading decisions.
36
Benefits of Artificial Intelligence in Algorithmic
Trading
37
Challenges and Limitations of Artificial
Intelligence in Algorithmic Trading
A. Data Limitations
Dependency: AI algorithms rely heavily on historical data.
Challenges: Insufficient or low-quality data can negatively impact algorithm
performance; changing market conditions can reduce data reliability. (Source: Fischer
et al., 2020)
C. Systemic Risks
Risk: Poorly designed or unverified AI-based trading strategies may increase market
volatility.
Mitigation: Regulators need to enforce supervision and establish risk management
measures. (Source: Zhang et al., 2018) 38
1. Aggressive HFT (Aggressive High-Frequency Trading): High-frequency trading that takes
market liquidity.
2. Algorithmic Trading: Electronic trading based on a set of predefined rules and parameters.
3. Direct Market Access (DMA): The process allowing a brokerage client, who is a member of
the exchange, to send orders through fully electronic channels, with orders passing through
the brokerage's order aggregation system and sent directly to the exchange. In direct market
access, it is essential for orders to undergo necessary risk checks within the member's system
before being transmitted to the exchange.
4. Co-location: Allowing broker servers to be placed physically close to exchange servers to
reduce latency.
5. Latency: The time taken for an order to travel from the client to the exchange system and for
the confirmation to return to the client. Also known as "round-trip latency."
6. Latency Jitter: The level of deviation from the average latency. The stability of latency is as
important as the latency itself.
7. Throughput: The amount of data processed per unit time, usually measured as the number
of messages received, sent, or processed per second.
8. Passive HFT: High-frequency trading that reduces market liquidity.
9. High-Frequency Trading (HFT): Algorithmic trading involving the rapid assessment of multiple
parameters and the submission/cancellation of numerous orders to the order book in
milliseconds or microseconds.
39
Q-A
40