remove openIndex and closeIndex from backtest-report

This commit is contained in:
Matthias 2020-06-26 09:27:07 +02:00
parent 04cbc2cde5
commit 0fa56be9d2
6 changed files with 3 additions and 23 deletions

View File

@ -429,8 +429,6 @@ class Edge:
'profit_abs': '', 'profit_abs': '',
'open_date': date_column[open_trade_index], 'open_date': date_column[open_trade_index],
'close_date': date_column[exit_index], 'close_date': date_column[exit_index],
'open_index': start_point + open_trade_index,
'close_index': start_point + exit_index,
'trade_duration': '', 'trade_duration': '',
'open_rate': round(open_price, 15), 'open_rate': round(open_price, 15),
'close_rate': round(exit_price, 15), 'close_rate': round(exit_price, 15),

View File

@ -41,8 +41,6 @@ class BacktestResult(NamedTuple):
profit_abs: float profit_abs: float
open_date: datetime open_date: datetime
close_date: datetime close_date: datetime
open_index: int
close_index: int
trade_duration: float trade_duration: float
open_at_end: bool open_at_end: bool
open_rate: float open_rate: float
@ -251,8 +249,6 @@ class Backtesting:
open_date=buy_row.date, open_date=buy_row.date,
close_date=sell_row.date, close_date=sell_row.date,
trade_duration=trade_dur, trade_duration=trade_dur,
open_index=buy_row.Index,
close_index=sell_row.Index,
open_at_end=False, open_at_end=False,
open_rate=buy_row.open, open_rate=buy_row.open,
close_rate=closerate, close_rate=closerate,
@ -268,8 +264,6 @@ class Backtesting:
close_date=sell_row.date, close_date=sell_row.date,
trade_duration=int(( trade_duration=int((
sell_row.date - buy_row.date).total_seconds() // 60), sell_row.date - buy_row.date).total_seconds() // 60),
open_index=buy_row.Index,
close_index=sell_row.Index,
open_at_end=True, open_at_end=True,
open_rate=buy_row.open, open_rate=buy_row.open,
close_rate=sell_row.open, close_rate=sell_row.open,

View File

@ -52,8 +52,10 @@ def backtest_result_to_list(results: DataFrame) -> List[List]:
:param results: Dataframe containing results for one strategy :param results: Dataframe containing results for one strategy
:return: List of Lists containing the trades :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(), 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] t.open_rate, t.close_rate, t.open_at_end, t.sell_reason.value]
for index, t in results.iterrows()] for index, t in results.iterrows()]

View File

@ -356,8 +356,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc
'profit_abs': '', 'profit_abs': '',
'open_date': np.datetime64('2018-10-03T00:05:00.000000000'), 'open_date': np.datetime64('2018-10-03T00:05:00.000000000'),
'close_date': np.datetime64('2018-10-03T00:10:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:10:00.000000000'),
'open_index': 1,
'close_index': 1,
'trade_duration': '', 'trade_duration': '',
'open_rate': 17, 'open_rate': 17,
'close_rate': 17, 'close_rate': 17,
@ -369,8 +367,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc
'profit_abs': '', 'profit_abs': '',
'open_date': np.datetime64('2018-10-03T00:20:00.000000000'), 'open_date': np.datetime64('2018-10-03T00:20:00.000000000'),
'close_date': np.datetime64('2018-10-03T00:25:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:25:00.000000000'),
'open_index': 4,
'close_index': 4,
'trade_duration': '', 'trade_duration': '',
'open_rate': 20, 'open_rate': 20,
'close_rate': 20, 'close_rate': 20,
@ -382,8 +378,6 @@ def test_process_expectancy(mocker, edge_conf, fee, risk_reward_ratio, expectanc
'profit_abs': '', 'profit_abs': '',
'open_date': np.datetime64('2018-10-03T00:30:00.000000000'), 'open_date': np.datetime64('2018-10-03T00:30:00.000000000'),
'close_date': np.datetime64('2018-10-03T00:40:00.000000000'), 'close_date': np.datetime64('2018-10-03T00:40:00.000000000'),
'open_index': 6,
'close_index': 7,
'trade_duration': '', 'trade_duration': '',
'open_rate': 26, 'open_rate': 26,
'close_rate': 34, 'close_rate': 34,

View File

@ -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, 'close_date': pd.to_datetime([Arrow(2018, 1, 29, 22, 35, 0).datetime,
Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True), Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True),
'open_index': [78, 184],
'close_index': [125, 192],
'trade_duration': [235, 40], 'trade_duration': [235, 40],
'open_at_end': [False, False], 'open_at_end': [False, False],
'open_rate': [0.104445, 0.10302485], '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', 'close_date': pd.to_datetime(['2018-01-29 20:45:00',
'2018-01-30 05:35:00', ], utc=True), '2018-01-30 05:35:00', ], utc=True),
'open_index': [78, 184],
'close_index': [125, 192],
'trade_duration': [235, 40], 'trade_duration': [235, 40],
'open_at_end': [False, False], 'open_at_end': [False, False],
'open_rate': [0.104445, 0.10302485], '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', 'close_date': pd.to_datetime(['2018-01-29 20:45:00',
'2018-01-30 05:35:00', '2018-01-30 05:35:00',
'2018-01-30 08:30:00'], utc=True), '2018-01-30 08:30:00'], utc=True),
'open_index': [78, 184, 185],
'close_index': [125, 224, 205],
'trade_duration': [47, 40, 20], 'trade_duration': [47, 40, 20],
'open_at_end': [False, False, False], 'open_at_end': [False, False, False],
'open_rate': [0.104445, 0.10302485, 0.122541], 'open_rate': [0.104445, 0.10302485, 0.122541],

View File

@ -214,8 +214,6 @@ def test_backtest_record(default_conf, fee, mocker):
Arrow(2017, 11, 14, 22, 58, 00).datetime], Arrow(2017, 11, 14, 22, 58, 00).datetime],
"open_rate": [0.002543, 0.003003, 0.003089, 0.003214], "open_rate": [0.002543, 0.003003, 0.003089, 0.003214],
"close_rate": [0.002546, 0.003014, 0.003103, 0.003217], "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], "trade_duration": [123, 34, 31, 14],
"open_at_end": [False, False, False, True], "open_at_end": [False, False, False, True],
"sell_reason": [SellType.ROI, SellType.STOP_LOSS, "sell_reason": [SellType.ROI, SellType.STOP_LOSS,