From 21aba1620c3bebc8089681ae2b2648edb1329995 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 15 Dec 2018 13:55:16 +0100 Subject: [PATCH] Replace calls to load_data --- freqtrade/data/history.py | 4 ++-- freqtrade/edge/__init__.py | 5 +++-- freqtrade/optimize/backtesting.py | 2 +- freqtrade/optimize/hyperopt.py | 7 ++++--- scripts/download_backtest_data.py | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/freqtrade/data/history.py b/freqtrade/data/history.py index 21636f8c0..00dc8470b 100644 --- a/freqtrade/data/history.py +++ b/freqtrade/data/history.py @@ -74,7 +74,7 @@ def load_tickerdata_file( path = make_testdata_path(datadir) pair_s = pair.replace('/', '_') file = path.joinpath(f'{pair_s}-{ticker_interval}.json') - gzipfile = file.with_suffix('.gz') + gzipfile = file.with_suffix(file.suffix + '.gz') # If the file does not exist we download it when None is returned. # If file exists, read the file, load the json @@ -94,7 +94,7 @@ def load_tickerdata_file( return pairdata -def load_data(datadir: Path, +def load_data(datadir: Optional[Path], ticker_interval: str, pairs: List[str], refresh_pairs: Optional[bool] = False, diff --git a/freqtrade/edge/__init__.py b/freqtrade/edge/__init__.py index 589ac6fe0..29f34ce27 100644 --- a/freqtrade/edge/__init__.py +++ b/freqtrade/edge/__init__.py @@ -1,9 +1,10 @@ # pragma pylint: disable=W0603 """ Edge positioning package """ import logging +from pathlib import Path from typing import Any, Dict, NamedTuple -import arrow +import arrow import numpy as np import utils_find_1st as utf1st from pandas import DataFrame @@ -99,7 +100,7 @@ class Edge(): logger.info('Using local backtesting data (using whitelist in given config) ...') data = history.load_data( - self.config['datadir'], + Path(self.config.get('datadir')) if self.config.get('datadir') else None, pairs=pairs, ticker_interval=self.ticker_interval, refresh_pairs=self._refresh_pairs, diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 0d025e696..1640adef4 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -370,7 +370,7 @@ class Backtesting(object): timerange = Arguments.parse_timerange(None if self.config.get( 'timerange') is None else str(self.config.get('timerange'))) data = history.load_data( - self.config['datadir'], + Path(self.config.get('datadir')) if self.config.get('datadir') else None, pairs=pairs, ticker_interval=self.ticker_interval, refresh_pairs=self.config.get('refresh_pairs', False), diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 2ac55dd9b..a405217e9 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -5,11 +5,12 @@ This module contains the hyperopt logic """ import logging -import multiprocessing +from argparse import Namespace import os import sys -from argparse import Namespace +from pathlib import Path from math import exp +import multiprocessing from operator import itemgetter from typing import Any, Dict, List @@ -240,7 +241,7 @@ class Hyperopt(Backtesting): timerange = Arguments.parse_timerange(None if self.config.get( 'timerange') is None else str(self.config.get('timerange'))) data = load_data( - datadir=str(self.config.get('datadir')), + datadir=Path(self.config.get('datadir')) if self.config.get('datadir') else None, pairs=self.config['exchange']['pair_whitelist'], ticker_interval=self.ticker_interval, timerange=timerange diff --git a/scripts/download_backtest_data.py b/scripts/download_backtest_data.py index ebfef05d5..6235fe667 100755 --- a/scripts/download_backtest_data.py +++ b/scripts/download_backtest_data.py @@ -82,7 +82,7 @@ for pair in PAIRS: dl_file.unlink() print(f'downloading pair {pair}, interval {tick_interval}') - download_backtesting_testdata(str(dl_path), exchange=exchange, + download_backtesting_testdata(dl_path, exchange=exchange, pair=pair, tick_interval=tick_interval, timerange=timerange)