Back to MAIN
1. Simple compounding vs continuous compounding
The inverse discount rate we can express as :
d_{i}^{1} = 1 + r_{si} t_{si}/Y_{si} = e^{ rcctcc/365}
so, we get r_{cc}=(365/t_{cc})Ln(1 + r_{si} t_{si} / Y_{si}) .. where
r_{cc} is the continuously compounded rate, Y_{si} is the no of days in one year based on the money market convention
r_{si} is the simple compounded rate, t_{cc} is the actual number of days in a period
t_{si} is the number of days in a period based on the money market convention.
the simple k4/kdb+ function for this can be :
tC:{[rsi;tsi;Ysi;tcc](365f%tcc)*log 1f+rsi*tsi%Ysi} /and we can now define a projection of tC ..
tCact360:{tC . (x;y;360f;y)}
2. The Future curves
If a futures market is available for a specific currency, we will get a sequence of implied forward rates
(from the quoted futures prices) f_{1},f_{2}, .. ,f_{n1},f_{n} and the corresponding forward
discount factors p_{1},p_{2}, .. ,p_{n1},p_{n}
where on the index set I_{n} holds: p_{j}=1 + f_{j} t_{mj}/Y_{si} and p_{0} is a stubrate^{*}.. I_{n} is equivalent to the set of the first n natural numbers.
t_{mj} is the number of days per future period j based on the convention of the money market.
The continuously compounded zero coupon rates we can obtain by : z_{j+1}^{cc}=(365/F_{j+1})Ln p_{0}p_{1}...p_{j1}p_{j} where j is in the index set
I_{n} including element {0}. In reality represents this product a recursion of pairs: (f_{n},t_{n}), where t_{n} is the difference
between the 1^{st} futures IMM dates T_{n} and T_{n+1}.
Just a sample....
We assume a given stubrate of 1.64% on the 17.Sep.2003 (simple compounded), the maturities of the futures we takes as:
(i should mention that we assume here also a significant trading volume of those sample contracts)
The reference spot date of the stubrate is 04.Aug.2003, and the tabledates below are 1^{st} IMM dates

Future Strips of a currency X (act/360) 

