Está en la página 1de 39

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN , 1

Algorithmic Trading Using Deep Neural


Networks on High Frequency Data
Andrés Arévalo, Jaime Niño, Germán Hernández, Javier Sandoval, Diego León and Arbey Aragón
Universidad Nacional de Colombia, Bogotá

Presented by Germán Hernández, ALGOS, UNAL

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL


2
MERCADO SE UNEN
http://disi.unal.edu.co/~algos/

https://www.meetup.com/Bogota-Algorithmic-Trading-Meetup/ Observatorio de Economía y


Operaciones Numéricas – ODEÓN

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 3


Outline
1. Algorithmic Trading Overview
2. Deep Neural Networks
3. High Frequency Stock Price Trend Prediction With Deep NN
4. Conclusions
5. Bibliography

http://disi.unal.edu.co/~algos/2018/BVCAbril/

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN


1. Algorithmic Trading Overview

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 5


Trading Bots

http://sebfor.com/bots-ethereum-
trading/

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN


Kevin Slavin: How algorithms shape our
world -TED Talk

Follow this link to see the talk 3:35 – 5:00

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN


Algorithmic Trading Overview:
Online Algorithms that place trading orders

Model Based Adversarial


Arbitrage Splitting up large orders
Strategies Depredators
Opportunities (HF) (LF -> MF/HF)
(LF, MF, HF) Algorithms (LF, MF, HF)

Financial
Operate Assets Classification
large Price Discover
Minimize Modelling
Discover orders at Minimize other
Obtain free- the algorithms Sniffing
risk profit
price best extra (Adversaries) algorithms
differentials market
market costs and beat
impact Predict them.
average Portfolio
trend
price Configuration
patterns

Figure. Algorithmic Trading Strategies. Source: Own elaboration – Based on (Aldridge, 2009; Chan, 2009; Seth, 2015)

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 8


Financial Assets Price Modelling

Analytical Techniques Machine Learning Techniques

Statistical Models Decision trees


Linear Models: LR, MLR,
ES, ARMA, ARIMA, GARCH Artificial Neural Networks (ANN)
Non Linear Models:
N- GARCH Kernel Methods
Stochastic Models Support Vector Machines

BM, Diffusion, Poisson, Dynamic Bayesian Networks


(Sandoval 2015)
Jumps, and Levy
Processes Deep Neural Networks (DNN)

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 9


2. Deep Neural Networks

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 10


Artificial Neuron

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 11


Deep Neural Networks

Artificial Neural
Networks: Deep Learning Deep Neural
Networks
One-hidden layer
perceptron
Techniques (DNNs)

Hierarchy feature
building from low-level
to high-level.

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 12


3. High Frequency Stock Price Trend
Prediction With Deep NN

WORKSHOP ON ENGINEERING APPLICATIONS – WEA 2017, SEPTEMBER 27-29 2017 13


Dataset description:
Apple prices (ticker: AAPL)
Tick-by-tick: 14,839,395 observations

19110 minutes = 39 days X 390 minutes/day

Between 300 and 2000 trades per minute (average 776)

From TAQ3 database of the NYSE:


Tick-by-tick series from the September 2nd to November 7th of the year 2008. (Financial crisis of 2008)
SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 14
Important Definitions

WORKSHOP ON ENGINEERING APPLICATIONS – WEA 2017, SEPTEMBER 27-29 2017 15


Pre-processing
FOR EACH MINUTE, TO AGGREGATE WITH A
TICK BY TICK SERIES
ONE-MINUTE DETAILED LEVEL:
Datetime Price
2010-01-10 9:30:00.001 100 The Standard

2010-01-10 9:30
Last pseudo-
2010-01-10 9:30:10.123 100,1 Deviation of
log-return
2010-01-10 9:30:26.456 100,2 Prices
2010-01-10 9:30:45.789 100,1
2010-01-10 9:30:55.001 100
The Trend

2010-01-10 9:31
2010-01-10 9:31:01.123 100
Indicator
2010-01-10 9:31:20.123 99,9
2010-01-10 9:31:30.456 99,9
2010-01-10 9:31:50.789 100,1

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 16


Features distribution

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 17


DNN Architecture
Several DNN architectures were tested.
Degrees of freedom

• Input combinations (Time, log-returns, pseudo-returns, trend indicator,


standard deviation of prices)
• Sliding window size n (Number of previous observations used) [2..20]
• Number of hidden layers h [2..10]
• Number of neurons on each layer
• Activation function (Tanh, Maxout , Rectifier)

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 18


SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 19
# Neurons by layer 14 14 11 8 5 2 1

Current Time
Hour Best Performing DNN Architecture h=5
Minute
Input combination and n=4

Output Transformation:
Current t Next predicted one-minute
t-1 average price
Pseudo-log-returns
t-2
t-3

Current t
Output:
Standard deviation t-1 Next predicted one-
minute pseudo-log-
of price t-2 return

t-3
Activation function
Current
• All except output neuron:
t-1 tanh
Trend indicator
t-2 • Output neuron: linear

