ranaroussi / quantstats

Portfolio analytics for quants, written in Python
Apache License 2.0
4.73k stars 827 forks source link

Risk Of Ruin Formula #298

Open eddiecailinux opened 1 year ago

eddiecailinux commented 1 year ago

can you give me the Risk Of Ruin Formula? I found formula here: https://www.newtraderu.com/2021/03/13/risk-of-ruin-formula/ and here: https://moneyzine.com/investments/risk-of-ruin/ they use below formla to calculate risk of ruin, which is quite different from quantstats using. Risk of Ruin = ((1 - (W - L)) / (1 + (W - L)))U W = The probability of a winning trade. L = The probability of a loss. U = The maximum number of trading risks that can be taken before the trader reaches their threshold for being ruined.

issamansur commented 1 year ago
def risk_of_ruin(returns, prepare_returns=True):
    """
    Calculates the risk of ruin
    (the likelihood of losing all one's investment capital)
    """
    if prepare_returns:
        returns = _utils._prepare_returns(returns)
    wins = win_rate(returns)
    return ((1 - wins) / (1 + wins)) ** len(returns)
issamansur commented 1 year ago

from https://patternswizard.com/risk-of-ruin/

grzesir commented 1 month ago

Check out https://github.com/Lumiwealth/quantstats_lumi, which is being updated regularly. We are a fork of this library that is being maintained by Lumiwealth