1 | <?php |
||
13 | class BondYTMCalculator extends BondCalculatorAbstract |
||
14 | { |
||
15 | |||
16 | // market value of the bond = 'P' |
||
17 | protected $bondMarketValue; |
||
18 | |||
19 | // INHERITED MEMBERS |
||
20 | // face value of the bond = 'F' |
||
21 | // $bondFaceValue; |
||
22 | |||
23 | // coupon rate of the bond per annum = 'c' |
||
24 | // $bondAnnualCouponRate; |
||
25 | |||
26 | // number of years to the maturity of the bond |
||
27 | // $bondYearsToMaturity; |
||
28 | |||
29 | // frequency of bond payments (expressed in a divisor of 12 months ~ 1 year) |
||
30 | // e.g.: divisor 2 means semi-annual payments |
||
31 | // $bondPaymentFrequency; |
||
32 | |||
33 | // props returned by the getResultAsArray method by default |
||
34 | protected $propResultArray = [ |
||
35 | "bondFaceValue", |
||
36 | "bondMarketValue", |
||
37 | "bondAnnualCouponRate", |
||
38 | "bondYearsToMaturity", |
||
39 | "bondPaymentFrequency", |
||
40 | "bondApproxYTM" => "approxBondYTM" |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * @param $bondFaceValue |
||
45 | * @param $bondMarketValue |
||
46 | * @param $bondAnnualCouponRate |
||
47 | * @param $bondYearsToMaturity |
||
48 | * @param $bondPaymentFrequency |
||
49 | */ |
||
50 | public function __construct( |
||
51 | $bondFaceValue, |
||
52 | $bondMarketValue, |
||
53 | $bondAnnualCouponRate, |
||
54 | $bondYearsToMaturity, |
||
55 | $bondPaymentFrequency = 1 |
||
56 | ) { |
||
57 | $this->setBondFaceValue($bondFaceValue); |
||
58 | $this->setBondMarketValue($bondMarketValue); |
||
59 | $this->setBondAnnualCouponRate($bondAnnualCouponRate); |
||
60 | $this->setBondYearsToMaturity($bondYearsToMaturity); |
||
61 | $this->setBondPaymentFrequency($bondPaymentFrequency); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param $bondMarketValue |
||
66 | */ |
||
67 | public function setBondMarketValue($bondMarketValue) |
||
71 | |||
72 | /** |
||
73 | * @return mixed |
||
74 | */ |
||
75 | public function getBondMarketValue() |
||
79 | |||
80 | /** |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getApproxBondYTM() |
||
116 | |||
117 | // TODO – add a method for precise bond YTM calculation by means of a polynomial equation |
||
118 | } |
||
119 | } |
||
120 |