コード例 #1
0
    def populate_indicators(self, dataframe: DataFrame) -> DataFrame:
        dataframe['sma5'] = ta.SMA(dataframe, timeperiod=5)
        dataframe['sma200'] = ta.SMA(dataframe, timeperiod=200)

        # resample our dataframes
        dataframe_short = resample_to_interval(dataframe, self.get_ticker_indicator() * 2)
        dataframe_long = resample_to_interval(dataframe, self.get_ticker_indicator() * 8)

        # compute our RSI's
        dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
        dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
        dataframe_short['cmf'] = cmf(dataframe_short, 14)
        dataframe_long['cmf'] = cmf(dataframe_long, 14)

        dataframe_short['osc'] = osc(dataframe_short, 14)
        dataframe_long['osc'] = osc(dataframe_long, 14)

        # merge dataframe back together
        dataframe = resampled_merge(dataframe, dataframe_short)
        dataframe = resampled_merge(dataframe, dataframe_long)

        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)

        # fill NA values with previes
        dataframe.fillna(method='ffill', inplace=True)

        # Volume Flow Index: Add VFI, VFIMA, Histogram to DF
        dataframe['vfi'], dataframe['vfima'], dataframe['vfi_hist'] =  \
            vfi(dataframe, length=130, coef=0.2, vcoef=2.5, signalLength=5, smoothVFI=True)

        return dataframe
コード例 #2
0
    def populate_indicators(self, dataframe: DataFrame) -> DataFrame:

        # otherwise freqshow import won't work
        # since lambda is too large with all the dependencies

        from technical.util import resample_to_interval
        from technical.util import resampled_merge
        from technical.indicators import cmf
        from technical.indicators import osc

        dataframe['sma5'] = ta.SMA(dataframe, timeperiod=5)
        dataframe['sma200'] = ta.SMA(dataframe, timeperiod=200)

        # resample our dataframes
        dataframe_short = resample_to_interval(dataframe,
                                               self.get_ticker_indicator() * 2)
        dataframe_long = resample_to_interval(dataframe,
                                              self.get_ticker_indicator() * 8)

        # compute our RSI's
        dataframe_short['rsi'] = ta.RSI(dataframe_short, timeperiod=14)
        dataframe_long['rsi'] = ta.RSI(dataframe_long, timeperiod=14)
        dataframe_short['cmf'] = cmf(dataframe_short, 14)
        dataframe_long['cmf'] = cmf(dataframe_long, 14)

        dataframe_short['osc'] = osc(dataframe_short, 14)
        dataframe_long['osc'] = osc(dataframe_long, 14)

        # merge dataframe back together
        dataframe = resampled_merge(dataframe, dataframe_short)
        dataframe = resampled_merge(dataframe, dataframe_long)

        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)

        # fill NA values with previes
        dataframe.fillna(method='ffill', inplace=True)

        return dataframe
コード例 #3
0
    def evaluate_osc(self,
                     period=12,
                     prefix="osc",
                     impact_buy=1,
                     impact_sell=1):
        """
        evaluates the osc
        :param dataframe:
        :param period:
        :param prefix:
        :return:
        """
        from technical.indicators import osc

        self._weights(impact_buy, impact_sell)
        dataframe = self.dataframe
        name = '{}_{}'.format(prefix, period)
        dataframe[name] = osc(dataframe, period)

        dataframe.loc[((dataframe[name] < 0.3)),
                      'buy_{}'.format(name)] = (1 * impact_buy)

        dataframe.loc[((dataframe[name] > 0.8)),
                      'sell_{}'.format(name)] = (1 * impact_sell)
コード例 #4
0
    def evaluate_osc(self,
                     period=12,
                     prefix="osc",
                     impact_buy=1,
                     impact_sell=1):
        """
        evaluates the osc
        :param dataframe:
        :param period:
        :param prefix:
        :return:
        """
        from technical.indicators import osc

        self._weights(impact_buy, impact_sell)
        dataframe = self.dataframe
        name = f"{prefix}_{period}"
        dataframe[name] = osc(dataframe, period)

        dataframe.loc[((dataframe[name] < 0.3)),
                      f"buy_{name}"] = 1 * impact_buy

        dataframe.loc[((dataframe[name] > 0.8)),
                      f"sell_{name}"] = 1 * impact_sell