The All-in-One Python Library for Quantitative Finance
MeridianAlgo is the most comprehensive Python platform for institutional quantitative finance. From trading research to portfolio analytics, from liquidity analysis to options pricing β everything you need in one professional-grade package.
| Feature | MeridianAlgo | QuantLib | Zipline | Pyfolio |
|---|---|---|---|---|
| Portfolio Analytics | β | β | β | |
| Options Pricing | β | β | β | β |
| Market Microstructure | β | β | β | β |
| Backtesting | β | β | β | β |
| Execution Algorithms | β | β | β | |
| Risk Management | β | β | β | |
| Factor Models | β | β | β | |
| Machine Learning | β | β | β | β |
| Liquidity Analysis | β | β | β | β |
| Tear Sheets | β | β | β | β |
# Standard installation
pip install meridianalgo
# With machine learning support
pip install meridianalgo[ml]
# Full installation (recommended)
pip install meridianalgo[full]
# Everything including distributed computing
pip install meridianalgo[all]import meridianalgo as ma
# Quick analysis of any asset
data = ma.get_market_data_quick(['AAPL', 'MSFT', 'GOOGL'], start='2023-01-01')
analysis = ma.quick_analysis(data['AAPL']['Close'])
print(f"Sharpe Ratio: {analysis['sharpe_ratio']:.2f}")
print(f"Max Drawdown: {analysis['max_drawdown']:.1%}")
print(f"Win Rate: {analysis['win_rate']:.1%}")Generate comprehensive performance tear sheets:
from meridianalgo.analytics import TearSheet, create_full_tear_sheet
# Create full performance tear sheet
ts = TearSheet(returns, benchmark=spy_returns)
ts.create_full_tear_sheet(filename='report.pdf')
# Print summary statistics
ts.print_summary()
# Get all metrics as DataFrame
metrics = ts.get_metrics_summary()Features:
- Cumulative returns visualization
- Rolling Sharpe ratio analysis
- Monthly returns heatmap
- Drawdown analysis & underwater chart
- Distribution analysis with VaR
- Benchmark comparison
Multiple optimization methods:
from meridianalgo.portfolio import (
PortfolioOptimizer, RiskParity,
BlackLitterman, EfficientFrontier
)
# Mean-variance optimization
optimizer = PortfolioOptimizer(returns)
weights = optimizer.optimize(method='sharpe')
# Risk parity portfolio
rp = RiskParity(returns)
rp_weights = rp.optimize()
# Black-Litterman with views
bl = BlackLitterman(returns, market_caps)
bl_weights = bl.optimize_with_views({'AAPL': 0.15, 'MSFT': 0.12})
# Efficient frontier
ef = EfficientFrontier(returns)
frontier = ef.calculate_frontier(n_portfolios=100)Comprehensive market microstructure:
from meridianalgo.liquidity import (
OrderBookAnalyzer, MarketMicrostructure,
VPIN, MarketImpact, VolumeProfile
)
# Order book analysis
analyzer = OrderBookAnalyzer()
analyzer.update(order_book)
imbalance = analyzer.order_imbalance()
toxicity = analyzer.flow_toxicity()
kyle_lambda = analyzer.kyle_lambda()
# VPIN (Volume-Synchronized PIN)
vpin = VPIN(trades)
current_toxicity = vpin.current_vpin()
regime = vpin.toxicity_regime()
# Market impact estimation
impact = MarketImpact(daily_volume=1e6, volatility=0.02)
cost = impact.estimate_total_cost(order_size=10000, price=150)
# Volume profile analysis
vp = VolumeProfile(trades)
poc = vp.point_of_control() # Price with highest volume
va_low, va_high = vp.value_area(0.70) # Value areaEnterprise-grade risk analytics:
from meridianalgo.risk import (
VaRCalculator, CVaRCalculator,
StressTest, DrawdownAnalyzer
)
from meridianalgo.analytics import RiskAnalyzer
# Risk analyzer
risk = RiskAnalyzer(returns)
# VaR & CVaR (multiple methods)
var_95 = risk.value_at_risk(0.95, method='historical')
var_99 = risk.value_at_risk(0.99, method='cornish_fisher')
cvar = risk.conditional_var(0.95)
# GARCH volatility
garch_vol = risk.garch_volatility()
# Stress testing
stress = risk.stress_test({
'Market Crash': -0.20,
'Flash Crash': -0.10,
'Black Swan': -0.40
})
# Comprehensive summary
risk_summary = risk.summary()Full options pricing suite:
from meridianalgo.derivatives import (
OptionsPricer, VolatilitySurface,
BlackScholes, GreeksCalculator
)
# Options pricing
pricer = OptionsPricer()
# Black-Scholes
price = pricer.black_scholes(S=100, K=105, T=0.5, r=0.05, sigma=0.2)
# Binomial tree (American options)
price = pricer.binomial_tree(S=100, K=105, T=0.5, r=0.05, sigma=0.2,
american=True, n_steps=100)
# Monte Carlo
price, std = pricer.monte_carlo_pricing(S=100, K=105, T=0.5, r=0.05,
sigma=0.2, n_simulations=10000)
# Greeks calculation
greeks = pricer.calculate_greeks(S=100, K=105, T=0.5, r=0.05, sigma=0.2)
print(f"Delta: {greeks['delta']:.4f}")
print(f"Gamma: {greeks['gamma']:.4f}")
print(f"Vega: {greeks['vega']:.4f}")
print(f"Theta: {greeks['theta']:.4f}")
# Implied volatility
iv = pricer.calculate_implied_volatility(S=100, K=105, T=0.5, r=0.05,
market_price=8.50)Institutional-grade execution:
from meridianalgo.execution import (
VWAP, TWAP, ImplementationShortfall, POV
)
# VWAP execution
vwap = VWAP(total_quantity=10000, start_time='09:30', end_time='16:00')
schedule = vwap.calculate_schedule(historical_volume)
# Implementation Shortfall (Almgren-Chriss)
is_algo = ImplementationShortfall(
total_quantity=50000,
total_time=1.0,
volatility=0.02,
risk_aversion=1e-6
)
trajectory = is_algo.calculate_optimal_trajectory()
costs = is_algo.calculate_expected_cost()Multi-factor analysis:
from meridianalgo.factors import (
FamaFrench, FactorModel, FactorRiskDecomposition
)
# Fama-French analysis
ff = FamaFrench(model_type='five_factor')
results = ff.fit(returns, factor_data)
print(f"Alpha: {results['alpha']:.4f} (t={results['alpha_t_stat']:.2f})")
print(f"Market Beta: {results['coefficients']['MKT']:.2f}")
print(f"SMB Beta: {results['coefficients']['SMB']:.2f}")
# Factor risk decomposition
decomp = FactorRiskDecomposition.decompose_variance(
weights, factor_exposures, factor_covariance, specific_variances
)Pairs trading and mean reversion:
from meridianalgo.quant import (
PairsTrading, CointegrationAnalyzer,
OrnsteinUhlenbeck, HiddenMarkovModel
)
# Cointegration test
coint = CointegrationAnalyzer()
result = coint.engle_granger_test(stock1, stock2)
# Pairs trading strategy
pt = PairsTrading(entry_threshold=2.0, exit_threshold=0.5)
hedge_ratio = pt.calculate_hedge_ratio(stock1, stock2)
signals = pt.generate_signals(stock1, stock2)
# Mean reversion dynamics (OU process)
ou = OrnsteinUhlenbeck()
params = ou.fit(spread)
print(f"Half-life: {params['half_life']:.1f} days")
# Regime detection
hmm = HiddenMarkovModel(n_states=2)
results = hmm.fit(returns)
current_regime = hmm.predict_state(returns).iloc[-1]- Statistical arbitrage strategies
- High-frequency signal generation
- Multi-factor alpha models
- Risk-adjusted portfolio construction
- Factor-based investing
- Portfolio optimization (MVO, Black-Litterman, Risk Parity)
- Transaction cost analysis
- Performance attribution
- Market microstructure analysis
- Regime detection and forecasting
- Cointegration and mean reversion testing
- VPIN and flow toxicity analysis
- VaR and CVaR calculation
- Stress testing and scenario analysis
- Drawdown risk monitoring
- Tail risk analysis
import meridianalgo as ma
# Configure the library
ma.set_config(
data_provider='yahoo', # Data source
cache_enabled=True, # Enable caching
parallel_processing=True, # Use multiprocessing
risk_free_rate=0.05, # Default risk-free rate
trading_days_per_year=252, # Trading days
)
# Enable GPU acceleration (if available)
ma.enable_gpu_acceleration()
# Enable distributed computing
ma.enable_distributed_computing(backend='ray')
# Get system info
info = ma.get_system_info()# Run all tests
pytest tests/ -v
# Run specific module tests
pytest tests/test_analytics.py -v
pytest tests/test_liquidity.py -v
# Run with coverage
pytest tests/ --cov=meridianalgo --cov-report=html
# Run performance benchmarks
pytest tests/benchmarks/ -v- API Reference: docs.meridianalgo.com
- Tutorials: tutorials/
- Examples: examples/
- Cookbook: cookbook/
meridianalgo/
βββ analytics/ # Pyfolio-style analytics & tear sheets
β βββ performance.py # Performance metrics (50+ measures)
β βββ risk_analytics.py # Risk analysis (VaR, CVaR, GARCH)
β βββ tear_sheets.py # Visual tear sheet generation
β βββ attribution.py # Performance attribution (Brinson, Factor)
β βββ drawdown.py # Drawdown analysis
β
βββ liquidity/ # Market microstructure & liquidity
β βββ order_book.py # Order book analysis, microprice
β βββ microstructure.py # PIN, VPIN, spread decomposition
β βββ spread.py # Effective & realized spread
β βββ volume.py # Volume profile, institutional flow
β βββ impact.py # Market impact models (Almgren-Chriss)
β βββ metrics.py # Amihud, turnover, liquidity ratios
β
βββ portfolio/ # Portfolio optimization
β βββ optimization.py # MVO, Black-Litterman, HRP
β βββ risk_parity.py # Risk parity strategies
β βββ rebalancing.py # Rebalancing algorithms
β
βββ risk/ # Risk management
β βββ var.py # VaR calculations
β βββ stress_test.py # Stress testing
β βββ scenario.py # Scenario analysis
β
βββ derivatives/ # Options & derivatives
β βββ pricing.py # Black-Scholes, Binomial, Monte Carlo
β βββ greeks.py # Greeks calculation
β βββ volatility.py # Vol surface, local vol
β
βββ execution/ # Execution algorithms
β βββ vwap.py # VWAP execution
β βββ twap.py # TWAP execution
β βββ impact.py # Implementation shortfall
β
βββ quant/ # Quantitative strategies
β βββ pairs_trading.py # Pairs trading, cointegration
β βββ regime.py # Regime detection (HMM)
β βββ arbitrage.py # Statistical arbitrage
β
βββ factors/ # Factor models
β βββ fama_french.py # Fama-French models
β βββ factor_risk.py # Factor risk decomposition
β
βββ ml/ # Machine learning
βββ signals/ # Technical indicators
βββ backtesting/ # Backtesting engine
βββ data/ # Data management
βββ fixed_income/ # Fixed income analytics
- Pyfolio-Style Analytics: Complete tear sheet generation with 50+ metrics
- Comprehensive Liquidity Module: Order book, VPIN, market impact, spread decomposition
- Modern Architecture: Lazy loading, configuration management, GPU support
- Type Hints Throughout: Full typing for better IDE support
- Modular design for better code organization
- Enhanced error handling and validation
- Performance optimizations across all modules
- Extended documentation and examples
MIT License - see LICENSE for details.
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@meridianalgo.com
@software{meridianalgo2025,
title = {MeridianAlgo: The Complete Quantitative Finance Platform},
author = {Meridian Algorithmic Research Team},
year = {2025},
version = {6.0.0},
url = {https://github.com/MeridianAlgo/Python-Packages}
}MeridianAlgo v6.0.0 β The Complete Quantitative Finance Platform
Built by students for quantitative finance.