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

Feature Request: Please add "is_returns" flag for monthly_heatmap_detailedview #57

Open
BlackArbsCEO opened this issue Aug 19, 2024 · 0 comments

Comments

@BlackArbsCEO
Copy link

when using qs._plotting.core.monthly_heatmap_detailedview it assumes that the data that is passed is in the form of prices. But there are many times where we don't have the "prices" but instead the strategy returns. It would be useful if we could tell the function if the data is in price form and needs conversion to returns or if it is already in daily return format. I give a quick and dirty example below that I did in my local version.


def monthly_heatmap_detailedview(
        returns,
        is_daily_returns=False,
        grayscale=False,
        figsize=(14, 6),
        annot_size=11,
        returns_label="Strategy",
        fontname="Arial",
        monthly_dd_font_rate=0.8,
        annual_dd_font_rate=0.8,
        return_font_rate=1.0,
        savefig=None,
        show=True,
):
    if is_daily_returns:
        daily_returns = returns.copy()
    else:
        daily_returns = returns.pct_change(fill_method=None).fillna(0)
    monthly_returns = daily_returns.resample('ME').apply(lambda x: (x + 1).prod() - 1) * 100
    monthly_drawdowns = calculate_monthly_drawdowns(returns) * 100

    monthly_combined = _pd.DataFrame({
        "Returns": monthly_returns,
        "Drawdowns": monthly_drawdowns
    })

    #...rest of function...
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

1 participant