CurrencySwap
Description
Create and price a CurrencySwap
instrument object for one
or more currency swap instruments using this workflow:
Use
fininstrument
to create aCurrencySwap
instrument object for one or more currency swap instruments.Use
ratecurve
to specify curve models for theCurrencySwap
instrument object.Use
finpricer
to specify aFXDiscount
pricing method.
For more information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
For more information on the available models and pricing methods for supported instruments, see Choose Instruments, Models, and Pricers.
Creation
Syntax
Description
creates a SwapInstrument
= fininstrument(InstrumentType
,Maturity
=maturity_date,LegRate
=leg_rate)CurrencySwap
object for one or more Currency
Swap instruments by specifying InstrumentType
and sets
the properties for the
required name-value arguments Maturity
and
LegRate
.
The CurrencySwap
object supports a Vanilla Currency Swap and a Forward Currency Swap.
Note
You can also use the Swap
instrument for a
single currency swap but not a cross-currency swap. For
cross-currency swaps, use CurrencySwap
. For more
information on using a Swap
instrument, see Vanilla Swap, Swap with Amortization, and Forward Swap.
sets optional properties using
name-value arguments in addition to the required arguments in the previous
syntax. For example, SwapInstrument
= fininstrument(___,Name=Value
)CurrencySwapInstrument =
fininstrument("CurrencySwap",Maturity=datetime(2024,8,30),LegRate=[0.06
0.12],LegType=["fixed","fixed"],Basis=1,Notional=10000,StartDate=datetime(2023,11,30),DaycountAdjustedCashFlow=true,BusinessDayConvention="follow",ProjectionCurve=ratecurve,Name="currencyswap_instrument")
creates a CurrencySwap
option with a maturity of August
30, 2024. You can specify multiple name-value pair arguments.
Input Arguments
Instrument type, specified as a string with the value of
"CurrencySwap"
, a character vector with the value
of 'CurrencySwap'
, an
NINST
-by-1
string array with
values of "CurrencySwap"
, or an
NINST
-by-1
cell array of
character vectors with values of 'CurrencySwap'
.
Data Types: char
| cell
| string
Name-Value Arguments
Specify required
and optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where
Name
is the argument name and Value
is
the corresponding value. Name-value arguments must appear after other arguments,
but the order of the pairs does not matter.
Example: CurrencySwapInstrument =
fininstrument("CurrencySwap",Maturity=datetime(2024,8,30),LegRate=[0.06
0.12],LegType=["fixed","fixed"],Basis=1,Notional=10000,StartDate=datetime(2023,11,30),DaycountAdjustedCashFlow=true,BusinessDayConvention="follow",ProjectionCurve=ratecurve,Name="currencyswap_instrument")
Required CurrencySwap
Name-Value Arguments
Currency swap maturity date, specified a scalar or an
NINST
-by-1
vector using a
datetime array, string array, or date character vectors.
If you use date character vectors or strings, the format must be
recognizable by datetime
because
the Maturity
property is stored as a
datetime.
Data Types: datetime
| string
| char
Currency swap Leg rate in decimal values, specified as a
NINST
-by-2
matrix. Each
row can be defined as one of the following:
[CouponRate Spread]
(fixed-float)[Spread CouponRate]
(float-fixed)[CouponRate CouponRate]
(fixed-fixed)[Spread Spread]
(float-float)
CouponRate
is the decimal annual rate.
Spread
is the number of basis points in
decimals over the reference rate. The first column represents the
receiving leg, while the second column represents the paying
leg.
Data Types: double
Optional CurrencySwap
Name-Value Arguments
Currency swap leg type, specified as a cell array of character
vectors or a string array with the supported values. The
LegType
defines the interpretation of the
values entered in LegRate
.
Data Types: cell
| string
Rate curve for projecting floating cash flows, specified as a
scalar ratecurve
object or an
NINST
-by-1
vector of
ratecurve
objects. You must create this
object using ratecurve
.
Data Types: object
Offset in rate setting, specified as an
NINST
-by-2
matrix.
Data Types: double
Frequency of payments per year, specified as a scalar (or an
NINST
-by-2
matrix if
Reset
is different for each leg) with one of
the following values: 0
, 1
,
2
, 3
,
4
, 6
, or
12
.
Data Types: double
Day count basis representing the basis for each leg, specified as
an NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
Basis
is different for each leg).
0 — actual/actual
1 — 30/360 (SIA)
2 — actual/360
3 — actual/365
4 — 30/360 (PSA)
5 — 30/360 (ISDA)
6 — 30/360 (European)
7 — actual/365 (Japanese)
8 — actual/actual (ICMA)
9 — actual/360 (ICMA)
10 — actual/365 (ICMA)
11 — 30/360E (ICMA)
12 — actual/365 (ISDA)
13 — BUS/252
For more information, see Basis.
Data Types: double
Notional value for each leg, specified as a scalar
1
-by-2
numeric
array.
Data Types: double
Latest floating rate for float legs, specified as a scalar numeric
or an NINST
-by-1
numeric
vector.
LatestFloatingRate
is an
NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
LatestFloatingRate
is different for each
leg).
Data Types: double
Flag to adjust cash flows based on day count convention, specified
as an NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
AdjustCashFlowsBasis
is different for each
leg) of logicals with values of true
or
false
.
Data Types: logical
Business day conventions for cash flow dates, specified as a
string (or an NINST
-by-2
string array if BusinessDayConvention
is
different for each leg) or a character vector (or an
NINST
-by-2
cell array of
character vectors if BusinessDayConvention
is
different for each leg). The selection for business day convention
determines how nonbusiness days are treated. Nonbusiness days are
defined as weekends plus any other date that businesses are not open
(for example, statutory holidays). Values are:
"actual"
— Nonbusiness days are effectively ignored. Cash flows that fall on nonbusiness days are assumed to be distributed on the actual date."follow"
— Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day."modifiedfollow"
— Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day. However, if the following business day is in a different month, the previous business day is adopted instead."previous"
— Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day."modifiedprevious"
— Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day. However, if the previous business day is in a different month, the following business day is adopted instead.
Data Types: char
| cell
| string
Holidays used in computing business days, specified as dates using
an NINST
-by-1
vector of
datetimes, cell array of date character vectors, or date string
array. For
example:
H = holidays(datetime('today'),datetime(2025,12,15)); Swap = fininstrument("CurrencySwap",'Maturity',datetime(2025,12,15),'LegRate',[0.06 20],'Holidays',H)
Data Types: datetime
| string
| char
End-of-month rule flag for generating dates when
Maturity
is an end-of-month date for a month
with 30 or fewer days, specified as a logical value of
true
or false
using an
NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
EndMonthRule
is different for each leg).
If you set
EndMonthRule
tofalse
, the software ignores the rule, meaning that a payment date is always the same numerical day of the month.If you set
EndMonthRule
totrue
, the software sets the rule on, meaning that a payment date is always the last actual day of the month.
Data Types: logical
Forward starting date of payments, specified as a scalar or an
NINST
-by-1
vector using a
datetime array, string array, or date character
vectors.
If you use date character vectors or strings, the format must be
recognizable by datetime
because
the StartDate
property is stored as a
datetime.
Data Types: datetime
| char
| string
| cell
Indicator whether the currency swap exchanges principal at
Settle
, specified as a scalar logical value
of true
or false
or an
NINST
-by-1
matrix.
Data Types: logical
Indicator whether the currency swap exchanges principal at
Maturity
, specified as a scalar logical
value of true
or false
or an
NINST
-by-1
matrix.
Data Types: logical
User-defined name for the instrument, specified as a scalar string
or character vector or an
NINST
-by-1
cell array of
character vectors or string array.
Data Types: char
| cell
| string
Output Arguments
Currency Swap instrument, returned as a
CurrencySwap
object.
Properties
Currency swap maturity date, returned as a scalar datetime or an
NINST
-by-1
vector of
datetimes.
Data Types: datetime
Currency swap leg rate, returned as an
NINST
-by-2
matrix of decimal
values, with each row defined as one of the following:
[CouponRate Spread]
(fixed-float)[Spread CouponRate]
(float-fixed)[CouponRate CouponRate]
(fixed-fixed)[Spread Spread]
(float-float)
Data Types: double
Currency swap leg type, returned as a string array with the values
["fixed","fixed"]
,
["fixed","float"]
,
["float","fixed"]
, or
["float","float"]
.
Data Types: string
Rate curve used in projecting the future cash flows, returned as a
ratecurve
object or an
NINST
-by-1
vector of
ratecurve
objects.
Data Types: object
Offset in rate setting, returned as an
NINST
-by-2
matrix.
Data Types: double
Frequency of payments per year, returned as a scalar or an
NINST
-by-2
matrix.
Data Types: double
Day count basis, returned as an
NINST
-by-1
or an
NINST
-by-2
matrix.
Data Types: double
Notional value for each leg, returned as a scalar
1
-by-2
numeric array.
Data Types: double
Latest floating rate for float legs, returned as a scalar numeric or an
NINST
-by-1
numeric vector or an
NINST
-by-2
if
LatestFloatingRate
is different for each leg.
Data Types: double
Flag to adjust cash flows based on day count convention, returned as an
NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
AdjustCashFlowsBasis
is different for each leg) of
logicals with values of true
or
false
.
Data Types: logical
Business day conventions for cash flow dates, returned as a string or an
NINST
-by-2
string array if
BusinessDayConvention
is different for each
leg.
Data Types: char
| cell
| string
Holidays used in computing business days, returned as an
NINST
-by-1
vector of
datetimes.
Data Types: datetime
End-of-month rule flag for generating dates when
Maturity
is an end-of-month date for a month with 30
or fewer days, returned as an
NINST
-by-1
matrix (or an
NINST
-by-2
matrix if
EndMonthRule
is different for each leg).
Data Types: logical
Forward starting date of payments, returned as a scalar datetime or an
NINST
-by-1
vector of datetimes.
Data Types: datetime
Indicator whether the currency swap exchanges principal at
Settle
, returned as a scalar logical value of
true
or false
or an
NINST
-by-1
matrix.
Data Types: logical
Indicator whether the currency swap exchanges principal at
Maturity
, returned as a scalar logical value of
true
or false
or an
NINST
-by-1
matrix.
Data Types: logical
User-defined name for the instrument, returned as a scalar string or an
NINST
-by-1
string array.
Data Types: string
Examples
This example shows the workflow to price a CurrencySwap
instrument by using two ratecurve
objects for two zero rates for different currencies and then use a FXDiscount
pricing method.
Create ratecurve
Objects
Create two ratecurve
objects using ratecurve
for the discounting cash flows for the CurrencySwap
instrument. The ZeroCurve_USD
zero curve is for US currency and the EUR_Zero
zero curve is for Euro currency.
Settle = datetime(2023,9,15); % US Currency USD_Dates = datemnth(Settle,[1 3 6 12*[1 2 3 5 7 10 20 30]]'); USD_Zero = [0.03 0.06 0.08 0.13 0.36 0.76 1.63 2.29 2.88 3.64 3.89]'/100; ZeroCurve_USD = ratecurve("zero",Settle,USD_Dates,USD_Zero,Compounding=1)
ZeroCurve_USD = ratecurve with properties: Type: "zero" Compounding: 1 Basis: 0 Dates: [11×1 datetime] Rates: [11×1 double] Settle: 15-Sep-2023 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
% Euro currency EUR_Dates = datemnth(Settle,[3 6 12*[1 2 3 5 7 10 20 30]]'); EUR_Zero = [0.017 0.033 0.088 .27 .512 1.056 1.573 2.183 2.898 2.797]'/100; ZeroCurve_EUR = ratecurve("zero",Settle,EUR_Dates,EUR_Zero,Compounding=1)
ZeroCurve_EUR = ratecurve with properties: Type: "zero" Compounding: 1 Basis: 0 Dates: [10×1 datetime] Rates: [10×1 double] Settle: 15-Sep-2023 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create CurrencySwap
Instrument Object
Use fininstrument
to create a CurrencySwap
instrument object.
% Cross-Currency Swap Data Maturity_FXSwap = Settle + calyears(10); LegRate_FXSwap = [2.5 4]/100; LegType_FXSwap = ["fixed" "fixed"]; LegReset_FXSwap = [2 2]; Notional_FXSwap = [100 100/1.1]; CurrencySwap = fininstrument("CurrencySwap",Maturity=Maturity_FXSwap,LegRate=LegRate_FXSwap,LegType=LegType_FXSwap,Reset=LegReset_FXSwap,Notional=Notional_FXSwap,Name="currencyswap_instrument")
CurrencySwap = CurrencySwap with properties: LegRate: [0.0250 0.0400] LegType: ["fixed" "fixed"] Reset: [2 2] Basis: [0 0] Notional: [100 90.9091] LatestFloatingRate: [NaN NaN] ResetOffset: [0 0] DaycountAdjustedCashFlow: [0 0] ProjectionCurve: [0×0 ratecurve] BusinessDayConvention: ["actual" "actual"] Holidays: NaT EndMonthRule: [1 1] ExchangeInitialNotional: 1 ExchangeMaturityNotional: 1 StartDate: NaT Maturity: 15-Sep-2033 Name: "currencyswap_instrument"
Create FXDiscount
Pricer Object
Use finpricer
to create a FXDiscount
pricer object and use the two ratecurve
objects for the DiscountCurve
name-value argument.
FXRate = [1 1.1];
myFXPricer = finpricer("FXDiscount",DiscountCurve=[ZeroCurve_EUR ZeroCurve_USD],FXRate=FXRate)
myFXPricer = FXDiscount with properties: DiscountCurve: [1×2 ratecurve] FXRate: [1 1.1000]
Price CurrencySwap
Instrument
Use price
to compute the price and sensitivities for the CurrencySwap
instrument.
[Price_FXSwap,outPR] = price(myFXPricer,CurrencySwap,"all")
Price_FXSwap = -7.5751
outPR = priceresult with properties: Results: [1×2 table] PricerData: []
outPR.Results
ans=1×2 table
Price DV01
_______ _________
-7.5751 0.0019076
This example shows the workflow to price multiple CurrencySwap
instruments by using two ratecurve
objects for two zero rates for different currencies and then use a FXDiscount
pricing method.
Create ratecurve
Objects
Create two ratecurve
objects using ratecurve
for the discounting cash flows for the CurrencySwap
instrument. The ZeroCurve_USD
zero curve is for US currency and the EUR_Zero
zero curve is for Euro currency.
Settle = datetime(2023,9,15); % US Currency USD_Dates = datemnth(Settle,[1 3 6 12*[1 2 3 5 7 10 20 30]]'); USD_Zero = [0.03 0.06 0.08 0.13 0.36 0.76 1.63 2.29 2.88 3.64 3.89]'/100; ZeroCurve_USD = ratecurve("zero",Settle,USD_Dates,USD_Zero,Compounding=1)
ZeroCurve_USD = ratecurve with properties: Type: "zero" Compounding: 1 Basis: 0 Dates: [11×1 datetime] Rates: [11×1 double] Settle: 15-Sep-2023 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
% Euro currency EUR_Dates = datemnth(Settle,[3 6 12*[1 2 3 5 7 10 20 30]]'); EUR_Zero = [0.017 0.033 0.088 .27 .512 1.056 1.573 2.183 2.898 2.797]'/100; ZeroCurve_EUR = ratecurve("zero",Settle,EUR_Dates,EUR_Zero,Compounding=1)
ZeroCurve_EUR = ratecurve with properties: Type: "zero" Compounding: 1 Basis: 0 Dates: [10×1 datetime] Rates: [10×1 double] Settle: 15-Sep-2023 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create CurrencySwap
Instrument Object
Use fininstrument
to create a CurrencySwap
instrument object with three Currency Swap instruments.
% Cross-Currency Swap Data LegRate_FXSwap = [2.5 4]/100; LegType_FXSwap = ["fixed" "fixed"]; LegReset_FXSwap = [2 2]; Notional_FXSwap = [100 100/1.1]; CurrencySwap = fininstrument("CurrencySwap",Maturity=datetime([2024,9,15 ; 2025,9,15 ; 2026,9,15]),LegRate=LegRate_FXSwap,LegType=LegType_FXSwap,Reset=LegReset_FXSwap,Notional=Notional_FXSwap,Name="currencyswap_instrument")
CurrencySwap=3×1 CurrencySwap array with properties:
LegRate
LegType
Reset
Basis
Notional
LatestFloatingRate
ResetOffset
DaycountAdjustedCashFlow
ProjectionCurve
BusinessDayConvention
Holidays
EndMonthRule
ExchangeInitialNotional
ExchangeMaturityNotional
StartDate
Maturity
Name
Create FXDiscount
Pricer Object
Use finpricer
to create a FXDiscount
pricer object and use the two ratecurve
objects for the DiscountCurve
name-value argument.
FXRate = [1 1.1];
myFXPricer = finpricer("FXDiscount",DiscountCurve=[ZeroCurve_EUR ZeroCurve_USD],FXRate=FXRate)
myFXPricer = FXDiscount with properties: DiscountCurve: [1×2 ratecurve] FXRate: [1 1.1000]
Price CurrencySwap
Instruments
Use price
to compute the price and sensitivities for the three CurrencySwap
instruments.
[Price_FXSwap,outPR] = price(myFXPricer,CurrencySwap,"all")
Price_FXSwap = 3×1
-1.4560
-2.8083
-3.7209
outPR=1×3 priceresult array with properties:
Results
PricerData
outPR.Results
ans=1×2 table
Price DV01
______ __________
-1.456 0.00082253
ans=1×2 table
Price DV01
_______ ________
-2.8083 0.001519
ans=1×2 table
Price DV01
_______ _________
-3.7209 0.0020789
More About
A vanilla currency swap consists of two streams (legs) of fixed or floating interest payments denominated in two currencies.
A vanilla currency swap involves two parties agreeing to exchange cash flows based on a notional amount in two different currencies. This notional amount, representing the swap's principal value, is used to calculate interest payments but is typically not exchanged.
For example, Party A agrees to pay Party B a fixed interest rate in USD on a notional amount of $1 million, while Party B agrees to pay Party A a floating interest rate in EUR on the same notional amount. The exchange of interest payments occurs periodically, such as semiannually or annually, based on predetermined dates.
The workflow includes:
Agreement — Two parties, the fixed and floating payers, agree on the notional amount.
Interest Rate Determination — The parties agree on fixed and floating interest rates. The floating rate is usually linked to a reference rate and reset periodically.
Cash Flow Exchange — Periodically, the parties exchange cash flows based on the notional amount in their respective currencies.
Currency Conversion — If the notional amounts are in different currencies, a conversion occurs using prevailing market rates.
Principal Exchange — At the currency swap's end, the notional amount is exchanged back between the parties at the current exchange rate.
The purpose of a vanilla currency swap is to secure cheaper debt (by borrowing at the best available rate regardless of currency and then swapping for debt in desired currency using a back-to-back loan) or to hedge against foreign exchange rate fluctuations.
A forward currency swap consists of two streams (legs) of fixed or floating interest payments denominated in two currencies in which the exchange of cash flows begins at a future date, rather than immediately.
In a forward currency swap, two parties agree to exchange specified amounts of two different currencies at a specified future date and then reverse the exchange at another future date. This agreement allows the parties to lock in exchange rates for future transactions, which can be particularly useful for hedging against potential adverse movements in currency exchange rates.
The workflow includes:
Agreement — Two parties, the fixed and floating payers, agree on the notional amount.
Interest Rate Determination — The parties agree on fixed and floating interest rates. The floating rate is usually linked to a reference rate for a forward exchange rate.
Cash Flow Exchange — On an agreed future date, the parties exchange cash flows based on the notional amount in their respective currencies.
Principal Exchange — At the currency swap's end at another future date, the notional amount is exchanged back between the parties at the agreed upon forward rate.
The are several purposes for using forward currency swaps, such as:
Hedge against a foreign exchange risk.
Speculate on the future movements in exchange rates.
Manage debt obligations if borrowing costs are lower in a foreign currency. A company might borrow in that currency and use a forward currency swap to eliminate the foreign exchange risk.
Arbitrage a discrepancy between the forward exchange rate and the expected future spot rate.
Manage liquidity if a company has assets in one currency but needs liquidity in another. A forward currency swap can provide access to the needed funds.
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)