作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何在 PHP 中实现 MS Excel 的“IRR()”公式?
我尝试了this page中提到的算法但结果不准确,而且速度非常慢。
最佳答案
经过一段时间的调查,我最终复制了下面的函数。
它基于this question .
function IRR($investment, $flow, $precision = 0.001) {
$min = 0;
$max = 1;
$net_present_value = 1;
while(abs($net_present_value - $investment) > $precision) {
$net_present_value = 0;
$guess = ($min + $max) / 2;
foreach ($flow as $period => $cashflow) {
$net_present_value += $cashflow / (1 + $guess) ** ($period + 1);
}
if ($net_present_value - $investment > 0) {
$min = $guess;
} else {
$max = $guess;
}
}
return $guess * 100;
}
关于PHP IRR(内部 yield )财务函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45246808/
我尝试进行投资组合优化,但随后出现了TypeError: minimize_sharpe() missing 1 required positional argument: 'log_returns'
考虑到 future 的速度读取和存档的全局大小,存储报价数据(开盘价、最高价、最低价、收盘价、成交量)的最有效方法是什么? XML ? But It is resource consumption
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 4年前关闭。 Improve thi
我正在尝试从 Yahoo! 检索市场数据财务和脚本多年来一直运行良好,但最近,它停止显示道琼斯数据。这是网址: http://download.finance.yahoo.com/d/quotes.c
因此,当我使用组合图表(条形图 + 折线图)时,我对以前版本的 Chartjs(即 2.5)遇到了一些问题,并且在处理时间序列数据时遇到了困难。 就上下文而言,我使用的是财务数据(股票价格和交易量)。
我是一名优秀的程序员,十分优秀!