来自numpy.irr和Excel IRR函数的IRR结果不同

时间:2018-10-12 03:22:59

标签: python numpy excel-formula

我有以下年度现金流量:

w=np.array([   -56501, -14918073,  -1745198, -20887403,  -9960686, -31076934,
               0,         0,  11367846,  26736802,  -2341940,  20853917,
        22166416,  19214094,  23056582, -11227178,  18867100,  24947517,
        28733869,  24707603, -17030396,   7753089,  27526723,  31534327,
        26726270, -24607953,  11532035,  29444013,  24350595,  30140678,
       -33262793,   5640172,  32846900,  38165710,  31655489, -74343373,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,         0,         0,         0,         0,         0,
               0,  -8727068])

我使用np.irr计算IRR

np.irr(w)
Out[141]: -0.05393588064654964

当我在Excel中使用IRR函数获得相同的现金流量时,我得到了12%。 这两个函数通常会产生相同的结果。有谁知道为什么在这种情况下结果如此不同?谢谢!

1 个答案:

答案 0 :(得分:1)

对于给定的现金流量,内部收益率不是唯一的;参见Multiple IRRsr的numpy和Excel值都满足NPV(r) = 0,其中NPV是净现值。

以下是w中数据的NPV(r)图。红星标记IRR值(其中NPV(r)为零)。

plot

以下是生成绘图的脚本:

import numpy as np
import matplotlib.pyplot as plt


w = np.array([   -56501, -14918073,  -1745198, -20887403,  -9960686, -31076934,
                      0,         0,  11367846,  26736802,  -2341940,  20853917,
               22166416,  19214094,  23056582, -11227178,  18867100,  24947517,
               28733869,  24707603, -17030396,   7753089,  27526723,  31534327,
               26726270, -24607953,  11532035,  29444013,  24350595,  30140678,
              -33262793,   5640172,  32846900,  38165710,  31655489, -74343373,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,         0,         0,         0,         0,         0,
                      0,  -8727068])

r_excel = 0.1200963665

r_numpy = np.irr(w)

rr = np.linspace(-0.055, 0.16, 500)
npvals = np.array([np.npv(r, w) for r in rr])

plt.plot(rr, npvals/1e6, alpha=0.8)
plt.plot(r_numpy, 0, 'r*')
plt.plot(r_excel, 0, 'r*')

plt.grid(True)
plt.xlabel('r')
plt.ylabel('NPV(r) [millions]')

plt.show()