Giter Club home page Giter Club logo

finance_ml's Introduction

finance_ml

Python implementations of Machine Learning helper functions for Quantiative Finance based on books, Advances in Financial Machine Learning and Machine Learning for Asset Managers , written by Marcos Lopez de Prado.

Installation

Excute the following command

python setup.py install

or

Simply add your/path/to/finace_ml to your PYTHONPATH.

Implementation

The following functions are implemented:

  • Labeling
  • Multiporcessing
  • Sampling
  • Feature Selection
  • Asset Allcation
  • Breakout Detection

Examples

Some of example notebooks are found under the folder MLAssetManagers.

multiprocessing

Parallel computing using multiprocessing library. Here is the example of applying function to each element with parallelization.

import pandas as pd
import numpy as np

def apply_func(x):
    return x ** 2

def func(df, timestamps, f):
    df_ = df.loc[timestamps]
    for idx, x in df_.items():
        df_.loc[idx] = f(x)
    return df_
    
df = pd.Series(np.random.randn(10000))
from finance_ml.multiprocessing import mp_pandas_obj

results = mp_pandas_obj(func, pd_obj=('timestamps', df.index),
                        num_threads=24, df=df, f=apply_func)
print(results.head())

Output:

0    0.449278
1    1.411846
2    0.157630
3    4.949410
4    0.601459

For more detail, please refer to example notebook!

finance_ml's People

Contributors

jjakimoto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

finance_ml's Issues

Typo in setup.py

py_modeuls=["finance_ml"]

should be
py_modules=["finance_ml"]

Typos in features.importance.py

Hi,
Thanks for this implementation of Marcos Lopez de Prado's code in his book. Great work there.
I believe there are two small typos in feat_imp_MDI and feat_imp_MDA on lines 33 and 108 of features.importance.py. One should divide the standard deviation by of the importance scores by the square root of the sample size. In that way, you get the standard error of the mean. That would be consistent with Pr. Marcos Lopez de Prado's code.

In any case, great work! Thank you.
Guillaume

Issue with MyProcessPoolExecutor class

When I tried to use the Financial Labels notebook(no 5) I was getting the following issue:

object has no attribute '_queue_management_thread_wakeup'

After some poking around the issue is with lines 44 and 46 of utils.py.

The methods that are currently used:

self._queue_management_thread_wakeup.wakeup()
self._start_queue_management_thread()

The its possible the methods that should be used are, but when I did this replacement the threads hang and nothing is returned.

self._executor_manager_thread_wakeup.wakeup()
self._start_executor_manager_thread()

Note: I am running this on windows, with python 3.9 and Cython==0.29.23. The issue could possibly be in the cython version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.