empyrical computes performance and risk statistics commonly used in quantitative finance
Project description
empyrical
Common financial risk metrics in Python.
Installation
empyrical requires Python 3.7+. You can install it using pip
:
pip install empyrical-reloaded
or conda
:
conda install -c ml4t empyrical-reloaded
empyrical requires and installs the following packages while executing the above commands:
- numpy>=1.9.2
- pandas>=1.0.0
- scipy>=0.15.1
- pandas-datareader>=0.4
- yfinance>=0.1.55
Usage
Simple Statistics
import numpy as np
from empyrical import max_drawdown, alpha_beta
returns = np.array([.01, .02, .03, -.4, -.06, -.02])
benchmark_returns = np.array([.02, .02, .03, -.35, -.05, -.01])
# calculate the max drawdown
max_drawdown(returns)
# calculate alpha and beta
alpha, beta = alpha_beta(returns, benchmark_returns)
Rolling Measures
import numpy as np
from empyrical import roll_max_drawdown
returns = np.array([.01, .02, .03, -.4, -.06, -.02])
# calculate the rolling max drawdown
roll_max_drawdown(returns, window=3)
Pandas Support
import pandas as pd
from empyrical import roll_up_capture, capture
returns = pd.Series([.01, .02, .03, -.4, -.06, -.02])
# calculate a capture ratio
capture(returns)
# calculate capture for up markets on a rolling 60 day basis
roll_up_capture(returns, window=60)
Support
Please open an issue for support.
Contributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
Testing
- install requirements
- "nose>=1.3.7",
- "parameterized>=0.6.1"
nosetests empyrical.tests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
empyrical-reloaded-0.5.7.tar.gz
(55.4 kB
view hashes)
Built Distribution
Close
Hashes for empyrical_reloaded-0.5.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dd03fdd5eba3541bb58bce11b2d56a835ce1a070d8f6b41571904aa8d8fd089 |
|
MD5 | 4c9a9a7233f8eae5bce6542f82c5a69d |
|
BLAKE2b-256 | c2f2d7cd0b134074072278563024ec649c1bde43df3ea499d2d4d5605fcac1bb |