Compute the Macaulay and modified duration of a bond from its cash flows.
Macaulay 久期 = 各期现金流现值乘以其时间 t 之和除以债券价格;修正久期 = Macaulay 除以 (1+每期收益率),表示收益率变动 1% 时价格变动的百分比。