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', 'ARB', 'WARB', 'SOL', 'WSOL'], cumulative_with_initial_cash=0.0, asset_colours={'AAVE': '#F289DA', 'ARB': 'red', 'All cash': 'black', 'BTC': 'orange', 'DOGE': 'darkorange', 'ETH': 'blue', 'MATIC': 'purple', 'MKR': '#1AAB9B', 'PEPE': 'darkmagenta', 'SOL': 'lightblue', 'Strategy': 'green'}, start_at=None, include_price_series=False)[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.

  • include_price_series

    Include price series for the comparison.

    Changes return type.

  • strategy_universe (TradingStrategyUniverse) –

  • start_at (pandas._libs.tslibs.timestamps.Timestamp | None) –

Returns:

DataFrame with returns series for each asset.

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

Return type:

pandas.core.frame.DataFrame | tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]