Exemple #1
0
    def stra_get_bars(self,
                      stdCode: str,
                      period: str,
                      count: int,
                      isMain: bool = False) -> WtKlineData:
        '''
        获取历史K线
        @stdCode   合约代码
        @period K线周期,如m3/d7
        @count  要拉取的K线条数
        @isMain 是否是主K线
        '''
        key = "%s#%s" % (stdCode, period)

        if key in self.__bar_cache__:
            #这里做一个数据长度处理
            return self.__bar_cache__[key]

        self.__bar_cache__[key] = WtKlineData(size=count)
        cnt = self.__wrapper__.cta_get_bars(self.__id__, stdCode, period,
                                            count, isMain)
        if cnt == 0:
            return None

        df_bars = self.__bar_cache__[key]
        df_bars.closed = False

        return df_bars
Exemple #2
0
    def stra_get_bars(self, code:str, period:str, count:int) -> WtKlineData:
        '''
        获取历史K线
        @code   合约代码
        @period K线周期,如m3/d7
        @count  要拉取的K线条数
        '''
        key = "%s#%s" % (code, period)

        if key in self.__bar_cache__:
            #这里做一个数据长度处理
            return self.__bar_cache__[key]

        self.__bar_cache__[key] = WtKlineData(size=count)
        cnt =  self.__wrapper__.sel_get_bars(self.__id__, code, period, count)
        if cnt == 0:
            return None

        df_bars = self.__bar_cache__[key]
        df_bars.closed = False

        return df_bars