From 1c5031b468865f800c295b32fb2a6443748b5680 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Dec 2018 14:28:37 +0100 Subject: [PATCH] load_data to return dataframe --- freqtrade/data/history.py | 8 +++++--- freqtrade/strategy/interface.py | 3 +-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/freqtrade/data/history.py b/freqtrade/data/history.py index c397f7adb..e561c7252 100644 --- a/freqtrade/data/history.py +++ b/freqtrade/data/history.py @@ -13,8 +13,10 @@ from pathlib import Path from typing import Optional, List, Dict, Tuple, Any import arrow +from pandas import DataFrame from freqtrade import misc, constants, OperationalException +from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.exchange import Exchange from freqtrade.arguments import TimeRange @@ -69,7 +71,7 @@ def load_tickerdata_file( timerange: Optional[TimeRange] = None) -> Optional[List[Dict]]: """ Load a pair from file, - :return dict OR empty if unsuccesful + :return dict(:) or None if unsuccesful """ path = make_testdata_path(datadir) pair_s = pair.replace('/', '_') @@ -99,7 +101,7 @@ def load_data(datadir: Optional[Path], pairs: List[str], refresh_pairs: Optional[bool] = False, exchange: Optional[Exchange] = None, - timerange: TimeRange = TimeRange(None, None, 0, 0)) -> Dict[str, List]: + timerange: TimeRange = TimeRange(None, None, 0, 0)) -> Dict[str, DataFrame]: """ Loads ticker history data for the given parameters :return: dict @@ -125,7 +127,7 @@ def load_data(datadir: Optional[Path], logger.warning('Missing data at end for pair %s, data ends at %s', pair, arrow.get(pairdata[-1][0] // 1000).strftime('%Y-%m-%d %H:%M:%S')) - result[pair] = pairdata + result[pair] = parse_ticker_dataframe(pairdata) else: logger.warning( 'No data for pair: "%s", Interval: %s. ' diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index c8284b44f..700b65f04 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -13,7 +13,6 @@ import arrow from pandas import DataFrame from freqtrade import constants -from freqtrade.data.converter import parse_ticker_dataframe from freqtrade.persistence import Trade logger = logging.getLogger(__name__) @@ -326,7 +325,7 @@ class IStrategy(ABC): """ Creates a dataframe and populates indicators for given ticker data """ - return {pair: self.advise_indicators(parse_ticker_dataframe(pair_data), {'pair': pair}) + return {pair: self.advise_indicators(pair_data, {'pair': pair}) for pair, pair_data in tickerdata.items()} def advise_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: