Rename duration to trade_duration
This commit is contained in:
		| @@ -16,7 +16,7 @@ from freqtrade.persistence import Trade | |||||||
| logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||||
|  |  | ||||||
| # must align with columns in backtest.py | # 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"] |                    "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) |     persistence.init(db_url, clean_open_orders=False) | ||||||
|  |  | ||||||
|     columns = ["pair", "open_date", "close_date", "profit", "profit_percent", |     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", |                "fee_open", "fee_close", "open_rate_requested", "close_rate_requested", | ||||||
|                "stake_amount", "max_rate", "min_rate", "id", "exchange", |                "stake_amount", "max_rate", "min_rate", "id", "exchange", | ||||||
|                "stop_loss", "initial_stop_loss", "strategy", "timeframe"] |                "stop_loss", "initial_stop_loss", "strategy", "timeframe"] | ||||||
|   | |||||||
| @@ -228,7 +228,7 @@ class Backtesting: | |||||||
|             open_rate=buy_row.open, |             open_rate=buy_row.open, | ||||||
|             open_date=buy_row.date, |             open_date=buy_row.date, | ||||||
|             stake_amount=stake_amount, |             stake_amount=stake_amount, | ||||||
|             amount=stake_amount / buy_row.open, |             amount=round(stake_amount / buy_row.open, 8), | ||||||
|             fee_open=self.fee, |             fee_open=self.fee, | ||||||
|             fee_close=self.fee, |             fee_close=self.fee, | ||||||
|             is_open=True, |             is_open=True, | ||||||
|   | |||||||
| @@ -163,7 +163,8 @@ def plot_trades(fig, trades: pd.DataFrame) -> make_subplots: | |||||||
|     if trades is not None and len(trades) > 0: |     if trades is not None and len(trades) > 0: | ||||||
|         # Create description for sell summarizing the trade |         # Create description for sell summarizing the trade | ||||||
|         trades['desc'] = trades.apply(lambda row: f"{round(row['profit_percent'] * 100, 1)}%, " |         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) |                                                   axis=1) | ||||||
|         trade_buys = go.Scatter( |         trade_buys = go.Scatter( | ||||||
|             x=trades["open_date"], |             x=trades["open_date"], | ||||||
|   | |||||||
| @@ -468,7 +468,7 @@ def test_backtest(default_conf, fee, mocker, testdatadir) -> None: | |||||||
|                                        Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True), |                                        Arrow(2018, 1, 30, 4, 10, 0).datetime], utc=True), | ||||||
|          'close_rate': [0.104969, 0.103541], |          'close_rate': [0.104969, 0.103541], | ||||||
|          'close_fee': [0.0025, 0.0025], |          'close_fee': [0.0025, 0.0025], | ||||||
|          'amount': [0.009574, 0.009706], |          'amount': [0.00957442, 0.0097064], | ||||||
|          'trade_duration': [235, 40], |          'trade_duration': [235, 40], | ||||||
|          'open_at_end': [False, False], |          'open_at_end': [False, False], | ||||||
|          'sell_reason': [SellType.ROI, SellType.ROI] |          'sell_reason': [SellType.ROI, SellType.ROI] | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user