Metadata-Version: 2.4
Name: quantlib-st
Version: 1.2.1
Summary: A quantitative finance library and cli for systematic trading
Author-email: Rodion Lim <rodion.lim@gmail.com>
Project-URL: Homepage, https://github.com/rodionlim/quantlib-st
Project-URL: Issues, https://github.com/rodionlim/quantlib-st/issues
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.4.0
Requires-Dist: pandas>=2.3.3
Provides-Extra: dev
Requires-Dist: pip>=25.3; extra == "dev"
Requires-Dist: pytest>=9.0.2; extra == "dev"
Requires-Dist: pyinstaller>=6.17.0; extra == "dev"
Requires-Dist: twine>=6.2.0; extra == "dev"
Dynamic: license-file

# quantlib

[![PyPI version](https://badge.fury.io/py/quantlib-st.svg)](https://badge.fury.io/py/quantlib-st)
[![CI](https://github.com/rodionlim/quantlib-st/actions/workflows/ci.yml/badge.svg)](https://github.com/rodionlim/quantlib-st/actions/workflows/ci.yml)
[![GHCR](https://img.shields.io/badge/ghcr-quantlib--st-blue?logo=github)](https://github.com/rodionlim/quantlib-st/pkgs/container/quantlib-st)

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

## Subcommands

- **[corr](src/correlation/README.md)**: Compute correlation matrices over time from returns.
- **[costs](src/src/costs/README.md)**: 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

```python
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"))
```
