Dive Deeper in Finance
GTC 2017 – San José – California
Daniel Egloff
- Dr. sc. math.
Managing Director QuantAlea May 7, 2017
Dive Deeper in Finance GTC 2017 San Jos California Daniel Egloff - - PowerPoint PPT Presentation
Dive Deeper in Finance GTC 2017 San Jos California Daniel Egloff Dr. sc. math. Managing Director QuantAlea May 7, 2017 Today Generative models for financial time series Sequential latent Gaussian Variational Autoencoder
GTC 2017 – San José – California
Daniel Egloff
Managing Director QuantAlea May 7, 2017
– Sequential latent Gaussian Variational Autoencoder
▪ Implementation in TensorFlow
– Recurrent variational inference using TF control flow operations
▪ Applications to FX data
– 1s to 10s OHLC aggregated data – Event based models for tick data is work in progress
– GANs – Generative adversarial networks – VAE – Variational autoencoders
▪ Training is computationally demanding
– Explorative modelling not possible without GPUs
replacement
▪ Deep Learning benefits
– Richer functional relationship between explanatory and response variables – Model complicated interactions – Automatic feature discovery – Capable to handle large amounts of data – Standard training procedures with back propagation and SGD – Frameworks and tooling
𝑞 𝑦 = 𝑞 𝑦 𝑨 𝑞 𝑨 𝑒𝑨 → max
▪ Problem: marginal 𝑞 𝑦 and posterior
𝑞 𝑨 𝑦 =
𝑞 𝑦 𝑨 𝑞 𝑨 𝑞 𝑦
are intractable and their calculation suffers from exponential complexity
– Markov Chain MC, Hamiltonian MC – Approximation and variational inference
minimizing a distance to real posterior?
𝑟∗ 𝑨 𝑦 = argmin
𝜄∈𝑅
𝐿𝑀 𝑟𝜄 𝑨 𝑦 ฮ𝑞𝜒 𝑨 𝑦 𝐿𝑀 𝑟𝜄 𝑨 𝑦 ฮ𝑞𝜒 𝑨 𝑦 = 𝐹𝑟𝜄 𝑨 𝑦 log 𝑟𝜄 𝑨 𝑦 − 𝐹𝑟𝜄 𝑨 𝑦 log 𝑞𝜒 𝑦, 𝑨 + log 𝑞𝜒 𝑦 ≥ 0 Can be made small if Q is flexible enough
▪ Problem: not computable because it involves marginal 𝑞𝜒 𝑦
minimizing a distance to real posterior?
𝑟∗ 𝑨 𝑦 = argmin
𝜄∈𝑅
𝐿𝑀 𝑟𝜄 𝑨 𝑦 ฮ𝑞𝜒 𝑨 𝑦 0 ≤ 𝐹𝑟𝜄 𝑨 𝑦 log 𝑟𝜄 𝑨 𝑦 − 𝐹𝑟𝜄 𝑨 𝑦 log 𝑞𝜒 𝑦, 𝑨 + log 𝑞𝜒 𝑦 −𝐹𝑀𝐶𝑃(𝜄, 𝜒)
▪ Drop left hand side because positive
minimizing a distance to real posterior?
𝑟∗ 𝑨 𝑦 = argmin
𝜄∈𝑅
𝐿𝑀 𝑟𝜄 𝑨 𝑦 ฮ𝑞𝜒 𝑨 𝑦 𝐹𝑀𝐶𝑃(𝜄, 𝜒) ≤ log 𝑞𝜒 𝑦
▪ Obtain tractable lower bound for marginal ▪ Training criterion: maximize evidence lower bound
▪ To interpret lower bound, write it as
= 𝐹𝑟𝜄(𝑨|𝑦) log 𝑞𝜒 𝑦 𝑨 − 𝐿𝑀 𝑟𝜄 𝑨 𝑦 ԡ𝑞 𝑨 Reconstruction score
𝑨~𝑟𝜄 𝑨 𝑦 𝑦
𝑞𝜒 𝑦 𝑨 Penalty of deviation from prior log 𝑞𝜒 𝑦 ≥ 𝐹𝑀𝑃𝐶 𝜄, 𝜒
▪ The smaller the tighter the lower bound
𝐿𝑀 𝑟𝜄 𝑨 𝑦 ฮ𝑞𝜒 𝑨 𝑦
– Gaussian distributions with parameters calculated from deep recurrent neural
network
– Prior standard Gaussian – Model training with variational inference
𝜈𝑢 𝜏𝑢 𝜈𝑢−1 𝜏𝑢−1
ℎ𝑢+1 ℎ𝑢+1 𝑨𝑢+1 𝑦𝑢+1
𝜈𝑢+1 𝜏𝑢+1 𝜈𝑢 𝜏𝑢
𝑦𝑢−1 𝑨𝑢−1 ℎ𝑢−1 ℎ𝑢−1
𝜈𝑢−1 𝜏𝑢−1 𝜈𝑢+1 𝜏𝑢+1
𝑦𝑢 ℎ𝑢 ℎ𝑢 𝑨𝑢
𝑟𝜄 𝑨 𝑦
𝑞𝜒 𝑦≤𝑈 𝑨≤𝑈 = ෑ
𝑢=1 𝑈
𝑞𝜒 𝑦𝑢 𝑦<𝑢, 𝑨≤𝑢 = ෑ
𝑢=1 𝑈
𝑂 𝑦𝑢 𝜈𝜒 𝑦<𝑢, 𝑨≤𝑢 , 𝜏𝜒 𝑦<𝑢, 𝑨≤𝑢
▪ Loss calculation
– Distributions can be easily simulated to calculate expectation term – Kullback Leibler term can be calculated analytically
𝑟𝜄 𝑨≤𝑈 𝑦≤𝑈 = ෑ
𝑢=1 𝑈
𝑟𝜄 𝑨𝑢 𝑦<𝑢, 𝑨<𝑢 = ෑ
𝑢=1 𝑈
𝑂 𝑨𝑢 𝜈𝜄 𝑦<𝑢, 𝑨<𝑢 , 𝜏𝜄 𝑦<𝑢, 𝑨<𝑢
– Kullback Leibler term can be calculated analytically – For fixed 𝑢 the quantities 𝜈𝜒, 𝜈𝜄, 𝜏𝜒, 𝜏𝜄 depend on
𝑨𝑢~𝑂 𝑨𝑢 𝜈𝜄 𝑦<𝑢, 𝑨<𝑢 , 𝜏𝜄 𝑦<𝑢, 𝑨<𝑢
– Simulate from this distribution to estimate expectation with a sample mean
𝐹𝑀𝐶𝑃 𝜄, 𝜒 = −𝐹𝑟 ቂ ቃ σ𝑢 ቄ ቅ 𝑦𝑢 − 𝜈𝜒
𝑈𝜏𝜒−1 𝑦𝑢 − 𝜈𝜒 + log det 𝜏𝜒 +
𝜈𝜄𝑈𝜈𝜄 + 𝑢𝑠𝜏𝜄 − log det 𝜏𝜄 Approximate with Monte Carlo sampling from 𝑟𝜄 𝑨≤𝑈 𝑦≤𝑈
𝜈𝑢 𝜏𝑢
ℎ𝑢+1 𝑨𝑢+1 𝑦𝑢+1
𝜈𝑢+1 𝜏𝑢+1
𝑦𝑢−1 𝑨𝑢−1 ℎ𝑢−1
𝜈𝑢−1 𝜏𝑢−1
𝑨𝑢
𝑞(𝑨)
ℎ𝑢 𝑦𝑢
𝑞𝜒 𝑦 𝑨
– Use lag of ~20 historical observations at every time step
Time steps Batch
t t +1 t +2
– Simple to use – Can handle variable sequence length
▪ Not flexible enough for generative networks
– More to program, need to understand control structures in more detail – Much more flexible
Recurrent neural network definition
Update inference rnn state
Update generator rnn state
– Not necessary to go through a centralized exchange – No single price for a currency at a given point in time
▪ Fierce competition between market participants ▪ 24 hours, 5 ½ days per week
– As one major forex market closes, another one opens
8am – 5pm EST 3am – 12am EST 5pm – 2am EST (Sidney)
London session US session Asian session
7pm – 4am EST (Tokyo)
5 4 3 2 1 12 11 10 9 8 7 6 5 4 3 2 1 12 11 10 9 8 7 6
5 pips 1/10 pips = 1 deci-pip
At high frequency FX prices fluctuate in range
Larger jumps in the order of multiple pips and more
𝜏 over training interval
▪ 260 trading days in 2016, one model per day ▪ 60 dim embedding, 2 dim latent space
ො 𝜏 Training Out of sample test
Training
algorithms with Jet.com
Daniel Egloff
Phone: +41 79 430 03 61 daniel.egloff@quantalea.net