markov_stock_analysis v2-4.py 文件源码

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

项目:markov_stock_analysis 作者: nb5hd 项目源码 文件源码
def compare_securities_2x2(sec_list, weeks, thresh=0.0):
    """
    Returns an excel sheet with stock name, this week's percentage change, mean of next week's predicted
    percentage change, and standard deviation of next week's predicted percentage change

    :param sec_list: <list> with all the security names
    :param weeks: <int> Number of weeks since the most recent recorded date (cannot use years/months because months and
    years have varying quantities of days; Numpy requires constancy in datetime arithmetic)
    :param thresh: <float> divides percentage changes into two categories (>= and <); applies to each security
    """
    sec_dict = {}
    for name in sec_list:
        sec_info = predict_percentage_change(name, weeks=weeks, threshold=thresh)
        sec_dict[name] = sec_info
    sec_df = pd.DataFrame(sec_dict).transpose()
    sec_df.columns = ['Last % Change', "Mean Predicted % Change", "Standard Deviation " +
                      "Predicted % Change"]
    sec_df= sec_df.sort_values(by=["Mean Predicted % Change"], ascending=True)
    writer = pd.ExcelWriter('output.xlsx')
    sec_df.to_excel(writer, 'Sheet1')
    writer.save()


#compare_securities_2x2(["BAC", "AAPL", "GOOG", "T"], weeks=26, thresh=2.0)
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号