def ema(data, num):
    """

    Parameters
    ----------
    data : Data for calculate Ema
    num : Number of Ema's period 

    Returns
    -------
    ema : Exponential moving avarage

    """
    ema=0
    k = 2 / (num+1)
    if ema == 0:
        first_ema = sum(data[-num : -1]) / (num-1)
        ema = data[-1] * k + first_ema * (1-k)
    else:
        ema = data[-1]* k + ema * (1-k)
    return ema