Skip to content

Refactor risk and return models #3

Description

@robertmartin8

Currently, there is a lot of repeated code within risk_models.py and expected_returns.py.

Almost all of the functions therein take prices as inputs, before processing them into returns, with the following couple of lines repeated a lot.

    if not isinstance(prices, pd.DataFrame):
        warnings.warn("prices are not in a dataframe", RuntimeWarning)
        prices = pd.DataFrame(prices)
    daily_returns = prices.pct_change().dropna(how="all")

In the spirit of DRY, I'd like to refactor this without complicating the API. Haven't decided the best way of proceeding. I suppose I could put these lines into a function, but that would probably need to go in a separate file (not very elegant IMO).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions