利用tushare数据源获取上证50每日开盘价并存入Excel

import datetime
import xlwt;
import xlrd;
import xlsxwriter
from xlrd import open_workbook
import numpy as np
import tushare as ts

symbol_dict=ts.get_sz50s()


workbook = xlsxwriter.Workbook(r'E:\py\Expenses01.xlsx')
worksheet = workbook.add_worksheet()


scode=symbol_dict.code
sname=symbol_dict.name


for i in range(50):

    opens=ts.get_hist_data(scode[i],start='2013-09-01',end='2014-09-1').open
    L=len(opens)
    worksheet.write(i,0,scode[i])
    worksheet.write(i,1,sname[i])
    for j in range(L):                     
        worksheet.write(i,j+2,opens[j])
workbook.close()    
展开阅读全文

没有更多推荐了,返回首页