コード例 #1
0
    def set_input_data(self, df):
        super().set_input_data(df)

        # Set dataFrame keys
        self.low_key = Constants.get_low_key()
        self.high_key = Constants.get_high_key()
        self.indicator_key = Constants.get_key("ADX")

        prices_temp = pd.DataFrame()

        df_list = []
        for ticker in self.tickers:
            if ticker in df:
                df_list.append(
                    pd.concat([
                        df[ticker].
                        loc[:, [self.low_key, self.high_key, self.prices_key]],
                        prices_temp
                    ],
                              axis=1,
                              keys=[ticker]))

        df_indicator = pd.concat(df_list, axis=1)

        self.df = df_indicator.copy()
コード例 #2
0
    def set_input_data(self, df):
        super().set_input_data(df)

        self.low_key = Constants.get_low_key()
        self.high_key = Constants.get_high_key()
        self.open_key = Constants.get_open_key()

        # Set dataframe keys
        prices_temp = pd.DataFrame()

        df_list = []
        for ticker in self.tickers:
            if ticker in df:
                df_temp = df[ticker].loc[:, [
                    self.high_key, self.low_key, self.open_key, self.prices_key
                ]]

                df_list.append(
                    pd.concat([df_temp, prices_temp], axis=1, keys=[ticker]))

        df_indicator = pd.concat(df_list, axis=1)

        self.df = df_indicator.copy()

        prices_temp = pd.DataFrame()

        df_list = []
        for ticker in self.tickers:
            df_temp = df[ticker]
            df_temp.reset_index(level=0, inplace=True)
            df_temp = df_temp.loc[:, [
                self.date_key, self.high_key, self.low_key, self.open_key,
                self.prices_key
            ]]  # TODO: Is this rebundant???

            df_temp.rename(columns={
                "Date": "date",
                self.high_key: "high",
                self.low_key: "low",
                self.open_key: "open",
                self.prices_key: "close"
            },
                           inplace=True)

            df_list.append(
                pd.concat([df_temp, prices_temp], axis=1, keys=[ticker]))

        df_indicator = pd.concat(df_list, axis=1)

        self.df_renko_input = df_indicator.copy()