Skip to content

BaseMetric


class backtide.metrics.base.BaseMetric()[source]

Abstract base class for custom experiment metrics.

A metric receives completed, caller-owned result tables and returns one finite scalar. Backtide calls it once for every strategy run.

Attributes

percentage : bool, default=False

Whether the returned fraction should be displayed as a percentage.

greater_is_better : bool, default=True
Whether larger values should rank ahead of smaller values.


Methods

compute Compute one scalar for a completed strategy run.


method compute(equity_curve, trades)[source]

Compute one scalar for a completed strategy run.

Parameters

equity_curve : pd.DataFrame | pl.DataFrame

Chronological samples with timestamp, equity, and drawdown columns.

trades : pd.DataFrame | pl.DataFrame
Completed trades with symbol, quantity, timestamps, prices, and pnl.

Returns

float

Finite metric value.