get_benchmark_data#

API documentation for tradeexecutor.analysis.multi_asset_benchmark.get_benchmark_data Python function.

get_benchmark_data(strategy_universe, max_count=2, interesting_assets=('BTC', 'WBTC', 'ETH', 'WETH', 'WMATIC', 'MATIC'), cumulative_with_initial_cash=0.0, asset_colours={'All cash': 'black', 'BTC': 'orange', 'ETH': 'blue', 'MATIC': 'purple', 'Strategy': 'green'})[source]#

Get returns series of different benchmark index assets from the universe.

  • Assets are: BTC, ETH, MATIC

To be used with compare_multiple_portfolios() and tradeexecutor.visual.benchmark.visualise_equity_curve_benchmark().

Example:

from tradeexecutor.analysis.multi_asset_benchmark import get_benchmark_data
from tradeexecutor.visual.benchmark import visualise_equity_curve_benchmark

benchmark_indexes = get_benchmark_data(
    strategy_universe,
    cumulative_with_initial_cash=state.portfolio.get_initial_cash()
)

fig = visualise_equity_curve_benchmark(
    name=state.name,
    portfolio_statistics=state.stats.portfolio,
    all_cash=state.portfolio.get_initial_cash(),
    benchmark_indexes=benchmark_indexes,
    height=800,
    log_y=False,
)

fig.show()
Parameters:
  • max_count – Return this many benchmark series

  • interesting_assets

    Choose to benchmark from these.

    We also check for wrapped token symbol varients.

  • cumulative_with_initial_cash (float) –

    Get cumulative returns instead of daily returns.

    Set to the cumulative initial cash value.

  • strategy_universe (TradingStrategyUniverse) –

Returns:

DataFrame with returns series for each asset.

Each series has colour and name metadata added to the series.attr.

Return type:

DataFrame