mirror of
https://github.com/corda/corda.git
synced 2024-12-27 00:21:12 +00:00
313 lines
16 KiB
HTML
313 lines
16 KiB
HTML
|
|
|
|
<!DOCTYPE html>
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>The Interest Rate Swap Contract — R3 Corda latest documentation</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="top" title="R3 Corda latest documentation" href="index.html"/>
|
|
<link rel="next" title="Where to start" href="where-to-start.html"/>
|
|
<link rel="prev" title="Node administration" href="node-administration.html"/>
|
|
|
|
|
|
<script src="_static/js/modernizr.min.js"></script>
|
|
|
|
</head>
|
|
|
|
<body class="wy-body-for-nav" role="document">
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
<div class="wy-side-scroll">
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
|
|
<a href="index.html" class="icon icon-home"> R3 Corda
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
<div class="version">
|
|
latest
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
|
|
|
|
<br>
|
|
<a href="api/index.html">API reference</a>
|
|
|
|
</div>
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
<p class="caption"><span class="caption-text">Overview</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1"><a class="reference internal" href="inthebox.html">What’s included?</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="getting-set-up.html">Getting set up</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="data-model.html">Data model</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="consensus.html">Consensus Model</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="messaging.html">Networking and messaging</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="running-the-demos.html">Running the demos</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="node-administration.html">Node administration</a></li>
|
|
<li class="toctree-l1 current"><a class="current reference internal" href="#">The Interest Rate Swap Contract</a><ul>
|
|
<li class="toctree-l2"><a class="reference internal" href="#creating-an-instance-and-lifecycle">Creating an instance and lifecycle</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="#technical-details">Technical Details</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">Tutorials</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="where-to-start.html">Where to start</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="tutorial-contract.html">Writing a contract</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="protocol-state-machines.html">Protocol state machines</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="oracles.html">Writing oracle services</a></li>
|
|
</ul>
|
|
<p class="caption"><span class="caption-text">Appendix</span></p>
|
|
<ul>
|
|
<li class="toctree-l1"><a class="reference internal" href="release-process.html">Release process</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release notes</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="visualiser.html">Using the visualiser</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="codestyle.html">Code style guide</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="building-the-docs.html">Building the documentation</a></li>
|
|
</ul>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
<a href="index.html">R3 Corda</a>
|
|
</nav>
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
<ul class="wy-breadcrumbs">
|
|
<li><a href="index.html">Docs</a> »</li>
|
|
|
|
<li>The Interest Rate Swap Contract</li>
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
<a href="_sources/irs.txt" rel="nofollow"> View page source</a>
|
|
|
|
|
|
</li>
|
|
</ul>
|
|
<hr/>
|
|
</div>
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
<div itemprop="articleBody">
|
|
|
|
<div class="section" id="the-interest-rate-swap-contract">
|
|
<h1>The Interest Rate Swap Contract<a class="headerlink" href="#the-interest-rate-swap-contract" title="Permalink to this headline">¶</a></h1>
|
|
<p>The Interest Rate Swap (IRS) Contract (source: IRS.kt, IRSUtils.kt, IRSExport.kt) is a bilateral contract to implement a
|
|
vanilla fixed / floating same currency IRS.</p>
|
|
<p>In general, an IRS allows two counterparties to modify their exposure from changes in the underlying interest rate. They
|
|
are often used as a hedging instrument, convert a fixed rate loan to a floating rate loan, vice versa etc.</p>
|
|
<p>The IRS contract exists over a period of time (normally measurable in years). It starts on its value date
|
|
(although this is not the agreement date), and is considered to be no longer active after its maturity date. During that
|
|
time, there is an exchange of cash flows which are calculated by looking at the economics of each leg. These are based
|
|
upon an amount that is not actually exchanged but notionally used for the calculation (and is hence known as the notional
|
|
amount), and a rate that is either fixed at the creation of the swap (for the fixed leg), or based upon a reference rate
|
|
that is retrieved during the swap (for the floating leg). An example reference rate might be something such as ‘LIBOR 3M’.</p>
|
|
<p>The fixed leg has its rate computed and set in advance, where as the floating leg has a fixing process whereas the rate
|
|
for the next period is fixed with relation to a reference rate. Then, a calculation is performed such that the interest
|
|
due over that period multiplied by the notional is paid (normally at the end of the period). If these two legs have the
|
|
same payment date, then these flows can be offset against each other (in reality there are normally a number of these
|
|
swaps that are live between two counterparties, so that further netting is performed at counterparty level).</p>
|
|
<p>The fixed leg and floating leg do not have to have the same period frequency. In fact, conventional swaps do not have
|
|
the same period.</p>
|
|
<p>Currently, there is no notion of an actual payment or obligation being performed in the contract code we have written;
|
|
it merely represents that the payment needs to be made.</p>
|
|
<p>Consider the diagram below; the x-axis represents time and the y-axis the size of the leg payments (not to scale), from
|
|
the view of the floating leg receiver / fixed leg payer. The enumerated documents represent the versions of the IRS as
|
|
it progresses (note that, the first version exists before the value date), the dots on the “y=0” represent an interest
|
|
rate value becoming available and then the curved arrow indicates to which period the fixing applies.</p>
|
|
<img alt="_images/irs.png" src="_images/irs.png" />
|
|
<p>Two days (by convention, although this can be modified), before the value date (ie the start of the swap) in the red
|
|
period the reference rate is observed from an oracle and fixed in the instance at 1.1%. At the end of the accrual period,
|
|
there is an obligation from the floating leg payer of 1.1% * notional amount * days in the accrual period / 360.
|
|
(Also note that the result of “days in the accrual period / 360” is also known as the day count factor, although other
|
|
conventions are allowed and will be supported). This amount is then paid at a determined time at the end of the accrual period.</p>
|
|
<p>Again, two working days before the blue period, the rate is fixed (this time at 0.5% - however in reality, the rates
|
|
would not be so significantly different), and the same calculation is performed to evaluate the payment that will be due
|
|
at the end of this period.</p>
|
|
<p>This process continues until the swap reaches maturity and the final payments are calculated.</p>
|
|
<div class="section" id="creating-an-instance-and-lifecycle">
|
|
<h2>Creating an instance and lifecycle<a class="headerlink" href="#creating-an-instance-and-lifecycle" title="Permalink to this headline">¶</a></h2>
|
|
<p>There are two valid operations on an IRS. The first is to generate via the <code class="docutils literal"><span class="pre">Agree</span></code> command (signed by both parties)
|
|
and the second (and repeated operation) is <code class="docutils literal"><span class="pre">Fix</span></code> to apply a rate fixing.
|
|
To see the minimum dataset required for the creation of an IRS, refer to <code class="docutils literal"><span class="pre">IRSTests.kt</span></code> which has two examples in the
|
|
function <code class="docutils literal"><span class="pre">IRSTests.createDummyIRS()</span></code>. Implicitly, when the agree function is called, the floating leg and fixed
|
|
leg payment schedules are created (more details below) and can be queried.</p>
|
|
<p>Once an IRS hase been agreed, then the the only valid operation is to apply a fixing on one of the entries in the
|
|
<code class="docutils literal"><span class="pre">Calculation.floatingLegPaymentSchedule</span></code> map. Fixes do not have to be applied in order (although it does make most
|
|
sense to do them so).</p>
|
|
<p>Examples of applying fixings to rates can been seen in <code class="docutils literal"><span class="pre">IRSTests.generateIRSandFixSome()</span></code> which loops through the next
|
|
fixing date of an IRS that is created with the above example function and then applies a fixing of 0.052% to each floating
|
|
event.</p>
|
|
<p>Currently, there are no matured, termination or dispute operations.</p>
|
|
</div>
|
|
<div class="section" id="technical-details">
|
|
<h2>Technical Details<a class="headerlink" href="#technical-details" title="Permalink to this headline">¶</a></h2>
|
|
<p>The contract itself comprises of 4 data state classes, <code class="docutils literal"><span class="pre">FixedLeg</span></code>, <code class="docutils literal"><span class="pre">FloatingLeg</span></code>, <code class="docutils literal"><span class="pre">Common</span></code> and <code class="docutils literal"><span class="pre">Calculation</span></code>.
|
|
Recall that the platform model is strictly immutable. To further that, between states, the only class that is modified
|
|
is the <code class="docutils literal"><span class="pre">Calculation</span></code> class.</p>
|
|
<p>The <code class="docutils literal"><span class="pre">Common</span></code> data class contains all data that is general to the entire swap, e.g. data like trade identifier,
|
|
valuation date, etc.</p>
|
|
<p>The Fixed and Floating leg classes derive from a common base class <code class="docutils literal"><span class="pre">CommonLeg</span></code>. This is due to the simple reason that
|
|
they share a lot of common fields.</p>
|
|
<p>The <code class="docutils literal"><span class="pre">CommonLeg</span></code> class contains the notional amount, a payment frequency, the effective date (as well as an adjustment
|
|
option), a termination date (and optional adjustment), the day count basis for day factor calculation, the payment delay
|
|
and calendar for the payment as well as the accrual adjustment options.</p>
|
|
<p>The <code class="docutils literal"><span class="pre">FixedLeg</span></code> contains all the details for the <code class="docutils literal"><span class="pre">CommonLeg</span></code> as well as payer details, the rate the leg is fixed at
|
|
and the date roll convention (ie what to do if the calculated date lands on a bank holiday or weekend).</p>
|
|
<p>The <code class="docutils literal"><span class="pre">FloatingLeg</span></code> contains all the details for the CommonLeg and payer details, roll convention, the fixing roll
|
|
convention, which day of the month the reset is calculated, the frequency period of the fixing, the fixing calendar and
|
|
the details for the reference index (source and tenor).</p>
|
|
<p>The <code class="docutils literal"><span class="pre">Calculation</span></code> class contains an expression (that can be evaluated via the ledger using variables provided and also
|
|
any members of the contract) and two schedules - a <code class="docutils literal"><span class="pre">floatingLegPaymentSchedule</span></code> and a <code class="docutils literal"><span class="pre">fixedLegPaymentSchedule</span></code>.
|
|
The fixed leg schedule is obviously pre-ordained, however, during the lifetime of the swap, the floating leg schedule is
|
|
regenerated upon each fixing being presented.</p>
|
|
<p>For this reason, there are two helper functions on the floating leg. <code class="docutils literal"><span class="pre">Calculation.getFixing</span></code> returns the date of the
|
|
earliest unset fixing, and <code class="docutils literal"><span class="pre">Calculation.applyFixing</span></code> returns a new Calculation object with the revised fixing in place.
|
|
Note that both schedules are, for consistency, indexed by payment dates, but the fixing is (due to the convention of
|
|
taking place two days previously) not going to be on that date.</p>
|
|
<div class="admonition note">
|
|
<p class="first admonition-title">Note</p>
|
|
<p class="last">Payment events in the <code class="docutils literal"><span class="pre">floatingLegPaymentSchedule</span></code> that start as a <code class="docutils literal"><span class="pre">FloatingRatePaymentEvent</span></code> (which is a
|
|
representation of a payment for a rate that has not yet been finalised) are replaced in their entirety with an
|
|
equivalent <code class="docutils literal"><span class="pre">FixedRatePaymentEvent</span></code> (which is the same type that is on the <code class="docutils literal"><span class="pre">FixedLeg</span></code>).</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<footer>
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
<a href="where-to-start.html" class="btn btn-neutral float-right" title="Where to start" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
<a href="node-administration.html" class="btn btn-neutral" title="Node administration" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
</div>
|
|
|
|
|
|
<hr/>
|
|
|
|
<div role="contentinfo">
|
|
<p>
|
|
© Copyright 2016, Distributed Ledger Group, LLC.
|
|
|
|
</p>
|
|
</div>
|
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
</footer>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT:'./',
|
|
VERSION:'latest',
|
|
COLLAPSE_INDEX:false,
|
|
FILE_SUFFIX:'.html',
|
|
HAS_SOURCE: true
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="_static/js/theme.js"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
jQuery(function () {
|
|
SphinxRtdTheme.StickyNav.enable();
|
|
});
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |