shiliangzhang-nku / barra_cne6 Goto Github PK
View Code? Open in Web Editor NEWBarra CNE6 因子构建
Barra CNE6 因子构建
我模拟了从810行开始到821行的逻辑,3支股票,2天的数据,构造了3个df:rs ,cap_sqrt ,ind_citic_lv1
以下这段代码除了构造df,其余都是源代码一样
`import numpy as np
import pandas as pd
'''构造数据'''
rs = pd.DataFrame(np.arange(6).reshape(2, 3), index=('20201201','20201202'), columns=('000001','600039','600519'))
cap_sqrt = pd.DataFrame(np.arange(6).reshape(2, 3)*0.1, index=('20201201','20201202'), columns=('000001','600039','600519'))
ind_citic_lv1 = pd.DataFrame(np.ones(6).reshape(2, 3), index=('20201201','20201202'), columns=('000001','600039','600519'))
ind_citic_lv1.iloc[:,1] = 0
'''以下同源代码'''
dat = pd.DataFrame()
for df in [rs, cap_sqrt, ind_citic_lv1]:
df.index.name = 'time'
df.columns.name = 'code'
dat = pd.concat([dat, df.unstack()], axis=1)
dat.columns = ['rs', 'weight', 'ind']
dat = dat.reset_index()
'''这里会报错'''
rs_ind = {(time, ind): (df['weight'] * df['rs']).sum() / df['weight'].sum()
for time, df_gp in dat.groupby(['time'])
for ind, df in df_gp.groupby(['ind'])}`
代码运行到rs_ind行报错,提示应该是找不到time索引,在执行dat.reset_index()之后,我查看了下dat,如下图
time和code索引在reset_index之后都不见了,是我理解有问题吗?
Hi author, I am studying your project and noticed that you use dask in your project to process factor matrix in parallel. But the fact is that the data file storing the daily frequency ticker data and the earnings data should not take up a lot of space. Since my data processing device does not have many cores for parallel computation, I would like to know if the performance difference between using dask and not using it is significant?
您好,方便告知下dask版本吗?新版本有些code已经不兼容了。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.