def download(self): """down load the content to the tmp file """ # 注意是否重新下载 datefrom = self.cd_datefrom.GetValue() dateto = self.cd_dateto.GetValue() rawlines = ystockquote.get_hist_lines(self.symbol,datefrom.Format("%Y%m%d") ,dateto.Format("%Y%m%d")) txtname = os.path.join(self.YahooTemp,self.symbol) try: txtout = open(txtname,'w') txtout.writelines(rawlines) txtout.close() except IOError : self.puts("warnning :can not write file %s " % txtname) fuquan = self.cc_fuquan.GetValue() data,div = rawlines2data(rawlines,1,fuquan) if div> 1 : self.puts('注意:本处成交量有缩小%s倍,因为大于了% ' % (div,0xffffffff))
if start_date == None : start_date = '19000101' if end_date == None: end_date = datetime.date.today().strftime('%Y%m%d') # 文件不存在用head # 文件存在复写时用head with_head = True if os.path.exists(fname): if stat == 'a' : with_head = False else: with_head = True else: with_head = True lines = ystockquote.get_hist_lines(symbol, start_date, end_date,with_head,b_sort=True) f = open(fname,stat) f.writelines(lines) f.close() return (len(lines),start_date,end_date) def myFormat(dd): """strftime当年度<1900时出错 """ return'%04d-%02d-%02d' % (dd.year,dd.month,dd.day) def manydowns(symbols,p_dir): """symbols [symbol,] """ logh = open('histlog.txt','a') for i in symbols :