當前位置:股票大全官網 - 股票行情 - 100銀子求助如何遍歷讀取TuShare的分筆股票數據

100銀子求助如何遍歷讀取TuShare的分筆股票數據

import tushare as ts

import time

while True:

df = ts.get_realtime_quotes('000581') #Single stock symbol

print df[['code','name','price','bid','ask','volume','amount','time']]

time.sleep(2)

根據 http://tushare.org/trading.html#id6 提供的例子,妳可以包裝成函數,傳入妳要獲取的股票代碼,df包含30個列的內容,妳可以輸出妳想要的列,也可以保存到數據庫裏。

tushare.org上都寫得很清楚了。

遍歷讀取無非就是

import tushare as ts

df = ts.get_tick_data('600848',date='2014-01-09')

for i in df.index:

print df.loc[i]

print df.loc[i]['price']

其中i就是序號,以i為基礎妳可以獲取所有row的數據,包括具體某壹行某壹列。python根據坐標讀取數據有多重方法,妳學明白python後,tushare用起來就方便了。