generate alpha factors
Project description
This programme is to automatically generate alpha factors
Dependencies
python >= 3.5
pandas >= 0.22.0
numpy >= 1.14.0
RNWS >= 0.1.1
numba >= 0.38.0
Sample
from alpha_factory import generator_class,get_memory_use_pct,clean
from RNWS import read
import numpy as np
import pandas as pd
factor_path='.'
frame_path='.'
# frames contains df_name,equation,dependency,type
# type includes df,cap,group
# original frames.csv have df_name: exr,cap,open_price,close,vwap,high,low,volume,ind1,ind2,ind3
df=pd.read_csv(frame_path+'/frames.csv')
# read in data
exr=read.read_df('./exr',file_pattern='exr',start=20160101,end=20170201)
cap=read.read_df('./cap',file_pattern='cap',header=0,dat_col='cap',start=20160101,end=20170201)
open_price,close,vwap,high,low,volume=read.read_df('./mkt_data',file_pattern='mkt',start=20160101,end=20170201,header=0,dat_col=['open','close','vwap','high','low','volume'])
ind1,ind2,ind3=read.read_df('./ind',file_pattern='ind',start=20160101,end=20170201,header=0,dat_col=['level1','level2','level3'])
parms={'exr':exr
,'cap':cap
,'open_price':open_price
,'close':close
,'vwap':vwap
,'high':high
,'low':low
,'volume':volume
,'ind1':ind1
,'ind2':ind2
,'ind3':ind3}
# generate starting:
gc=generator_class(df,factor_path,**parms)
gc.generator(batch_size=3)
gc.generator(batch_size=3)
gc.output_df(path=frame_path+'/frames_new.csv')
# generate continue:
with generator_class(df,factor_path,**parms) as gc:
gc.reload_df(path=frame_path+'/frames_new.csv')
gc.reload_factors()
clean()
for i in range(5):
gc.generator(batch_size=2)
print('step %d memory usage:\t %.1f%% \n'%(i,get_memory_use_pct()))
if get_memory_use_pct()>65:
break
gc.output_df(path=frame_path+'/frames_new2.csv')
multiprocessing is deprecated due to memory sharing issue
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
alpha_factory-0.1.6.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file alpha_factory-0.1.6.tar.gz.
File metadata
- Download URL: alpha_factory-0.1.6.tar.gz
- Upload date:
- Size: 7.9 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50d3ece6e811e9675fef17080ee482c4e11971e8ddef6543c2b61e2dae54db82
|
|
| MD5 |
a5bdef0777b7bcbe173f409ed93922b1
|
|
| BLAKE2b-256 |
85dc0a543da3a1590c0947ddf070075d2d444ca20e3a50f659fe73fdd59e210f
|
File details
Details for the file alpha_factory-0.1.6-py3-none-any.whl.
File metadata
- Download URL: alpha_factory-0.1.6-py3-none-any.whl
- Upload date:
- Size: 12.4 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4872332e31ae1845e4e1288247a570b0cabaec656cc3591a6f9e9d41ac2b7162
|
|
| MD5 |
dd4c1317d4d191aa00c2d2bf6b9c947a
|
|
| BLAKE2b-256 |
939a7ae0006a3d8b75274c21bf62b8919e7d19dfdf2c3e31b86d20eb4d8a1720
|