diff --git a/freqtrade/data/btanalysis.py b/freqtrade/data/btanalysis.py index d6af67a32..f34dbf313 100644 --- a/freqtrade/data/btanalysis.py +++ b/freqtrade/data/btanalysis.py @@ -16,7 +16,7 @@ from freqtrade.persistence import Trade logger = logging.getLogger(__name__) # must align with columns in backtest.py -BT_DATA_COLUMNS = ["pair", "profit_percent", "open_date", "close_date", "index", "duration", +BT_DATA_COLUMNS = ["pair", "profit_percent", "open_date", "close_date", "index", "trade_duration", "open_rate", "close_rate", "open_at_end", "sell_reason"] @@ -144,7 +144,7 @@ def load_trades_from_db(db_url: str) -> pd.DataFrame: persistence.init(db_url, clean_open_orders=False) columns = ["pair", "open_date", "close_date", "profit", "profit_percent", - "open_rate", "close_rate", "amount", "duration", "sell_reason", + "open_rate", "close_rate", "amount", "trade_duration", "sell_reason", "fee_open", "fee_close", "open_rate_requested", "close_rate_requested", "stake_amount", "max_rate", "min_rate", "id", "exchange", "stop_loss", "initial_stop_loss", "strategy", "timeframe"] diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index d00f033cd..18881f9db 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -228,7 +228,7 @@ class Backtesting: open_rate=buy_row.open, open_date=buy_row.date, stake_amount=stake_amount, - amount=stake_amount / buy_row.open, + amount=round(stake_amount / buy_row.open, 8), fee_open=self.fee, fee_close=self.fee, is_open=True, diff --git a/freqtrade/plot/plotting.py b/freqtrade/plot/plotting.py index 6d50defaf..eee338a42 100644 --- a/freqtrade/plot/plotting.py +++ b/freqtrade/plot/plotting.py @@ -163,7 +163,8 @@ def plot_trades(fig, trades: pd.DataFrame) -> make_subplots: if trades is not None and len(trades) > 0: # Create description for sell summarizing the trade trades['desc'] = trades.apply(lambda row: f"{round(row['profit_percent'] * 100, 1)}%, " - f"{row['sell_reason']}, {row['duration']} min", + f"{row['sell_reason']}, " + f"{row['trade_duration']} min", axis=1) trade_buys = go.Scatter( x=trades["open_date"], diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index d5a6f8888..2c855fbc0 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -468,7 +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], + 'amount': [0.00957442, 0.0097064], 'trade_duration': [235, 40], 'open_at_end': [False, False], 'sell_reason': [SellType.ROI, SellType.ROI]