Skip to main content

Financial ML toolkit

Project description

FinMLKit Header FinMLKit is an open-source, lightweight financial machine learning library designed to be simple, fast, and easy to contribute to. Whether you’re a seasoned quant or a beginner in finance and programming, FinMLKit welcomes contributions from everyone.

The main goal of this library is to provide a solid foundation for financial machine learning, enabling users to process raw trades data, generate different types of bars, intra-bar features (eg. footprints), bar-level features (indicators), and labels for supervised learning.

Why FinMLKit?

FinMLKit is an open-source, lightweight financial data processing library with a focus on preparing data and labels for ML models. It is specialized for High Frequency Trading (HFT) and building on the most granular data level, the price tick data (raw trades data). This enables the building of intra-bar features (e.g., footprints, fow imbalance) that provide additional information to ML models compared to conventional and ubiquitous OHLCV data. Working with large amount of raw data requires a special design approach to ensure speed and efficiency, which is why FinMLKit is built with Numba for high-performance computation and parallelization. To illustrate this, if we were to aggregate raw trades data into OHLCV bars using Pandas, it would take around 100x longer than using FinMLKit. A task that would take 1 minute in Pandas would take below 1 second with FinMLKit.

So FinMLKit is built on Python’s Numba for high-performance computation, while using Pandas only as a wrapper for easier handling of data. Numba’s Just-In-Time (JIT) compilation allows it to convert Python code into machine code, significantly improving performance, especially in iterative tasks where parallelization can be utilized. In contrast, Pandas, while great for structuring and managing data, is slow and cumbersome for such operations. Therefore, we use Pandas only as a wrapper for handling data, allowing it to shine where it excels, while Numba powers the core algorithmic computations for efficiency and clarity. This way, we can avoid relying on slow and elusive pandas operations and focus on efficient, more explicit codes in the core functions.

Key principles are Simplicity, Speed, and Accessibility (SSA):

  • Simplicity 🧩 No complex frameworks, no elusive pandas operations, just efficient, explicit, well-documented algorithms.
  • Speed ⚡ Core functions built with Numba for high-performance computation and parallelization in mind.
  • Accessibility 🌍 The goal is to make it easy for anyone – regardless of their background – to contribute and enhance the library, fostering an open-source collaborative spirit.

🔥 Motivation & Vision

FinMLKit provides the essential tools for financial machine learning focusing on the processing of raw trades data. This library offers the core infrastructure that can be applied in countless ways to create custom strategies. By developing this open-source foundation, contributors from around the world can enhance the tools and create something far more robust than any single entity could achieve alone. This approach allows us to leverage collective expertise and wisdom to build a powerful library that serves everyone.

By pooling our expertise, we can create a stronger foundation for financial machine learning that benefits the entire community, far exceeding what any small team could achieve alone.

📑 Trusted Methodologies

FinMLKit implements methods from trusted sources, including renowned academic papers and books. We avoid experimental techniques and instead focus on proven methods. Our primary reference is Marcos Lopez de Prado’s Advances in Financial Machine Learning, which lays the foundation for many of the algorithms and methods in this package. We prioritize transparency and accuracy in both the implementation and explanation of these methodologies. Each algorithm is accompanied by detailed documentation that:

  • Cites the original sources from which the methods were derived (papers, books, and other trusted research).
  • Describes the algorithms comprehensively, explaining the theory behind them and how they are applied in practice. By ensuring that the algorithms are well-documented, with clear references to their origins, we aim to foster trust and enable users to fully understand the underlying mechanics of the tools they are using. This also makes it easier for contributors to extend the package, knowing exactly how each method works and what references to consult.

🤝 Contribution

We aim to make FinMLKit as easy to contribute to as possible. Whether it’s fixing bugs, adding new features, or improving documentation, your contribution matters. Let’s work together to make the financial machine learning space better for everyone!

🧱 Project Structure

Bars

Bars are the primary data structure in FinMLKit – constructed from raw trades data –, representing the historical price data of an asset. Bars can be in the form of OHLCV (Open, High, Low, Close, Volume) or any other format that includes the necessary information for analysis (e.g. footprint data, directional features). Bars are used as input for indicators, strategies, and other components of the library. In summary, the bars module is responsible for processing unstructured raw trades data into structured data that can be used for further analysis.

