Skip to content

Instantly share code, notes, and snippets.

@wrwills
Created December 13, 2010 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrwills/739041 to your computer and use it in GitHub Desktop.
Save wrwills/739041 to your computer and use it in GitHub Desktop.
/*
* Counterparty A receives: 1.43% absolute on amortising notional (decreasing periodically from an initial notional of £200m).
Counterparty B receives: Previous coupon + 5 x [Max(Ref Index – 6.65%, 0.00%) + Max(2% - Ref Index, 0.00%)] on fixed notional of £200m.
The reference index is CMS EUR 10y set in arrears, available on Reuters website at ISDAFIX2
A Bermudan call option is conferred on Counterparty B who may terminate for 0 payment within a 10 day band every quarter.
Payment dates are quarterly, reset dates and accrual periods are also defined.
The Maturity Date is 2014.
Initial coupon is 0.00%, (over short first period) for floating rate leg.
1.43% for fixed leg rate is per annum rate.
Fixed leg of swap is the right to receive 1.43% fixed interest rate per annum over life of swap but interest on amortising sum which is initially 200 million euros and thereafter decreases as per spec.
Floating leg is right to receive 0% per annum interest on non-amortising sum of 200m over life of swap plus any extra amount by which CMS rate may exceed strangle band (2%-6.65%) either above or below, multiplied by 5, calculated quarterly with twist that add-ons are cumulative.
Thus floating leg would be 0% until CMS rate is, say, down to 1%, when floating leg pays 0% + (5x1%), i.e. 5%.
If the next quarter the CMS rate is still 1% then, I think but am not sure, that the floating leg pays 5% + (5x1%), i.e. 10%.
I guess I need to know the maximum and minimum amounts payable over the life of the swap on the floating leg assuming a realistic cap of 10% and a floor of 0%, and to compare with the returns on the fixed leg. I don’t see how you can help me with probabilities, I guess one would have to work in an investment bank to work out the probabilities of the CMS rate doing this or that in future.
*/
/*
Initial notional for both legs is the same 200,000,000.00 euros and remains such until March 2008. It then decreases/amortises every six months, in the context of the fixed leg only, by 14-15 million euros until June 2014 when it will total 14,285,718.00
* ie 13 periods of decreasing and 3 constant
*/
val numberOfHalfYears = 16
val notional = 200000000
val amortiseAmt = (notional - 14285718) / (numberOfHalfYears - 3)
// Vector(200000000, 200000000, 200000000, 185714286, 171428572, 157142858, 142857144, 128571430, 114285716, 100000002, 85714288, 71428574, 57142860, 42857146, 28571432, 14285718)
val contractANotionals =
((1 to 3) map (x => 200000000)) ++ ((1 to (numberOfHalfYears - 3)) map ( x => 200000000 - (amortiseAmt * x)))
val partyAReceives = (contractANotionals map (_ * (0.0143/2))).sum.longValue // 13,585,000
// floating leg is quarterly
val constantIndices = (1 to (numberOfHalfYears * 2)) map (x => 0.045)
// so you only get a payment if the index is greater than
def contractBPayment(previous: Double, i: Double): Double =
previous + ( 5 * (math.max(i - 0.0665, 0.0) + math.max(0.02 -i, 0.0)) * notional)
def snowball(previous: Double, indices: Seq[Double]): List[Double] =
indices.headOption match {
case Some(i) => {
val amt = contractBPayment(previous, i)
List(amt) ++ snowball(amt, indices.tail)
}
case None => List()
}
def contractBPayout( indices: Seq[Double]) =
snowball(0, indices).sum.toLong
println(contractBPayout( (1 to (numberOfHalfYears * 2)) map ( x => 0.07))) // 1,848,000,000
println(contractBPayout( (1 to (numberOfHalfYears * 2)) map ( x => 0.01))) // 5,280,000,000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment