Skip to content

integerQuant/ddstats

Repository files navigation

ddstats

Fast drawdown & CED metrics in Rust with NumPy bindings.

Overview

ddstats provides high-performance financial metrics, including drawdown and Expected Drawdown (CED), implemented in Rust and exposed to Python via NumPy bindings. This allows for fast computations directly from Python, leveraging Rust's speed and safety.

Features

  • Drawdown metrics: Compute maximum drawdown and related statistics.
  • CED (Conditional Expected Drawdown): Efficient calculation for risk analysis.
  • NumPy integration: Seamless usage from Python with NumPy arrays.
  • Cross-platform: Works on Windows, macOS, and Linux.

Installation

You can install ddstats using pip:

pip install ddstats

Or build from source:

git clone https://github.com/integerQuant/ddstats.git
cd ddstats
pip install maturin
maturin develop

Usage

import numpy as np
import ddstats

x = np.array([0.01, -0.02, 0.03], dtype=float)
max_dd = ddstats.max_drawdown(x)
print("Max Drawdown:", max_dd)

API

ddstats.max_drawdown(x: np.ndarray) -> float

Computes the maximum drawdown of a time series.

  • x: 1D NumPy array of floats.

ddstats.ced(x: np.ndarray, level: float) -> float

Computes the Conditional Expected Drawdown at a given confidence level.

  • x: 1D NumPy array of floats.
  • level: Confidence level (e.g., 0.95).

Building

This project uses maturin for building Python bindings:

maturin build

License

MIT License. See LICENSE.

About

Fast drawdown & CED metrics in Rust with NumPy bindings

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published