Skip to main content

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


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.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

data_box-0.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file data_box-0.0.1.tar.gz.

File metadata

  • Download URL: data_box-0.0.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for data_box-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a84211522f8e482f6e4e57304669cc978bbb0dd0d5643f5138a76caf33a18691
MD5 8eb0626a1924d415324dd1ad985c6a17
BLAKE2b-256 d8d3be4978738bfa3d5aecad0a3d4bb9f3166f0ab52e9f7252af2d8a5a5b2467

See more details on using hashes here.

File details

Details for the file data_box-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: data_box-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for data_box-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c88a3f47917067c2aa260c4a873e7a10433c73795e78acd3997304a440214e7
MD5 89b2123016e3c487fbe48fb389b46941
BLAKE2b-256 3cbafc75ff4429ad36d0e4a40c799a6bf6f529835d3ece2ad1f95c8bb563dc2c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page