<liclass="toctree-l2"><aclass="reference internal"href="#important-common-instructions-for-all-demos">Important : Common Instructions for all demos</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="oracles.html#implementing-an-oracle-with-continuously-varying-data">Implementing an oracle with continuously varying data</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="oracles.html#using-an-oracle">Using an oracle</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="setting-up-a-corda-network.html">Introduction - What is a corda network?</a></li>
<liclass="toctree-l1"><aclass="reference internal"href="setting-up-a-corda-network.html#setting-up-your-own-network">Setting up your own network</a></li>
<h2>Important : Common Instructions for all demos<aclass="headerlink"href="#important-common-instructions-for-all-demos"title="Permalink to this headline">¶</a></h2>
develop the demos themselves. For more details about running via the command line or within IntelliJ - see <aclass="reference internal"href="CLI-vs-IDE.html"><spanclass="doc">CLI vs IDE</span></a>.</p>
<p><em>For all demos:</em> The <codeclass="docutils literal"><spanclass="pre">install</span></code> gradle task is automatically ran if required; this no longer needs to be run independently.</p>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:trader-demo:deployNodes</span></code> to create a set of configs and installs under <codeclass="docutils literal"><spanclass="pre">samples/trader-demo/build/nodes</span></code></li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./samples/trader-demo/build/nodes/runnodes</span></code> (or <codeclass="docutils literal"><spanclass="pre">runnodes.bat</span></code> on Windows) to open up three new terminals with the three nodes.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:trader-demo:runBuyer</span></code> to set up the buyer node with some self-issued cash. This step
is not expected to print much.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:trader-demo:runSeller</span></code> to trigger the transaction. You can see both sides of the
trade print their progress and final transaction state in the bank node tabs/windows.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:irs-demo:deployNodes</span></code> to install configs and a command line tool under <codeclass="docutils literal"><spanclass="pre">samples/irs-demo/build</span></code>.</li>
<li>Change to the <codeclass="docutils literal"><spanclass="pre">samples/irs-demo/build</span></code> directory.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./nodes/runnodes</span></code> (or <codeclass="docutils literal"><spanclass="pre">runnodes.bat</span></code> on Windows) to open up three new terminals with the three nodes.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./install/irs-demo/bin/irs-demo</span><spanclass="pre">--role</span><spanclass="pre">UploadRates</span></code> (or use <codeclass="docutils literal"><spanclass="pre">irs-demo.bat</span></code> on Windows). You should see a
message be printed to the first node (the notary/oracle/network map node) saying that it has accepted some new
interest rates.</li>
<li>Now run <codeclass="docutils literal"><spanclass="pre">irs-demo</span></code> as in step 4, but this time with <codeclass="docutils literal"><spanclass="pre">--role</span><spanclass="pre">Trade</span><spanclass="pre">1</span></code>. The number is a trade ID. You should
see lots of activity as the nodes set up the deal, notarise it, get it signed by the oracle and so on.</li>
<li>Now run <codeclass="docutils literal"><spanclass="pre">irs-demo</span><spanclass="pre">--role</span><spanclass="pre">Date</span><spanclass="pre">2016-12-12</span></code> to roll the simulated clock forward and see some fixings take place.</li>
<aclass="reference external"href="http://localhost:10005/web/irsdemo">http://localhost:10005/web/irsdemo</a> and <aclass="reference external"href="http://localhost:10007/web/irsdemo">http://localhost:10007/web/irsdemo</a> to see both node’s view of the ledger.</p>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:attachment-demo:deployNodes</span></code> to create a set of configs and installs under <codeclass="docutils literal"><spanclass="pre">samples/attachment-demo/build/nodes</span></code></li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./samples/attachment-demo/build/nodes/runnodes</span></code> to open up three new terminal tabs/windows with the three nodes.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:attachment-demo:runRecipient</span></code>, which will block waiting for something to happen.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:attachment-demo:runSender</span></code> in another terminal window to trigger the transaction.
Now look at the other windows to see the output of the demo.</li>
</ol>
<p>Or you can run them from inside IntelliJ, but when done this way, all the node output is printed to a single console.</p>
<spanid="notary-demo"></span><h2>Distributed Notary demo<aclass="headerlink"href="#distributed-notary-demo"title="Permalink to this headline">¶</a></h2>
<p>This is a simple demonstration showing a party getting transactions notarised by a distributed <aclass="reference external"href="https://raft.github.io/">Raft</a>-based notary service.
The demo will start three distributed notary nodes, and two counterparty nodes. One of the parties will generate transactions
that move a self-issued asset to the other party, and submit them for notarisation.</p>
<p>The output will display a list of notarised transaction ids and corresponding signer public keys. In the Raft distributed notary
every node in the cluster services client requests, and one signature is sufficient to satisfy the notary composite key requirement.
You will notice that subsequent transactions get signed by different members of the cluster (usually allocated in a random order).</p>
<p>To run from IntelliJ:</p>
<olclass="arabic simple">
<li>Open the Corda samples project in IntelliJ and run the <codeclass="docutils literal"><spanclass="pre">Notary</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Nodes</span></code> configuration to start the nodes.
Once all nodes are started you will see several “Node started up and registered in ...” messages.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">Notary</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Notarisation</span></code> to make a call to the “Party” node to initiate notarisation requests.
In a few seconds you will see a message “Notarised 10 transactions” with a list of transaction ids and the signer public keys.</li>
</ol>
<p>To run from the command line:</p>
<olclass="arabic simple">
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:raft-notary-demo:deployNodes</span></code>, which will create node directories with configs under <codeclass="docutils literal"><spanclass="pre">samples/raft-notary-demo/build/nodes</span></code>.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./samples/raft-notary-demo/build/nodes/runnodes</span></code>, which will start the nodes in separate terminal windows/tabs.
Wait until a “Node started up and registered in ...” appears on each of the terminals.</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:raft-notary-demo:notarise</span></code> to make a call to the “Party” node to initiate notarisation requests.
In a few seconds you will see a message “Notarised 10 transactions” with a list of transaction ids and the signer public keys.</li>
</ol>
<p>Notary nodes store consumed states in a replicated commit log, which is backed by a H2 database on each node.
To ascertain that the commit log is synchronised across the cluster you access and compare each of the nodes’ backing stores
by using the H2 web console:</p>
<ul>
<li><pclass="first">Firstly, download <aclass="reference external"href="http://www.h2database.com/html/download.html">H2 web console</a> (download the “platform-independent zip”),
and start it using a script in the extracted folder: <codeclass="docutils literal"><spanclass="pre">h2/bin/h2.sh</span></code> (or <codeclass="docutils literal"><spanclass="pre">h2.bat</span></code> for Windows)</p>
</li>
<li><pclass="first">The H2 web console should start up in a web browser tab. To connect we first need to obtain a JDBC connection string.
Each node outputs its connection string in the terminal window as it starts up. In a terminal window where a node is running,
<p>You can use the string on the right to connect to the h2 database: just paste it in to the <cite>JDBC URL</cite> field and click <em>Connect</em>.
You will be presented with a web application that enumerates all the available tables and provides an interface for you to query them using SQL.</p>
</li>
<li><pclass="first">The committed states are stored in the <codeclass="docutils literal"><spanclass="pre">NOTARY_COMMITTED_STATES</span></code> table. Note that the raw data is not human-readable,
but we’re only interested in the row count for this demo.</p>
<h2>SIMM and Portfolio Demo - aka the Initial Margin Agreement Demo<aclass="headerlink"href="#simm-and-portfolio-demo-aka-the-initial-margin-agreement-demo"title="Permalink to this headline">¶</a></h2>
<h3>Background and SIMM Introduction<aclass="headerlink"href="#background-and-simm-introduction"title="Permalink to this headline">¶</a></h3>
<p>This app is a demonstration of how Corda can be used for the real world requirement of initial margin calculation and
agreement; featuring the integration of complex and industry proven third party libraries into Corda nodes.</p>
<p>SIMM is an acronym for “Standard Initial Margin Model”. It is effectively the calculation of a “margin” that is paid
by one party to another when they agree a trade on certain types of transaction. This margin is
paid such that, in the event of one of the counterparties suffering a credit event
(a financial term and a polite way to say defaulting, not paying the debts that are due, or potentially even bankruptcy),
then the party that is owed any sum already has some of the amount that it should have been paid. This payment to the
receiving party is a preventative measure in order to reduce the risk of a potentially catastrophic default domino
effect that caused the <aclass="reference external"href="https://en.wikipedia.org/wiki/Financial_crisis_of_2007%E2%80%932008">Great Financial Crisis</a>,
as it means that they can be assured that if they need to pay another party, they will have a proportion of the funds
that they have been relying on.</p>
<p>To enact this, in September 2016, the ISDA committee - with full backing from various governing bodies -
<aclass="reference external"href="http://www2.isda.org/news/isda-simm-deployed-today-new-industry-standard-for-calculating-initial-margin-widely-adopted-by-market-participants">issued a ruling on what is known as the ISDA SIMM ™ model</a>,
a way of fairly and consistently calculating this margin. Any parties wishing to trade a financial product that is
covered under this ruling would, independently, use this model and calculate their margin payment requirement,
agree it with their trading counterparty and then pay (or receive, depending on the results of this calculation)
this amount. In the case of disagreement that is not resolved in a timely fashion, this payment would increase
and so therefore it is in the parties’ interest to reach agreement in as short as time frame as possible.</p>
<p>To be more accurate, the SIMM calculation is not performed on just one trade - it is calculated on an aggregate of
intermediary values (which in this model are sensitivities to risk factors) from a portfolio of trades; therefore
the input to a SIMM is actually this data, not the individual trades themselves.</p>
<p>Also note that implementations of the SIMM are actually protected and subject to license restrictions by ISDA
(this is due to the model itself being protected). We were fortunate enough to technically partner with
<aclass="reference external"href="http://www.opengamma.com">OpenGamma</a> who allowed us to demonstrate the SIMM process using their proprietary model.
In the source code released, we have replaced their analytics engine with very simple stub functions that allow
the process to run without actually calculating correct values, and can easily be swapped out in place for their real libraries.</p>
<p>Open the Corda samples project in IntelliJ and run the “Simm Valuation Demo” configuration</p>
<p>Now open <aclass="reference external"href="http://localhost:10005/web/simmvaluationdemo">http://localhost:10005/web/simmvaluationdemo</a> and <aclass="reference external"href="http://localhost:10007/web/simmvaluationdemo">http://localhost:10007/web/simmvaluationdemo</a> to view the two
nodes that this will have started respectively. You can now use the demo by creating trades and agreeing the valuations.
Also see the README located in samples/simm-valuation-demo.</p>
<h3>What happens in the demo (notionally)<aclass="headerlink"href="#what-happens-in-the-demo-notionally"title="Permalink to this headline">¶</a></h3>
<dlclass="docutils">
<dt>Preliminaries</dt>
<dd><ulclass="first last simple">
<li>Ensure that there are a number of live trades with another party financial products that are covered under the
ISDA SIMM agreement (if none, then use the demo to enter some simple trades as described below).</li>
</ul>
</dd>
<dt>Initial Margin Agreement Process</dt>
<dd><ulclass="first last simple">
<li>Agree that one will be performing the margining calculation against a portfolio of trades with another party, and agree the trades in that portfolio. In practice, one node will start the flow but it does not matter which node does.</li>
<li>Individually (at the node level), identify the data (static, reference etc) one will need in order to be able to calculate the metrics on those trades</li>
<li>Confirm with the other counterparty the dataset from the above set</li>
<li>Calculate any intermediary steps and values needed for the margin calculation (ie sensitivities to risk factors)</li>
<li>Agree on the results of these steps</li>
<li>Calculate the initial margin</li>
<li>Agree on the calculation of the above with the other party</li>
<li>In practice, pay (or receive) this margin (omitted for the sake of complexity for this example)</li>
<h3>Demo execution (step by step)<aclass="headerlink"href="#demo-execution-step-by-step"title="Permalink to this headline">¶</a></h3>
<p>The demonstration can be run in two ways - via IntelliJ (which will allow you to add breakpoints, debug, etc), or via gradle and the command line.</p>
<p>Run with IntelliJ</p>
<blockquote>
<div><olclass="arabic simple">
<li>Open the <codeclass="docutils literal"><spanclass="pre">corda</span></code> project with IntelliJ</li>
<li>Run the shared run configuration “SIMM Valuation Demo”</li>
</ol>
</div></blockquote>
<p>Run via CLI</p>
<blockquote>
<div><olclass="arabic">
<li><pclass="first">Navigate to the <codeclass="docutils literal"><spanclass="pre">samples/simm-valuation-demo</span></code> directory in your shell</p>
</li>
<li><pclass="first">Run the gradle target <codeclass="docutils literal"><spanclass="pre">deployNodes</span></code> (ie; <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">deployNodes</span></code> for Unix or <codeclass="docutils literal"><spanclass="pre">gradlew.bat</span></code> on Windows)</p>
<li>Browse to <aclass="reference external"href="http://localhost:10005/web/simmvaluationdemo">http://localhost:10005/web/simmvaluationdemo</a></li>
<li>Select the other counterparty (ie Bank B)</li>
<li>Enter at least 3 trades - via the “Create New Trade” tab.</li>
<li>On the “Agree Valuations” tab, click the “Start Calculations” button.</li>
</ol>
</dd>
</dl>
<p>Additionally, you can confirm that these trades are not visible from <aclass="reference external"href="http://localhost:10009/web/simmvaluationdemo/">Bank C’s node</a>.</p>
<p>Please note that any URL text after <cite>simmvaluationdemo</cite> should not be bookmarked or navigated directly to as they are only for aesthetics.</p>
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.