mizarlabs.transformers.trading package

Submodules

mizarlabs.transformers.trading.bet_sizing module

class mizarlabs.transformers.trading.bet_sizing.BetSizingBase[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Base class for bet sizing transformers

transform(X: pandas.core.frame.DataFrame)pandas.core.series.Series[source]
class mizarlabs.transformers.trading.bet_sizing.BetSizingFromProbabilities(num_classes: int, average_active: bool = False, meta_labeling: bool = False, discretise: bool = False, step_size: Optional[float] = None, probability_column_name: str = 'prob', prediction_column_name: str = 'pred', side_column_name: str = 'side', event_end_time_column_name: str = 'event_end_time', bet_size_column_name: str = 'bet_size')[source]

Bases: mizarlabs.transformers.trading.bet_sizing.BetSizingBase

Calculate the bet size using the predicted probability.

Parameters
  • num_classes (int) – Number of labeled classes

  • average_active (bool, optional) – Whether we need to apply the average active to the bet sizing signal

  • meta_labeling (bool, optional) – Whether the bet sizing is calculated from a metalabeling signal

  • discretise (bool, optional) – Whether the output needs to be discretised

  • step_size (int, optional) – The step size of the discretisation

  • probability_column_name (str, optional) – The column name of the probabilities

  • prediction_column_name (str, optional) – The column name of the predictions

  • side_column_name (str, optional) – The column name of the side of the ‘simpler’ metalabeling model

  • event_end_time_column_name – The column name of the event end time

Rtype event_end_time_column_name

str, optional

mizarlabs.transformers.trading.bet_sizing.avg_active_signals(signals: pandas.core.frame.DataFrame, event_end_time_column_name: str = 'event_end_time', bet_size_column_name: str = 'bet_size')pandas.core.series.Series[source]

Average the bet sizes of all concurrently not closed positions (e.i. no barrier has been hit yet)

Parameters
  • signals – Signal from which the active average is calculated

  • event_end_time_column_name (str, optional) – the name of the event end time

  • bet_size_column_name (str, optional) – the name of the bet size column

Rtype signals

pd.DataFrame

Returns

The active average signal

Return type

pd.DataFrame

mizarlabs.transformers.trading.bet_sizing.discretise_signal(signal: pandas.core.series.Series, step_size: float)pandas.core.series.Series[source]

Discretise the bet size signal based on the step size given.

Parameters
  • signal (pd.Series) – Signal to discretise

  • step_size (float) – the step size to use for the discretisation

Returns

Discretised signal

Return type

pd.Series

Module contents