Python and Cython scripts of machine learning, econometrics and statistical features for financial analysis
Project description
Fynance
Python and Cython package providing machine learning, econometric and statistical tools for financial analysis and backtesting of trading strategies.
Installation
pip install fynance
From source:
git clone https://github.com/ArthurBernard/Fynance.git
cd Fynance
pip install -e ".[dev]"
python setup.py build_ext --inplace
Subpackages
Algorithms fynance.algorithms
Portfolio allocation methods (ERC, HRP, IVP, MDP, MVP) and rolling walk-forward wrappers.
Backtest fynance.backtest
Profit-and-loss plotting and performance measurement.
Estimator fynance.estimator
Cython ARMA / GARCH parameter estimation.
Features fynance.features
Kalman filter, financial indicators (Bollinger, RSI, MACD, …), statistical momentums (SMA, EMA, WMA, …),
metrics (Sharpe, Sortino, Calmar, drawdown, …), scaling, and rolling functions.
Models fynance.models
Econometric models (MA, ARMA, ARMA-GARCH), neural networks with PyTorch (MLP, RNN, GRU, LSTM,
MultiHeadAttention), differentiable loss functions (SharpeLoss, SortinoLoss,
DirectionalAccuracyLoss), and walk-forward rolling evaluation.
Quick start
import numpy as np
import fynance as fy
# Sharpe ratio
returns = np.random.randn(252) * 0.01
print(fy.sharpe(returns))
# ERC portfolio allocation
cov = np.cov(np.random.randn(5, 252))
weights = fy.ERC(cov)()
print(weights)
Rolling walk-forward training with a neural network:
from fynance.models.rolling import RollMultiLayerPerceptron
model = RollMultiLayerPerceptron(X, y, layers=[64, 32])
model(n=252, s=21, r=21) # 252-day train, 21-day test, 21-day roll step
for eval_result in model:
print(eval_result)
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fynance-1.4.0.tar.gz.
File metadata
- Download URL: fynance-1.4.0.tar.gz
- Upload date:
- Size: 836.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56dab4ba8c0086d6f771fedfa3bd8e820c22cf53db1870bed0e530b961ae62e5
|
|
| MD5 |
e2205bbf5410c13233642eec728986ba
|
|
| BLAKE2b-256 |
14db3c08fe865a595858518fb4aadcde876f7208d5ad5db4d1573af52ab94894
|
Provenance
The following attestation bundles were made for fynance-1.4.0.tar.gz:
Publisher:
release.yml on ArthurBernard/Fynance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fynance-1.4.0.tar.gz -
Subject digest:
56dab4ba8c0086d6f771fedfa3bd8e820c22cf53db1870bed0e530b961ae62e5 - Sigstore transparency entry: 1817556953
- Sigstore integration time:
-
Permalink:
ArthurBernard/Fynance@a0476618dc1959a70d7e3b9139907de472020c06 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ArthurBernard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0476618dc1959a70d7e3b9139907de472020c06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7c62ab5052396beb7e653f02c24ad745935a8073cb030843079334647b0c873
|
|
| MD5 |
64650ee428aa28800644f534fb4ebba2
|
|
| BLAKE2b-256 |
c5157ae4f1a0a215d84640e3e982e74be32eafbd71e1ba2196bb00f2e2a47490
|
Provenance
The following attestation bundles were made for fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ArthurBernard/Fynance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
e7c62ab5052396beb7e653f02c24ad745935a8073cb030843079334647b0c873 - Sigstore transparency entry: 1817557298
- Sigstore integration time:
-
Permalink:
ArthurBernard/Fynance@a0476618dc1959a70d7e3b9139907de472020c06 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ArthurBernard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0476618dc1959a70d7e3b9139907de472020c06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.2 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7a3dc6a9e9df62480fa23c5f39f0ed2feedd89a00457d9de8d2f784050677cf
|
|
| MD5 |
601ca9d8ad0e69b6b4d65f88dd3a4144
|
|
| BLAKE2b-256 |
819b80891875fb4fc43e5ea65c98966203db98b6837c4079b12e8b9ad57a1f46
|
Provenance
The following attestation bundles were made for fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ArthurBernard/Fynance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
d7a3dc6a9e9df62480fa23c5f39f0ed2feedd89a00457d9de8d2f784050677cf - Sigstore transparency entry: 1817557081
- Sigstore integration time:
-
Permalink:
ArthurBernard/Fynance@a0476618dc1959a70d7e3b9139907de472020c06 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ArthurBernard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0476618dc1959a70d7e3b9139907de472020c06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a25ef2aac1f1305c632770a2ccf8a1e2cb865ba0eeaa8e0d12a41fd1d2b2becb
|
|
| MD5 |
5073f2d81f4e87ef9f505c7e6a62c0a1
|
|
| BLAKE2b-256 |
fe64e8787c8996b4a4be03313fa293083b6b406844e8fded808d86e2f92a5260
|
Provenance
The following attestation bundles were made for fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
release.yml on ArthurBernard/Fynance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
a25ef2aac1f1305c632770a2ccf8a1e2cb865ba0eeaa8e0d12a41fd1d2b2becb - Sigstore transparency entry: 1817557455
- Sigstore integration time:
-
Permalink:
ArthurBernard/Fynance@a0476618dc1959a70d7e3b9139907de472020c06 -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/ArthurBernard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a0476618dc1959a70d7e3b9139907de472020c06 -
Trigger Event:
push
-
Statement type: