作家
登录

用Python做股市数据分析(一)

作者: 来源: 2017-07-07 08:50:15 阅读 我要评论

  •  
  •     else
  •  
  •         raise ValueError('Valid inputs to argument "stick" include the strings "day", "week", "month", "year", or a positive integer'
  •  
  •     # Set plot parameters, including the axis object ax used for plotting 
  •  
  •     fig, ax = plt.subplots() 
  •  
  •     fig.subplots_adjust(bottom=0.2) 
  •  
  •     if plotdat.index[-1] - plotdat.index[0] < pd.Timedelta('730 days'): 
  •  
  •         weekFormatter = DateFormatter('%b %d')  # e.g., Jan 12 
  •  
  •         ax.xaxis.set_major_locator(mondays) 
  •  
  •         ax.xaxis.set_minor_locator(alldays) 
  •  
  •     else
  •  
  •         weekFormatter = DateFormatter('%b %d, %Y'
  •  
  •     ax.xaxis.set_major_formatter(weekFormatter) 
  •  
  •     ax.grid(True
  •  
  •     # Create the candelstick chart 
  •  
  •     candlestick_ohlc(ax, list(zip(list(date2num(plotdat.index.tolist())), plotdat["Open"].tolist(), plotdat["High"].tolist(), 
  •  
  •                       plotdat["Low"].tolist(), plotdat["Close"].tolist())), 
  •  
  •                       colorup = "black", colordown = "red", width = stick * .4) 
  •  
  •     # Plot other series (such as moving averages) as lines 
  •  
  •     if otherseries != None: 
  •  
  •         if type(otherseries) != list: 
  •  
  •             otherseries = [otherseries] 
  •  
  •         dat.loc[:,otherseries].plot(ax = ax, lw = 1.3, grid = True
  •  
  •     ax.xaxis_date() 
  •  
  •     ax.autoscale_view() 
  •  
  •     plt.setp(plt.gca().get_xticklabels(), rotation=45, horizontalalignment='right'
  •  
  •     plt.show() 
  •  
  • pandas_candlestick_ohlc(apple)   
  • 烛状图中黑色线条代表该交易日闭市价格高于开市价格(盈利),红色线条代表该交易日开市价格高于闭市价格(吃亏)。刻度线代表当天交易的最高价和最低价(影线用来指明烛身的哪端是开市,哪端是闭市)。烛状图在金融和技巧分析中被广泛应用在交易决定计划上,应用烛身的外形,色彩和地位。我今天不会涉及到策略。


      推荐阅读

      WOT讲师杨钊:人工智能将在不同应用场景逐步落地

    【51CTO.com原创稿件】由51CTO主办的WOTA2017全球立异技巧峰会将于2017年7月21日拉开帷幕。本次峰会,将环绕机>>>详细阅读


    本文标题:用Python做股市数据分析(一)

    地址:http://www.17bianji.com/lsqh/36070.html

    关键词: 探索发现

    乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

    网友点评
    自媒体专栏

    评论

    热度

    精彩导读
    栏目ID=71的表不存在(操作类型=0)