Code Monkey home page Code Monkey logo

cordapp-option's Introduction

Corda

Option CorDapp

This CorDapp allows nodes to issue, trade and exercise call and put options.

When issuing or trading an option, an oracle is used to ensure that the option is being exchanged for the correct amount of cash, based on the oracle's knowledge of stock prices, volatility and the Black-Scholes model.

The CorDapp is split into three modules:

  • Client: The flows required by non-oracle nodes to query the oracle and request their signature over a transaction including oracle data. Also includes a web front-end and a flow to self-issue cash
  • Oracle: The flows and services required by oracle nodes to respond to data and signing queries
  • Base: A collection of files that non-oracle and oracle nodes need to share, such as contract and state definitions

There is also a series of tests under src/.

The project is structured in this way so that non-oracle nodes only have to run the non-oracle flows and the web API, while oracle nodes only have to run the oracle flows and services.

Pre-requisites:

See https://docs.corda.net/getting-set-up.html.

Usage

Running the nodes:

See https://docs.corda.net/tutorial-cordapp.html#running-the-example-cordapp.

Interacting with the nodes:

You should interact with this CorDapp using the web front-end. Each node exposes this front-end on a different address:

  • Issuer: localhost:10007/web/option
  • PartyA: localhost:10010/web/option
  • PartyB: localhost:10013/web/option

When using the front-end:

  1. Start by issuing yourself some cash using the Issue cash button (the sky's the limit - about 1,000 should do)
  2. Request the issuance of an option from another node using the Request option button
    • The issuer will sell you the option requested at it's fair value calculated using Black-Scholes
  3. Hit the refresh button (either the one on the web UI or your browser's) and you should see a list of your options and remaining cash
  4. You can now choose to:
    • Trade the option with another node for cash, by clicking the Exercise button next to the option. The option will disappear (assuming the other node already has enough cash to pay for it!). If you visit the front-end of the node that you traded the option with, you will now see it listed there
    • Exercise the option. This will lock in the exercise date, allowing you to redeem it with the issuer at a later date (this functionality is not implemented yet, but would only require an additional flow and piece of contract logic)

To-Do

  • Exercised options cannot yet be redeemed for cash from the issuer
  • Only five stocks are supported, and the exercise date is hardcoded
  • Once exercised, the Trade button is still displayed next to a node's options
  • The contract tests are focused on the happy-path

cordapp-option's People

Contributors

caismanai avatar caisr3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cordapp-option's Issues

Can not issue two option from the same node?

Hi there,

I found that I cannot issue two options from the same node. Say I(PartyB) want to request two options from the Issuer. When I request the second one, it will raise error that "the initiator of collectsignaturesFlow must pass in exact sessions". How to fix the bug?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.