# -*- coding:utf-8 -*- import tushare.stock.cons as ct import tushare.stock.trading as td import tushare.stock.fundamental as fd if __name__ == '__main__': df = td.get_hist_data('cyb') print df #.ix['2015-01-26 10:30:00'] # print td.get_realtime_quotes(['600848','sh','sz','000981','zxb','cyb']) # df = fd.get_stock_basics() # df.to_csv('c:\\allstocks.csv') # print get_report_data(2013,4) # print get_profit_data(1999,2) # print get_operation_data(1999,2) # print get_growth_data(2014,3) # print get_debtpaying_data(2014,2) # print get_cashflow_data(2014,2) # print get_stock_basics()
def test_histData(self): self.set_data() td.get_hist_data(self.code, start=self.start, end=self.end)
def test_get_hist_data(self): self.set_data() print(fd.get_hist_data(self.code, self.start))
import matplotlib.pyplot as plt import tushare.stock.trading as td sz = td.get_hist_data(code='sh', start='2015-04-01', end='2015-05-22') sz = sz[['close']] close.plot() plt.show()
import tushare.stock.trading as fd # get your own free bQuandl API key from https://www.quandl.com/ # choose run_example = 0 for everything # run_example = 1 - create a plain and Keen.io based template for a chart webpage run_example = 0 if run_example == 1 or run_example == 0: df1 = fd.get_hist_data("300431",'2017-01-12') df1['code'] ="300431" df1['300431'] = df1['close'] df2 = fd.get_hist_data("000786",'2016-03-12') df2['000786'] = df2['close'] framses =[df1.filter(items=['300431']),df2.filter(items=['000786'])] #dfcontact = pd.concat(framses) dfcontact = df1.filter(items=['300431']).append(df2.filter(items=['000786'])) chart_plotly1 = Chart(df=dfcontact, chart_type='line', engine='plotly', style=Style(title="股价对比图", source="Quandl/Fred", scale_factor=-2, width=500, height=300, silent_display=True)) text = "A demo of chartpy canvas!!"