macrosynergy.learning.forecasting.torch.modules#
- class LongShortModule(dollar_neutral=False)[source]#
Bases:
ModuleNormalizes a neural network layer so that the sum of absolute values equals one.
- Parameters:
dollar_neutral (bool, default=False) – If True, the layer is first demeaned to ensure that the sum of the outputs equals zero.
Notes
Whilst this can be used as a standalone layer, this has been designed to be used as the final layer of a neural network to ensure that the outputs can be interpreted as fractions of capital allocated to a collection of assets, with allowance for both long and short positions.
If dollar_neutral is set to True, equal capital is allocated to long and short positions.