計算未來價值
計算未來價值是建立債券定價觀念的重要一步,因為債券定價其實就是把未來價值的計算反過來算。這裡你會使用先前的 npf.fv() 公式,求出一項投資的未來價值。
本練習屬於課程
使用 Python 進行債券評價與分析
練習說明
- 將
numpy_financial套件以別名npf匯入。 - 計算一筆投資:投入 10,000 美元,每年再加碼 5,000 美元,投資 30 年,年利率 5% 的未來價值,並將結果指定給
savings。 - 列印結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import numpy_financial package using the alias npf
____
# Calculate the future value of an investment
savings = npf.fv(rate=____, nper=____, pmt=____, pv=____)
# Print the result
____