Skip to content

High-performance multi-factor quantitative framework built on Polars.

License

Notifications You must be signed in to change notification settings

quantbai/elvers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elvers

License: MIT Python 3.10+ Polars

ELVERS is a high-performance, strictly typed multi-factor alpha research engine powered by Polars.

Design Philosophy

Quantitative research requires rapid iteration over large universe panels without compromising execution speed. Legacy pandas-based pipelines are interpretable but inherently scale poorly. elvers addresses this through a robust two-layer abstraction:

  • Panel — A continuous, balanced panel container enforcing strict (timestamp, symbol) alignment. It mitigates look-ahead bias and standardizes index integrity across all transformations.
  • Factor — A fully evaluated, eagerly executed vector of signal exposures. Bound directly to the global panel, factors resolve native Polars expressions instantaneously utilizing highly-parallelized core routines underneath Rust and C.

The architecture guarantees that complex computational graphs—from primitive time-series aggregations to complex cross-sectional neutralizations—are resolved at theoretical hardware peaks with virtually zero Python interpreter overhead in the hot path.

Installation

pip install elvers

Quick Start

Compose factors exactly as intuitively as they are expressed mathematically:

from elvers import load, ts_rank, zscore

# Load your own data
# panel = load("your_ohlcv.csv")

# Load built-in sample dataset
panel = load()

close = panel["close"]
volume = panel["volume"]

# Define and execute expressions instantly
momentum = ts_rank(close, 20)
alpha = zscore(momentum)

# Extract native Polars DataFrame
result = alpha.df
print(result)

Both Panel and Factor expose a .df property that returns the underlying pl.DataFrame:

  • panel.df — Full panel frame with all OHLCV columns intact.
  • factor.df — Flat (T_days * N_symbols, 3) frame aligned to the original spatial coordinates:
shape: (T_days * N_symbols, 3)
┌────────────┬────────┬───────────┐
│ timestamp  ┆ symbol ┆ factor    │
│ ---        ┆ ---    ┆ ---       │
│ date       ┆ str    ┆ f64       │
╞════════════╪════════╪═══════════╡
│ 2024-01-01 ┆ BTC    ┆ null      │
│ ...        ┆ ...    ┆ ...       │
│ 2024-12-31 ┆ ETH    ┆ 1.243     │
└────────────┴────────┴───────────┘

Rows are ordered by timestamp (ascending), then symbol (ascending).

Note: Rolling window operators naturally yield null for the initial window - 1 periods per symbol. The full dense panel shape is preserved throughout all operations.

Operator Library

Category Supported Operators
Time-Series ts_delay, ts_delta, ts_mean, ts_sum, ts_std_dev, ts_min, ts_max, ts_median, ts_rank, ts_skewness, ts_kurtosis, ts_zscore, ts_corr, ts_covariance, ts_product, ts_decay_linear, ts_av_diff, ts_scale, ts_quantile, ts_cv, ts_autocorr, ts_count_nans, ts_backfill
Cross-Sectional rank, zscore, mean, median, scale, normalize, signal
Neutralization vector_neut, regression_neut, group_neutralize, group_rank, group_zscore, group_scale, group_normalize
Math log, ln, sqrt, sign, power, signed_power, inverse, s_log_1p, maximum, minimum, where, standard operators (+, -, *, /, **, abs)

About

High-performance multi-factor quantitative framework built on Polars.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages