未來價值
numpy 模組也提供類似的函式 .fv(rate, nper, pmt, pv),可以用簡單的幾個參數計算投資的未來價值:
- rate: 投資的報酬率
- nper: 投資期間
- pmt: 每期期初或期末的(固定)付款金額(本例為 0)
- pv: 投資的現值
請注意,在這個函式呼叫中,若 pv 代表的是「負的現金流」(也就是資金流出),就必須傳入「負值」。換句話說,若你要計算一個需要先支付現金的投資之未來價值,在 .fv() 的 pv 參數就需要傳入負值。
本練習屬於課程
Python 金融概念入門
練習說明
- 使用 NumPy 的
.fv()函式,計算一筆 $10,000 投資以每年 5% 報酬率、投資 15 年的未來價值,並指定給investment_1。 - 計算一筆 $10,000 投資以每年 8% 報酬率、投資 15 年的未來價值,並指定給
investment_2。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
import numpy as np
# Calculate investment_1
investment_1 = ____(rate=____, nper=____, pmt=0, pv=____)
print("Investment 1 will yield a total of $" + str(round(investment_1, 2)) + " in 15 years")
# Calculate investment_2
investment_2 = ____
print("Investment 2 will yield a total of $" + str(round(investment_2, 2)) + " in 15 years")