maxdrawdown             package:tseries             R Documentation

_M_a_x_i_m_u_m _D_r_a_w_d_o_w_n _o_r _M_a_x_i_m_u_m _L_o_s_s

_D_e_s_c_r_i_p_t_i_o_n:

     This function computes the maximum drawdown or maximum loss of the
     univariate time series (or vector) `x'.

_U_s_a_g_e:

     maxdrawdown(x)

_A_r_g_u_m_e_n_t_s:

       x: a numeric vector or univariate time series.

_D_e_t_a_i_l_s:

     The max drawdown or max loss statistic is defined as the maximum
     value drop after one of the peaks of `x'. For financial
     instruments the max drawdown represents the worst investment loss
     for a buy-and-hold strategy invested in `x'.

_V_a_l_u_e:

     A list containing the following two components: 

maxdrawdown: double representing the max drawdown or max loss
          statistic.

    from: the index where the max drawdown period starts.

      to: the index where the max drawdown period ends.

_A_u_t_h_o_r(_s):

     A. Trapletti

_E_x_a_m_p_l_e_s:

     # Toy example
     x <- c(1:10, 9:7, 8:14, 13:8, 9:20)
     mdd <- maxdrawdown(x)
     mdd

     plot(x)
     segments(mdd$from, x[mdd$from], mdd$to, x[mdd$from], col="grey")
     segments(mdd$from, x[mdd$to], mdd$to, x[mdd$to], col="grey")
     mid <- (mdd$from + mdd$to)/2
     arrows(mid, x[mdd$from], mid, x[mdd$to], col="red", length = 0.16)

     # Realistic example
     data(EuStockMarkets)
     dax <- log(EuStockMarkets[,"DAX"])
     mdd <- maxdrawdown(dax)
     mdd

     plot(dax)
     segments(time(dax)[mdd$from], dax[mdd$from],
              time(dax)[mdd$to], dax[mdd$from], col="grey")
     segments(time(dax)[mdd$from], dax[mdd$to],
              time(dax)[mdd$to], dax[mdd$to], col="grey")
     mid <- time(dax)[(mdd$from + mdd$to)/2]
     arrows(mid, dax[mdd$from], mid, dax[mdd$to], col="red", length = 0.16)

