macro.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:Multiple-factor-risk-model 作者: icezerowjj 项目源码 文件源码
def macro_reg_ret(ret, macro_data):
    '''
    ?????????????????????????????????????????????????
    ??????????????????????????*???????????????-??????
    :param DataFrame ret: ??????????
    :param DataFrame macro_index: ??????????
    :return: [DataFrame,dict] [loading,significant_list]: ???????????????;??????????
    '''
    macro_loading = pd.DataFrame(np.zeros([ret.shape[1], macro_data.shape[1]]))
    # ??????????
    for i in range(ret.shape[1]):
        y = ret.values[:, i]
        # ??????????????
        for j in range(macro_data.shape[1]):
            x = macro_data.values[:, j]
            model = sm.OLS(y, x).fit()
            macro_loading.iloc[i, j] = model.params[0]
    return macro_loading
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号