<p>The demos can be run either from the command line, or from inside IntelliJ. Running from the command line is
recommended if you just want to see the demos run, whereas using IntelliJ can be helpful if you want to debug or
extend the demos. For more details about running via the command line or from within IntelliJ, see <aclass="reference internal"href="CLI-vs-IDE.html"><spanclass="doc">CLI vs IDE</span></a>.</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> to open up four new terminals with the four nodes</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:trader-demo:runBuyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node.
<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>
</ol>
<p>To run from the command line in Windows:</p>
<olclass="arabic simple">
<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> to open up four new terminals with the four nodes</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">samples:trader-demo:runBuyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node.
This step will display progress information related to the cash issuance process (in the Bank of Corda node log output)</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>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <codeclass="docutils literal"><spanclass="pre">Trader</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Nodes</span></code> configuration, which will start four 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">Trader</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Buyer</span></code> to instruct the buyer node to request issuance of some cash from the Bank of Corda node</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">Trader</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Seller</span></code> to trigger the transaction</li>
<li>In the “Trader Demo: Run Nodes” run configuration window, you should see some log lines scroll past. Within a few seconds, the message
“Purchase complete - we are a happy customer!” should be printed.</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>Move 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> to open up three new terminals with the three nodes (you may have to install xterm).</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./install/irs-demo/bin/irs-demo</span><spanclass="pre">--role</span><spanclass="pre">UploadRates</span></code>. You should see a
message be printed to the first node (the notary/oracle/network map node) saying that it has accepted the new
interest rates</li>
<li>Now run <codeclass="docutils literal"><spanclass="pre">./install/irs-demo/bin/irs-demo</span><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">./install/irs-demo/bin/irs-demo</span><spanclass="pre">--role</span><spanclass="pre">Date</span><spanclass="pre">2017-12-12</span></code> to roll the simulated clock forward and see some fixings take place</li>
</ol>
<p>To run from the command line in Windows:</p>
<olclass="arabic simple">
<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>Move 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> 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>. You should see a
message be printed to the first node (the notary/oracle/network map node) saying that it has accepted the new
interest rates</li>
<li>Now run <codeclass="docutils literal"><spanclass="pre">install\irs-demo\bin\irs-demo</span><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">install\irs-demo\bin\irs-demo</span><spanclass="pre">--role</span><spanclass="pre">Date</span><spanclass="pre">2017-12-12</span></code> to roll the simulated clock forward and see some fixings take place</li>
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <codeclass="docutils literal"><spanclass="pre">IRS</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Nodes</span></code> configuration to start three 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">IRS</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Upload</span><spanclass="pre">Rates</span></code> to upload the new interest rates to the oracle</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">IRS</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Trade</span></code> to have the nodes agree on a trade</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">IRS</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Date</span><spanclass="pre">Change</span></code> to roll the simulated clock forward and see some fixings take place</li>
<li>In the “IRS Demo: Run Nodes” window you’ll see a lot of activity when you run the trade and when you change the date.
The date change rolls the clock forwards and causes the nodes to agree on the fixings over a period.</li>
<p>This demo also has a web app. To use this, run nodes and upload rates, then navigate to
<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 each node’s view of the ledger.</p>
<p>To use the web app, click the “Create Deal” button, fill in the form, then click the “Submit” button. You can then
use the time controls at the top left of the home page to run the fixings. Click any individual trade in the blotter to view it.</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 a trade to start</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:attachment-demo:runSender</span></code> in another terminal window to send the attachment. Now look at the other windows to
<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 a trade to start</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">samples:attachment-demo:runSender</span></code> in another terminal window to send the attachment. Now look at the other windows to
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <codeclass="docutils literal"><spanclass="pre">Attachment</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Nodes</span></code> configuration to start three 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">Attachment</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Recipient</span></code>, which will wait for a trade to start</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">Attachment</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Sender</span></code> to send the attachment</li>
<li>In the “Attachment Demo: Run Nodes” window you should see some log lines scroll past. Within a few seconds, the
message “File received - we’re happy!” should be printed.</li>
<h2>Raft Notary demo<aclass="headerlink"href="#raft-notary-demo"title="Permalink to this headline">¶</a></h2>
<p>This demo shows 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 counterparties will generate transactions
that transfer 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 can service client requests, and one signature is sufficient to satisfy the notary composite key requirement.
You will notice that successive transactions get signed by different members of the cluster (usually allocated in a random order).</p>
<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 ...” message 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>To run from the command line in Windows:</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 ...” message 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>To run from IntelliJ:</p>
<olclass="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>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 the <codeclass="docutils literal"><spanclass="pre">Notary</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Notarisation</span></code> configuration 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>
<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\bin\h2</span></code> for Windows)</p>
</li>
<li><pclass="first">If you are uncertain as to which version of h2 to install or if you have connectivity issues, refer to <codeclass="docutils literal"><spanclass="pre">build.gradle</span></code>
located in the <codeclass="docutils literal"><spanclass="pre">node</span></code> directory and locate the compile step for <codeclass="docutils literal"><spanclass="pre">com.h2database</span></code>. Use a client of the same
<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,
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:bank-of-corda-demo:deployNodes</span></code> to create a set of configs and installs under <codeclass="docutils literal"><spanclass="pre">samples/bank-of-corda-demo/build/nodes</span></code></li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./samples/bank-of-corda-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:bank-of-corda-demo:runRPCCashIssue</span></code> to trigger a cash issuance request</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:bank-of-corda-demo:runWebCashIssue</span></code> to trigger another cash issuance request.
Now look at the Bank of Corda terminal tab/window to see the output of the demo</li>
</ol>
<p>To run from the command line in Windows:</p>
<olclass="arabic simple">
<li>Run <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">samples:bank-of-corda-demo:deployNodes</span></code> to create a set of configs and installs under <codeclass="docutils literal"><spanclass="pre">samples\bank-of-corda-demo\build\nodes</span></code></li>
<li>Run <codeclass="docutils literal"><spanclass="pre">samples\bank-of-corda-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:bank-of-corda-demo:runRPCCashIssue</span></code> to trigger a cash issuance request</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">samples:bank-of-corda-demo:runWebCashIssue</span></code> to trigger another cash issuance request.
Now look at the Bank of Corda terminal tab/window to see the output of the demo</li>
</ol>
<p>To run from IntelliJ:</p>
<olclass="arabic simple">
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <codeclass="docutils literal"><spanclass="pre">Bank</span><spanclass="pre">Of</span><spanclass="pre">Corda</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Issuer</span></code> configuration to start three 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">Bank</span><spanclass="pre">Of</span><spanclass="pre">Corda</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">RPC</span><spanclass="pre">Cash</span><spanclass="pre">Issue</span></code> to request issuance of some cash on behalf of Big Corporation via RPC</li>
<li>Run <codeclass="docutils literal"><spanclass="pre">Bank</span><spanclass="pre">Of</span><spanclass="pre">Corda</span><spanclass="pre">Demo:</span><spanclass="pre">Run</span><spanclass="pre">Web</span><spanclass="pre">Cash</span><spanclass="pre">Issue</span></code> to request issuance of some cash on behalf of Big Corporation via HTTP</li>
<div><codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">tools:explorer:run</span></code> (on Unix) or <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">tools:explorer:run</span></code> (on Windows)</div></blockquote>
<p>See <aclass="reference external"href="https://docs.corda.net/node-explorer.html">https://docs.corda.net/node-explorer.html</a> for further details on usage.</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>
<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>
<li>Deploy the nodes using <codeclass="docutils literal"><spanclass="pre">./gradlew</span><spanclass="pre">samples:simm-valuation-demo:deployNodes</span></code></li>
<li>Run the nodes using <codeclass="docutils literal"><spanclass="pre">./samples/simm-valuation-demo/build/nodes/runnodes</span></code></li>
<li>Deploy the nodes using <codeclass="docutils literal"><spanclass="pre">gradlew</span><spanclass="pre">samples:simm-valuation-demo:deployNodes</span></code></li>
<li>Run the nodes using <codeclass="docutils literal"><spanclass="pre">samples\simm-valuation-demo\build\nodes\runnodes</span></code></li>
<li>Open the Corda project in IntelliJ and import the Gradle project</li>
<li>Run the <codeclass="docutils literal"><spanclass="pre">SIMM</span><spanclass="pre">Valuation</span><spanclass="pre">Demo</span></code> configuration</li>
<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>
and are visible to <aclass="reference external"href="http://localhost:10007/web/simmvaluationdemo/">Bank B</a>.</p>
<p>Please note that any URL path information after <cite>simmvaluationdemo</cite> should not be bookmarked or navigated to directly, as it is only provided for aesthetic purposes.</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>.