def bond_mod_duration(price, par, T, coup, freq, dy=0.01):
    ytm = bond_ytm(price, par, T, coup, freq)

    ytm_minus = dy - ytm    
    price_minus = bond_price(par, T, ytm_minus, coup, freq)
    
    ytm_plus = ytm + dy
    price_plus = bond_price(par, T, ytm_plus, coup, freq)
    
    mduration = (price_minus-price_plus)/(2.*price*dy)
    return mduration
dataset/ETHPy150Open jamesmawm/Mastering-Python-for-Finance-source-codes/B03898_05_Codes/bond_mod_duration.py/bond_mod_duration/swapped operands of `-`