47 if (!is_numeric($f1) || !is_numeric($f2)) {
50 if (($f1 * $f2) < 0.0) {
54 } elseif (abs($f1) < abs($f2)) {
101 if ((!is_array(
$values)) && (!is_array($dates))) {
106 if (count(
$values) != count($dates)) {
110 $datesCount = count($dates);
111 for (
$i = 0;
$i < $datesCount; ++
$i) {
115 return $e->getMessage();
127 for (
$i = 0;
$i < $valCount; ++
$i) {
129 if (!is_numeric($fld)) {
131 } elseif ($fld > 0) {
133 } elseif ($fld < 0) {
137 if (!self::bothNegAndPos($foundneg, $foundpos)) {
163 if ((abs($f_mid) < self::FINANCIAL_PRECISION) || (abs($dx) < self::FINANCIAL_PRECISION)) {
184 return $e->getMessage();
188 for (
$i = 0;
$i < $valCount; ++
$i) {
196 return $e->getMessage();
198 if ($date0 > $datei) {
203 if (!is_numeric($dif)) {
206 $xnpv +=
$values[
$i] / (1 + $rate) ** ($dif / 365);
214 if (!is_numeric($rate)) {
218 if ($valCount != count($dates)) {
221 if ($valCount > 1 && ((min(
$values) > 0) || (max(
$values) < 0))) {
An exception for terminatinating execution or to throw for unit testing.
static interval($startDate, $endDate, $unit='D')
DATEDIF.
static getDateValue($dateValue, bool $allowBool=true)
getDateValue.
static bothNegAndPos($neg, $pos)
const FINANCIAL_MAX_ITERATIONS
static presentValue($rate, $values, $dates)
XNPV.
static xirrPart2(&$values)
static xnpvOrdered($rate, $values, $dates, $ordered=true)
static xirrPart3($values, $dates, $x1, $x2)
static validateXnpv($rate, $values, $dates)
const FINANCIAL_PRECISION
static xirrPart1(&$values, &$dates)
static rate($values, $dates, $guess=0.1)
XIRR.
static flattenArray($array)
Convert a multi-dimensional array to a simple 1-dimensional array.
static flattenSingleValue($value='')
Convert an array to a single scalar value by extracting the first element.