Metric | |
---|---|
Continuous Integration | |
Documentation | |
pypi | |
pyversions | |
Code Quality |
Releases are available PyPI and can be installed with pip
.
pip install stylefact
stylefact
only supports Python 3
- probability distribution
- autocorrelation function
- leverage effect
- coarse-fine volatility
- gain/loss asymmetry
import datetime as dt
import pandas_datareader.data as web
import numpy as np
import stylefact.finance as sff
import stylefact.visualize as sfv
st = dt.datetime(1990,1,1)
en = dt.datetime(2020,1,1)
data = web.get_data_yahoo('GM', start=st, end=en)
prices = data['Adj Close'].to_numpy()
log_prices = np.log(prices)
returns = np.diff(log_prices)
x,y = sff.linear_distribution(returns)
sfv.linear_distribution(x,y,'linear_distribution')
x,y = sff.log_distribution(returns,'positive')
sfv.log_distribution(x,y,'log_positive_distribution')
x,y = sff.log_distribution(returns,'negative')
sfv.log_distribution(-x,y,'log_negative_distribution')
x,y = sff.autocorrelation(returns)
sfv.autocorrelation(x,y,'autocorrelation',scale='linear')
x,y = sff.autocorrelation(np.abs(returns))
sfv.autocorrelation(x,y,'abs_autocorrelation',scale='log')
x,y = sff.leverage_effect(returns)
sfv.leverage_effect(x,y,'leverage_effect')
x,y = sff.coarsefine_volatility(returns)
sfv.coarsefine_volatility(x,y,'coarsefine')
positive_dist,negative_dist = sff.gainloss_asymmetry(returns)
sfv.gainloss_asymmetry(positive_dist,negative_dist,'gainloss_asymmetry')
These requirements reflect the testing environment. It is possible that stylefact will work with older versions.
- Python (3.6+)
- NumPy (1.14+)
- matplotlib (2.0+)