Skip to main content

MeridianAlgo

PyPI version Python versions License

MeridianAlgo is a Python library for quantitative finance and algorithmic trading. It covers portfolio optimization, risk management, derivatives pricing, backtesting, machine learning, execution algorithms, and more, all in one library.

Installation

pip install meridianalgo

Optional extras add heavier capabilities on demand.

pip install "meridianalgo[ml]"            # scikit-learn, torch, statsmodels, hmmlearn
pip install "meridianalgo[optimization]"  # cvxpy, cvxopt
pip install "meridianalgo[volatility]"    # arch (GARCH family)
pip install "meridianalgo[all]"           # everything

Requires Python 3.10 or newer. The core install runs on numpy, pandas, and scipy alone. A feature that needs an optional dependency raises MissingDependencyError naming the extra to install. The package ships a py.typed marker, so type checkers read its annotations directly.

Quick start

import meridianalgo as ma

# Prices to returns and back, periodicity inferred from the index
returns = ma.to_returns(prices)
cagr = ma.annualize_return(returns)
worst = ma.drawdown_table(returns, top=5)

# Top level convenience metrics on a return series
sharpe = ma.calculate_sharpe_ratio(returns)
max_dd = ma.calculate_max_drawdown(returns)
cvar_95 = ma.calculate_expected_shortfall(returns)

# One call summary of around 28 metrics plus a formatted text report
stats = ma.summary_stats(returns)
print(ma.tearsheet(returns))

# Rolling risk, all return a pandas Series aligned to the input
roll_sharpe = ma.rolling_sharpe(returns, window=63)
roll_vol = ma.rolling_volatility(returns, window=63)
drawdown = ma.rolling_drawdown(returns)

# Technical indicators, base install, no extras
rsi = ma.RSI(prices, period=14)
upper, mid, lower = ma.BollingerBands(prices, period=20)

Importing the package is fast and pulls in no heavy dependencies. Names load lazily, so import meridianalgo never imports torch, scikit learn, or statsmodels until you use a feature that needs them.

Portfolio optimization takes annualized expected returns as a pandas Series and a covariance matrix as a pandas DataFrame.

from meridianalgo import MeanVariance

expected_returns = returns.mean() * 252
covariance = returns.cov() * 252
result = MeanVariance().optimize(expected_returns, covariance, objective="max_sharpe")
print(result.weights, result.sharpe_ratio)

What is inside

Domain Highlights
Portfolio Mean variance, HRP, Black Litterman, risk parity, Kelly, CPPI
Risk VaR, CVaR, stress testing, scenario analysis, risk budgeting
Derivatives Black Scholes, greeks, implied vol, exotics
Volatility GARCH and the GARCH family, realized vol estimators, regimes
Monte Carlo GBM, Heston, jump diffusion, CIR, variance reduction
Credit Merton model, CDS pricing, Z spread, expected loss
Fixed income Bond pricing, duration, convexity, yield curves
Backtesting Event driven engine, order management, slippage
Machine learning LSTM models, walk forward CV, feature engineering
Execution VWAP, TWAP, POV, implementation shortfall
Signals More than forty technical indicators, functional and OOP APIs
Utilities Return conversion, annualization, resampling, drawdown tables

Links

License

MIT License. For research and educational use. Trading involves substantial risk of loss, and past performance does not guarantee future results.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meridianalgo-7.3.0.tar.gz (433.3 kB view details)

Uploaded Source

Built Distribution

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

meridianalgo-7.3.0-py3-none-any.whl (405.5 kB view details)

Uploaded Python 3

File details

Details for the file meridianalgo-7.3.0.tar.gz.

File metadata

  • Download URL: meridianalgo-7.3.0.tar.gz
  • Upload date:
  • Size: 433.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for meridianalgo-7.3.0.tar.gz
Algorithm Hash digest
SHA256 ac8cabbde28d1b25bf923f5c09449ed6cdd1c73ef26f8055ee2f4ca76a820351
MD5 1ba1d061da4e39489e22777eb99e6ec8
BLAKE2b-256 e70b17507f8bfaf6ff4dde37b1f1a5f1141ad821dc41633389a918ce0d23802a

See more details on using hashes here.

File details

Details for the file meridianalgo-7.3.0-py3-none-any.whl.

File metadata

  • Download URL: meridianalgo-7.3.0-py3-none-any.whl
  • Upload date:
  • Size: 405.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for meridianalgo-7.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d57d74dae63e20767b9129963d4240a1d785f0f5a1a7b3dfe7dcaf6e4fea261
MD5 2252b76822bb3a0529e0faac3807a7d6
BLAKE2b-256 0c0e1ade450d279ef50bd72cb365c884c4b8cb19b2acc044cfe97aa8105003c3

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

7.3.0 This release

2 files

7.2.1

2 files

7.2.0

2 files

7.1.0

2 files

7.0.0

2 files

6.2.4

2 files

6.2.3

2 files

6.2.2

2 files

6.2.1

2 files

6.1.0

2 files

6.0.0

2 files

4.1.0

2 files

4.0.4

2 files

4.0.3

2 files

4.0.2

2 files

4.0.1

2 files

4.0.0

2 files

3.1.0

2 files

3.0.0

2 files

2.2.1

2 files

2.2.0

2 files

2.1.2

2 files

2.1.1

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

0.3.3

2 files

0.3.2

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page