Generative Modeling of Foreign Exchange Rates with Matrix Product States
In the following project I am applying the Matrix Product State (MPS) training method from the paper Unsupervised Generative Modeling Using Matrix Product States [1] to a financial dataset that consists of foreign exchange rates (FX). The code can be found in my quantum-research github repository.
Data Preprocessing
The dataset consists of four FX pairs: EURUSD, GBPUSD, USDCAD, USDJPY. In recent literature about generative modeling in finance, this dataset is a popular choice. [2] For each of the four currencies we observe the daily mid price .
For preprocessing our dataset we first compute the log returns.
The we substract the mean and divide by the standard deviation.
The resulting series can be seen in belows plot.
Following histograms represent the marginal distributions of the target distribution that is objective to be learnt.
Since the Matrix Product State model only takes binary values we need to binarize our features. For that purpose the algorithm from [2] is used.
To transform from real to binary we use
To transform from binary to real we use
The binarized features represent the actual distribution that we are going to model. Ideally we could use a sufficient amount of bits per feature such that the target distributions could be rather closely recovered. In this experiment we limit ourselves to using f bits per feature to let the mps training finish in reasonable time, although it is possible to scale up using more compute resources.
MPS Training
During training the bond dimensions are adjusted from all 2 to [ 2 4 8 15 21 33 46 71 74 43 23 12 8 4 2 1].
The NLL Loss decreases notably within the first five iterations and changes minimal in all subsequent iterations.
Results
For assessing how close the target distribution was actually modeled, we generate 100000 samples from the trained MPS with adjusted bond dimensions and compare them visually to the target marginal distributions.
References
[1] Zhao-Yu Han, et al., Unsupervised Generative Modeling Using Matrix Product States, Phys. Rev. X 8, 031012, (17 July 2018). https://doi.org/10.1103/PhysRevX.8.031012
[2] Kondratyev, Oleksiy and Schwarz, Christian, The Market Generator (May 8, 2019). http://dx.doi.org/10.2139/ssrn.3384948