Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_years_past() clarification #11

Open
kmcminn opened this issue Sep 8, 2021 · 1 comment
Open

get_years_past() clarification #11

kmcminn opened this issue Sep 8, 2021 · 1 comment

Comments

@kmcminn
Copy link

kmcminn commented Sep 8, 2021

trying to unpack this. pd.Series.index returns integers when I pass a log return series to this function and thus (end_date - start_date) evaluates to a single element tuple

def get_years_past(series: pd.Series) -> float:
    """
    Calculate the years past according to the index of the series for use with
    functions that require annualization   
    """
    start_date = series.index[0]
    end_date = series.index[-1]
    return (end_date - start_date).days / 365.25
    ```
@chrisconlan
Copy link
Owner

Hey there, sorry for the late reply. The output of this function is intended to be a precise and easy-to-access annualization factor for metrics like the Sharpe ratio that require it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants