Analytics for quants
Project description
jQuantStats: Portfolio analytics for quants
Overview
jQuantStats is a Python library for portfolio analytics that helps quants and portfolio managers understand their performance through in-depth analytics and risk metrics. It provides tools for calculating various performance metrics and visualizing portfolio performance.
The library is inspired by and currently exposes a subset of the functionality of QuantStats, focusing on providing a clean, modern API with enhanced visualization capabilities using Plotly.
We have made the following changes when compared to quantstats:
- added tests (based on pytest), pre-commit hooks and github ci/cd workflows
- removed a direct dependency on yfinance to inject data
- moved all graphical output to plotly and removed the matplotlib dependency
- removed some statistical metrics but intend to bring them back
- moved to Marimo for demos
- gave up on the very tight coupling with pandas
Along the way we broke downwards compatibility with quantstats but the
underlying usage pattern is too different. Users familiar with
Dataclasses may find the chosen path appealing.
A data class is
constructed using the build_data function.
This function is essentially
the only viable entry point into jquantstats.
It constructs and returns
a _Data object which exposes plots and stats via its member attributes.
At this early stage the user would have to define a benchmark and set the underlying risk-free rate.
Features
- Performance Metrics: Calculate key metrics like Sharpe ratio, Sortino ratio, drawdowns, volatility, and many more
- Risk Analysis: Analyze risk through metrics like Value at Risk (VaR), Conditional VaR, and drawdown analysis
- Visualization: Create interactive plots for portfolio performance, drawdowns, return distributions, and monthly heatmaps
- Benchmark Comparison: Compare your portfolio performance against benchmarks
Installation
pip install jquantstats
For development:
pip install jquantstats[dev]
Quick Start
import polars as pl
from jquantstats.api import build_data
# Create a Data object from returns
returns = pl.DataFrame(...) # Your returns data
# Basic usage
data = build_data(returns=returns)
# With benchmark and risk-free rate
benchmark = pl.DataFrame(...) # Your benchmark returns
data = build_data(
returns=returns,
benchmark=benchmark,
rf=0.0002, # risk-free rate (e.g., 0.02% per day)
)
# Calculate statistics
sharpe = data.stats.sharpe()
volatility = data.stats.volatility()
# Create visualizations
fig = data.plots.plot_snapshot(title="Portfolio Performance")
fig.show()
# Monthly returns heatmap
fig = data.plots.monthly_heatmap()
fig.show()
Documentation
For detailed documentation, visit jQuantStats Documentation.
Requirements
- Python 3.10+
- numpy
- polars
- plotly
- kaleido (for static image export)
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the Apache License 2.0 - see the LICENSE.txt file for details.
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 Distribution
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 jquantstats-0.0.12.tar.gz.
File metadata
- Download URL: jquantstats-0.0.12.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b191ebdef0ac602b9d65cf88f9f8803f2c0071bcf049413c758c451981170f85
|
|
| MD5 |
eee6a98777087e6551ececab632ed64f
|
|
| BLAKE2b-256 |
0a7be5fd93e51aabd81f4ee2659e15bd98caf8efbec895a4abdbb57524f7340f
|
Provenance
The following attestation bundles were made for jquantstats-0.0.12.tar.gz:
Publisher:
release.yml on tschm/jquantstats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jquantstats-0.0.12.tar.gz -
Subject digest:
b191ebdef0ac602b9d65cf88f9f8803f2c0071bcf049413c758c451981170f85 - Sigstore transparency entry: 214843221
- Sigstore integration time:
-
Permalink:
tschm/jquantstats@7645b75fc458406343f6620467af4d513093b9a2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7645b75fc458406343f6620467af4d513093b9a2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file jquantstats-0.0.12-py3-none-any.whl.
File metadata
- Download URL: jquantstats-0.0.12-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4283f19c97179527260d3f6d323a935afb4a64613cb43907a59c659f21e242e4
|
|
| MD5 |
b9a438cb8b9c7ad5fe6cc59f2ccca722
|
|
| BLAKE2b-256 |
c6cf111987d6678db6dddbcb59457decc86b13b75cbeed5531ce75358e4d935f
|
Provenance
The following attestation bundles were made for jquantstats-0.0.12-py3-none-any.whl:
Publisher:
release.yml on tschm/jquantstats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jquantstats-0.0.12-py3-none-any.whl -
Subject digest:
4283f19c97179527260d3f6d323a935afb4a64613cb43907a59c659f21e242e4 - Sigstore transparency entry: 214843222
- Sigstore integration time:
-
Permalink:
tschm/jquantstats@7645b75fc458406343f6620467af4d513093b9a2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7645b75fc458406343f6620467af4d513093b9a2 -
Trigger Event:
workflow_dispatch
-
Statement type: