Skip to main content

This programme is built for back testing alpha factors. Each factor is tested alone.

sample with a single processor

from single_factor_model.single import preprocessing,back_testing,ic_measurement,ic_measure_summary,back_test_summary,bt_figure

parms={'factor_path':'factor_folder_path'# file name: xxx_yyyymmdd.csv columns(no order): StkID,factor1,factor2,...
      ,'ind_path':'industry_folder_path'# file name: xxx_yyyymmdd.csv columns(no order): StkID,level1,level2,...
      ,'ind_level':'industry_level_name'
      ,'price_path':'market_folder_path'# file name: xxx_yyyymmdd.csv columns(no order): StkID,vwap,adjfactor,susp_days,maxupordown
      ,'cap_path':'cap_folder_path' # file name: xxx_yyyymmdd.csv columns(no order): StkID,SRcap
      ,'index_weight_path':'index_weight_folder_path'  file name: xxx_yyyymmdd.csv columns(no header): StkID,weight
      ,'start_time':20170101
      ,'end_time':20180101
      ,'sub_factor':None # or list of factors of interest
      ,'flag':'monthly' # monthly or daily
      ,'day_lag':1 # lag of days to receive these factors
      ,'ind_mapping_flag':False # whether to use number to represent industry, this could spead up calculation
      }
parms2={'n':5 # portfolio number
        ,'silent':True # whether to output detail
        }
parms3={'window':3 # window for regression sample data
        ,'half_decay':200 # weight for regression parameters
        }
P=preprocessing()
D=P(**parms)
T=back_testing(D) # back testing
B=T(**parms2)
T2=ic_measurement(D) # regression
M=T2(**parms3)

Table0=ic_measure_summary(M)
Dict1,Table2,Dict3=back_test_summary(B)
Dict4=bt_figure(B,show_plot=True) # plot backtesting result

Table0.to_csv('table0.csv')

from RNWS import write
write.write_dict(Dict1,path='E:',file_pattern='dict1')

sample with multi processors

nearly same as single processor sample. Just replace single_factor_model.single to single_factor_model.multi. Then you can address 'processors' in parms and parms2 and parms3 as processors. Also if __name__=='__main__': is needed to run programme on Windows.

Release files for single-factor-model 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for single-factor-model 0.0.7
File Size Uploaded
single_factor_model-0.0.7.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for single-factor-model 0.0.7
File Interpreter ABI Platform
single_factor_model-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 42.4 kB

Release files / single_factor_model-0.0.7.tar.gz

Download URL single_factor_model-0.0.7.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e5142c7acec2d9d47da1da4a07cf27d40783e62a073716abd7c0fb31a9b01d94
BLAKE2b-256 checksum
How to use checksums
33b8738a0b656e19af3ba8fda1208fdeefe9ae42189c0c71feda0622aeb7e17e
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / single_factor_model-0.0.7-py3-none-any.whl

Download URL single_factor_model-0.0.7-py3-none-any.whl
Size 26.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecf2a37c48372e02171e9c485b0df7d7624a736e5106c6392134b7ea1d5aefb5
BLAKE2b-256 checksum
How to use checksums
c69656d4bcef619a141bdc9c818aca33680909d8085db537556b1e642e59c7de
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

0.3.2

2 release files

0.3.0

1 release file

0.2.1

1 release file

0.2.0

2 release files

0.1.8

2 release files

0.1.7

1 release file

0.1.6

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page