Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
mlfinlab Python Package Released (Advances in Financial Machine Learning)

Hi everyone,

A group of my friends and I have been working hard on an open-source implementation for the research laid out in the textbook Advances in Financial Machine Learning by Marcos Lopez de Prado, called mlfinlab. We have recently released it to the PyPi index.

pip install mlfinlab  

We hope that such a package will have uses in this community. I recently wrote a long-form blog article titled: A Laboratory for Machine Learning in Finance which lays out much of the work in depth.

The package is also available on Github:

  1. mlfinlab
  2. Research Notebooks
  3. Slide Show Presentaions & Reports

One of the great outcomes of this project was that we got to spend more time working on some of the great ideas laid out in the book. We spent a lot of time focused on meta-labeling and believe you will find that the results are promising.


TLDR:

  • Package based on the textbook: Advances in Financial Machine Learning
  • It specifically addresses the problems found in financial machine learning
  • The book has some barriers to entry, the package reduces this friction

Features at the moment:

  • Creating new financial data structures and sampling techniques with better statistical properties
  • Fixes some problems with futures trading by making use of the ETF trick
  • Provides a new labeling technique called the Triple Barrier Method (used in classification)
  • Introduces meta-labeling and how it can be used to filter out false positives
  • multiprocessing engine for speed

New features in the pipeline:

5 responses

@Jaques,
Very nice! I've been going through the book,and am ready to start applying it, so this will help!
alan

Very cool, thanks for sharing. We also explored implementing a couple of the ideas from the book on Quantopian:

Would be great to add this library to the Q platform.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@Jaques,

Great work! I agree with @Thomas Wiecki that it would be great to incorporate library to Q platform. How can this be done?

@Alan, Thank you very much. We certainly hope you find it useful. Currently, we are spending a lot of time on implementing chapter 4 on sample weights and the sequential bootstrap algo.

@Tom, These are some great resources that I wasn't aware of. I like that some of them include better implementations of the code in the book. I am going to investigate adding this to the package. I would do backflips to have this package incorporated into the Q platform. I think the first question that comes to mind is in what setting. Currently, it all works very well in a jupyter notebook/research setting but I am not sure it will generalize to a live data feed. That is something we need to investigate, how to use Q data streams to create the financial data structures.

@James, Thank you very much. At this stage, I am open to suggestions. We are a team of about 4 working on the package and we use the agile style of proj management so can easily fit in new features. Something that will be really useful is to have someone from the community that is really familiar with the Q platform to help cross the bridge for the financial data structures.

@Jaques: Great! Unfortunately adding new libraries to the platform is a bit of an ordeal so we would need to first figure out if and how it would fit into the workflow. The NBs I posted provide some pointers, let me know your thoughts. And definitely feel free to reuse any code in there you find useful.