Skip to main content

Python and Cython scripts of machine learning, econometrics and statistical features for financial analysis

Project description

Fynance logo

Fynance

Python versions PyPI PyPI status CI License
Documentation Coverage Docstring coverage Downloads


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


Download files

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

Source Distribution

fynance-1.4.0.tar.gz (836.6 kB view details)

Uploaded Source

Built Distributions

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

fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

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

Hashes for fynance-1.4.0.tar.gz
Algorithm Hash digest
SHA256 56dab4ba8c0086d6f771fedfa3bd8e820c22cf53db1870bed0e530b961ae62e5
MD5 e2205bbf5410c13233642eec728986ba
BLAKE2b-256 14db3c08fe865a595858518fb4aadcde876f7208d5ad5db4d1573af52ab94894

See more details on using hashes here.

Provenance

The following attestation bundles were made for fynance-1.4.0.tar.gz:

Publisher: release.yml on ArthurBernard/Fynance

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

File details

Details for the file fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e7c62ab5052396beb7e653f02c24ad745935a8073cb030843079334647b0c873
MD5 64650ee428aa28800644f534fb4ebba2
BLAKE2b-256 c5157ae4f1a0a215d84640e3e982e74be32eafbd71e1ba2196bb00f2e2a47490

See more details on using hashes here.

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

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

File details

Details for the file fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7a3dc6a9e9df62480fa23c5f39f0ed2feedd89a00457d9de8d2f784050677cf
MD5 601ca9d8ad0e69b6b4d65f88dd3a4144
BLAKE2b-256 819b80891875fb4fc43e5ea65c98966203db98b6837c4079b12e8b9ad57a1f46

See more details on using hashes here.

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

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

File details

Details for the file fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a25ef2aac1f1305c632770a2ccf8a1e2cb865ba0eeaa8e0d12a41fd1d2b2becb
MD5 5073f2d81f4e87ef9f505c7e6a62c0a1
BLAKE2b-256 fe64e8787c8996b4a4be03313fa293083b6b406844e8fded808d86e2f92a5260

See more details on using hashes here.

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

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