Skip to content

Instantly share code, notes, and snippets.

@adxrgh
Last active May 25, 2017 16:51
Show Gist options
  • Save adxrgh/d1110fa8e2fc77a2fbe329af9d32723a to your computer and use it in GitHub Desktop.
Save adxrgh/d1110fa8e2fc77a2fbe329af9d32723a to your computer and use it in GitHub Desktop.
[k线 with pynance] #tags:ts,plot
#coding:utf-8
import tushare as ts
import pynance as pn
ticker=input('input your ticker:')
t=ts.get_k_data(ticker)
x=t.set_index('date')#设置日期为索引
x.index=x.index.to_datetime()#将索引转为日期格式
x.index.names=['Date']#为索引指定名称
x.volume=x.volume.astype(int)#转换为整数格式
x.rename(columns={'volume':'Volume'},inplace=True)#volume名称修改
y=x[['open','high','low','close','Volume']]
pn.chart.candlestick(y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment