Home Cross Currency Swap (CCS)
Post
Cancel

Cross Currency Swap (CCS)

This post is about cross currency swap. Though CCS is not familiar, IRS can offer interest rate risk - currency rate risk mitigation. If you heavily invest on foreign currency based asset classes for long term, CCS is absoultely what you are looking for.

What is Cross Currency Swap

Suppose you are portfolio manager at Korea, you want to invest certain asset in US with USDollar. Some might think FX swap as a solution to mitigate currency risk since FX swap combines spot and forward agreement. However, typical FX swap contracts have maturity under 1 year. So, if use forward aggrement in rolling manner, you cannot mitigate risk completely.

Cross Currency Swap is used in this situation. CCS is OTC contract which participants exchange interest of each currency to use foreing currency. For example, one pay KRW interest to use KRW currency loan and the others pay USD interest to use USD loan. Typically, notional amount (loan amount) is exchanged at the beginning of contract with spot exchange rate.

Typically, every 6 month, interest are payed. And participants who have KRW & use USD pays fixed interest and the other participant who have USD & use KRW pays floating interest to others. See below image to help your understanding.
CCS

How to valuate Cross Currency Swap

Swap can be caluclated by summing present value of expected cashflows. Since interest rate of each currency is different, we need to build two individual interest rate swap curve for each currency. Equation is like below.
$CCS Swap Value = {Receive} - {Pay}$
where,
$Receive = N \times e_{t_0} \times [1-\frac{1}{({1+z_{t_n}}^{KRW})^{t_n}} + \sum_{i=1}^{n} \frac{{s_{t_0}}^{KRW} \delta_{i-1}}{({1+z_{t_i}}^{KRW})^{t_i}}] $ $Pay = N \times [1-\frac{1}{(1+z_{t_n}^{USD})^{t_n}} - \sum_{i=1}^{n} \frac{L_{t_{i-1}}^{USD} \delta_{i-1}}{(1+z_{t_i}^{USD})^{t_i}}]$

Below picture gives you what really consists of CCS. CCS decomposition helps you to understand how above frightening equation is derived from.
CCS

Buyer and seller of cross currency swap (CCS)

Bid CCS (CCS pay) = expect exchage rate rise, KRW interest rate rise, USD interest rate fall
Ask CCS (CCS receive) = expect exchange rate fall, KRW interest rate fall, USD interest rate fall
CCS

Summary

See below picture, if you are facing trouble in memorizing the CCS structure. CCS

Prequisite 1

1
2
pip install QuantLib==1.18
pip install QuantExt-Python==1.8.3.3.5

We use extended QuantLib package. So, you need to install stated version to calculate CCS.
Since original quantlib cannot incorporate multiple curve, which is essential for cross currency products, We have to use extended QuantLib package. Please follow above code.

Prequisite 2

1
from quant_lib.fx_swap_curve import get_quote, usdirs_curve, krwccs_curve

If you don’t want to make your own swap curve library, go to this link and download and place it appripriate directory.
FX_Swap_Curve_Code

Result

Let’s price cross currency swap

1
2
3
4
5
price of FXF = 19914.3747
FX Delta = -4296.0136
USD IR Delta = -6301.2805
KRW IR Delta = 4523955.1303
Theta = -23596.1045

Let’s code this idea

Full code can be found at below link.
CODE

Full Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
import os
import datetime
import numpy as np
import pandas as pd

import QuantExt as qe

from quant_lib.fx_swap_curve import get_quote, usdirs_curve, krwccs_curve

class CCS():
    def __init__(self, today, effective_date, maturity_date, ccs_rate, fx_spot, usd_notional, position):
        
        # initial setup
        self.date = today
        self.usd_curve = self.usd_curve(self.date)
        self.krw_curve = self.krw_curve(self.date)
        self.fx_spot = fx_spot

        self.effective_date = qe.Date(effective_date.day, effective_date.month, effective_date.year)
        self.maturity_date = qe.Date(maturity_date.day, maturity_date.month, maturity_date.year)

        self.ccs_rate = ccs_rate

        self.usd = qe.KRWCurrency()
        self.krw = qe.USDCurrency()
        self.usd_notional = usd_notional
        self.krw_notional = usd_notional * fx_spot

        self.day_count = qe.ActualActual()

        if position == 'long':
            self.position = qe.VanillaSwap.Payer
        else:
            self.position = qe.VanillaSwap.Receiver

        self.length = 2
        self.spread = 0.0
        self.convention = qe.ModifiedFollowing
        self.calendar = qe.JointCalendar(qe.SouthKorea(), qe.UnitedStates())
        self.tenor = qe.Period(6, qe.Months)

        self.fixed_day_count = qe.Actual365Fixed()
        self.float_day_count = qe.Actual360()
        self.dateGeneration = qe.DateGeneration.Backward()

        # pricing result
        self.npv = self.PRICING(self.usd_curve, self.krw_curve, self.fx_spot)
        self.fx_delta = self.FX_DELTA()
        self.usd_ir_delta = self.USD_IR_DELTA()
        self.krw_ir_delta = self.KRW_IR_DELTA()
        self.theta = self.THETA()
    
    def usd_curve(self, date):
        return usdirs_curve(date, get_quote(date, 'USD'))
    
    def krw_curve(self, date):
        return krwccs_curve(date, get_quote(date, 'KRW'))


    def PRICING(self, usd_curve, krw_curve, fx_spot):
        
        # Handles of Market variables
        usd_curve_handle = qe.YieldTermStructureHandle(usd_curve)
        krw_curve_handle = qe.YieldTermStructureHandle(krw_curve)
        fx_spot_handle = qe.QuoteHandle(qe.SimpleQuote(fx_spot))

        # Reference Rate
        usd_6m_libor = qe.USDLibor(qe.Period(6, qe.Months), usd_curve_handle)

        # Fixed Schedule
        fixed_schedule = qe.Schedule(self.effective_date,
                                     self.maturity_date,
                                     self.tenor,
                                     self.calendar,
                                     self.convention,
                                     self.convention,
                                     self.dateGeneration,
                                     False
                                )
        
        float_schedule = qe.Schedule(self.effective_date,
                                     self.maturity_date,
                                     self.tenor,
                                     self.calendar,
                                     self.convention,
                                     self.convention,
                                     self.dateGeneration,
                                     False
                                )
        
        ccs = qe.CrossCcyFixFloatSwap(self.position,
                                      self.krw_notional,
                                      self.krw,
                                      fixed_schedule,
                                      self.ccs_rate,
                                      self.fixed_day_count,
                                      self.convention,
                                      self.length,
                                      self.calendar,
                                      self.usd_notional,
                                      self.usd,
                                      float_schedule,
                                      usd_6m_libor,
                                      self.spread,
                                      self.convention,
                                      self.length,
                                      self.calendar
                                )
        
        # Price Engine
        engine = qe.CrossCcySwapEngine(self.krw,
                                       krw_curve_handle,
                                       self.usd,
                                       usd_curve_handle,
                                       fx_spot_handle
                                )

        # conduct prcing
        ccs.setPricingEngine(engine)

        # net present value
        npv = ccs.NPV()

        return npv

    
    def FX_DELTA(self):

        percentage = 0.01

        # CCS price when 1% up
        up_fx = self.fx_spot * (1 + percentage)
        up_ccs = self.PRICING(self.usd_curve, self.krw_curve, up_fx)

        # CCS price when 1% down
        down_fx = self.fx_spot * (1 - percentage)
        down_ccs = self.PRICING(self.usd_curve, self.krw_curve, down_fxf)

        return  (up_ccs - down_ccs) / 2




    def USD_IR_DELTA(self):
        # Handle of USD curve
        curve_handle = qe.YieldTermStructureHandle(self.usd_curve)

        # 1 bp
        basis_point = 0.0001

        # ccs price when 1bp up
        up_curve = qe.ZeroSpreadedTermStructure(curve_handle, qe.QuoteHandle(qe.SimpleQuote(basis_point)))
        up_ccs = self.PRICING(up_curve, self.krw_curve, self.fx_spot)

        # ccs price when 1bp down
        down_curve = qe.ZeroSpreadedTermStructure(curve_handle, qe.QuoteHandle(qe.SimpleQuote(-basis_point)))
        down_ccs = self.PRICING(down_curve, self.krw_curve, self.fx_spot)       

        return (up_ccs - down_ccs) / 2
    
    
    def KRW_IR_DELTA(self):
        # Handle of KRW curve
        curve_handle = qe.YieldTermStructureHandle(self.krw_curve)

        # 1 bp
        basis_point = 0.0001

        # ccs price when 1bp up
        up_curve = qe.ZeroSpreadedTermStructure(curve_handle, qe.QuoteHandle(qe.SimpleQuote(basis_point)))
        up_ccs = self.PRICING(self.usd_curve, up_curve, self.fx_spot)

        # ccs price when 1bp down
        down_curve = qe.ZeroSpreadedTermStructure(curve_handle, qe.QuoteHandle(qe.SimpleQuote(basis_point)))
        down_ccs = self.PRICING(self.usd_curve, down_curve, self.fx_spot)

        return (up_ccs - down_ccs) / 2



    def THETA(self):
        # theta is change in value if one unit time passes.
        # in here, unit time is 1 day
        # since derivative product have time value, time to maturity is major variable in pricing derivatives
        price_t0 = self.PRICING(self.usd_curve, self.krw_curve, self.fx_spot)

        # ccsprice at t1
        usd_curve_t1 = self.usd_curve(self.date + datetime.datetime(days=1))
        krw_curve_t1 = self.krw_curve(self.date + datetime.datetime(days=1))

        price_t1 = self.PRICING(usd_curve_t1, krw_curve_t1, self.fx_spot)

        return price_t1 - price_t0


## build CCS contract information
todays_date = datetime.date(2020, 10, 8)
effective_date = datetime.date(2021, 11, 1)
maturity_date = datetime.date(2025, 11, 1)

position = 'long'
fx_spot = 1133.85

ccs_rate = 0.002438
usd_notional = 10000000

# build CCS object
ccs = CCS(today=todays_date,
        effective_date=effective_date,
        maturity_date=maturity_date,
        ccs_rate=ccs_rate,
        fx_spot=fx_spot,
        usd_notional=usd_notional,
        position=position
)

# Print result
print("price of FXF = {}".format(round(ccs.npv,4)))
print("FX Delta = {}".format(round(ccs.fx_delta,4)))
print("USD IR Delta = {}".format(round(ccs.usd_ir_delta,4)))
print("KRW IR Delta = {}".format(round(ccs.krw_ir_delta,4)))
print("Theta = {}".format(round(ccs.theta,4)))
This post is licensed under CC BY 4.0 by the author.