Skip to content
New: Star-import, signal unraveling, Python 3.12 support, and more

#
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.

#### Cookie consent

We use cookies to recognize your repeated visits and preferences, as well as to measure the effectiveness of our documentation and whether users find what they're searching for. With your consent, you're helping us to make our documentation better.

- Google Analytics
- GitHub

Manage settings