clean factor data
Project description
This project is to clean factor data and to prepare for back test.
Dependencies
python 3.5
pandas 0.22.0
numpy 1.14.3
pickle
sklearn 0.19.1 (for pca only)
Example
from data_box import data_box
db=data_box()\
.set_lag(freq='d',day_lag=0)\
.load_adjPrice(price)\ # 'price' is a pd.DataFrame with dates(20190101 int type) as its index and tickers as its column
.load_indestry(ind)\
.load_suspend(sus)\
.load_indexWeight(index_weight)\
.calc_indweight()\ # calculate industry weight based on index weight and stocks' industry in this index
.load_cap(cap)\
.add_factor('f1',factor1)\
.add_factor('f2',factor2)\
.add_factor('f3',factor3)\
.align_data()\
.factor_pca()\
.factor_ind_neutral()\
.factor_size_neutral()\
.factor_zscore()
print(db.Factor)
print(db.Price)
print(db.Sus)
print(db.Cap)
# save and reload
db.save(path)
db2=databox().load(path)
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
data_box-0.0.0a1.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for data_box-0.0.0a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4610c601f37b840258c90fae44908f4816457cadf7f17ca6014602fdfedfaabe |
|
MD5 | 1ddc0c8e381efa79f1752a5c0630e675 |
|
BLAKE2b-256 | 498108ebfea48ca746d154e9a3ca9864ce7900fbe161fea9e8f69ff410b6ea91 |