Skip to main content
Fintuna Logo

Fintuna: Parameter optimization for finance

Fintuna is a framework that uses machine learning for asset management. It enables fast prototyping for multi-asset applications such as stock-picking.

Features:
  • model training

  • hyper-parameters tuning

  • walk-forward backtesting

  • strategy evaluation

It is a lightweight framework that combines LightGBM, Optuna, Quantstats and Shap to develop ML-based stock-picking strategies.

Multi Asset

Looking at multiple assets is supposed to reveal more alpha-opportunities than looking at a single one. Also, the more assets the more data which is beneficial for machine learning tasks. Therefore, Fintuna is designed for multi-asset applications. The data structure is a Pandas Multiindex Dataframe where the index is time, the first column-level is the asset and the second is the feature (= panel or longitudinal data). Internally features are stacked and a model is trained to learn cross-asset patterns.

#

Asset 1

Asset 2

Asset 3

Asset 4

#

feature1

feature2

feature1

feature2

feature1

feature2

feature1

feature2

t0

float

category

float

category

float

category

float

NaN

t1

float

category

float

category

float

category

float

NaN

Strategy Agnostic

Fintuna is not tied to one specific trading strategy. Strategies are implemented as fintuna.model.ModelBase. It defines the classification task (= extract_label) as well as a a classification-to-returns mapping (= realized_returns). A simple example is to predict the directional change and buy the asset with the most confident prediction (see fintuna.model.LongOnly).

Backtesting

Fintuna uses walk-forward backtesting.

  • Train data is used to train the classifier.

  • Tune data is used for hyper-parameter optimization.

  • Eval data is used for backtesting

Executing the fintuna.Finstudy.explore method multiple times on same data introduces the risk of overfitting. Use feature importance and shap values, rather than merely looking at trading performance.

Walk-Forward Backtesting

Calling fintuna.Finstudy.finish prepares the model for deployment. It sub-selects models that also perform well on evaluation data. and refits them on all data.

Data First

A good trading strategy demands good and possibly unique data. Fintuna does NOT help you in finding the right data. But consider the following guidelines:

  • Have at least a few hundreds of observations.

  • Use multiple assets.

  • Use assets with similar characteristics (e.g. cryptos, tech-stocks, etc.).

  • Make sure features across assets have similar properties (otherwise use zscore).

  • Use lagged features to boost performance.

Usage

Install fintuna via pip.

pip install fintuna

Run the most basic example below. For detailed guidance look at examples at docs or at docs/source/examples.

import fintuna as ft

# get data
data, specs = ft.data.get_crypto_features()

# explore
crypto_study = ft.FinStudy(ft.model.LongOnly, data, data_specs=specs)
results = crypto_study.explore(n_trials=50, ensemble_size=3)

# analyze
ft.utils.plot_backtest(results['performance'], results['benchmark'])

TODO

  • Binance Trading Sink

  • MajorityVoteEnsemble

  • Backtest plots with shap values

Metadata

Release files for fintuna 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fintuna 0.1.5
File Size Uploaded Provenance Actions
fintuna-0.1.5.tar.gz 36.9 MB Without provenance Details for fintuna-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fintuna 0.1.5
File Interpreter ABI Platform Actions
fintuna-0.1.5-py3-none-any.whl Python 3 none any Details for fintuna-0.1.5-py3-none-any.whl

Total release size: 73.7 MB

Release files / fintuna-0.1.5.tar.gz

Download URL fintuna-0.1.5.tar.gz
Size 36.9 MB
Tags Source
SHA-256 checksum
How to use checksums
7527aeb6a792490e4dfd135aa387dab65911b00337de731ad015e8ef3a1a3ebc
BLAKE2b-256 checksum
How to use checksums
82b4db4270ba2c4e333eef01712ada1114838815566cd04d1e58a16b55458152
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Release files / fintuna-0.1.5-py3-none-any.whl

Download URL fintuna-0.1.5-py3-none-any.whl
Size 36.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
d0b9c2b3987d5d33170020b5f6819d555f196595ef2574a54df3973e7ec2dd65
BLAKE2b-256 checksum
How to use checksums
ae478558db24d5aa8df324156e7cf1c12b60040194707dee108d184cde5e52c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.13

Security for fintuna 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page