From 77388eb423f8867aa63860ace494dd85505dd416 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 2 Oct 2021 15:23:48 +0200 Subject: [PATCH] Improve generate_test_data to make it easier to use --- tests/optimize/conftest.py | 20 ++++++++++++++------ tests/strategy/test_strategy_helpers.py | 4 ++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/optimize/conftest.py b/tests/optimize/conftest.py index 690934b07..13d90b36f 100644 --- a/tests/optimize/conftest.py +++ b/tests/optimize/conftest.py @@ -39,17 +39,25 @@ def hyperopt(hyperopt_conf, mocker): def hyperopt_results(): return pd.DataFrame( { - 'pair': ['ETH/BTC', 'ETH/BTC', 'ETH/BTC', 'ETH/BTC'], + 'pair': ['ETH/USDT', 'ETH/USDT', 'ETH/USDT', 'ETH/USDT'], 'profit_ratio': [-0.1, 0.2, -0.1, 0.3], 'profit_abs': [-0.2, 0.4, -0.2, 0.6], 'trade_duration': [10, 30, 10, 10], + 'amount': [0.1, 0.1, 0.1, 0.1], 'sell_reason': [SellType.STOP_LOSS, SellType.ROI, SellType.STOP_LOSS, SellType.ROI], + 'open_date': + [ + datetime(2019, 1, 1, 9, 15, 0), + datetime(2019, 2, 1, 8, 55, 0), + datetime(2019, 3, 1, 9, 15, 0), + datetime(2019, 4, 1, 9, 15, 0), + ], 'close_date': [ - datetime(2019, 1, 1, 9, 26, 3, 478039), - datetime(2019, 2, 1, 9, 26, 3, 478039), - datetime(2019, 3, 1, 9, 26, 3, 478039), - datetime(2019, 4, 1, 9, 26, 3, 478039), - ] + datetime(2019, 1, 1, 9, 25, 0), + datetime(2019, 2, 1, 9, 25, 0), + datetime(2019, 3, 1, 9, 25, 0), + datetime(2019, 4, 1, 9, 25, 0), + ], } ) diff --git a/tests/strategy/test_strategy_helpers.py b/tests/strategy/test_strategy_helpers.py index a01b55050..cb7cf97a1 100644 --- a/tests/strategy/test_strategy_helpers.py +++ b/tests/strategy/test_strategy_helpers.py @@ -9,13 +9,13 @@ from freqtrade.strategy import (merge_informative_pair, stoploss_from_absolute, timeframe_to_minutes) -def generate_test_data(timeframe: str, size: int): +def generate_test_data(timeframe: str, size: int, start: str = '2020-07-05'): np.random.seed(42) tf_mins = timeframe_to_minutes(timeframe) base = np.random.normal(20, 2, size=size) - date = pd.period_range('2020-07-05', periods=size, freq=f'{tf_mins}min').to_timestamp() + date = pd.date_range(start, periods=size, freq=f'{tf_mins}min', tz='UTC') df = pd.DataFrame({ 'date': date, 'open': base,