1. 程式人生 > >獲取股票歷史資料[日線][Python][Tushare]

獲取股票歷史資料[日線][Python][Tushare]

import tushare as ts

file = open("d:/stock_txt/stocklist_python.txt")
path='d:/tushare/history/' 
filetype='.csv'

     
while 1:
    line = file.readline()
    rs=line.replace('\n', '')
    if not line:
        break
    pass # 
    name=path+rs+filetype
    print(name)
    df=ts.get_hist_data(rs,retry_count=50)
    df.to_csv(name)
  
stocklist_python.txt 裡的全部的股票號碼,可以從同花順等軟體中匯出