更多金融函数

用 Python 进行债券定价与分析

Joshua Mayhew

Options Trader

nper() 函数

  • 告诉您将现值增长到终值所需的期数
import numpy_financial as npf
?npf.nper
Signature: npf.nper(rate, pmt, pv, fv=0)

Compute the number of periodic payments.

Parameters rate : Rate of interest (per period)
pmt : Payment
pv : Present value
fv : (optional) Future value
用 Python 进行债券定价与分析

nper() 函数

  • 每月投资 USD 270,年利率 5%(月复利),攒到 USD 7,000 需多长时间?
import numpy_financial as npf
npf.nper(rate=0.05/12, pmt=-270, pv=0, fv=7000)
24.67
用 Python 进行债券定价与分析

pmt() 函数

  • 告诉您将现值增长到终值所需的付款额
import numpy_financial as npf
?npf.pmt
Signature: npf.pmt(rate, nper, pv, fv=0)

Compute the payment against loan principal plus interest.

Given: * an interest `rate` compounded once per period, of which there are
* `nper` total
* a present value, `pv` (e.g., an amount borrowed)
* a future value, `fv` (e.g., 0)
Return: the (fixed) periodic payment.
用 Python 进行债券定价与分析

pmt() 函数

  • 我们以年利率 3.5%(月复利)借入 USD 275,000
  • 10 年内还清房贷需每月还款多少?
import numpy_financial as npf
npf.pmt(rate=0.035/12, nper=10*12, pv=275000, fv=0)
-2719.36
用 Python 进行债券定价与分析

rate() 函数

  • 告诉您将现值增长到终值所需的利率
import numpy_financial as npf
?npf.rate
Signature: npf.rate(nper, pmt, pv, fv)

Compute the rate of interest per period.

Parameters nper : Number of compounding periods
pmt : Payment
pv : Present value
fv : Future value
用 Python 进行债券定价与分析

rate() 函数

  • 30 年后退休需要多少投资回报?
  • 您每月存 USD 1,500,目标为 USD 100 万。
  • 假设按月复利。
import numpy_financial as npf
12 * npf.rate(nper=30*12, pmt=-1500, pv=0, fv=1000000)
0.0377
用 Python 进行债券定价与分析

开始练习!

用 Python 进行债券定价与分析

Preparing Video For Download...