ALGORITHMIC TRADING Hidden Markov Models. Overview a)Introduction b)Methodology c)Programming codes d)Conclusion.

Slides:



Advertisements
Similar presentations
Probabilistic Reasoning over Time
Advertisements

Hidden Markov Models (1)  Brief review of discrete time finite Markov Chain  Hidden Markov Model  Examples of HMM in Bioinformatics  Estimations Basic.
1 Hidden Markov Model Xiaole Shirley Liu STAT115, STAT215, BIO298, BIST520.
Automatic Speech Recognition II  Hidden Markov Models  Neural Network.
Hidden Markov Model 主講人:虞台文 大同大學資工所 智慧型多媒體研究室. Contents Introduction – Markov Chain – Hidden Markov Model (HMM) Formal Definition of HMM & Problems Estimate.
Hidden Markov Models Reading: Russell and Norvig, Chapter 15, Sections
Hidden Markov Models. A Hidden Markov Model consists of 1.A sequence of states {X t |t  T } = {X 1, X 2,..., X T }, and 2.A sequence of observations.
Introduction to Hidden Markov Models
Cognitive Computer Vision
Page 1 Hidden Markov Models for Automatic Speech Recognition Dr. Mike Johnson Marquette University, EECE Dept.
Hidden Markov Models Ellen Walker Bioinformatics Hiram College, 2008.
Ch 9. Markov Models 고려대학교 자연어처리연구실 한 경 수
Statistical NLP: Lecture 11
Ch-9: Markov Models Prepared by Qaiser Abbas ( )
Hidden Markov Models Theory By Johan Walters (SR 2003)
Statistical NLP: Hidden Markov Models Updated 8/12/2005.
Foundations of Statistical NLP Chapter 9. Markov Models 한 기 덕한 기 덕.
Hidden Markov Models Fundamentals and applications to bioinformatics.
Hidden Markov Models in NLP
Advanced Artificial Intelligence
Sequential Modeling with the Hidden Markov Model Lecture 9 Spoken Language Processing Prof. Andrew Rosenberg.
Apaydin slides with a several modifications and additions by Christoph Eick.
Albert Gatt Corpora and Statistical Methods Lecture 8.
GS 540 week 6. HMM basics Given a sequence, and state parameters: – Each possible path through the states has a certain probability of emitting the sequence.
Hidden Markov Models I Biology 162 Computational Genetics Todd Vision 14 Sep 2004.
Announcements Midterm scores (without challenge problem): –Median 85.5, mean 79, std 16. –Roughly, ~A, ~B,
Learning, Uncertainty, and Information Big Ideas November 8, 2004.
Hidden Markov Models K 1 … 2. Outline Hidden Markov Models – Formalism The Three Basic Problems of HMMs Solutions Applications of HMMs for Automatic Speech.
1 Hidden Markov Model Instructor : Saeed Shiry  CHAPTER 13 ETHEM ALPAYDIN © The MIT Press, 2004.
Scenario Generation for the Asset Allocation Problem Diana Roman Gautam Mitra EURO XXII Prague July 9, 2007.
Fall 2001 EE669: Natural Language Processing 1 Lecture 9: Hidden Markov Models (HMMs) (Chapter 9 of Manning and Schutze) Dr. Mary P. Harper ECE, Purdue.
Visual Recognition Tutorial1 Markov models Hidden Markov models Forward/Backward algorithm Viterbi algorithm Baum-Welch estimation algorithm Hidden.
Combined Lecture CS621: Artificial Intelligence (lecture 25) CS626/449: Speech-NLP-Web/Topics-in- AI (lecture 26) Pushpak Bhattacharyya Computer Science.
Ch10 HMM Model 10.1 Discrete-Time Markov Process 10.2 Hidden Markov Models 10.3 The three Basic Problems for HMMS and the solutions 10.4 Types of HMMS.
Isolated-Word Speech Recognition Using Hidden Markov Models
Gaussian Mixture Model and the EM algorithm in Speech Recognition
CS344 : Introduction to Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 21- Forward Probabilities and Robotic Action Sequences.
Fundamentals of Hidden Markov Model Mehmet Yunus Dönmez.
Hidden Markov Models Yves Moreau Katholieke Universiteit Leuven.
Cognitive Computer Vision Kingsley Sage and Hilary Buxton Prepared under ECVision Specific Action 8-3
Hidden Markov Models in Keystroke Dynamics Md Liakat Ali, John V. Monaco, and Charles C. Tappert Seidenberg School of CSIS, Pace University, White Plains,
Homework 1 Reminder Due date: (till 23:59) Submission: – – Write the names of students in your team.
ECE 8443 – Pattern Recognition ECE 8423 – Adaptive Signal Processing Objectives: ML and Simple Regression Bias of the ML Estimate Variance of the ML Estimate.
S. Salzberg CMSC 828N 1 Three classic HMM problems 2.Decoding: given a model and an output sequence, what is the most likely state sequence through the.
PGM 2003/04 Tirgul 2 Hidden Markov Models. Introduction Hidden Markov Models (HMM) are one of the most common form of probabilistic graphical models,
Hidden Markovian Model. Some Definitions Finite automation is defined by a set of states, and a set of transitions between states that are taken based.
1 CS 552/652 Speech Recognition with Hidden Markov Models Winter 2011 Oregon Health & Science University Center for Spoken Language Understanding John-Paul.
1 Hidden Markov Model Observation : O1,O2,... States in time : q1, q2,... All states : s1, s2,... Si Sj.
1 Hidden Markov Model Presented by Qinmin Hu. 2 Outline Introduction Generating patterns Markov process Hidden Markov model Forward algorithm Viterbi.
1 Hidden Markov Models (HMMs). 2 Definition Hidden Markov Model is a statistical model where the system being modeled is assumed to be a Markov process.
ECE 8443 – Pattern Recognition ECE 8527 – Introduction to Machine Learning and Pattern Recognition Objectives: Elements of a Discrete Model Evaluation.
Hidden Markov Models (HMMs) –probabilistic models for learning patterns in sequences (e.g. DNA, speech, weather, cards...) (2 nd order model)
Albert Gatt Corpora and Statistical Methods. Acknowledgement Some of the examples in this lecture are taken from a tutorial on HMMs by Wolgang Maass.
1 Hidden Markov Model Observation : O1,O2,... States in time : q1, q2,... All states : s1, s2,..., sN Si Sj.
CPSC 7373: Artificial Intelligence Lecture 12: Hidden Markov Models and Filters Jiang Bian, Fall 2012 University of Arkansas at Little Rock.
Hidden Markov Model Parameter Estimation BMI/CS 576 Colin Dewey Fall 2015.
Hidden Markov Models. A Hidden Markov Model consists of 1.A sequence of states {X t |t  T } = {X 1, X 2,..., X T }, and 2.A sequence of observations.
Definition of the Hidden Markov Model A Seminar Speech Recognition presentation A Seminar Speech Recognition presentation October 24 th 2002 Pieter Bas.
Other Models for Time Series. The Hidden Markov Model (HMM)
Visual Recognition Tutorial1 Markov models Hidden Markov models Forward/Backward algorithm Viterbi algorithm Baum-Welch estimation algorithm Hidden.
1 Hidden Markov Model Xiaole Shirley Liu STAT115, STAT215.
Hidden Markov Models Wassnaa AL-mawee Western Michigan University Department of Computer Science CS6800 Adv. Theory of Computation Prof. Elise De Doncker.
Hidden Markov Models BMI/CS 576
Learning, Uncertainty, and Information: Learning Parameters
CHAPTER 15: Hidden Markov Models
CHAPTER 15: Hidden Markov Models
4.0 More about Hidden Markov Models
Hassanin M. Al-Barhamtoshy
CPSC 503 Computational Linguistics
Hidden Markov Models By Manish Shrivastava.
Presentation transcript:

