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.

Install (editable - for developers)

From the repo root:

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

This installs the quantlib command.

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

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_for_returns(
    data,
    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.1.0.tar.gz (14.9 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.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quantlib_st-1.1.0.tar.gz
  • Upload date:
  • Size: 14.9 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.1.0.tar.gz
Algorithm Hash digest
SHA256 a7dec83b470adf749b2247ab3ea3f7408d07f77466b6ed2de3271e9a3aa3b347
MD5 7f3fe5db27349cfcfdc03988068db893
BLAKE2b-256 f5f57ff979816894a6502accecd0acd458188317aae4e6b30bd75cdb79f42ee6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quantlib_st-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff7392852a68aa139b80bb95c4502c09634385b9d883c8c753bfffd9f55df4c8
MD5 26634c8f266419393e3646c63616303e
BLAKE2b-256 da8f1e0e60e4c0df077319bc9d0d48f7fd7fd1ec6e4507d64a5df1a9da5da623

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