コード例 #1
0
ファイル: Finance.php プロジェクト: altesien/FinalProject
 /**
 * Returns the price per $100 face value of a discounted bond
 * Excel equivalent: PRICEDISC
 *
 * @param int        Settlement date (UNIX timestamp)
 * @param int        Maturity date (UNIX timestamp)
 * @param float      The bond's discount rate
 * @param float      The bond's redemption value per $100 face value
 * @param int        Type of day count basis:
                         FINANCE_COUNT_NASD(default):    US(NASD) 30/360
                         FINANCE_COUNT_ACTUAL_ACTUAL:    Actual/actual
                         FINANCE_COUNT_ACTUAL_360:       Actual/360
                         FINANCE_COUNT_ACTUAL_365:       Actual/365
                         FINANCE_COUNT_EUROPEAN:         European 30/360
 * @return float     
 * @static
 * @access public
 */
 function priceDiscount($settlement, $maturity, $discount, $redemption, $basis = 0)
 {
     $days_per_year = Math_Finance::daysPerYear(date('Y', $settlement), $basis);
     $dsm = Math_Finance::daysDifference($settlement, $maturity, $basis);
     return $redemption - $discount * $redemption * $dsm / $days_per_year;
 }
コード例 #2
0
 function testdepreciationSYD()
 {
     $this->assertTrue(abs(4090.909091 - Math_Finance::depreciationSYD(30000, 7500, 10, 1)) < FINANCE_PRECISION);
     $this->assertTrue(abs(409.090909 - Math_Finance::depreciationSYD(30000, 7500, 10, 10)) < FINANCE_PRECISION);
 }