ALGORITHMIC TRADING Hidden Markov Models

Overview a)Introduction b)Methodology c)Programming codes d)Conclusion

a) Introduction Markov Chain Named after Andrey Markov, Russian mathematician. Mathematical system that undergoes transitions from one state to another state. From a finite or countable number of possible states in a chainlike manner. Next state depends ONLY on the current state and not the past.

a) Introduction Simple 2 States Markov Chain Models

a) Introduction System is in a certain state at each step. States are changing randomly between steps. Steps can be time or others measurements. Random process is simply to map states to steps.

a) Introduction 1 2 Markov Property – The state at next step or all future steps, given its current state depends only on the current state. Transition Probabilities – Probability of transiting to various states.

a) Introduction The Drunkard’s Walk Random walk on the number line At each step, position change by +1 or -1 or 0. Depends only on current position.

a) Introduction Transition Probability Matrix Simple matrix holding all the state changing probabilities. Eg: : Imagine that the sequence of rainy and sunny days is such that each day’s weather depends only on the previous day’s, and the transition probabilities are given by the following table.

a) Introduction Day t+1 Day tRainySunny Rainy Sunny if today is rainy, the probability that tomorrow will be rainy is 0.9; if today is sunny, that probability is 0.6. The weather is then a two-state Markov chain, with t.p.m. Γ given by: Γ =

a) Introduction to HMM Hidden Markov Model it is a Markov chain but the states are hidden, not observable. In a normal Markov chain, t.p.m are the only parameters. In HMM, although state is not directly visible BUT the output which is dependent on the state is visible! Thus the sequence of output reveals something about the sequence of states.

a) Introduction to HMM Therefore, what is available to the observer is another stochastic process linked to the Markov chain. The underlying Markov chain a.k.a the regime or state, will be directly affecting the distribution of the observed process.

