admin管理员组

文章数量:1558064

一、前言

在财务与nump_financial的路上越走越远了,自从上次学习了终值公式,一发不可收拾,继续学习净现值公式。
现值(present value)是指资产在当前时刻的价值。净现值(net present value)定义为按折现率计算的净现金流之和。
今天学习用numpy_financial的财务净现值公式来计算净现值。

二、程序展示

1、例子描述

现金流量为:-150, 42,48,88,20,38,
利率为3%
计算净现值。

2、净现值计算公式

这个地方要注意,npf.npv的计算公式中,有一段描述:
npv considers a series of cashflows starting in the present (t = 0).
NPV can also be defined with a series of future cashflows, paid at the
end, rather than the start, of each period. If future cashflows are used,
the first cashflow values[0] must be zeroed and added to the net
present value of the future cashflows. This is demonstrated in the
examples.
主要意思就是必须在现金流的数组中,在最前面增加一个0。也就是下面的cash_flows[0]必须为0,要不然计算结果不正确。

import numpy_financial as npf

cash_flows = [0,-150, 42,48,88,20,38] 
netPv = npf.npv(0.03,cash_flows)
print("净现值为:",netPv)

计算结果为:
净现值为: 65.14819752964704

本文标签: 现值现金流利率公式资金