From 71bb348698e5f7de928ed6232fbae55fca789a73 Mon Sep 17 00:00:00 2001 From: kryofly Date: Mon, 15 Jan 2018 21:49:06 +0100 Subject: [PATCH] rename --timeperiod to --timerange --- docs/backtesting.md | 4 ++-- freqtrade/misc.py | 8 ++++---- freqtrade/optimize/__init__.py | 6 +++--- freqtrade/optimize/backtesting.py | 2 +- freqtrade/optimize/hyperopt.py | 2 +- freqtrade/tests/optimize/test_backtesting.py | 2 +- freqtrade/tests/optimize/test_optimize.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/backtesting.md b/docs/backtesting.md index 800420ea6..7984e67bc 100644 --- a/docs/backtesting.md +++ b/docs/backtesting.md @@ -52,12 +52,12 @@ python3 ./freqtrade/main.py backtesting --datadir freqtrade/tests/testdata-20180 ``` **Running backtest with smaller testset** -Use the --timeperiod argument to change how much of the testset +Use the --timerange argument to change how much of the testset you want to use. The last N ticks/timeframes will be used. Example: ```bash -python3 ./freqtrade/main.py backtesting --timeperiod -200 +python3 ./freqtrade/main.py backtesting --timerange -200 ``` **Update testdata directory diff --git a/freqtrade/misc.py b/freqtrade/misc.py index 9c2bce84f..c019509d6 100644 --- a/freqtrade/misc.py +++ b/freqtrade/misc.py @@ -191,11 +191,11 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None: dest='refresh_pairs', ) backtesting_cmd.add_argument( - '--timeperiod', + '--timerange', help='Use the last N ticks of data.', default=None, type=int, - dest='timeperiod', + dest='timerange', ) # Add hyperopt subcommand @@ -224,11 +224,11 @@ def build_subcommands(parser: argparse.ArgumentParser) -> None: metavar='INT', ) hyperopt_cmd.add_argument( - '-tp', '--timeperiod', + '-tp', '--timerange', help='Use the last N ticks of data.', default=None, type=int, - dest='timeperiod', + dest='timerange', ) diff --git a/freqtrade/optimize/__init__.py b/freqtrade/optimize/__init__.py index 3f6a98ac1..54d339b73 100644 --- a/freqtrade/optimize/__init__.py +++ b/freqtrade/optimize/__init__.py @@ -68,9 +68,9 @@ def load_data(datadir: str, ticker_interval: int = 5, pairs: Optional[List[str]] return result -def tickerdata_to_dataframe(data, timeperiod=None): - if timeperiod: - data = trim_tickerlist(data, timeperiod) +def tickerdata_to_dataframe(data, timerange=None): + if timerange: + data = trim_tickerlist(data, timerange) preprocessed = preprocess(data) return preprocessed diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index afcd0c539..5b8afc267 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -175,7 +175,7 @@ def start(args): from freqtrade import main main._CONF = config - preprocessed = optimize.tickerdata_to_dataframe(data, timeperiod=args.timeperiod) + preprocessed = optimize.tickerdata_to_dataframe(data, timerange=args.timerange) # Print timeframe min_date, max_date = get_timeframe(preprocessed) logger.info('Measuring data from %s up to %s ...', min_date.isoformat(), max_date.isoformat()) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index 15019e16b..abba7c35f 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -260,7 +260,7 @@ def start(args): config = load_config(args.config) pairs = config['exchange']['pair_whitelist'] data = optimize.load_data(args.datadir, pairs=pairs, ticker_interval=args.ticker_interval) - PROCESSED = optimize.tickerdata_to_dataframe(data, timeperiod=args.timeperiod) + PROCESSED = optimize.tickerdata_to_dataframe(data, timerange=args.timerange) if args.mongodb: logger.info('Using mongodb ...') diff --git a/freqtrade/tests/optimize/test_backtesting.py b/freqtrade/tests/optimize/test_backtesting.py index d4172d983..c6bcdd713 100644 --- a/freqtrade/tests/optimize/test_backtesting.py +++ b/freqtrade/tests/optimize/test_backtesting.py @@ -159,7 +159,7 @@ def test_backtest_start(default_conf, mocker, caplog): args.level = 10 args.live = False args.datadir = None - args.timeperiod = None # needed due to MagicMock malleability + args.timerange = None # needed due to MagicMock malleability backtesting.start(args) # check the logs, that will contain the backtest result exists = ['Using max_open_trades: 1 ...', diff --git a/freqtrade/tests/optimize/test_optimize.py b/freqtrade/tests/optimize/test_optimize.py index 6decb1414..bfbc99745 100644 --- a/freqtrade/tests/optimize/test_optimize.py +++ b/freqtrade/tests/optimize/test_optimize.py @@ -179,5 +179,5 @@ def test_load_tickerdata_file(): def test_tickerdata_to_dataframe(): tick = load_tickerdata_file(None, 'BTC_UNITEST', 1) tickerlist = {'BTC_UNITEST': tick} - data = optimize.tickerdata_to_dataframe(tickerlist, timeperiod=-100) + data = optimize.tickerdata_to_dataframe(tickerlist, timerange=-100) assert 100 == len(data['BTC_UNITEST'])