zoukankan      html  css  js  c++  java
  • candlestick用法

    import matplotlib.pyplot as plt

     
    from matplotlib.dates import DateFormatter, WeekdayLocator, DayLocator, MONDAY,YEARLY
    from matplotlib.finance import quotes_historical_yahoo_ohlc, candlestick_ohlc
     
    plt.rcParams['font.sans-serif'= ['SimHei']
    plt.rcParams['axes.unicode_minus'= False
     
    ticker = '600028' # 600028 是"中国石化"的股票代码
    ticker += '.ss'   # .ss 表示上证 .sz表示深证
     
    date1 = (201581# 起始日期,格式:(年,月,日)元组
    date2 = (201611)  # 结束日期,格式:(年,月,日)元组
     
     
    mondays = WeekdayLocator(MONDAY)            # 主要刻度
    alldays = DayLocator()                      # 次要刻度
    #weekFormatter = DateFormatter('%b %d')     # 如:Jan 12
    mondayFormatter = DateFormatter('%m-%d-%Y'# 如:2-29-2015
    dayFormatter = DateFormatter('%d')          # 如:12
     
    quotes = quotes_historical_yahoo_ohlc(ticker, date1, date2)
    if len(quotes) == 0:
        raise SystemExit
     
    fig, ax = plt.subplots()
    fig.subplots_adjust(bottom=0.2)
     
    ax.xaxis.set_major_locator(mondays)
    ax.xaxis.set_minor_locator(alldays)
    ax.xaxis.set_major_formatter(mondayFormatter)
    #ax.xaxis.set_minor_formatter(dayFormatter)
     
    #plot_day_summary(ax, quotes, ticksize=3)
    candlestick_ohlc(ax, quotes, width=0.6, colorup='r', colordown='g')
     
    ax.xaxis_date()
    ax.autoscale_view()
    plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right')
     
    ax.grid(True)
    plt.title('中国石化 600028')
    plt.show()
  • 相关阅读:
    Apache虚拟主机配置
    【笔记】php常用函数
    【笔记】linux x86漏洞利用
    【笔记】ubuntu如何切换到root用户&&linux如何关闭各种保护
    【实验吧】登陆一下好吗???
    渗透相关website
    【实验吧】Reverse400
    ajax+jquery+ashx如何实现上传文件
    使用Jquery解析Json基础知识
    C#中把Datatable转换为Json的5个代码实例
  • 原文地址:https://www.cnblogs.com/changbosha/p/5816522.html
Copyright © 2011-2022 走看看