From 0fa56be9d2a06fcc11b4f9bcdfa5b3564315539d Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 26 Jun 2020 09:27:07 +0200 Subject: [PATCH] remove openIndex and closeIndex from backtest-report --- freqtrade/edge/edge_positioning.py | 2 -- freqtrade/optimize/backtesting.py | 6 ------ freqtrade/optimize/optimize_reports.py | 4 +++- tests/edge/test_edge.py | 6 ------ tests/optimize/test_backtesting.py | 6 ------ tests/optimize/test_optimize_reports.py | 2 -- 6 files changed, 3 insertions(+), 23 deletions(-) diff --git a/freqtrade/edge/edge_positioning.py b/freqtrade/edge/edge_positioning.py index 169732314..9843d4e83 100644 --- a/freqtrade/edge/edge_positioning.py +++ b/freqtrade/edge/edge_positioning.py @@ -429,8 +429,6 @@ class Edge: 'profit_abs': '', 'open_date': date_column[open_trade_index], 'close_date': date_column[exit_index], - 'open_index': start_point + open_trade_index, - 'close_index': start_point + exit_index, 'trade_duration': '', 'open_rate': round(open_price, 15), 'close_rate': round(exit_price, 15), diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 4197ec087..1eef4f4b9 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -41,8 +41,6 @@ class BacktestResult(NamedTuple): profit_abs: float open_date: datetime close_date: datetime - open_index: int - close_index: int trade_duration: float open_at_end: bool open_rate: float @@ -251,8 +249,6 @@ class Backtesting: open_date=buy_row.date, close_date=sell_row.date, trade_duration=trade_dur, - open_index=buy_row.Index, - close_index=sell_row.Index, open_at_end=False, open_rate=buy_row.open, close_rate=closerate, @@ -268,8 +264,6 @@ class Backtesting: close_date=sell_row.date, trade_duration=int(( sell_row.date - buy_row.date).total_seconds() // 60), - open_index=buy_row.Index, - close_index=sell_row.Index, open_at_end=True, open_rate=buy_row.open, close_rate=sell_row.open, diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index de609589a..8f9104640 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -52,8 +52,10 @@ def backtest_result_to_list(results: DataFrame) -> List[List]: :param results: Dataframe containing results for one strategy :return: List of Lists containing the trades """ + # Return 0 as "index" for compatibility reasons (for now) + # TODO: Evaluate if we can remove this return [[t.pair, t.profit_percent, t.open_date.timestamp(), - t.open_date.timestamp(), t.open_index - 1, t.trade_duration, + t.open_date.timestamp(), 0, t.trade_duration, t.open_rate, t.close_rate, t.open_at_end, t.sell_reason.value] for index, t in results.iterrows()] diff --git a/tests/edge/test_edge.py b/tests/edge/test_edge.py index ea1e709a2..cd5f623e3 100644 --- a/tests/edge/test_edge.py +++ b/tests/edge/test_edge.py @@ -356,8 +356,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc 'profit_abs': '', 'open_date': np.datetime64('2018-10-03T00:05:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:10:00.000000000'), - 'open_index': 1, - 'close_index': 1, 'trade_duration': '', 'open_rate': 17, 'close_rate': 17, @@ -369,8 +367,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc 'profit_abs': '', 'open_date': np.datetime64('2018-10-03T00:20:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:25:00.000000000'), - 'open_index': 4, - 'close_index': 4, 'trade_duration': '', 'open_rate': 20, 'close_rate': 20, @@ -382,8 +378,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc 'profit_abs': '', 'open_date': np.datetime64('2018-10-03T00:30:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:40:00.000000000'), - 'open_index': 6, - 'close_index': 7, 'trade_duration': '', 'open_rate': 26, 'close_rate': 34, diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index e7a13f251..c0a9e798a 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -464,8 +464,6 @@ def test_backtest(default_conf, fee, mocker, testdatadir) -> None: ), 'close_date': pd.to_datetime([Arrow(2018, 1, 29, 22, 35, 0).datetime, Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True), - 'open_index': [78, 184], - 'close_index': [125, 192], 'trade_duration': [235, 40], 'open_at_end': [False, False], 'open_rate': [0.104445, 0.10302485], @@ -761,8 +759,6 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat ), 'close_date': pd.to_datetime(['2018-01-29 20:45:00', '2018-01-30 05:35:00', ], utc=True), - 'open_index': [78, 184], - 'close_index': [125, 192], 'trade_duration': [235, 40], 'open_at_end': [False, False], 'open_rate': [0.104445, 0.10302485], @@ -779,8 +775,6 @@ def test_backtest_start_multi_strat_nomock(default_conf, mocker, caplog, testdat 'close_date': pd.to_datetime(['2018-01-29 20:45:00', '2018-01-30 05:35:00', '2018-01-30 08:30:00'], utc=True), - 'open_index': [78, 184, 185], - 'close_index': [125, 224, 205], 'trade_duration': [47, 40, 20], 'open_at_end': [False, False, False], 'open_rate': [0.104445, 0.10302485, 0.122541], diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index 7efd87787..9f06043cc 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -214,8 +214,6 @@ def test_backtest_record(default_conf, fee, mocker): Arrow(2017, 11, 14, 22, 58, 00).datetime], "open_rate": [0.002543, 0.003003, 0.003089, 0.003214], "close_rate": [0.002546, 0.003014, 0.003103, 0.003217], - "open_index": [1, 119, 153, 185], - "close_index": [118, 151, 184, 199], "trade_duration": [123, 34, 31, 14], "open_at_end": [False, False, False, True], "sell_reason": [SellType.ROI, SellType.STOP_LOSS,