Professional Documents
Culture Documents
All IR or FX derivatives are derived from an underlying random variable, which is called an index, such as USDLIBOR3M, USDJPY
spot. A contingent claim must specify a payoff, it is a function dependent on the random variable, a fixing day and a settlement day
(or a list of fixing and settlement days for structured product). Fixing and settlement steps are decoupled and independent. Pricing
of a contingent claim involves solving for the distribution of the index as of today (the index is stochastic as of today, it will become
deterministic on fixing day). For linear product like forward contract, only expectation of the distribution matters, hence there is no
need to solve for the whole density function, for nonlinear product like option, volatility kicks in.
Once we have defined the index or underlying random variable, we can then describe the random process of the index with a SDE.
In case of analytic pricer, the SDE is not involved in engine implementation, because we must either (1) derive a BSPDE or a Heston
PDE from the SDE, and solve for the price analytically using contingent claim’s payoff as boundary conditions, or (2) derive the pdf
of index on fixing day given market data today, and perform risk neutral pricing. However for Monte Carlo simulation or binomial
tree, SDE must be involved in the implementation of pricing engine, hence we need to define clearly how the dynamics in the SDE
work, for FX in particular. However, before that, we need to clarify our notations.
Apart from t, s and , all other variables remain constant as time proceeds. On approaching maturity, timepoint T is fixed, while the
time-to-maturity T- t decreases.
R0,t,T = YieldTermStructure::forwardRate(t,T)
R0,T = YieldTermStructure::zeroRate(T)
r0,t = YieldTermStructure::forwardRate(t,t+dt)
0,t,T = BlackVolTermStructure::blackForwardVol(t,T,strike)
t,T = BlackVolTermStructure::blackVol(T,strike)
0,t = BlackVolTermStructure::blackForwardVol(t,t+dt,strike)
Sometimes we use variance instead of volatility, variance is the time integral of volatility square.
Zero rate and term volatility can be regarded as time average of their instantaneous counterparts.
1 T 0,t,T = 1 T 2
R0,t ,T = r0, s ds
T t t
and 0, s ds
T t t
1 T 0,T 1 T 2
R0,T = r0, s ds
T 0
and = 0, s ds
T 0
r0,t = t (tR0,t ) = R0,t ( t R0,t ) t and 0,t = 2 t)
t ( 0,t =
2 ( 2 ) t
0,t t 0,t
1
Forward zero rate can be deduced by comparing long term zero rate and short term zero rate.
T t T
0 r0, sds = 0 r0, sds t r0, sds
R0,T T = R0,t t R0,t ,T (T t )
R0,t ,T = ( R0,T T R0,t t ) /(T t ) both forward zero rate and zero rate are deterministic
Given information today 0, instantaneous rate instantaneous volatility, zero and forward rates, term and forward volatilities are all
deterministic, since zero rate and term volatility are directly available from market data, forward rate and volatility can be deduced
from short term and long term zero rates and volatilities, whereas instantaneous counterparts are first order derivatives of zero rate
and term volatility. Therefore, variables are deterministic if the first subscript is zero, and stochastic otherwise.
R0,t,T 0,t,T are deterministic as of time 0 no abbreviation, keep all 3 subscripts for clarity
R0,T = RT 0,T = T are deterministic as of time 0 abbreviated as RT and T
r0,t = rt 0,t = t are deterministic as of time 0 abbreviated as rt and t, normally used as variable in SDE
Rs,t,T s,t,T are stochastic as of time 0 for s > 0 as we don’t know the market data at time s
Rs,T s,T are stochastic as of time 0 for s > 0
rs,t s,t are stochastic as of time 0 for s > 0
These indices become deterministic as of time t, i.e. fixing at time t. We can model the stochastic indices using Black Scholes or Hull
White. Lets move forward to foreign exchange. We need to specify FX spot rate St and FX cash rate Xt. Given market at time 0, both
S0 and X0 are fixed, as S0 is given as spot quote, while X0 is related to S0 via foreign and domestic yield curve :
2
X0 = S0 exp( 0 (rd , r f , ) d ) S0 and X0 are fixed together at time 0.
As of time 0, spot rate and cash rate in the future (i.e. St and Xt) are stochastic, but they are still related in a deterministic way :
t 2
Xt = St exp( t ( rd , r f , ) d ) (eq1) St and Xt are random variables, both fixed at t,
hence no expectation
t 2
Xt St exp( t ( rd ,t , r f ,t , ) d ) integrand is random, which is not true
Equation 1 implies that spot rate and cash rate (the stochastic rates themselves, NOT their expectations) are related in deterministic way.
The forward price with maturity T is the expectation of FX spot fixing at time T given market data at time 0, thus in particular for
FX, forward implies forward spot.
Forward price given forward market data at time t is called forward-forward. Again spot rate and forward-forward rate are related
by a deterministic drift, which can be explaint by the tower property.
In short, as of time 0, S0, X0 and F0,T are deterministic, while St, Xt and Ft,T stochastic. Spot rate and cash rate are related by equation 1,
spot rate and forward-forward rate are related by equation 2, whereas cash rate dynamic is governed by the underlying model, such
as Black Scholes. Deterministic instantaneous rates are used in both drift term and diffusion term of Black Scholes SDE, otherwise if
stochastic rates rf,t,t and rd,t,t are used, we are in fact introducing multiple risk factors into the model.
Given equation 1, 2 and Black Scholes, we can find the SDE for St and Ft,T using Ito’s lemma (beware alignment in time domain).
M
t
(1) St = t 2
X t exp( (rd , r f , ) d )
t
dSt = ( t M t ) X t dt M t dX t using Ito’s lemma
t 2
t M t = M t t ( t ( rd , r f , ) d ) using x exp( f ) exp( f ) x f
= M t ((rd ,t 2 r f ,t 2 ) ( rd ,t r f ,t ))
dSt = M t (( rd ,t 2 r f ,t 2 ) ( rd ,t r f ,t )) X t dt M t dX t
= ( rd ,t 2 r f ,t 2 ) M t X t dt t M t X t dzt
= ( rd ,t 2 r f ,t 2 ) St dt t St dzt
Therefore t is the instantaneous volatility for both cash rate and spot rate. Using the same approach, we have :
L
t
(2) Ft ,T = T 2
St exp( t 2 ( rd , r f , ) d )
dFt ,T = (t Lt ) St dt Lt dSt
= Lt ( rd ,t T r f ,t T ) St dt Lt dSt
= Lt ( rd ,t T r f ,t T ) St dt Lt ((rd ,t 2 r f ,t 2 ) St dt t St dzt )
= t Lt St dzt
= t Ft dzt
With above underlying spot model in (1), we solve for the spot rate on maturity.
E[ S | I ] exp(v / 2 v )
ST = T 0
F0,T
We can then solve for the analytic solutions of FX forward and FX option.
T 2
F0,T = S0 exp(2 (rd , r f , )d ) forward price with maturity T
exp(( Rd ,T 2 R f ,T 2 ) (T 2))
= S0
exp(( Rd ,2 R f ,2 ) 2)
C0,T Rd ,T 2 (T 2)
= ( F0,T N (d1) KN ( d 2 ))e call option price with maturity T (payment T+2)
d1, 2 = (ln( F0,T / K ) v / 2) / v where fwd = E[ST|I0], variable F is reserved for FX
cash
T 2
where v = 0 t dt where t is instantaneous vol of spot rate or cash rate
2
= 0,T T
In short, the term “spot” is confusing and misleading, it can be made simpler if we think in the following perspective. It is simply a
random variable, to be fixed at time T, yet its payment will occur later at time T+2, the critical point is the alignment of St with yield
curve in time domain, there is a 2 days shift, i.e. we integrate the drift term from time 2 to T+2 to find forward, beyond that, we can
use Black Scholes like equity : FTN(d1)-KN(d2), but final discounting is done from T+2 to today 0. Therefore a Black calculator which
decouples forward, optionality and discounting is necessary.
or PV f = L E[ payoff f | I 0 ] DF f
= L E[( ST K ) / F0,T | I 0 ] DF f
= L ( E[ ST | I 0 ] K ) / F0,T DF f
PV f = L ( F0,T K ) / F0,T DF f
L (F K ) DF / S0
= 0,T d since F0,T S0 DF f / DFd
PVd
The latter approach regards the forward contract as an exchange of currencies at T, buyer of the contract will receive L units foreign
currency at the expense of LK units domestic currency, cash inflow and cash outflow are discounted by corresponding curves, main
difference from the former method is that the former involves only 1 curve, while this method involves 2 curves.
4
= ( L DF f ) S0 ( LK DFd ) method 2’s implementation
PV d# = ( L DF f ) S0 ( LK DFd )
There is no differences using either method 1a, 1b or 2 for a single deal, but when there is a portfolio of mixed currencies, we cannot
simply add the PVs together, as they come with different units. We can either convert all deals to the same reporting currency via 2
routines i.e. method 1a or b, according to collateral currencies (use method 1a for collateral in domestic currency, use method 1b for
collateral in foreign currency) or report each currency separately using method 2 without summing them up. Consider one porfolio
with USDJPY and EURJPY positions, with spot rate S0 S1 and one-year forward rate F0 F1 respectively, here is the illustration :
5
Example : collateral in USD
USD JPY EUR USD
time T payoff x/F1 method 1b x y method 1a yF2
Delta calculation is more complicated than PV, as nominator and denominator can be either be foreign or domestic, thus there are 4
combinations, among which, we prefer to use the same currency for both nominator and denominator. Deltad/d in domestic currency
is easier to understand, yet it requires re-implication of domestic curve from shocked swap points, while Deltaf/f in foreign currency
doesn’t require re-implication, but it needs multiplication with forward at the end (it is less understandable) which converts from
domestic currency to foreign currency. Suppose f is contingent claim’s payoff :
PV
shocked in
foreign
shocked cashflowin foreign
1Mdelta f / d = Lf ( S0 , F0,1M , OISUSD , vol ) Lf ( S0 , F0,1M , OISUSD , vol )
DF f DF f
F0,1M F0,1M
shocking in domestic
The following is an illustration of method1b for delta calculation, this method is prefered for finding delta of USDJPY forward, as it
involves USD curve only, thus there is no need to re-imply JPY curve from swap point after shocking market data.
cashflowUS
D
PVUSD = cashflowJPY
L ( F0,T K ) / F0,T DF f
PV 'USD = L (( F0,T FJPY ) K ) /( F0,T FJPY ) DF f
delta f / d = ( PV 'USD PVUSD ) / FJPY unit USD/JPY change in PV (in USD) per infinitesimal change
in F0,T in JPY
delta f / f = ( PV 'USD PVUSD ) / FJPY F0,T unit USD/USD change in PV (in USD) per infinitesimal
change in F0,T in USD
( PV 'USD PVUSD ) /( FJPY / F0,T )
=
FUSD
6
Simplify equation A for 1M USDJPY forward :
L( F0,1M K )
1Mdelta f / f = DFUSD,1M F0,1M
F0,1M F0,1M
=
F0,1M
L (1 K / F0,1M ) DFUSD,1M F0,1M
= [ L ( K / F0,1M ) DFUSD,1M ]
7
Review of TDMS-IR
The following instruments are supported in TDMS :
IRS
swaption (European or Bermudan)
callable swaption (ordinary swap or zero callable)
Zero callable means a callable swap with a normal floating leg, but no coupon in the fixed leg, instead the coupon in the fixed leg is
reinvested into the swap, hence increasing the notional. Therefore, zero callable can be regarded as IR swap with a time dependent
notional, which jumps on the original coupon payment dates, having jump size equivalent to coupon size, the notional of a callable
swap does look like a staircase.
QuantLib offers at least two swap classes, a generic swap which contains multiple paying-legs and receiving-legs, and vanilla swap
which has exactly one paying-leg and one receiving-leg, among which, one is fixed and the other must be floating, besides notional
of vanilla swap is constant in time, and equivalent between both legs. The generic swap is too generic for TDMS, yet the vanilla one
cannot handle zero callable, therefore we create cathay-swap to accommodate this requirement, this class differs from the vanilla in
the following inputs, which are supported in cathay-swap but not in QuantLib’s vanilla swap :
TDMS is segmented into 3 major parts : market data, deal term or term sheet and quant. Market data in TDMS includes QuantLib ’s
term structure (for yield and volatility), rate helper and calibration helper, while helper is simply an abstraction of one market data
point (rate helper contains a data point on yield curve for boostrapping, while calibration helper contains a point on vol-surface for
model calibration, bootstrapping is implicit, i.e. it is triggered when instruments NPV is called, calibration is explicit, i.e. user needs
to call model.calibrate(vec_helpers,levmar,criteria) before the model can be used for pricing). Deal term in TDMS is equivalent to
instrument in QuantLib, while quant in TDMS is equivalent to random process, model and pricing engine in QuantLib. Recall that
the communication between instrument and in engine QuantLib is done through ARG and RES, when instrument::NPV is called, setup
argument and fetch result will be triggered, besides instrument has a pointer to engine, which is updated inside setPricingEngine.
TDMS’s market data section rf,rd,vol rf,rd calibration helper (encap vol)
model::calibrate
constructed from
BS analytic engine for vanilla
BS finite diff engine for vanilla
BS monte carlo engine for vanilla
HT analytic engine for vanilla
HT finite diff engine for vanilla setPricingEngine
HT monte carlo engine for vanilla instrument
TDMS’s deal term section
Cathay-swap can be regarded as an abstraction between vanilla swap and generic swap. The market data section and quant section
for swap in QuantLib can be reused, there is no need to implement cathay’s version market data and quant-for-swap. We then goto
swaption, it is simply combo of cathay-swap plus an option, the latter is consisted of an exercise and a payoff. Risk neutral pricing
states that the price of a contingent claim is the expected value of payoff f, according to underling X :
price = ˆ [ f ( x )]
DF E
= ˆ [ ax b]
DF E if f is linear, example f = ax+b, like forward
= ˆ [ x ] b)
DF ( aE then only the expected value of X’s pdf is needed (which is risk free rate), no vol is
needed
However, when payoff f is nonlinear, such as an option, volatility then kicks in. Major challenge in IR swaption is that, market data
of volatility is quoted as log-normal vol, i.e. assuming Black Scholes model for IR process, yet TDMS uses normal vol, i.e. assuming
Hull White model for IR process, therefore a cathay-convertor is implemented to convert log-normal vol into normal vol. Using this
vol-surface, we can price other IR derivatives of the same currency, including cap and floor etc. Finally for the last product, callable
swaption, as pricing part is done by Dr Yan’s code, which is called BR3, the main task for the cathay library is to do data conversion
from QuantLib’s term structure and instrument into C++’s primitive types.
8
9
Design of TDMS-FX
FX synthetic forward is a combination of long position in ITM call plus short position in OTM put with the same strike but different
notionals (or long position in ITM put plus short position in OTM call). Consider a US company running a business in HK, it wants
to protect its HK revenue from downside FX market risk (i.e. a rise in USDHKD), then it longs a synthetic forward, from which it is
compensated in case of HKD depreciation. In fact, it can simply enter a USDHKD call option, yet ITM call option may be
expensive, whereas OTM call option involves premium fee without a guaranteed future cash inflow. Therefore, synthetic forward
is offered to suit this need, as the notional (in USD) of the short side is greater than (usually double) that of the long side, initial
premium can be reduced, initial cash may also be received by the client company.
TARF is a sequence of (usually 12 or 24) monthly synthetic forwards. Clients prefer to be more ITM which comes along with higher
premium, hence knock out feature is added (to protect the bank and to reduce the premium), which allows the contract to be called
by the bank when target profit is made by the client, as it is equivalent to selling a call option to the bank, premium is then reduced.
Target redemption is triggered when :
If the nth payment triggers the redemption, the nth payment is defined as the following according to different TARF options :
Sn K full redemption
nth payment = n if in1(Si K ) Tar
Tar i 1( Si K ) partial redemption
Please note that only positive intrinsic values are added in the above summation. Similarly, TARF may have a cap-loss which limits
the maximum loss from the short side, unlike target redemption there is no full cap loss or partial cap loss, cap loss is a hard
bound. Finally, clients may want a margin in the short side, they dont want to lose money as fixing is lower than strike, an
European knock in feature is added to the short side option, this feature increases TARF ’s premium. In general, the notional, strike
and EKI can vary payment by payment, while target redemption and cap loss is per deal.
Discrete knock out DKO is another FX exotic that is very similar to TARF, the only difference is the knocked out criteria :
In general, there is no EKI for DKO. Besides, it is possible for a DKO to have no payment on the first few fixings (there are KO
only). Finally, we have double no touch, which is a double barrier exotic product. For example, a double no touch which pays 4%
coupon quarterly when USDCNH lies within 6.75 and 6.85 in the whole 3M period, pays nothing otherwise, it matures in 2Y (i.e. 8
periods). There is no knock out conditions, the FX rate range can be different per period. This is a digitial contract, hence it isn’t
continuously differentiable, i.e. it cannot be dynamically hedged with vanilla products.
10