From f368aabcc7bce32752f93f26d020be7222e12678 Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 26 Jun 2020 20:51:36 +0200 Subject: [PATCH] Add amount to backtest-result --- freqtrade/optimize/backtesting.py | 3 +++ freqtrade/optimize/optimize_reports.py | 1 + tests/optimize/test_backtesting.py | 1 + 3 files changed, 5 insertions(+) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 7021e85b6..d00f033cd 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -45,6 +45,7 @@ class BacktestResult(NamedTuple): close_date: datetime close_rate: float close_fee: float + amount: float trade_duration: float open_at_end: bool sell_reason: SellType @@ -254,6 +255,7 @@ class Backtesting: close_date=sell_row.date, close_rate=closerate, close_fee=self.fee, + amount=trade.amount, trade_duration=trade_dur, open_at_end=False, sell_reason=sell.sell_type @@ -270,6 +272,7 @@ class Backtesting: close_date=sell_row.date, close_rate=sell_row.open, close_fee=self.fee, + amount=trade.amount, trade_duration=int(( sell_row.date - buy_row.date).total_seconds() // 60), open_at_end=True, diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index d1c58617d..a7cc8a7d6 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -250,6 +250,7 @@ def generate_backtest_stats(config: Dict, btdata: Dict[str, DataFrame], 'backtest_days': backtest_days, 'trades_per_day': round(len(results) / backtest_days, 2) if backtest_days > 0 else None, 'market_change': market_change, + 'stake_amount': config['stake_amount'] } result['strategy'][strategy] = strat_stats diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 4ee03f6ba..d5a6f8888 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -468,6 +468,7 @@ def test_backtest(default_conf, fee, mocker, testdatadir) -> None: Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True), 'close_rate': [0.104969, 0.103541], 'close_fee': [0.0025, 0.0025], + 'amount': [0.009574, 0.009706], 'trade_duration': [235, 40], 'open_at_end': [False, False], 'sell_reason': [SellType.ROI, SellType.ROI]