Swap
From ThetaWiki
Contents |
Description
A Swap is a derivative where two parties exchange one stream of cash flow against eachother. Usually at least one of the cash payment streams has a rate that is variable.
ThetaScript
Model swap import N "Notional" import f_r "fixed rate" import T "Maturity" import bp "basis premium" import EUR "Numeraire" import r "Libor interest rate" export V "value of swap(for fixed)" c=0 loop T theta 1 c=c+(r+bp/100-f_r)*N*EUR end V=c end
Knock Out Swap
A Knock-Out Swap is a swap which is cancelled when a given condition is reached. For example, a swap can be knocked out if the LIBOR interest rate reaches a certain threshold.
ThetaScript
Model KnockOutSwap import N "Notional" import f_r "fixed rate" import T "Maturity" import bp "basis premium" import EUR "Numeraire" import r " Libor interest rate" import B "Barrier" export P "value of swap(for fixed)" P = E(V!) c=0 cond=0 loop T theta 1 % knock-out? if r > B cond=1 end % knocked-out earlier? if cond < 1 c=c+(r+bp/100-f_r)*N*EUR end end V=c end