t-3

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 20


Proposed Strategy
At the beginning of each minute and using the predicted closing price

Previous Minute Previous Minute


BUY Close + spread < Close - spread > SELL
Predicted Predicted

Predicted closing Do nothing for


price +/- spread that minute
Yes reached or
minute ends

No (next tick)

Close position

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 21


Strategy testing: AAPL - 2008

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 22


Strategy testing: AAPL – 2016

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 23


AAPL – 2016: Spread 0

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 24


AAPL – 2016: Spread 0,01

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 25


AAPL – 2016: Spread 0,1

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 26


4. Conclusions
Nevertheless spreads were
taken into account, It is The strategy can be extended
The strategy has a consistent
desirable to extend the analysis by including other data sources,
performance
including additional transaction such as volume and news.
cost.

The inclusion of time as an


There is an overfitting
input, proved to be definitive
possibility due to the extend
for improving performance.
search of the best performed
Further analysis of this effect is
trained DNN
desirable

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 27


Forthcoming Work
High-Frequency Financial Time Series Forecasting with
Deep Neural Networks and Discrete Wavelet Transforms
• DNN
• DMLP
• LSTM
• GRU
• DWT

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 28


Wavelet Transform
a complete orthonormal system, for the Hilbert
space L2(R) of square integrable functions.

Frequency domain
Time domain
• With time resolution

Wavelet
coefficients

Scaling
coefficients
Haar Filter

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 29


Directional Accuracy:
Some DOW30 companies

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 30


5. Bibliography
[1] De Gooijer, Jan G. ; Hyndman, Rob J.: 25 years of time series forecasting. In: International Journal of
Forecasting 22 (2006), 1, Nr. 3, p. 443-473. ISSN 01692070
[2] Härdle, W ; Kleinow, T ; Stahl, G: Applied quantitative finance: theory and computational tools. (2013)

[3] Tsay, Ruey S.: Analysis of financial time series. Vol. 543. John Wiley & Sons, 2005
[4] Krollner, B ; Vanstone, B ; Finnie, G: Financial time series forecasting with machine learning techniques:
A survey. (2010)
[5] Mills, TC ; Markellos, RN: The econometric modelling of financial time series. (2008)
[6] Schmidhuber, Jürgen: Deep learning in neural networks: An overview. In: Neural Networks 61 (2014),
10, p. 85-117. ISSN 08936080
[7] Hinton, Geoffrey E. ; Osindero, Simon ; Teh, Yee-Whye: A fast learning algorithm for deep belief nets.
In: Neural computation 18 (2006), 7, Nr. 7, p. 1527-54. ISSN 08997667

SINAPSIS BVC, EL ESPACIO DONDE LA ACADEMIA Y EL MERCADO SE UNEN 31


Deep Learning based Algorithmic Trading
Strategies: A case for Colombian Market
AUTHOR:
J A I M E H U M B E R TO N I N O - P E N A ; J H N I N O P @ U N A L . E D U . C O
+57 300 2039 342
Agenda
Motivation
Experiment description
◦ Data collection – transformation
◦ Graph construction
Results
Conclusions
Challenges ahead
Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342
Motivation
Financial data complexity
Colombian Market Particularities
Macro trends in Global Financial Markets
Deep Learning alternatives for Financial Time Series modelling

Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342


Experiment
Limit Order Book Data for 12 stocks within Colombian Market
Image–like representation of Market data
Use of Convolutional Neural Networks
Predict Market movements (up, down, flat)

Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342


Results
Experiment Topology Data Input Performance
CNN 2 Conv-layers, dense and dropout LOB Data 58.23%
CNN 2 Conv-layers, dense and dropout LOB + Tick data 65.31%

Each image contains 10 LOB snapshots


Tick data as Images

Network inputs
Some other works from ALGOS research
group members
Topology Title Data Input Performance
DBN 4 layers Price Direction Prediction on High FB Tick + LOB 57.00%
Frequency Data Using Deep Belief
Networks
Clustering Detecting Informative Patterns in LOB USDCOP 57.61%
Financial Market Trends Based on Visual
Analysis
Multilayer Algorithmic trading using deep neural Tick NYSE (HF) 66.00%
Network networks on high frequency data FB, AAPL
RNN Family Deep Learning and Wavelets for High- Tick NYSE (HF), 64.0 – 72.0 %
Frequency Price Forecasting Several

Machine Learning applied to Portfolio Selection and real implementations


Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342
Conclusions
◦ Proposed methodology offers advantages as:
◦ Performance
◦ Re-training delay
◦ Time invariance for financial data analysis
◦ Trained model for multi-asset use

Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342


Challenges for Colombian Market
No data availability
No API availability
Transaction costs (Very high)
AT can help to improve:
◦ Market liquidity, Price discovery and transaction cost reduction

Stakeholders will (Regulators, Exchange, Institutions)

Nino, Jaime (jhninop@unal.edu.co) + 57 300 2039 342

También podría gustarte