未來價值與複利頻率

使用 Python 進行債券評價與分析

Joshua Mayhew

Options Trader

多筆現金流的複利

  • 存入 USD 1,000
  • 月付 3% 利率
  • 每月月底追加 USD 100
  • 3 個月後有多少?
使用 Python 進行債券評價與分析

多筆現金流的複利

deposit_fv = 1000 * (1 + 0.03) ^ 3

topup_1_fv = 100 * (1 + 0.03) ^ 2
topup_2_fv = 100 * (1 + 0.03) ^ 1
topup_3_fv = 100
print(deposit_fv + topup_1_fv + topup_2_fv + topup_3_fv)
1401.82
print(deposit_fv + topup_1_fv + topup_2_fv + topup_3_fv - 1000 - 100 - 100 - 100)
101.82
使用 Python 進行債券評價與分析

未來價值函式

  • 先前做法會非常重複
  • NumPy Financial 可簡化這些計算
import numpy_financial as npf

?npf.fv
Signature: npf.fv(rate, nper, pmt, pv)

Given: * an interest `rate` compounded once per period, of which there are
* `nper` total
* a (fixed) payment, `pmt`
* a present value, `pv`
Return: the value at the end of the `nper` periods
使用 Python 進行債券評價與分析

未來價值函式

  • 利率:每期(每月)3%
  • 期數:3 個月
  • 支付:每月月底追加 USD -100
  • PV:存入 USD -1,000
使用 Python 進行債券評價與分析

未來價值函式

npf.fv(rate=0.03, nper=3, pmt=-100, pv=-1000)
1401.82
使用 Python 進行債券評價與分析

複利頻率

將 USD 1,000 投資 10 年(無追加),在以下情況各有多少?

  • 年息 5%,每年複利
  • 年息 5%,每月複利
  • 年息 5%,每日複利
使用 Python 進行債券評價與分析

複利頻率

  • 將利率除以複利頻率,期數乘上複利頻率
# 使用每年複利頻率
npf.fv(rate=0.05, nper=10, pmt=0, pv=-1000)
1628.89
# 使用每月複利頻率
npf.fv(rate=0.05/12, nper=10*12, pmt=0, pv=-1000)
1647.01
# 使用每日複利頻率
npf.fv(rate=0.05/365, nper=10*365, pmt=0, pv=-1000)
1648.66
使用 Python 進行債券評價與分析

一起來練習吧!

使用 Python 進行債券評價與分析

Preparing Video For Download...