这是在 php 中(我认为):来自这个页面
/**
* ACCRINT
*
* Returns the discount rate for a security.
*
* @param mixed issue The security's issue date.
* @param mixed firstinter The security's first interest date.
* @param mixed settlement The security's settlement date.
* @param float rate The security's annual coupon rate.
* @param float par The security's par value.
* @param int 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
*/
public static function ACCRINT($issue, $firstinter, $settlement, $rate, $par=1000, $frequency=1, $basis=0) {
$issue = self::flattenSingleValue($issue);
$firstinter = self::flattenSingleValue($firstinter);
$settlement = self::flattenSingleValue($settlement);
$rate = (float) self::flattenSingleValue($rate);
$par = (is_null($par)) ? 1000 : (float) self::flattenSingleValue($par);
$frequency = (is_null($frequency)) ? 1 : (int) self::flattenSingleValue($frequency);
$basis = (is_null($basis)) ? 0 : (int) self::flattenSingleValue($basis);
// Validate
if ((is_numeric($rate)) && (is_numeric($par))) {
if (($rate <= 0) || ($par <= 0)) {
return self::$_errorCodes['num'];
}
$daysBetweenIssueAndSettlement = self::YEARFRAC($issue, $settlement, $basis);
if (!is_numeric($daysBetweenIssueAndSettlement)) {
return $daysBetweenIssueAndSettlement;
}
$daysPerYear = self::_daysPerYear(self::YEAR($issue),$basis);
if (!is_numeric($daysPerYear)) {
return $daysPerYear;
}
$daysBetweenIssueAndSettlement *= $daysPerYear;
return $par * $rate * ($daysBetweenIssueAndSettlement / $daysPerYear);
}
return self::$_errorCodes['value'];
} // function ACCRINT()