Ejemplo n.º 1
0
 def getTradeDay(d1, d2, dtype=backtest_runner.BackTestPolicy.enum.hisdat_mode):
     """确定是交易日
     return: (d1, d2)"""
     if dtype == backtest_runner.BackTestPolicy.enum.hisdat_mode:
         df = stock.getHisdatDataFrameFromRedis(code, start_day=d1)
     else:
         df = stock.getFenshiDfUseRedis(code, d1, d2)
     d2 = agl.datetime_to_date(df.index[-1])
     if agl.DateTimeCmp(d1, agl.datetime_to_date(df.index[0])) <0:
         d1 =  agl.datetime_to_date(df.index[0])
     return d1, d2
Ejemplo n.º 2
0
def genOne(code):
    #print code
    #先清理5分钟分时redis
    stock.FenshiCodeCache(code).delKey()
    try:
        #通过日线来取最近的5天
        df_hisdat = stock.getHisdatDataFrameFromRedis(code)
        df_hisdat = df_hisdat.tail()
        start_day = agl.datetime_to_date(df_hisdat.index[0])
        end_day = agl.datetime_to_date(df_hisdat.index[-1])

        df_fenshi = stock.getFenshiDfUseRedis(code, start_day,
                                              end_day).dropna()
    except:
        return
    stock.FenshiCodeCache(code).set(df_fenshi)
Ejemplo n.º 3
0
 def getTradeDay(d1, d2, dtype=backtest_runner.BackTestPolicy.enum.hisdat_mode):
     """确定是交易日
     return: (d1, d2)"""
     try:
         if dtype == backtest_runner.BackTestPolicy.enum.hisdat_mode:
             df = stock.getHisdatDataFrameFromRedis(code, d1, d2)
         else:
             df = stock.getFenshiDfUseRedis(code, d1,d2)
         if len(df) == 0:
             #在指定日期内没有数据,应该是新股或次新股
             return d2,d2
         d2 = agl.datetime_to_date(df.index[-1])
         if agl.DateTimeCmp(d1, agl.datetime_to_date(df.index[0])) <0:
             d1 =  agl.datetime_to_date(df.index[0])
     except:
         pass
     return d1, d2
Ejemplo n.º 4
0
 def _test_DrawTs(self):
     code = '300059'
     date = ['2016-1-1', '2016-3-1']
     fenshi = stock.getFenshiDfUseRedis(code, date[0], date[1])
     print(fenshi)
     DrawTs(pl, ts=fenshi['p'])
Ejemplo n.º 5
0
 def _test_fenshi_horizontal(self):
     code = jx.THS
     df = stock.getFenshiDfUseRedis(code,
                                    start_day='2017-12-1',
                                    end_day='2017-12-5')
     ui.drawFenshi(pl, df)