dates 
17.9.2003 
17.12.2003 
17.3.2004 
16.6.2004 
22.9.2004 
22.12.2004 
23.3.2005 
15.6.2005 
21.9.2005 
quotes 
98.25 
98.05 
97.81 
97.49 
97.11 
96.76 
96.39 
96.05 
last 1st IMM 
the simple k4 solution for this can be :
T:2003.08.04,2003.09.17,2003.12.17,2004.03.17,2004.06.16,2004.09.22,2004.12.22,2005.03.23,2005.06.15,2005.09.12
R:1.64,100.098.25,98.05,97.81,97.49,97.11,96.76,96.39,96.05
k)daysa:+\daysd:1_':T
r:tCact360 . (0.01*R;daysd)
(r@0) {[x;y]((x*y0y2)+(y@1)*y2:y@2)%y0:y@0}\ +(1_daysa;1_r;1_daysd)
.. returns the zero points determined by our future prices
^{*} The stubrate corresponds to the period from now to the maturity of the first futures contract can be obtained by
linearly interpolating the last two continuously compounded money market rates r_{i}^{cc} and r_{i+1}^{cc}, so that
F_{1} in the closed interval [t_{i} , t_{i+1}] where F_{1} is the maturity date of the futures contract which falls between the two money market dates
If r_{i}^{cc} is not available from money market data, we assume that : r_{i}^{cc} = r_{i+1}^{cc} = p_{0}^{cc},
where p_{0}^{cc} is the continuously compounded stub rate. In the normal case we get it from :
p_{0}^{cc}=[r_{i}^{cc} Dt_{i}+(F_{1}  t_{i})(r_{i+1}^{cc}  r_{i}^{cc})]/Dt_{i}
where Dt_{i} = t_{i+1}  t_{i}.
3. Playing with FRA's
An FRA is simply one pair of cashflows.
Let be t_{1} the time from the transaction date to the settlement date and t_{2} the time between the transaction date and the maturity date,
and r_{c}^{cc} is the continuously compounded FRA contract rate, r_{1}^{cc} is the zerocoupon rate at the settlement, r_{2}^{cc} is the zerocoupon
rate of the maturity.
The net unrealized profit at a time t = t_{0} we simply obtain as the sum of the both cashflows A_{s}(settlement) and A_{m}(maturity).
So, the FRA_{pl} = A_{s}e^{r1cc(t1t0)}+(A_{m})e^{r2cc(t2t0)} = A_{s}(e^{r1cc(t1t0)}e^{rccc(t2t1)r2cc(t2t0)})
We can now use the definition of the delta D _{ s } where the index s refers to the simple compounding, and we let be r(i) the
mapping from the continuous into the simple compounding form.
The D _{ s } = dV_{t}/di=dV_{t}/dr_{t}*dr_{t}/di where V_{t} is the present value at the current timepoint t and F_{0} the originally invested nominal
in t = 0, so V_{t}=F_{0}e^{r2cct2  rtcc(t2t)} and where t_{2} is the
maturity timepoint and the r^{cc} are as usual the correspondingly observed
cont.compounded zero rates.
As dr_{t}/di = t_{M}[Y_{M}(t_{2}t)]^{1}e^{ rtcc(t2t)} .. thus dV_{t}/di=  V_{t}t_{M}Y_{M}^{1}e^{rtcc(t2t)} .... however in practice we rather use the
socalled basis point value bpv = 0.0001 V_{t}t_{M}Y_{M}^{1}e^{rtcc(t2t)}
In FRA terms we obtain the bpv_{FRA} as the sum of bpv_{S} and bpv_{M} where S refers again to the settlement and M to the maturity.
So, bpv_{FRA} = 0.0001 A_{s}Y_{M}^{1}[(t_{2}t)_{M}e^{2r2cc(t2t)+rccc(t2t1)}  (t_{1}t)_{M}e^{2r1cc(t1t)}] where the subscript M relates to the money market day count convetion.
Here a simple kdb script simulating a random portfolio of 300'000 FRA's having 40 currencies. The FRA valuation itself is
actually a one or twoliner, all other lines are just used for comment and for building my sample portfolio, which would
clearly exceed the classical size of an FRAbook of a large bank by many times (10 to 100). The currency variety i took
is higher than in any other "real" portfolio.
FRA simulation Kdb+ script
4. European Options
..just a short introduction...
The payoff(expectation value) of an European call we can express as :
C = e^{r(Tt)}J[ max(0;S_{T}X)h(X_{T})dS_{T};0;infinity ]
where J[ f ; a; b ] describes the definite integral of f over [a;b]
where X is the strike, S is the spot(asset) price, T is the maturity date, t is our timepoint, r is the (riskless) rate


