visualise_advanced_metrics#

API documentation for tradeexecutor.analysis.advanced_metrics.visualise_advanced_metrics Python function.

visualise_advanced_metrics(returns, mode=AdvancedMetricsMode.basic, benchmark=None)[source]#

Calculate advanced strategy performance statistics using Quantstats.

Calculates multiple metrics used to benchmark strategies for risk-adjusted returns in one go.

See Quantstats for more information.

Example:

from tradeexecutor.visual.equity_curve import calculate_equity_curve, calculate_returns
from tradeexecutor.analysis.advanced_metrics import visualise_advanced_metrics

equity = calculate_equity_curve(state)
returns = calculate_returns(equity)
df = visualise_advanced_metrics(returns)
display(df)

Example with benchmarking against buy and hold ETH:

from tradeexecutor.visual.equity_curve import calculate_equity_curve, calculate_returns, generate_buy_and_hold_returns
from tradeexecutor.analysis.advanced_metrics import visualise_advanced_metrics, AdvancedMetricsMode

equity = calculate_equity_curve(state)
returns = calculate_returns(equity)
benchmark_returns = generate_buy_and_hold_returns(benchmark_indexes["ETH"])

metrics = visualise_advanced_metrics(
    returns,
    mode=AdvancedMetricsMode.full,
    benchmark=benchmark_returns,
)

display(metrics)

See also calculate_advanced_metrics().

Parameters:
Returns:

A DataFrame ready to display

Return type:

DataFrame