Skip to main content

factor model

Project description

This programme is built for back-testing factors.


  • python 3.5
  • pandas 0.23.0
  • numba 0.38.0
  • empyrical 0.5.0
  • data_box
  • pickle
  • multiprocessing


Data Box: pre-process

from data_box import data_box
# freq can be 'd' or 'm', for detail please refer to db.set_lag doc.

Where price,ind,ind_weight,sus,factor0,factor1 are all dataframes with index as date (yyyymmdd,int) and column as tickers. You can save and load this data box object by'path') and db.load('path'). You can find more in data_box project.

Back Test

from single_factor_model import run_back_test

single process


multi process



with __name__=='__main__':

To check detailed position of each portfolio each day, just assign weight_path.

Summary and Plot

calculate return including long short portfolio(and reverse)

from single_factor_model import calc_return
Return = calc_return(Value,Turnover,long_short,double_side_cost=0.003)


from single_factor_model import summary



Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for single-factor-model, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size single_factor_model-0.2.0-py3-none-any.whl (10.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size single_factor_model-0.2.0.tar.gz (8.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page