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 using interactive Plotly charts.
The library is inspired by QuantStats, but focuses on providing a clean, modern API with enhanced visualization capabilities. Key improvements include:
- Support for both pandas and polars DataFrames
- Modern interactive visualizations using Plotly
- Comprehensive test coverage with pytest
- Clean, well-documented API
- Efficient data processing with polars
✨ Features
- Performance Metrics: Calculate key metrics like Sharpe ratio, Sortino ratio, drawdowns, volatility, and more
- Risk Analysis: Analyze risk through metrics like Value at Risk (VaR), Conditional VaR, and drawdown analysis
- Interactive Visualizations: Create interactive plots for portfolio performance, drawdowns, and return distributions
- Benchmark Comparison: Compare your portfolio performance against benchmarks
- Pandas & Polars Support: Work with either pandas or polars DataFrames as input
📦 Installation
pip install jquantstats
For development:
pip install jquantstats[dev]
🚀 Quick Start
# Import jquantstats
import polars as pl
from jquantstats import build_data
# Create sample returns data
returns = pl.DataFrame({
"Date": ["2023-01-01", "2023-01-02", "2023-01-03"],
"Asset1": [0.01, -0.02, 0.03],
"Asset2": [0.02, 0.01, -0.01]
}).with_columns(pl.col("Date").str.to_date())
# Basic usage
data = build_data(returns=returns)
# With benchmark and risk-free rate
benchmark = pl.DataFrame({
"Date": ["2023-01-01", "2023-01-02", "2023-01-03"],
"Market": [0.005, -0.01, 0.02]
}).with_columns(pl.col("Date").str.to_date())
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()
fig = data.plots.plot_snapshot(title="Portfolio Performance")
fig.show()
📚 Documentation
For detailed documentation, visit jQuantStats Documentation.
🔧 Requirements
- Python 3.10+
- numpy
- polars
- pandas
- plotly
- scipy
👥 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 MIT License - see the LICENSE 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.36.tar.gz.
File metadata
- Download URL: jquantstats-0.0.36.tar.gz
- Upload date:
- Size: 23.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ea7596d910fadd2d01809ac5ab7964020fb6caed5018ef5570a13bc585c57dd
|
|
| MD5 |
41e5d0142d07ae28df47fee3a3ae78f7
|
|
| BLAKE2b-256 |
24e141742bb5c2cc0a1fec0c237d2524695d2d4c8d54d383422b3f2ece0c74ea
|
Provenance
The following attestation bundles were made for jquantstats-0.0.36.tar.gz:
Publisher:
rhiza_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.36.tar.gz -
Subject digest:
4ea7596d910fadd2d01809ac5ab7964020fb6caed5018ef5570a13bc585c57dd - Sigstore transparency entry: 1155295096
- Sigstore integration time:
-
Permalink:
tschm/jquantstats@04dd594be2a65188aaad64b35d282d31bb28a9f4 -
Branch / Tag:
refs/tags/v0.0.36 - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rhiza_release.yml@04dd594be2a65188aaad64b35d282d31bb28a9f4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file jquantstats-0.0.36-py3-none-any.whl.
File metadata
- Download URL: jquantstats-0.0.36-py3-none-any.whl
- Upload date:
- Size: 19.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab2e6ce438b82b48a907c05f22c2ff6af4d33bc95b1bca8249fb7ac50af43a04
|
|
| MD5 |
90115592a80b1bc18fa31cd338175faf
|
|
| BLAKE2b-256 |
a17908459ba79a2cac226c21dda6d809704d93c45dafcdc57efa6b0c562f9a0b
|
Provenance
The following attestation bundles were made for jquantstats-0.0.36-py3-none-any.whl:
Publisher:
rhiza_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.36-py3-none-any.whl -
Subject digest:
ab2e6ce438b82b48a907c05f22c2ff6af4d33bc95b1bca8249fb7ac50af43a04 - Sigstore transparency entry: 1155295099
- Sigstore integration time:
-
Permalink:
tschm/jquantstats@04dd594be2a65188aaad64b35d282d31bb28a9f4 -
Branch / Tag:
refs/tags/v0.0.36 - Owner: https://github.com/tschm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
rhiza_release.yml@04dd594be2a65188aaad64b35d282d31bb28a9f4 -
Trigger Event:
push
-
Statement type: