public static function PHPExcel_Calculation_Financial::COUPDAYS 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::COUPDAYS()
* COUPDAYS * * Returns the number of days in the coupon period that contains the settlement date. * * Excel Function: * COUPDAYS(settlement,maturity,frequency[,basis]) * * @access public * @category Financial Functions *
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 mixed frequency the number of coupon payments per year. * Valid frequency values are: * 1 Annual * 2 Semi-Annual * 4 Quarterly * If working in Gnumeric Mode, the following frequency options are * also available * 6 Bimonthly * 12 Monthly * @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
1 call to PHPExcel_Calculation_Financial::COUPDAYS()
- PHPExcel_Calculation_Financial::PRICE in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Calculation/ Financial.php, line 509
Class
- PHPExcel_Calculation_Financial
- PHPExcel_Calculation_Financial
Code
public static function COUPDAYS($settlement, $maturity, $frequency, $basis = 0) {
$settlement = PHPExcel_Calculation_Functions::flattenSingleValue($settlement);
$maturity = PHPExcel_Calculation_Functions::flattenSingleValue($maturity);
$frequency = (int) PHPExcel_Calculation_Functions::flattenSingleValue($frequency);
$basis = is_null($basis) ? 0 : (int) PHPExcel_Calculation_Functions::flattenSingleValue($basis);
if (is_string($settlement = PHPExcel_Calculation_DateTime::_getDateValue($settlement))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if (is_string($maturity = PHPExcel_Calculation_DateTime::_getDateValue($maturity))) {
return PHPExcel_Calculation_Functions::VALUE();
}
if ($settlement > $maturity || !self::_validFrequency($frequency) || ($basis < 0 || $basis > 4)) {
return PHPExcel_Calculation_Functions::NaN();
}
switch ($basis) {
case 3:
// Actual/365
return 365 / $frequency;
case 1:
// Actual/actual
if ($frequency == 1) {
$daysPerYear = self::_daysPerYear(PHPExcel_Calculation_DateTime::YEAR($maturity), $basis);
return $daysPerYear / $frequency;
}
else {
$prev = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, False);
$next = self::_coupFirstPeriodDate($settlement, $maturity, $frequency, True);
return $next - $prev;
}
default:
// US (NASD) 30/360, Actual/360 or European 30/360
return 360 / $frequency;
}
return PHPExcel_Calculation_Functions::VALUE();
}