markov_stock_analysis v2-4.py 文件源码

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

项目:markov_stock_analysis 作者: nb5hd 项目源码 文件源码
def percent_change_as_time_plot(adjusted_df, security):
    """
    This function visualizes the percentage change data as a time series plot.

    :param adjusted_df: Pandas DataFrame with columns: Date, Adjusted Close, and Percentage Change.
    :param security: <SecurityInfo class> Holds information about the requested security
    """

    pct_change_list = adjusted_df['Percentage Change'].tolist()
    date_list = adjusted_df.index.values
    fig, ax = plt.subplots()
    ax.plot(date_list, pct_change_list)
    plt.xlabel("Dates")
    plt.ylabel("Percentage change from last period")
    if security.get_period() == "none":
        plt.title("Percentage change in " + security.get_name(), y=1.03)
    else:
        plt.title("Percentage change in " + security.get_name() + " " + security.get_period() + " data", y=1.03)
    ax.xaxis.set_minor_locator(MonthLocator())
    ax.yaxis.set_minor_locator(MultipleLocator(1))
    ax.fmt_xdata = DateFormatter('%Y-%m-%d')
    ax.autoscale_view()
    fig.autofmt_xdate()

    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号