Skip to main content

A quantitative finance library and cli for systematic trading

Project description

quantlib

PyPI version CI GHCR

Minimal, self-contained CLI tools and library for quantitative finance.

Subcommands

  • corr: Compute correlation matrices over time from returns.
  • costs: Calculate Sharpe Ratio (SR) costs for instruments based on spread and fees.

Modules

  • estimators: Volatility and Forecast Scalar estimators — contains robust_vol_calc and mixed_vol_calc for daily volatility estimation, and forecast_scalar for scaling forecasts.
  • accounts: P&L calculation framework — contains account_forecast for generating P&L curves from forecasts and prices.

Install (editable - for developers)

From the repo root:

  • cd quantlib
  • python -m pip install -e .

This installs the quantlib command.

  • uv sync --extra dev

Docker

Pull a published image from GitHub Container Registry:

  • docker pull ghcr.io/rodionlim/quantlib-st:latest

Run a quick correlation query by piping a CSV into the container (one-liner):

  • cat sample_data/returns_10x4.csv | docker run --rm -i ghcr.io/rodionlim/quantlib-st:latest corr --min-periods 3 --ew-lookback 10

When publishing the image the Makefile also tags and pushes :latest in addition to the versioned tag.

Package Sample Usage

Correlation

import pandas as pd
import numpy as np

from quantlib_st import correlation

# Sample data
data = pd.DataFrame(
    np.random.randn(100, 3),
    columns=['Asset_A', 'Asset_B', 'Asset_C'],
    index=pd.date_range(start='2020-01-01', periods=100, freq='D')  # daily dates
)
# Compute correlation matrix
corr_matrix = correlation.correlation_over_time(
    data,
    is_price_series=False,
    frequency='D', # resampling purpose
    interval_frequency='7D',
    date_method='expanding',
    ew_lookback=50,
    min_periods=10
)
print(corr_matrix.as_("jsonable"))
print(corr_matrix.as_("long"))

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

quantlib_st-1.8.0.tar.gz (143.4 kB view details)

Uploaded Source

Built Distribution

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

quantlib_st-1.8.0-py3-none-any.whl (198.0 kB view details)

Uploaded Python 3

File details

Details for the file quantlib_st-1.8.0.tar.gz.

File metadata

  • Download URL: quantlib_st-1.8.0.tar.gz
  • Upload date:
  • Size: 143.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for quantlib_st-1.8.0.tar.gz
Algorithm Hash digest
SHA256 c1314034f771619b6cf5a61902c1c6f45f0b30d445e671534a051c9d710b4464
MD5 ecbb3a024dfb73408f88d987ec55482d
BLAKE2b-256 9eef957e223d7d7a72679d3f97addc8e0611e88b1a1736419f4ae255ebc95978

See more details on using hashes here.

File details

Details for the file quantlib_st-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: quantlib_st-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 198.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for quantlib_st-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0197f3e99fe5d2a767f4119643c8318ba605eba8b81006daf7503c023a61e7dd
MD5 25fb9f5b411606b926eba28ee19c6cc0
BLAKE2b-256 9d98bb9961e9578fd0d8f6d542d8d35c7805912f52cefda1a8b6884add89a000

See more details on using hashes here.

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