Add amount to backtest-result

This commit is contained in:
Matthias 2020-06-26 20:51:36 +02:00
parent 6e94734678
commit f368aabcc7
3 changed files with 5 additions and 0 deletions

View File

@ -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,

View File

@ -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

View File

@ -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]