What is Calmar Ratio?

1. Purpose

I will explain the meaning and calculation method of Calmar Ratio.

2 Contents

2-1 Return calculation method

Return from the start date to the current day of a certain issue [follows this definition](https://qiita.com/NT1123/items/096dc41c24751934747e#2-1-return%E3%81%AE%E5%AE%9A % E7% BE% A9).

2-2 How to calculate Max dropdown

It is an expression that evaluates the rate at which Return falls and bottoms out after the maximum of Return. </ b>

Specifically, let the maximum value of Return be $ R_ {max} ^ {(n)} $ in the period from the start date to n business days.

R_{max}^{(n)}=max\left\{R_{i} | 0<i≦n \right\}

Here, Maxdrowdown $ MDD_ {max} ^ {(n)} $ is defined by the following formula.

MDD_{max}^{(n)}=max\left\{\frac{R_{max}^{(n)}}{R_{i}} | 0<i≦n \right\}
90.JPG

2-3 Calmar Ratio calculation method

Definition formula of Calmar Ratio

Calmar Ratio=\frac{CAGR(n)}{MDD_{max}^{(n)}}

The CAGR definition formula is listed here.

Supplement: Compared to Shapen Ratio, Calmar Ratio is an index that considers the worst rate of decline. </ b>

2-4 Calmar Ratio calculation formula code example

test.py


def CAGR(DF):
    df = DF.copy()
    df["daily_ret"] = DF["Close"].pct_change() #Calculate the rate of change from the day before the closing price of the stock price.
    df["cum_return"] = (1 + df["daily_ret"]).cumprod() #cumprod(Returns the cumulative product of all elements in a scalar y.
    n = len(df)/252 #The trading day for one year is set to 252 days.
    print( "df[cum_return]" )    
    print( df["cum_return"] )
    print( "df[cum_return][-1] ")           
    print( df["cum_return"][-1] )    
    CAGR = (df["cum_return"][-1])**(1/n) - 1
    return CAGR

def max_dd(DF):
    "function to calculate max drawdown"
    df = DF.copy()
    df["daily_ret"] = DF["Close"].pct_change()
    df["cum_return"] = (1 + df["daily_ret"]).cumprod()  #cumprod()Multiply all elements.
    print(df["cum_return"])

    #ax.legend() #Draw a legend
    df["cum_roll_max"] = df["cum_return"].cummax()
    df["drawdown"] = df["cum_roll_max"] - df["cum_return"]
    df["drawdown_pct"] = df["drawdown"]/df["cum_roll_max"]
    max_dd = df["drawdown_pct"].max()
    ax=df["cum_return"].plot(marker="*",figsize=(10, 5))    
    ax=df["cum_roll_max"].plot(marker="*",figsize=(10, 5))    
    ax=df["drawdown"].plot(marker="*",figsize=(10, 5))   
    ax=df["drawdown_pct"].plot(marker="*",figsize=(10, 5))       
    ax.legend() #Draw a legend
    return max_dd
    
def calmar(DF):
    "function to calculate calmar ratio"
    df = DF.copy()
    clmr = CAGR(df)/max_dd(df)
    return clmr

Recommended Posts