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.3.4.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

fynance-1.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

fynance-1.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

fynance-1.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

Details for the file fynance-1.3.4.tar.gz.

File metadata

  • Download URL: fynance-1.3.4.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fynance-1.3.4.tar.gz
Algorithm Hash digest
SHA256 37d42e328167e3668b8d0e762e701d8457dc19126ce851b9fef63bd97609d5c4
MD5 19060d343934926f06bce01ffaba981c
BLAKE2b-256 f0feb81768a50ff49420a575d67932cfcd88f4c1415e3acbae0dbffe0de362d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for fynance-1.3.4.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.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.3.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 07592a6c5ddeaeaabbcd1fa592701faba8b375c55476358e100206b8865dfeb4
MD5 c6a6213690d1aaef116de918c0e6f166
BLAKE2b-256 ce15166fd16086798ed107f5a631775c050e5fdf8b7e94d097a347e966a47cc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fynance-1.3.4-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.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 474dfe3d27f614c741b7ae00d076991c68b5defc9dd1d19be1fa3b660bc5369c
MD5 6d6b301e8d4c9dfed5fe359dbb4f0234
BLAKE2b-256 982cdf18eb107127767b21067b26bb83cc992027f387c670e302bed02e78f02e

See more details on using hashes here.

Provenance

The following attestation bundles were made for fynance-1.3.4-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.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fynance-1.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44ce5875fa9cbf231107aada1594532beac24f7858a54c4d8822aaad593b9965
MD5 7f279f884d6bfcb1ba377d178c8cac10
BLAKE2b-256 af28ac779035ea75ca218d02b2ea6fb210bb0d9cd287b3ad04b45716f5bb4f9d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fynance-1.3.4-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