ActiveState Recipes站点具有在Python中实现
Internal Rate of Return的功能:
def irr(cashflows, iterations=100):
"""The IRR or Internal Rate of Return is the annualized effective
compounded return rate which can be earned on the invested
python为什么叫爬虫。capital, i.e., the yield on the investment.
>>> irr([-100.0, 60.0, 60.0, 60.0])
0.36309653947517645
"""
rate = 1.0
investment = cashflows[0]
python计算存款收益代码?for i in range(1, iterations+1):
rate *= (1 - npv(rate, cashflows) / investment)
return rate
此代码返回正确的值(至少对于我已针对Excel检查的几个示例),但我想知道原因.
>它似乎不是牛顿方法(无衍生物)或正割方法(仅跟踪一次迭代)的实现.
>特别是,投资变量作为第一个现金流元素(以及随后的使用)的定义让我感到困惑.
python输入,有任何想法吗?
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态