This 3-month project aimed at detecting and utilizing mean-reverting phenomenon with machine learning techniques.
Code provides everything to perform the implementation of mean-reverting portfolios from scratch, meaning from data retrieval, to machine learning utilization, and strategies set up.
Analysis were based on 151 financial return series from Euro stocks over the period [2004-2016].
- Below is a typical result from returns series reconstruction using autoencoders.
- The following Figure displays returns we got using neural network (autoencoder) buy/sell signals, compared to benchmark.

- Python 2.7 (see https://www.continuum.io/downloads)
- Keras (see https://keras.io for a step-by-step install guide)
- Mingw
Scripts are described in the chronological/logical order they have been used. One can play with the whole model just running bold scripts (mains)
- marketData
- Describe data formatting process, and choices made in the project regarding raw data
- Standalone notebook which explains step by step process
- statsDesc
- Quick statistics on returns. Basics + correlations between stocks
- Standalone notebook
- neuralNetwork_utils
- Some utils useful to neural networks: data formatting and plotting functions
- Normally, no need to edit it (except for model improvement)
- neuralNetwork_smoothness
- Smoothness implementation. See script for further details
- Normally, no need to edit it (except for model improvement)
- neuralNetwork
- Describe the neural network structure and all related steps (e.g. fitting, score saving, some plots)
- Normally, no need to edit it (except for model improvement)
- neuralNetwork_main
- Train the above network. Parameters may be edited upond needs !
- As for now, parameters in the script are parameters retained all along the project. They enable to train all the networks. It is easy just to train a single model: just avoid the loop.
- portfolio
- Describe a portfolio and the useful flow to implement a strategy
- Normally, no need to edit it (except for model improvement)
- portfolio_main
- Run the above portfolio. Parameters may be edited upond needs ! As for now, parameters in the script are the last parameters retained. See the script to know how to tune parameters.
- resultsAnalysis_utils
- A bunch of useful functions to plot results in a fashion way
- Normally, no need to edit it (except for model improvement)
- resultsAnalysis_dataLoading
- Load hard data that are never edited
- Normally, no need to edit it (except for model improvement)
- resultsAnalysis_machineLearning
- Go through neural network results: statistics, plots, correlations, ...
- Standalone notebook
- resultsAnalysis_portfolio
- Go through portfolio results: statistics, plots, correlations, ...
- Standalone notebook