예제 #1
0
파일: Loopmain.py 프로젝트: dxcv/PreTrade
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
예제 #2
0
파일: DayAverage.py 프로젝트: dxcv/PreTrade
def ComputerAvgVol():
    """计算某一天交易的合约平均成交量"""
    TradingDay = datetime.datetime.now().strftime("%Y-%m-%d")
    TradingDay = '2019-01-15'
    info = InfoApi()
    mysql1 = info.GetStaticDataconnect()
    templist = IsExistData(Instrumentsql % TradingDay, info)

    sqllist = []
    progress = ProgressBar()
    for i in progress(templist):
        #Instrumentlist.append(str(i[0]).encode("utf-8"))
        InstrumentID = str(i[0]).encode("utf-8").strip()
        """for each InstrumentID"""
        temp = ComputerAvgEachInstrumentID(info, InstrumentID)
        sqllist = sqllist + temp
    mysql1.ExecmanysNonQuery(InsertSql, sqllist)