1 | <?php |
||
14 | class BondDurationCalculator extends BondCalculatorAbstract |
||
15 | { |
||
16 | |||
17 | // annual yield of the bond |
||
18 | protected $bondAnnualYield; |
||
19 | |||
20 | // INHERITED MEMBERS |
||
21 | // face value of the bond = 'F' |
||
22 | // $bondFaceValue; |
||
23 | |||
24 | // coupon rate of the bond per annum = 'c' |
||
25 | // $bondAnnualCouponRate; |
||
26 | |||
27 | // number of years to the maturity of the bond |
||
28 | // $bondYearsToMaturity; |
||
29 | |||
30 | // frequency of bond payments (expressed in a divisor of 12 months ~ 1 year) |
||
31 | // e.g.: divisor 2 means semi-annual payments |
||
32 | // $bondPaymentFrequency; |
||
33 | |||
34 | // props returned by the getResultAsArray method by default |
||
35 | protected $propResultArray = [ |
||
36 | "bondFaceValue", |
||
37 | "bondAnnualCouponRate", |
||
38 | "bondAnnualYield", |
||
39 | "bondYearsToMaturity", |
||
40 | "bondPaymentFrequency", |
||
41 | "bondYieldPerPaymentPeriod", |
||
42 | "bondNominalCashFlows", |
||
43 | "bondDiscountedCashFlows", |
||
44 | "bondPresentValue", |
||
45 | "bondDuration" |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @param $bondFaceValue |
||
50 | * @param $bondAnnualCouponRate |
||
51 | * @param $bondAnnualYield |
||
52 | * @param $bondYearsToMaturity |
||
53 | * @param $bondPaymentFrequency |
||
54 | */ |
||
55 | public function __construct( |
||
56 | $bondFaceValue, |
||
57 | $bondAnnualCouponRate, |
||
58 | $bondAnnualYield, |
||
59 | $bondYearsToMaturity, |
||
60 | $bondPaymentFrequency = 1 |
||
61 | ) { |
||
62 | $this->setBondFaceValue($bondFaceValue); |
||
63 | $this->setBondAnnualCouponRate($bondAnnualCouponRate); |
||
64 | $this->setBondAnnualYield($bondAnnualYield); |
||
65 | $this->setBondYearsToMaturity($bondYearsToMaturity); |
||
66 | $this->setBondPaymentFrequency($bondPaymentFrequency); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * @param $bondAnnualYield |
||
71 | */ |
||
72 | public function setBondAnnualYield($bondAnnualYield) |
||
76 | |||
77 | /** |
||
78 | * @return mixed |
||
79 | */ |
||
80 | public function getBondAnnualYield() |
||
84 | |||
85 | /** |
||
86 | * @return string |
||
87 | */ |
||
88 | public function getBondYieldPerPaymentPeriod() |
||
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getBondNominalCashFlows() |
||
113 | |||
114 | /** |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getBondDiscountedCashFlows() |
||
136 | |||
137 | /** |
||
138 | * @return float |
||
139 | */ |
||
140 | public function getBondPresentValue() |
||
150 | |||
151 | /** |
||
152 | * @return string |
||
153 | */ |
||
154 | public function getBondDuration() |
||
173 | } |
||
174 | } |
||
175 |