a) Introduction to HMM The Urn Problem A genie is in a room that is not visible to you. It is drawing balls labeled y1, y2, y3,... from the urns X1, X2, X3,... in that room and putting the balls on a conveyor belt, where you can observe the sequence of the balls but not the sequence of urns from which they were chosen.

The genie has some procedure to choose urns; the choice of the urn for the n-th ball depends upon only a random number and the choice of the urn for the (n − 1)-th ball. Because the choice of urn does not directly depend on the urns further previous choices, this is called a Markov process with hidden states 。 a) Introduction to HMM

Probabilistic parameters of a hidden Markov model x — states y — possible observations a — state transition probabilities b — output probabilities

END OF INTRODUCTION! M ETHODOLOGY

Methodology Main Idea Total No. of data: 1400=

Markov Chain s2: Clou dy s1: Sun ny s3: Rain y a22 = ? a11 = ?a33 = ? a12 = ? a21 = ? a23 = ? a32 = ? a13 = ? a31 = ?

Model—λ = {A,B,Π} A = {a11, a12,..., aNN} : a transition probability matrix A, where each aij represents the probability of moving from state si to state sj B = bi(ot) : a sequence of observation likelihoods, also called emission probabilities, expressing the probability of an observation ot being generated from a state si at time t Π = {π1, π2,..., πN} : an initial probability distribution, where πi indicates the probability of starting in state si.

Model—Other Parameters S = {s1, s2,..., sN} a set of N hidden states, Q = {q1, q2,..., qT } a state sequence of length T taking values from S, O = {o1, o2,..., oT } an observation sequence consisting of T observations, taking values from the discrete alphabet V = {v1, v2,..., vM},

Model—Likelihood : P(O|λ) Forward αt(i) = P(o1, o2,..., ot, qt = si|λ) Backward βt(i) = P(ot+1, ot+2,..., oT |qt = si, λ)

Forward—L2

Backward—L2

Model—Decoding : Viterbi Algo

Model—Learning: Re-estimation ξt(i, j) = P(qt = si, qt+1 = sj |O, λ) γt(i) = P(qt = si|O, λ)

Model—Learning: Re-estimation

Applying HMM(Discrete) Model:  Window length=100; N=3; M=;  Initial parameter estimation: Random λ = {A,B,Π}  Final model

Applying HMM(Discrete) Test  Out of sample  Generating trading signals  Ot+1 & Ot : Trading strategy

Content A Ideas B Code Structure C Results D Limitations and TODOs

Section A - Ideas Parameter Estimation Prediction Trading Strategy

Parameter estimation-HMM A, B, pie 3 steps: likelihood, decoding, learning Greeks Updating, Iteration

the Choice of B Discrete - not smooth Time homogenous, why? a. Memory cost N * M * T (3 * 1000 * 100) in one iteration step b. Difficult to update Why continuous dist. can do this? a. Less parameters, less cost b. Update the time varying B directly

Parameter Updating How to compute updated B? Function get_index and its inverse function How to choose size of B? Extend the min and max, prepare to for extreme value. set a max, min, then interval length, set a function

Convergence Condition P converges to Po, set the eps Local maximum, not global

Prediction Find the q from last window -> the most likely state(t + 1) Find the B from last window -> the most likely obs given state Combine them to get most likely o(t + 1) Drawback: previous B to get new obs

Trading Strategy o(t + 1) > o(t) buy, otherwise sell set an indicator function I(buy or sell), which value is +1 when buy, -1 when sell Valuation: daily P&L = I * (true value(t + 1) - true value(t)) Sum daily P&L to get accumulate P&L, plot

section c - results P&L, window length = 30, state number = 3

Section b - Code Structure double update data {input = window length data output = a, b, pie in one step iteration, by using HMM} int main { generate a b pie( window length, state numbers) in uniformly distribution update data( 1~ window length) compute p, q update until p converges get best a, b, time 1 ~ window length use a, b, time period 1 as initialization, run update data iteration until p converges iteration until end of data prediction: q at last window b at last window to get most likely time t + 1, say o(t + 1) our strategy backtesting and draw p & l (in Matlab for convenience) }

section c - results P&L, window length = 50, state number = 3

section c - results P&L, window length = 70, state number = 3

section c - results P&L, window length = 100, state number = 3

section d - drawbacks and todos Drawbacks: a. Iteration: Why we can use paras from last window to initialize paras of this window? b. Prediction: Why can use previous B to get next observation? c. Matrix B: time homogenous, does not make sense d. Discrete Distribution: Not smooth, not continuous... e. How many shares we will buy/sell?

todos a. Continuous Distribution and GMM b. More Trading Strategy: Computing expectation price rather than the most likely one because their are too many probabilities in a vector; their differences are slight -> more errors c. Transaction Cost: when o(t + 1) - o(t) >(<) c, buy/sell