[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

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.

kate spade black friday hollister cyber monday hollister black friday Abercrombie and fitch black friday coach black Friday victoria secret black friday gucci black friday under armour black friday Dior black friday bose cyber monday north face black friday michael kors cyber monday coach black Friday uggs black friday Babyliss cyber monday uggs black Friday uggs cyber monday michael kors cyber monday north face black friday uggs cyber monday moncler black friday uggs black Friday beats by dre black friday michael kors black friday moncler cyber monday north face cyber monday gucci black friday north face black Friday Babyliss black friday gucci black friday canada goose cyber monday michael kors cyber Monday tod's black friday north face cyber monday lululemon black friday moncler black friday canada goose black friday Designer handbags black friday Polo cyber monday moncler cyber monday burberry black Friday lululemon cyber monday canada goose black friday beats by dre cyber Monday celine black friday north face cyber monday michael kors cyber Monday beats by dre cyber Monday kate spade black friday pandora black Friday north face cyber monday tory burch black Friday Juicy Couture black friday christian louboutin cyber monday michael kors cyber Monday Ray Ban black Friday Longchamp black friday moncler black friday gucci cyber monday coach cyber monday uggs cyber monday nike black friday moncler cyber monday jordan cyber monday kate spade black friday kate spade black friday uggs cyber monday nike cyber monday Victoria Secret cyber monday north face cyber monday jordan 11 legend blue canada goose black friday louis vuitton outlet jordan 13 grey toe michael kors black Friday north face cyber Monday true religion black friday north face black Friday hollister black friday grey toe 13s nike black friday legend blue 11s kate spade cyber monday canada goose black friday legend blue 11s uggs black friday gucci cyber monday victoria secret black friday north face black Friday kate spade cyber monday beats by dre black Friday north face cyber Monday uggs cyber monday north face black Friday north face outlet uggs black Friday coach outlet online coach outlet online jordan 6 black infrared michael kors outlet canada goose black friday kate spade cyber monday hollister cyber monday north face outlet uggs cyber monday north face outlet beats by dre cyber monday gucci cyber monday gucci black friday legend blue 11s beats by dre black Friday hollister black friday north face black Friday true religion black friday lululemon black friday north face black Friday jordan 13 grey toe beats by dre cyber Monday jordan 13 bred black infrared 6s kate spade black friday nike black friday gucci cyber monday canada goose cyber monday nike cyber monday uggs cyber monday kate spade black friday lululemon cyber monday jordan black friday north face outlet