Changes in the spot price are the sum of a random component and a timedependent deterministic component..
Eg: dS = (r  d )Sdt + s Sdz, where d represents the annual dividend yield. dz represents a sum of independent random
events over the time horizon dt. So, dz must follow a normal distribution, according to the central limit theorem, eg we can
describe dz by its variance (which is dt) and mean (which is 0).
This means the process for x = ln(S) leads us to the equation:
dx = (r  d  0.5 s ^{2})dt + s dz
dx is a linear combination of a constant and the normally distributed dz, so must be normally distributed, too.
The mean of dx is (r  d  0.5 s ^{2})dt, and its variance is s ^{2}dt.
The natural logarithm of S at maturity is normally distributed with the following parameters:
N [(Ln S) + (r  d  0.5 s ^{2})(T  t) ; s (T  t)^{0.5}
This allows to revisit the integral mentioned above  and to solve it. This way we obtain
the BlackScholes solution for an
European call option.
C = Se^{d (T  t)}N(d_{1})  Xe^{r (T  t)}N(d_{2})


..and symetrically for the European putoption
P = Xe^{r (T  t)}N(d_{2})  Se^{d (T  t)}N(d_{1})


..and where d_{1} = s ^{1}(T  t)^{ 0.5}[ Ln (S/X) + (r  d + 0.5 s ^{2})(T  t)] and d_{2} = d_{1}  s (T  t)^{0.5}
A solution in Kdb+ can look like...(in case of an european currency option)
optBS:{{[S;X;rf;rd;t;s] /rd=domestic yield(cc), rf=foreign yield(cc), s=implied volatility
d1:((log S%X)+t0*((s*s*0.5)+rdrf))%a:s*sqrt t0:t%365f;(S*(exp neg rf*t0)*g d1)X*(exp neg rd*t0)*g d1a}
..where g is the gauss function ..
pi:acos 1
g:{abs (neg x>0f)+(1f%sqrt 2f*pi)*(exp 0.5*x*x)*t*0.31938153+t*0.356563782+t*1.781477937+ ..
.. t*1.821255978+1.330274429*t:1f%1f+0.2316419*abs x}
if we change the Spot S..and let the other dimensions constant..we will obtain (in case of a call) the profile:
xunits are in 0.001 .. (if C=1 we have a call, C=0 we have a put)
5. American Options
This formula of Black and Scholes is of course widely used and it is quite handy and traceable from the
analytical point of view. Its simplicity has the price that it can be only used for classical European
styled options. American styled options are more "worth" than European styled options, as they can be
exercised at any day until the option maturity. One possible way to price an American option is the
binomial method, which is the common method. The binomial method has been introduced 1978 by Sharpe.
Although the binomial method is not that handy closed a formula, it is a fairly simple and intuitive method.
As the name suggests..there are only two possible states(up and down) in that tree in each timeinterval
T/n.(T is the maturity and n the number of chosen intervals). Further we assume recombining nodes on the
tree, so we don't run into a messy megatree.
As we stated above already, Ln S_{dt} is normally distributed, and the mean is Ln S_{0} + (r_{d}  r_{f}  0.5 s ^{2})dt,
the variance is s ^{2}dt
Exactly this finding helps us to find the UP's and DOWN's in the binomial tree. Theoretically we "assume"
that the chosen timemetrics is small enough, that we can find based on the above stated characteristics
of Ln S_{dt} and the classical relation for independent random variables, VAR(X) = E(X^{2})  [E(X)]^{2},
that VAR(S_{1,T}) = S_{0}^{2}e^{2T(rd  rf)}(e^{ s 2T}  1). We see here also that the standard deviation of S_{1,T} is
monotonously increasing with s . With this, the future exchange rate movements are defined.
Thus:




UP 
p 
S_{0}u 

S_{0} 


DOWN 
1p 
S_{0}d 
Where: u = e^{ s (Dt)0.5}, d = u^{1} and p = (u  d)^{1}(e^{(rd  rf)Dt}  d). For each last timepoint jDt
we calculate the optiontree out of the pricetree: Q_{jDt,i }= max [0,L*S_{0}z^{2(i1)}  X] ..where i in {1,2,..., j+1}, z in {u,d} and where
L = 1 for a call option, and 1 for a put.
The rest of the optiontree (where m in {j1,j2,...,1,0}) we have for each Q_{mDt,n} the equation that:
Q_{mDt,n } = max{L*E*(S_{0}z^{m  2(n1)}  X) , e^{rdDt}(pQ_{(n+1)Dt,n} + (1  p)Q_{(n+1)Dt,n+1}) } and where E is the early exercise flag.
eg. E is 1 in case we exercise, and otherwise 0.
The answer using Kdb+ can be..
Xn:neg X;dt:T%n;n1:1f;l:exp n1*rd*dt
q:1p:((neg@ d)+exp dt*rdrf)%(u:1f%d)d:exp neg@ s*sqrt dt:T%n
On:0fh*Xn+S*last atree:xexp[u;{x2*til x+1} each 1+til n];
On {max each flip (n1*Xn+S*y;fx x)}/1 _ reverse 1f,atree
function fx should remain secret, but is only a short expression.
The graph below shows how the binomial model converges against the correct value in case of variable timeintervals
which represent the xaxis(starting from 1 and going up to 300)
The upper path in the graph below is an European put, and the other is an American put.
Back to MAIN
© ++ MILAN ONDRUS