Git Product home page Git Product logo

cairo-black-scholes's Introduction

Cairo Black-Scholes Library

Black-Scholes library implemented as a Cairo smart contract.

All inputs, outputs, and internal calculations use 27-digit fixed-point numbers.

Library

This library implements the interface described here. The external functions exposed allow you to retrieve the Black-Scholes call and put option prices and the option greeks, given the expiration time, volatility, spot price, strike price, and interest rate.

Validation

The pytest deploys the smart contract in a local test environment and queries for the call and put option prices with randomly generated test inputs. Each test input consists of (expiration time, volatility, spot price, strike price, interest rate).

The results are compared against the options prices as computed by the py_vollib library. The test validates that the error from the Cairo library and the py_vollib libary is minimal. Option greeks were validated against online tools such as this one.

Test Instructions

  1. First make sure you can run a basic StarkNet contract unit test (see here).
  2. Install py_vollib: pip install py_vollib.
  3. Clone this repo and run pytest black_scholes_test.py.

SHARP

In the sharp/ folder, you can generate a proof of call option price computation for a given input (input.json) using the Shared Prover (SHARP) and check that the proof gets verified on-chain by running:

cairo-sharp submit --source black_scholes.cairo --program_input input.json

cairo-sharp status {JOB_KEY}

When the status is "PROCESSED", you can check to see if it is verified on chain.

cairo-sharp is_verified {FACT} --node_url https://goerli-light.eth.linkpool.io/

cairo-black-scholes's People

Contributors

bengtlofgren avatar araghava avatar

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.