empyrical-reloaded
raw JSON → 0.5.12 verified Sat May 09 auth: no python
empyrical-reloaded is a fork of the original empyrical library that computes performance and risk statistics commonly used in quantitative finance, such as Sharpe ratio, Sortino ratio, max drawdown, and others. Current version 0.5.12 targets Python >=3.9 and is under active maintenance with occasional releases.
pip install empyrical-reloaded Common errors
error ModuleNotFoundError: No module named 'empyrical' ↓
cause You installed the original 'empyrical' (compromised) or 'empyrical-reloaded' is not installed.
fix
Run: pip install empyrical-reloaded
error TypeError: sharpe_ratio() missing 1 required positional argument: 'returns' ↓
cause Called sharpe_ratio without parentheses or with wrong arguments.
fix
Use: sharpe_ratio = empyrical.sharpe_ratio(returns, period='daily', annualization=252)
error ValueError: Input must be a pandas Series or DataFrame ↓
cause Passed a list or numpy array instead of a pandas object.
fix
Convert to pandas Series: returns = pd.Series(returns_list)
error ImportError: cannot import name 'sharpe_ratio' from 'empyrical' ↓
cause Trying to import from a different module structure (e.g., from empyrical.stats).
fix
Import directly: from empyrical import sharpe_ratio
Warnings
breaking The original 'empyrical' package was taken over by a malicious actor. 'empyrical-reloaded' is the maintained fork. Do not install 'empyrical' (0.5.10 or earlier) as it may be compromised. ↓
fix Uninstall empyrical and install empyrical-reloaded: pip uninstall empyrical; pip install empyrical-reloaded
gotcha Many functions require returns sorted in ascending order (oldest first). Passing a series in reverse order will produce incorrect results without warning. ↓
fix Ensure returns are sorted by date ascending before passing to empyrical functions
gotcha 'period' keyword is sometimes required, sometimes ignored. For example, 'sharpe_ratio' needs a 'period' to determine annualization, while 'max_drawdown' does not. Check docstrings. ↓
fix Always provide 'period' and 'annualization' for metrics that depend on frequency (Sharpe, Sortino, Calmar, etc.).
deprecated The 'annualization' parameter default is set to None, which may raise a TypeError in future versions. You must explicitly provide it. ↓
fix Always pass annualization=252 for daily data, 52 for weekly, 12 for monthly.
Imports
- empyrical wrong
import empyrical as emp (works but often causes confusion for submodule access)correctimport empyrical - sharpe_ratio wrong
from empyrical.stats import sharpe_ratiocorrectfrom empyrical import sharpe_ratio
Quickstart
import pandas as pd
import empyrical
# Example returns series
returns = pd.Series([0.01, -0.02, 0.03, 0.02, -0.01], name='Returns')
# Compute Sharpe ratio (assumes risk-free rate = 0)
sharpe = empyrical.sharpe_ratio(returns, period='daily', annualization=252)
print(f"Sharpe ratio: {sharpe:.4f}")
# Compute max drawdown
max_dd = empyrical.max_drawdown(returns)
print(f"Max drawdown: {max_dd:.4%}")