资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

利用pythonnumpy+matplotlib绘制股票k线图的方法-创新互联

一、python numpy + matplotlib 画股票k线图

创新互联主要从事网站设计制作、成都网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务原州,10年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
# -- coding: utf-8 --
import requests
import numpy as np  
from matplotlib import pyplot as plt  
from matplotlib import animation
 
fig = plt.figure(figsize=(8,6), dpi=72,facecolor="white")
axes = plt.subplot(111)
axes.set_title('Shangzheng')
axes.set_xlabel('time')
line, = axes.plot([], [], linewidth=1.5, linestyle='-')
alldata = []
 
def dapan(code):
	url = 'http://hq.sinajs.cn/?list='+code
	r = requests.get(url)
	data = r.content[21:-3].decode('gbk').encode('utf8').split(',')
	alldata.append(data[3])
	axes.set_ylim(float(data[5]), float(data[4]))
	return alldata
 
def init():
	line.set_data([], [])
	return line
 
def animate(i): 
 	axes.set_xlim(0, i+10)
 	x = range(i+1)
 	y = dapan('sh000001')
 	line.set_data(x, y)
 	return line
 
anim=animation.FuncAnimation(fig, animate, init_func=init, frames=10000, interval=5000)
 
plt.show()

当前名称:利用pythonnumpy+matplotlib绘制股票k线图的方法-创新互联
文章地址:http://cdkjz.cn/article/dhhscg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220