Data Structures:

  • OHLCV bars
  • Directional features (e.g. buy/sell tick, volume, dollars, min. cum. volume, max. cum. volume etc.)
  • Trade size features (Are there large trade block prints in the bar?)
  • Bar footprints

Bar Types:

  • Time bars
  • Tick bars
  • Volume bars
  • Dollar bars
  • CUSUM bars
  • Imbalance bars
  • Run bars

Features

Everything that processes bars data (candlestick/OHLCV, directional features, or footprints) and calculates derived values from it is considered a feature. This includes moving averages, RSI, MACD, etc. Here we are focusing on more unconventional indicators that are not commonly found in other libraries and builds on our advanced data structures like footprints, for example, volume profile features. Features are the building blocks of trading strategies and are used to generate signals for buying or selling assets.

  • Adjusted Exponential Moving Average
  • Standard Volatility Estimators
  • Volume Profile Indicators: Commitment of Traders (COT), Buy/Sell Imbalance price levels, High Volume Nodes (HVN), Low Volume Nodes (LVN), Point of Control (POC)
  • Cusum Monitoring structural break feature (Chu-Stinchcombe-White CUSUM Test on Levels based on Homm and Breitung (2011)

Labels

Labels are the target values that we want to predict in a supervised learning problem. Currently, Triple Barrier Method is implemented with meta-label support, which is an advanced approach in financial machine learning.

  • Triple Barrier Method
  • Meta-Labeling
  • Label Concurrency weights
  • Return Attribution weights
  • Class Imbalance weights

Sampling

  • CUSUM Filter

📚 Documentation

FinMLKit is designed to be well-documented, with detailed explanations of each algorithm, method, and function. It uses reStructured style docstrings to provide clear and concise documentation for each function, class, and module. This makes it easier for users to understand how to use the library and what each function does. It uses Sphinx to generate the documentation and automatically deploy it in readthedocs.io. This way, users can access the documentation online and easily navigate through the library's features and functionalities.

⚡ Speed & Performance Tests

FinMLKit is built with speed in mind. We use Numba for high-performance computation, allowing us to avoid slow and elusive pandas operations and focus on efficient, more explicit codes in the core functions. This way, we can ensure that the library is fast and efficient, even when dealing with large datasets or complex algorithms.

Some results are collected below to demonstrate the effectiveness of the numba framework:

  • Exponentially Weighted Moving Average (EWMA) calculation: 4x speedup compared to Pandas function
  • Standard Volatility Estimator: 8.12x speedup compared to Pandas implementation
  • CUSUM monitoring for structural breaks: 6.25x speedup with parallelization compared to non-parallelized implementation.
  • OHLCV Time Bar generation: 100x speedup compared to Pandas implementation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

finmlkit-0.1.5.tar.gz (85.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

finmlkit-0.1.5-py3-none-any.whl (92.3 kB view details)

Uploaded Python 3

File details

Details for the file finmlkit-0.1.5.tar.gz.

File metadata

  • Download URL: finmlkit-0.1.5.tar.gz
  • Upload date:
  • Size: 85.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for finmlkit-0.1.5.tar.gz
Algorithm Hash digest
SHA256 16849eb399bec8e50f85935b83f703f1e9001c56209e39539ac507c98e97a9ff
MD5 bd893b089e0676cebd2894cbaf6bbf47
BLAKE2b-256 d64c31991942d467aa0ed94a5388dcc59f087eacd81e74f0dce4014b42a7b448

See more details on using hashes here.

Provenance

The following attestation bundles were made for finmlkit-0.1.5.tar.gz:

Publisher: deploy.yml on quantscious/finmlkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file finmlkit-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: finmlkit-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 92.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for finmlkit-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8880ffa1457af4e5fb4f8310d140bc8c306c41cc07ea117f8bbaeae6726af4eb
MD5 6c4797c23c06449f7bb538d2f121371d
BLAKE2b-256 0aa0ca80d1d6787b934613c4fe9e55192ae2deb6857352cac06de609afd9fa32

See more details on using hashes here.

Provenance

The following attestation bundles were made for finmlkit-0.1.5-py3-none-any.whl:

Publisher: deploy.yml on quantscious/finmlkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page