Exemplo n.º 1
0
    def analyze_ticker(self, ticker_history: List[Dict],
                       metadata: dict) -> DataFrame:
        """
        Parses the given ticker history and returns a populated DataFrame
        add several TA indicators and buy signal to it
        :return DataFrame with ticker data and indicator data
        """

        dataframe = parse_ticker_dataframe(ticker_history)

        pair = str(metadata.get('pair'))

        # Test if seen this pair and last candle before.
        # always run if process_only_new_candles is set to true
        if (not self.process_only_new_candles
                or self._last_candle_seen_per_pair.get(
                    pair, None) != dataframe.iloc[-1]['date']):
            # Defs that only make change on new candle data.
            logging.debug("TA Analysis Launched")
            dataframe = self.advise_indicators(dataframe, metadata)
            dataframe = self.advise_buy(dataframe, metadata)
            dataframe = self.advise_sell(dataframe, metadata)
            self._last_candle_seen_per_pair[pair] = dataframe.iloc[-1]['date']
        else:
            logging.debug("Skippinig TA Analysis for already analyzed candle")
            dataframe['buy'] = 0
            dataframe['sell'] = 0

        # Other Defs in strategy that want to be called every loop here
        # twitter_sell = self.watch_twitter_feed(dataframe, metadata)
        logging.debug("Loop Analysis Launched")

        return dataframe
Exemplo n.º 2
0
 def tickerdata_to_dataframe(
         self, tickerdata: Dict[str, List]) -> Dict[str, DataFrame]:
     """
     Creates a dataframe and populates indicators for given ticker data
     """
     return {
         pair: self.advise_indicators(parse_ticker_dataframe(pair_data),
                                      {'pair': pair})
         for pair, pair_data in tickerdata.items()
     }
Exemplo n.º 3
0
 def analyze_ticker(self, ticker_history: List[Dict],
                    metadata: dict) -> DataFrame:
     """
     Parses the given ticker history and returns a populated DataFrame
     add several TA indicators and buy signal to it
     :return DataFrame with ticker data and indicator data
     """
     dataframe = parse_ticker_dataframe(ticker_history)
     dataframe = self.advise_indicators(dataframe, metadata)
     dataframe = self.advise_buy(dataframe, metadata)
     dataframe = self.advise_sell(dataframe, metadata)
     return dataframe
def result():
    with open('freqtrade/tests/testdata/ETH_BTC-1m.json') as data_file:
        return parse_ticker_dataframe(json.load(data_file))
def test_dataframe_correct_length(result):
    dataframe = parse_ticker_dataframe(result)
    assert len(result.index) - 1 == len(
        dataframe.index)  # last partial candle removed
def test_parse_ticker_dataframe(ticker_history):
    columns = ['date', 'open', 'high', 'low', 'close', 'volume']

    # Test file with BV data
    dataframe = parse_ticker_dataframe(ticker_history)
    assert dataframe.columns.tolist() == columns