Skip to content

decorators module

Class decorators for portfolio.


attach_returns_acc_methods function

attach_returns_acc_methods(
    config
)

Class decorator to attach returns accessor methods.

config must contain target method names (keys) and settings (values) with the following keys:

  • source_name: Name of the source method. Defaults to the target name.
  • docstring: Method docstring.

The class must be a subclass of Portfolio.


attach_shortcut_properties function

attach_shortcut_properties(
    config
)

Class decorator to attach shortcut properties.

config must contain target property names (keys) and settings (values) with the following keys:

  • method_name: Name of the source method. Defaults to the target name prepended with the prefix get_.
  • use_in_outputs: Whether the property can return an in-place output. Defaults to True.
  • method_kwargs: Keyword arguments passed to the source method. Defaults to None.
  • decorator: Defaults to cached_property for object types 'records' and 'red_array'. Otherwise, to cacheable_property.
  • docstring: Method docstring.
  • Other keyword arguments are passed to the decorator and can include settings for wrapping, indexing, resampling, stacking, etc.

The class must be a subclass of Portfolio.