@@ -2006,6 +2006,10 @@ public static function SYD($cost, $salvage, $life, $period)
2006
2006
*
2007
2007
* Returns the bond-equivalent yield for a Treasury bill.
2008
2008
*
2009
+ * @Deprecated 1.18.0
2010
+ *
2011
+ * @see Use the bondEquivalentYield() method in the Financial\TreasuryBill class instead
2012
+ *
2009
2013
* @param mixed $settlement The Treasury bill's settlement date.
2010
2014
* The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
2011
2015
* @param mixed $maturity The Treasury bill's maturity date.
@@ -2016,37 +2020,21 @@ public static function SYD($cost, $salvage, $life, $period)
2016
2020
*/
2017
2021
public static function TBILLEQ ($ settlement , $ maturity , $ discount )
2018
2022
{
2019
- $ settlement = Functions::flattenSingleValue ($ settlement );
2020
- $ maturity = Functions::flattenSingleValue ($ maturity );
2021
- $ discount = Functions::flattenSingleValue ($ discount );
2022
-
2023
- // Use TBILLPRICE for validation
2024
- $ testValue = self ::TBILLPRICE ($ settlement , $ maturity , $ discount );
2025
- if (is_string ($ testValue )) {
2026
- return $ testValue ;
2027
- }
2028
-
2029
- if (is_string ($ maturity = DateTime::getDateValue ($ maturity ))) {
2030
- return Functions::VALUE ();
2031
- }
2032
-
2033
- if (Functions::getCompatibilityMode () === Functions::COMPATIBILITY_OPENOFFICE ) {
2034
- ++$ maturity ;
2035
- $ daysBetweenSettlementAndMaturity = DateTime::YEARFRAC ($ settlement , $ maturity ) * 360 ;
2036
- } else {
2037
- $ daysBetweenSettlementAndMaturity = (DateTime::getDateValue ($ maturity ) - DateTime::getDateValue ($ settlement ));
2038
- }
2039
-
2040
- return (365 * $ discount ) / (360 - $ discount * $ daysBetweenSettlementAndMaturity );
2023
+ return Financial \TreasuryBill::bondEquivalentYield ($ settlement , $ maturity , $ discount );
2041
2024
}
2042
2025
2043
2026
/**
2044
2027
* TBILLPRICE.
2045
2028
*
2046
- * Returns the yield for a Treasury bill.
2029
+ * Returns the price per $100 face value for a Treasury bill.
2030
+ *
2031
+ * @Deprecated 1.18.0
2032
+ *
2033
+ * @see Use the price() method in the Financial\TreasuryBill class instead
2047
2034
*
2048
2035
* @param mixed $settlement The Treasury bill's settlement date.
2049
- * The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
2036
+ * The Treasury bill's settlement date is the date after the issue date
2037
+ * when the Treasury bill is traded to the buyer.
2050
2038
* @param mixed $maturity The Treasury bill's maturity date.
2051
2039
* The maturity date is the date when the Treasury bill expires.
2052
2040
* @param int $discount The Treasury bill's discount rate
@@ -2055,53 +2043,21 @@ public static function TBILLEQ($settlement, $maturity, $discount)
2055
2043
*/
2056
2044
public static function TBILLPRICE ($ settlement , $ maturity , $ discount )
2057
2045
{
2058
- $ settlement = Functions::flattenSingleValue ($ settlement );
2059
- $ maturity = Functions::flattenSingleValue ($ maturity );
2060
- $ discount = Functions::flattenSingleValue ($ discount );
2061
-
2062
- if (is_string ($ maturity = DateTime::getDateValue ($ maturity ))) {
2063
- return Functions::VALUE ();
2064
- }
2065
-
2066
- // Validate
2067
- if (is_numeric ($ discount )) {
2068
- if ($ discount <= 0 ) {
2069
- return Functions::NAN ();
2070
- }
2071
-
2072
- if (Functions::getCompatibilityMode () === Functions::COMPATIBILITY_OPENOFFICE ) {
2073
- ++$ maturity ;
2074
- $ daysBetweenSettlementAndMaturity = DateTime::YEARFRAC ($ settlement , $ maturity ) * 360 ;
2075
- if (!is_numeric ($ daysBetweenSettlementAndMaturity )) {
2076
- // return date error
2077
- return $ daysBetweenSettlementAndMaturity ;
2078
- }
2079
- } else {
2080
- $ daysBetweenSettlementAndMaturity = (DateTime::getDateValue ($ maturity ) - DateTime::getDateValue ($ settlement ));
2081
- }
2082
-
2083
- if ($ daysBetweenSettlementAndMaturity > self ::daysPerYear (DateTime::YEAR ($ maturity ), 1 )) {
2084
- return Functions::NAN ();
2085
- }
2086
-
2087
- $ price = 100 * (1 - (($ discount * $ daysBetweenSettlementAndMaturity ) / 360 ));
2088
- if ($ price <= 0 ) {
2089
- return Functions::NAN ();
2090
- }
2091
-
2092
- return $ price ;
2093
- }
2094
-
2095
- return Functions::VALUE ();
2046
+ return Financial \TreasuryBill::price ($ settlement , $ maturity , $ discount );
2096
2047
}
2097
2048
2098
2049
/**
2099
2050
* TBILLYIELD.
2100
2051
*
2101
2052
* Returns the yield for a Treasury bill.
2102
2053
*
2054
+ * @Deprecated 1.18.0
2055
+ *
2056
+ * @see Use the yield() method in the Financial\TreasuryBill class instead
2057
+ *
2103
2058
* @param mixed $settlement The Treasury bill's settlement date.
2104
- * The Treasury bill's settlement date is the date after the issue date when the Treasury bill is traded to the buyer.
2059
+ * The Treasury bill's settlement date is the date after the issue date
2060
+ * when the Treasury bill is traded to the buyer.
2105
2061
* @param mixed $maturity The Treasury bill's maturity date.
2106
2062
* The maturity date is the date when the Treasury bill expires.
2107
2063
* @param int $price The Treasury bill's price per $100 face value
@@ -2110,35 +2066,7 @@ public static function TBILLPRICE($settlement, $maturity, $discount)
2110
2066
*/
2111
2067
public static function TBILLYIELD ($ settlement , $ maturity , $ price )
2112
2068
{
2113
- $ settlement = Functions::flattenSingleValue ($ settlement );
2114
- $ maturity = Functions::flattenSingleValue ($ maturity );
2115
- $ price = Functions::flattenSingleValue ($ price );
2116
-
2117
- // Validate
2118
- if (is_numeric ($ price )) {
2119
- if ($ price <= 0 ) {
2120
- return Functions::NAN ();
2121
- }
2122
-
2123
- if (Functions::getCompatibilityMode () == Functions::COMPATIBILITY_OPENOFFICE ) {
2124
- ++$ maturity ;
2125
- $ daysBetweenSettlementAndMaturity = DateTime::YEARFRAC ($ settlement , $ maturity ) * 360 ;
2126
- if (!is_numeric ($ daysBetweenSettlementAndMaturity )) {
2127
- // return date error
2128
- return $ daysBetweenSettlementAndMaturity ;
2129
- }
2130
- } else {
2131
- $ daysBetweenSettlementAndMaturity = (DateTime::getDateValue ($ maturity ) - DateTime::getDateValue ($ settlement ));
2132
- }
2133
-
2134
- if ($ daysBetweenSettlementAndMaturity > 360 ) {
2135
- return Functions::NAN ();
2136
- }
2137
-
2138
- return ((100 - $ price ) / $ price ) * (360 / $ daysBetweenSettlementAndMaturity );
2139
- }
2140
-
2141
- return Functions::VALUE ();
2069
+ return Financial \TreasuryBill::yield ($ settlement , $ maturity , $ price );
2142
2070
}
2143
2071
2144
2072
private static function bothNegAndPos ($ neg , $ pos )
0 commit comments