[Back to Intro]

SOFTWARE

Several of my papers discuss implementations of various algorithms in Python language. This facilitates the replication of my results, and allows the reader to run independent experiments. Enthought's Canopy product contains all the necessary libraries. Although the code is generally included in the appendix, it is easier to download the source code from the table below. In order to do that, please follow these steps:

1) Point your mouse on a link.
2) Right-click, select "Save as" and press "Save".
3) Rename the saved file, by removing the extension ".txt"

Note: All code in this website is provided “as is”, and contributed to the academic community for non-business purposes only, under a GNU-GPL license. Users explicitly renounce to any claim against the authors. The authors retain the commercial rights of any for-profit application of this software, which must be pre-authorized in written by the authors.

AUTHOR

VERSION

LINK

PAPER

DESCRIPTION

University of Newcastle (Australia)

2016

The Tenure Maker Simulator

Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance

This online tools overfits an econometric investment strategy within the parameter ranges specified by the user.
Berkeley Lab

2014

Backtest Overfitting Simulator

Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance

This online tools overfits a seasonal investment strategy within the parameter ranges specified by the user. Special thanks to Stephanie Ger, who set up this web application and prepared this research poster.

Lopez de Prado, Marcos

20151227

HRP.py.txt
HRP_MC.py.txt

Building Diversified Portfolios that Outperform Out-Of-Sample

HRP.py performs a hierarchical portfolio construction. Changing the np.random.seed in generateData() will produce different random correlation matrices on which the method can be tested. HRP_MC.py runs a Monte Carlo experiment to show that HRP solutions deliver lower variance than CLA's out-of-sample, even though minimum-variance is CLA's optimization goal.

Lopez de Prado, Marcos

20140731

DSR.py.txt

The Deflated Sharpe Ratio: Correcting for Selection Bias, Backtest Overfitting and Non-Normality

DSR.py computes the expected value of the maximum of a series of IID Normal random variables, applying our closed-form solution. The accuracy of this solution is verified numerically.

Lopez de Prado, Marcos

20140407

KCA_1.py.txt
KCA_2.py.txt
KCA_3.py.txt
KCA_4.py.txt

Kinetic Component Analysis

KCA_1.py implements the Kinetic Component Analysis (KCA) algorithm. KCA_2.py carries out the analogous calculation using a Fast Fourier Transform (FFT). KCA_3.py performs a comparison of KCA vs. FFT. KCA_4.py compares KCA with the Locally Weighted Scatterplot Smoothing (LOWESS) method.

Lopez de Prado, Marcos

20140131

OTR.py.txt

Determining Optimal Trading Rules without Backtesting

OTR.py contains the code needed to determine the Optimal Trading Rule (OTR) on an instrument with a price that follows a discrete Ornstein-Uhlenbeck process.

Lopez de Prado, Marcos

20140119

SFD_1.py.txt

Stochastic Flow Diagrams

SFD_1.py contains the code needed to build Stochastic Flow Diagrams.

Lopez de Prado, Marcos

20140119

SFD_2.py.txt

The Topology of Macro Financial Flows: An Application of Stochastic Flow Diagrams

SFD_2.py implements Fisher's variance stabilizing transformation on the Correlation coefficient.

Lopez de Prado, Marcos

20130813

CSCV_1.py.txt
CSCV_2.py.txt

The Probability of Backtest Overfitting

CSCV_1.py implements the PBO estimation via Monte Carlo. CSCV_2.py implements the PBO estimation by Extreme Value Theory.

Lopez de Prado, Marcos

20130813

CSCV_3.py.txt

Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance

CSCV_3.py simulates the performance of a seasonal trading strategy under various overfitting scenarios, which can be used to corroborate the Probability of Backtest Overfitting (PBO) usefulness in real investment applications.

Lopez de Prado, Marcos

20130108

DD1.py.txt
DD2.py.txt
DD3.py.txt

DD4.py.txt
Data1.csv.txt
Data2.csv.txt

Drawdown-based Stop-Outs and the "Triple Penance" rule

DD1.py contains the Monte Carlo which confirms the accuracy of our close-formula derivation of the quantile function. DD2.py computes the maximum of the Drawdown (DD) function, under the more general assumption of first-order serially-correlated outcomes. DD3.py the maximum of the Time under Water (TuW) function, under the more general assumption of first-order serially-correlated outcomes. DD4.py reproduces our empirical analysis on hedge fund indices (Data1.csv and Data2.csv).

Lopez de Prado, Marcos

20130108

CLA.py.txt
CLA_Main.py.txt
CLA_Data.csv.txt

An Open-Source implementation of the Critical-Line Algorithm for Portfolio Optimization

A Python class containing the Critical-Line Algorithm for quadratic optimization subject to inequality constraints. CLA.py is the class. CLA_Main.py is an example of how to use the CLA class. CLA_Data.csv is sample data. A seminar on this code can be watched here, and the presentation downloaded here. Enthough has built a GUI on our CLA class, which can be downloaded here.

Lopez de Prado, Marcos

20120516

ERC.py.txt

Balanced Baskets: A New Approach to Trading and Hedging Risks

ERC basket optimization algorithm.

Lopez de Prado, Marcos

20120516

MMSC.py.txt

Balanced Baskets: A New Approach to Trading and Hedging Risks

MMSC basket optimization algorithm.

Lopez de Prado, Marcos

20120516

Clustering.py.txt

Balanced Baskets: A New Approach to Trading and Hedging Risks

Covariance clustering algorithm.

Lopez de Prado, Marcos

20120502

PSR.py.txt

The Sharpe Ratio Efficient Frontier

Implementation of PSR statistics.

Lopez de Prado, Marcos

20120502

PSR_Optimal_Constrained.py.txt

The Sharpe Ratio Efficient Frontier

Implementation of PSR portfolio optimization.

Lopez de Prado, Marcos

20120316

OEH.py.txt

Optimal Execution Horizon

Determination of the optimal execution horizon.

Lopez de Prado, Marcos

20120217

EF3M.py.txt

Markowitz meets Darwin: Portfolio Oversight and Evolutionary Divergence

Implementation of the EF3M algorithm.