public static function PHPExcel_Calculation_Financial::INTRATE in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Calculation/Financial.php \PHPExcel_Calculation_Financial::INTRATE()
* INTRATE * * Returns the interest rate for a fully invested security. * * Excel Function: * INTRATE(settlement,maturity,investment,redemption[,basis]) * *
Parameters
mixed $settlement The security's settlement date.: * The security settlement date is the date after the issue date when the security is traded to the buyer. * @param mixed $maturity The security's maturity date. * The maturity date is the date when the security expires. * @param integer $investment The amount invested in the security. * @param integer $redemption The amount to be received at maturity. * @param integer $basis The type of day count to use. * 0 or omitted US (NASD) 30/360 * 1 Actual/actual * 2 Actual/360 * 3 Actual/365 * 4 European 30/360 * @return float
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php, line 1253
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function INTRATE($settlement, $maturity, $investment, $redemption, $basis = 0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$investment = PHPExcel_Calculation_Functions::flattenSingleValue($investment);
$redemption = PHPExcel_Calculation_Functions::flattenSingleValue($redemption);
$basis = PHPExcel_Calculation_Functions::flattenSingleValue($basis);
// Validate
if (is_numeric($investment) && is_numeric($redemption) && is_numeric($basis)) {
$investment = (double) $investment;
$redemption = (double) $redemption;
$basis = (int) $basis;
if ($investment <= 0 || $redemption <= 0) {
return PHPExcel_Calculation_Functions::NaN();
}
$daysBetweenSettlementAndMaturity = PHPExcel_Calculation_DateTime::YEARFRAC($settlement, $maturity, $basis);
if (!is_numeric($daysBetweenSettlementAndMaturity)) {
// return date error
return $daysBetweenSettlementAndMaturity;
}
return ($redemption / $investment - 1) / $daysBetweenSettlementAndMaturity;
}
return PHPExcel_Calculation_Functions::VALUE();
}