show buy_tag only if not None
This commit is contained in:
parent
8ce5536dd8
commit
a9f14ac119
@ -235,9 +235,9 @@ def plot_trades(fig, trades: pd.DataFrame) -> make_subplots:
|
|||||||
# Trades can be empty
|
# Trades can be empty
|
||||||
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"{row['profit_ratio']:.2%}, "
|
trades['desc'] = trades.apply(lambda row: f"{row['profit_ratio']:.2%}, " + \
|
||||||
f"{row['buy_tag']}, "
|
(f"{row['buy_tag']}, " if row['buy_tag'] is not None else "") + \
|
||||||
f"{row['sell_reason']}, "
|
f"{row['sell_reason']}, " + \
|
||||||
f"{row['trade_duration']} min",
|
f"{row['trade_duration']} min",
|
||||||
axis=1)
|
axis=1)
|
||||||
trade_buys = go.Scatter(
|
trade_buys = go.Scatter(
|
||||||
|
@ -187,7 +187,7 @@ def test_plot_trades(testdatadir, caplog):
|
|||||||
assert len(trades.loc[trades['profit_ratio'] <= 0]) == len(trade_sell_loss.x)
|
assert len(trades.loc[trades['profit_ratio'] <= 0]) == len(trade_sell_loss.x)
|
||||||
assert trade_sell_loss.marker.color == 'red'
|
assert trade_sell_loss.marker.color == 'red'
|
||||||
assert trade_sell_loss.marker.symbol == 'square-open'
|
assert trade_sell_loss.marker.symbol == 'square-open'
|
||||||
assert trade_sell_loss.text[5] == '-10.45%, None, stop_loss, 720 min'
|
assert trade_sell_loss.text[5] == '-10.45%, stop_loss, 720 min'
|
||||||
|
|
||||||
|
|
||||||
def test_generate_candlestick_graph_no_signals_no_trades(default_conf, mocker, testdatadir, caplog):
|
def test_generate_candlestick_graph_no_signals_no_trades(default_conf, mocker, testdatadir, caplog):
|
||||||
|
Loading…
Reference in New Issue
Block a user