plot_mae_mfe
function backtide.analysis.mae_mfe.plot_mae_mfe(run, interval=None, symbols=None, title=None, legend="upper left", figsize=(900, 600), filename=None, display=True)[source]
Plot Maximum Adverse Excursion vs Maximum Favourable Excursion per trade.
For each closed trade, compute the maximum unrealized loss (MAE) and gain (MFE)
versus the entry price. Markers are colored by final PnL sign (green = winner,
red = loser). The diagonal reference line marks mfe == mae.
| Parameters |
run : RunResult
The strategy run whose trades will be analyzed.
interval : str | Interval | None, default=None
Bar interval to load (e.g., "1d", "1h"). When
symbols : list[str] | None, default=NoneNone, the function uses
the first available interval in the database.
List of symbols to include in the plot. If
title : str | dict | None, default=NoneNone or empty, all traded
symbols are included.
Title for the plot.
legend : str | dict | None, default="upper left"
Legend for the plot. See the user guide for an extended
description of the choices.
figsize : tuple[int, int], default=(900, 600)
Figure's size in pixels, format as (x, y).
filename : str | Path | None, default=None
Save the plot using this name. The type of the file depends on the
provided name (
display : bool | None, default=True.html, .png, .pdf, etc...). If filename has no
file type, the plot is saved as .html. If None, the plot isn't saved.
Whether to render the plot. If
None, it returns the figure.
|
| Returns |
Figure | None
The Plotly figure object. Only returned if
display=None.
|
See Also
Create a per-trade PnL over time plot for one or more strategy runs.
A single round-trip trade (open + close of a position).
Return stored OHLCV bars as a dataframe.
Example
>>> from backtide.analysis import plot_mae_mfe
>>> from backtide.storage import query_experiments, query_strategy_runs
>>> exp = query_experiments().iloc[0]
>>> run = query_strategy_runs(exp.id)[-1]
>>> plot_mae_mfe(run)