def main(): Directory = "E:/options/" startdate = "20190516" startdate = datetime.datetime.strptime(startdate, '%Y%m%d') info = InfoApi() info.GetDbHistoryConnect() info.GetStaticDataconnect() t = TradingDay(info) enddate = datetime.datetime.now() # if datetime.datetime.now().hour<17: # enddate=datetime.datetime.now()-datetime.timedelta(days=1) # if not t.IsTradingDayFuture(enddate.strftime("%Y%m%d")): # enddate = t.NextTradingDayFuture(enddate.strftime("%Y%m%d"), False) # enddate = datetime.datetime.strptime(enddate, "%Y%m%d") enddate = datetime.datetime.strptime("20190516", "%Y%m%d") while startdate <= enddate: print startdate starttime = datetime.datetime.now() setattr(info, 'TradingDay', startdate) GetSourceData(info) startdate = t.NextTradingDayFuture(startdate.strftime("%Y%m%d"), True) startdate = datetime.datetime.strptime(startdate, '%Y%m%d') endtime = datetime.datetime.now() print endtime - starttime
# Add a header format. header_format = workbook.add_format({ 'bold': True, 'text_wrap': True, 'valign': 'vcenter', 'border': 1 }) header_format.set_align('center') header_format.set_align('vcenter') writer.save() if __name__ == '__main__': info = InfoApi() info.GetDbHistoryConnect() #初始化mysql t = TradingDay(info) productlist = ['i', 'ni'] #成交量持仓量的品种代码 startdate = '20190524' startdate = datetime.datetime.strptime(startdate, "%Y%m%d") enddate = datetime.datetime.now() startdate = t.NextTradingDayFuture(enddate.strftime("%Y%m%d"), False) startdate = datetime.datetime.strptime(startdate, "%Y%m%d") while startdate <= enddate: print info.mysql Prestartdate = t.NextTradingDayFuture(startdate.strftime("%Y%m%d"), False) Prestartdate = Prestartdate[0:4] + "-" + Prestartdate[
GetCZCEPosition(info, startdate, "CZCE") # 获取郑商所日成交top20 else: print 'CZCE', "持仓排名top20数据已经存在" # GetDCEPosition(info,startdate,"DCE") #大商所持仓信息 # # GetSHFEPosition(info, startdate, "SHFE") # 上期所 # # # GetCZCEPosition(info, startdate, "CZCE") # 郑商所阶段性前20名 # GetDCEStagedTurnover(info,startdate,"DCE") #阶段性成交 if __name__ == "__main__": info = InfoApi() info.GetDbHistoryConnect() info.Get_Msplider() t = NextTradingDay.TradingDay(info) startdate = datetime.datetime.now() - datetime.timedelta(days=7) startdate = t.NextTradingDay(startdate.strftime("%Y%m%d"), False) startdate = datetime.datetime.strptime(startdate, "%Y%m%d") enddate = datetime.datetime.now() mysplider = info.mysplider while startdate.strftime("%Y%m%d") <= enddate.strftime("%Y%m%d"): print startdate, main(startdate, mysplider, info) startdate = t.NextTradingDay(startdate.strftime("%Y%m%d"), True) startdate = datetime.datetime.strptime(startdate, "%Y%m%d")