Script:
~addons/finance/finexec/basicfinance/rba.ijs
Contributor: William Szuch
Updated: 2022 6 25
Depend: ~addons/finance/finexec/basicfinance/compound.ijs
~addons/finance/finexec/toolbox/bisection.ijs
Definitions: loaded to locale base
Status: todo equations
Script source: rba.ijs
RBA - Treasury Bond calculations.
Financial calculations based on the Reserve Bank formula.
Equations:

Methodology set out in the Reserve Bank of Australia
note dated: 27/10/1992 No. 92-24
RBA
Notes and Equations
Treasury Bond Yield Calculation
Using bisection method with (E)pvcf(C;T)
Working backwards - calculate market value then
reverse process to calculate yield.
rba_tb(1992 11 1);(1998 1 15);(1993 1 15);6.25;0.0415;100
121.132
OR
C =: (11 # 6.25),100
T =: (75%184)+(i. 11),10
(0.0415)pvcf(C;T)
121.132
M =: 121.132 NB. Market value
Solve for E using bisection:
0 = M - (E)pvcf(C;T)
define
f1 =: M - pvcf&(C;T)
f1 =: 121.132 - pvcf&(C;T)
(f1) bisection (0.03;0.06)
0.041499
_0.000908185
Definitions
rba_bond (verb)
Bond valuation - generalised approach
Using basis similar to RBA.
Method also applicable for bills as cash flow basis is used.
Market value on a discounted cash flow basis
Syntax
rba_bond(y0;y1;y2;y3;y4;y5;y6;y7;y8)
y0 = Name of security
y1 = Valuation Date - yyyy mm dd
y2 = Maturity Date
y3 = Next interest payment date
y4 = Yearly rate of coupon per $100 face value eg 5
y5 = Coupon frequency payment 1/2/3/4/6/12 times per year
y6 = Nominal annual yield to maturity : effective half yearly eg 0.07
y7 = Face value on maturity
y8 = 0 = cum interest, 1 = ex interest; 2 cum interest BUT exc. accrued interest
Example
rba_bond('ABC Bond';1997 6 30;2001 11 15;1997 11 15;6;2;0.07;1000;0)
┌────────┬─────────┬──────────┬──────────┬─┬─┬────┬────┬─┬────────────┬──────┐
│ABC Bond│1997 6 30│2001 11 15│1997 11 15│6│2│0.07│1000│0│MKT VALUE = │970.27│
└────────┴─────────┴──────────┴──────────┴─┴─┴────┴────┴─┴────────────┴──────┘
rba_tb (verb)
Form: explicit
Depend: todayno
RBA - Treasury Bonds Basic Formula as taken from notes.
Syntax
([X])rbs_tb(Y0;Y1;Y2;Y3;Y4;Y5)
[X] Optional - Default value = 0
= 0 Cum interest
= 1 Ex Interest at next date
= 2 Excluding Accrued Interest
= 3 Near Maturing Bonds - specifically those entitling a purchaser
to only the final coupon payment and repayment of principal
date format: yyyy mm dd
Y0 = Valuation Date
Y1 = Maturity Date
Y2 = Next interest payment date
Y3 = Half yearly rate of coupon per $100 face value eg 3.0
Y4 = Effective half yearly yield to maturity eg. 0.035
Y5 = Face value on maturity
Example
rba_tb(1992 11 1);(1998 1 15);(1993 1 15);6.25;0.0415;100
121.132 NB. agrees with notes.
Value at coupon date
rba_tb(1993 1 15);(1998 1 15);(1993 1 15);6.25;0.0415;100
123.156
rba_tb(2003 10 24);(2015 4 15);(2004 4 15);3.125;0.028;100
105.6
Using basic formula, the price of
the 2.75% 21 November 2028 Treasury Bond,
assuming a yield to maturity of 2.8300% per annum
and settlement date of 27 October 2017, is calculated to be $100.431.
In this example, i = 0.014150 (i.e. 2.830 divided by 200),
f = 25, d = 184, g = 1.375 (i.e. half of 2.75) and n = 22.
rba_tb(2017 10 27);(2028 11 21);(2017 11 21);1.375;0.014150;100
100.431
Note
Alternative method using a cash flow
approach.
Using (E)pvcf(C;T)
C =: (11 # 6.25),100
T =: (75%184)+(i. 11),10
(0.0415)pvcf(C;T)
121.132
C =: (11 # 6.25),100
T =: (0%184)+(i. 11),10
(0.0415)pvcf(C;T)
123.156
C =: (23 # 3.125),100
T =: (174%183)+(i. 23),22
(0.028)pvcf(C;T)
105.6
C =: (23 # 1.375),100
T =: (25%184)+(i. 23),22
(0.01415)pvcf(C;T)
100.431
Using: (E)vt(T)
C =: (11 # 6.25),100
T =: (75%184)+(i. 11),10
+/C*(0.0415)vt(T)
121.132
Using only: v(E)
C =: (11 # 6.25),100
T =: (75%184)+(i. 11),10
+/C*(v(0.0415))^T
121.132
rba_tb_capital_index
(verb)
RBA - Treasury Bonds Basic Formula - Treasury
Capital Index Bonds - cum or ex interest.
Syntax
rba_tb_capital_index(y0;y1;y2;y3;y4;y5;y6;y7;y8)
Interest payments are quarterly
y0= Valuation Date - yyyy mm dd
y1= Maturity Date
y2= Next quarterly interest payment date
y3= Rate of quarterly coupon per $100 face value eg 3
y4= Quarterly real yield 0.012
y5= Face value
y6= K0 index factor per $100
y7= K1 index factor per $100
y8= 1 = cum interest, 0 = ex interest
Kt are based on $100, formula
Example
rba_tb_capital_index(1992 10 15 ; 2005 8 20; 1992 11 20;1;0.012;100;159.77;159.55;1)
148.414 NB. as per notes
rba_tn (verb)
Treasury Notes - Basic Formula.
Using RBA formula
Syntax
[x0]rba_tn(y0;y1;y2;y3)
x0 = Default: Discounting
rba_tn_yield (verb)
Treasury Notes - Basic Formula
Using RBA formula - Calculate yield.
Syntax
[x0]rba_tn_yield(y0;y1;y2;y3)