Coder Social home page Coder Social logo

ashayp22 / volatility-surface-explorer Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 1.91 MB

Interactive Implied Volatility Surface Explorer

Home Page: https://ashayp22.github.io/volatility-surface-explorer/

License: GNU General Public License v3.0

HTML 0.18% JavaScript 97.98% Rust 1.72% CSS 0.12%
implied-volatility plotlyjs rayon rust simd wasm

volatility-surface-explorer's Introduction

Implied Volatility Surface Explorer

Implied Volatility Surface Explorer website

An interactive, fast, and practical Implied Volatility Surface Explorer for SPY and similar options from the CBOE quotes dashboard. Implied Volatility is calculated using the Bisection method and optimized with SIMD and Rayon and ported to the web with WASM. Surfaces are plotted using Plotly.

Usage

Local

To run locally, add below to Cargo.toml:

[lib]
crate-type = ["cdylib"]

Next, compile from Rust to WASM with (if your machine doesn't support WASM, remove the RUSTFLAGS):

RUSTFLAGS='-C target-feature=+simd128' wasm-pack build --target web

This will generate a pkg directory. Then, run the website locally:

npx serve

You may view the sample data or upload the most recent SPY data from CBOE. To do this, visit the CBOE delayed quotes website:

Implied Volatility Surface Explorer website

Then, update the Volume, Expiration Type, Options Range, Size, and Expiration filters as desired and scroll to the bottom to Download CSV.

Implied Volatility Surface Explorer website

Finally, download the CSV file and upload it to the website.

Performance and Testing

To run the Rust benchmark locally, comment out these lines in the Cargo.toml

[lib]
crate-type = ["cdylib"]

and then run

cargo bench

Similarily, for tests:

cargo test

Performance

Calculated on a Macbook M1:

Calculating implied volatility for ~25000 options (~25x speed-up):

  • bs::implied_vol() (single): ~25.2ms
  • vol32x8::implied_vol() (SIMD and multithreaded): ~1ms

Calculating interest rate using Put-Call parity for ~25000 options (~2x speed-up):

  • bs::parity_interest_rate() (single): ~91.683 µs
  • vol32x8::parity_interest_rate() (SIMD and multithreaded): ~56.079 µs

Extensions

  1. In real-life applications, the implied volatility calculation should happen in the backend in order to full utilize SIMD instructions and multithreading. Instead of being converted to WASM, the Rust code can be deployed in a backend system and connected to the frontend with HTTP or another protocol.
  2. If the Rust -> WASM is kept, multithreading can be utilized in the frontend by enabling SharedArrayBuffer in the browser, adding wasm-bindgen-rayon, and re-compiling to WASM.
  3. Support other historical or realtime market data feeds.

License

GNU GPL v3

volatility-surface-explorer's People

Contributors

ashayp22 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

shabbirhasan1

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.