Skip to main content

BaseTransformer

BaseTransformer()
Base class for transforming trading metrics.

Ancestors

  • abc.ABC

Descendants

  • systematica.portfolio.transformers.logistic.Logistic

Methods

transform

transform(
    self,
    metrics: Dict[strfloat],
) ‑> Dict[strfloat]
Transform metrics based on the selected transformation method. Parameters:
NameTypeDefaultDescription
metricstp.Dict[str, float]--A dictionary containing performance metrics, where keys are metric names and values are their corresponding values.
Returns:
TypeDescription
tp.Dict[str, float]A dictionary of transformed metrics, where keys are the same as input and values are the transformed values.

Reward

Reward(
    transformer: systematica.portfolio.transformers.base.BaseTransformer,
    weights: Dict[strfloat= _Nothing.NOTHING,
)
Computes a composite reward score. This class computes a reward score as a weighted sum of processed metrics. It uses a processor to transform the raw metrics and applies weights to each metric. The weight for ‘max_drawdown’ is inverted because a lower value is preferable. Method generated by attrs for class Reward.

Instance variables

  • transformer: systematica.portfolio.transformers.base.BaseTransformer: An instance of a transformer to process the metrics. If None, defaults to Logistic.
  • weights: Dict[str, float]: A dictionary mapping metric names to weights. Defaults to an empty dictionary.

Methods

run

run(
    self,
    metrics: Dict[strfloat],
) ‑> float
Calculate the composite reward score. This method adjusts specific metrics (e.g., inverting ‘max_drawdown’), processes the metrics using the assigned processor, and computes a weighted sum of the processed metrics to derive a composite reward score. Parameters:
NameTypeDefaultDescription
metricstp.Dict[str, float]--A dictionary containing performance metrics. If max_drawdown is present, its value will be inverted prior to processing.
Returns:
TypeDescription
floatThe computed composite reward score.