ActiveState Recipesサイトには、Pythonで内部収益率を実装する機能があります。
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
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]
for i in range(1, iterations+1):
rate *= (1 - npv(rate, cashflows) / investment)
return rate
このコードは正しい値を返します(少なくともExcelに対してチェックしたいくつかの例では)が、その理由を知りたいと思います。
- ニュートン法(導関数なし)または割線法(1回の反復のみを追跡する)の実装ではないようです。
- 特に、最初のキャッシュフロー要素としての投資変数の定義(およびその後の使用)は私を混乱させます。
何か案は?