Variables
default_metric_registry: Default metric registry instance.
MetricRegistry
Instance variables
registry: vectorbtpro.utils.config.HybridConfig: Metricvbt.HybridConfigregistry. This registry should have a retrivable metric name as key and schema. ifNone, fallbacks toMETRIC_REGISTRY.
Methods
get_all_metrics
| Name | Type | Default | Description |
|---|---|---|---|
include_non_tunable | bool | False | Whether to include non-tunable metrics. Defaults to False. |
| Type | Description |
|---|---|
List[str] | List of metric keys with valid (non-NaNs) rolling_func values. |
get_all_rolling_metrics
rolling_func.
Optionally include non-tunable metrics based on user choice.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
include_non_tunable | bool | False | Whether to include non-tunable metrics. Defaults toFalse. |
| Type | Description |
|---|---|
List[str] | List of metric keys with valid (non-NaNs) rolling_func values. |
get_all_pf_metrics
| Name | Type | Default | Description |
|---|---|---|---|
include_non_tunable | bool | False | Whether to include non-tunable metrics. Defaults to False. |
| Type | Description |
|---|---|
List[str] | List of metric keys with valid (non-NaNs) pf_func values. |
get_all_non_tunable_metrics
| Type | Description |
|---|---|
List[str] | List of non-tunable metrics. |
run
vbt.deep_get_attr. Only includes metrics
with non-None and string-type values.
- Metrics with
Noneor missing are excluded. - The function stops iterating once all requested metrics are found.
- Input validation ensures all provided metrics exist in the registry.
| Name | Type | Default | Description |
|---|---|---|---|
pf | vbt.Portfolio | -- | Portfolio instance. |
metrics | str | -- | or list of str A single metric key or a list of metric keys to look up in the registry. |
key | str | -- | Type of key to fetch. |
frame_to_dict | bool | True | Change frame format output to dict type if set to True. Raw pd.DataFrame object data otherwise. Frames are retrieve when group_by is False in the vbt.PF configuration and/or when rolling calculation is triggered. Defaults to True. |
validate_metrics | bool | True | Check if metric is valid in the registry. Might slow-down code if set to True. Defaults to True. |
kwargs | tp.Kwargs | -- | Additional key-word arguments. |
| Type | Description |
|---|---|
KeyError | If any provided metric key is not found in the registry. |
| Type | Description |
|---|---|
tp.Dict[str, float | tp.SeriesFrame] | Dictionary mapping valid metric keys to their corresponding output values. |
run_rolling_metric
vbt.deep_get_attr. Only
includes metrics with non-None and string-type values.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
pf | vbt.Portfolio | -- | Portfolio instance. |
metrics | str | -- | or list of str A single metric key or a list of metric keys to look up in the registry. |
window | int | -- | Rolling window size. |
minp | int | None | Minimum number of observations required. |
to_numpy | bool | False | If False, returns a pandas DataFrame. Otherwise a numpy array. |
validate_metrics | bool | True | Check if metric is valid in the registry. Might slow-down code if set to True. Defaults to True. |
kwargs | tp.Kwargs | -- | Additional key-word arguments. |
| Type | Description |
|---|---|
pd.DataFrame | tp.Array | Rolling output. |
run_pf_metric
vbt.deep_get_attr. Only
includes metrics with non-None and string-type values.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
pf | vbt.Portfolio | -- | Portfolio instance. |
metrics | str | -- | or list of str A single metric key or a list of metric keys to look up in the registry. |
frame_to_dict | bool | True | Change frame format output to dict type if set toTrue. Raw pd.DataFrame object data otherwise. Frames are retrieve when group_by is False in the vbt.PF configuration. Defaults to True. |
to_numpy | bool | False | If False, returns a pandas DataFrame. Otherwise a numpy array. |
validate_metrics | bool | True | Check if metric is valid in the registry. Might slow-down code if set to True. Defaults to True. |
kwargs | tp.Kwargs | -- | Additional key-word arguments. |
| Type | Description |
|---|---|
OrderedDict | Float or int if metrics is standalone. OrderedDict mapping valid metric keys to their corresponding output. |

