plot-profit should fail gracefully if no trade is within the selected timerange
closes #4119
This commit is contained in:
parent
b8899b39ec
commit
2fdda8e448
@ -444,6 +444,8 @@ def generate_profit_graph(pairs: str, data: Dict[str, pd.DataFrame],
|
||||
|
||||
# Trim trades to available OHLCV data
|
||||
trades = extract_trades_of_period(df_comb, trades, date_index=True)
|
||||
if len(trades) == 0:
|
||||
raise OperationalException('No trades found in selected timerange.')
|
||||
|
||||
# Add combined cumulative profit
|
||||
df_comb = create_cum_profit(df_comb, trades, 'cum_profit', timeframe)
|
||||
|
@ -353,6 +353,10 @@ def test_generate_profit_graph(testdatadir):
|
||||
profit_pair = find_trace_in_fig_data(figure.data, f"Profit {pair}")
|
||||
assert isinstance(profit_pair, go.Scatter)
|
||||
|
||||
with pytest.raises(OperationalException, match=r"No trades found.*"):
|
||||
# Pair cannot be empty - so it's an empty dataframe.
|
||||
generate_profit_graph(pairs, data, trades.loc[trades['pair'].isnull()], timeframe="5m")
|
||||
|
||||
|
||||
def test_start_plot_dataframe(mocker):
|
||||
aup = mocker.patch("freqtrade.plot.plotting.load_and_plot_trades", MagicMock())
|
||||
|
Loading…
Reference in New Issue
Block a user