Code Monkey home page Code Monkey logo

ultimaql's Introduction

REST API web application for derivative pricing and market data storage

Fast and scalable server for derivative pricing

Key features

  • Async runtime
  • Multithreading for compute intensive pricing
  • swagger ui

Products supported

  • EuropeanOptions

Models supported

  • Black76

Architecture & Tech Stack

Rust for web sevrer and compute

Although we could easily achieve the same output with Python and Django/Flask the performance sensitive nature of our task begs for a better solution. I chose Rust, a modern language compiled to Assembly just like C, for the reasons outlined below:

  • No garbage collector, making our server extremely fast and efficient
  • async frameworks like Actix
  • multi-core utilization for compute intensive work (options pricing). Unlike Python, we are not limited by GIL and hence can utilise all cores of the running host.
  • Easy integration with Python. For example ultibi and polars are written in Rust and have very well-functioning python interface (for more details see pyo3)

MongoDB

Naturally, Market Data comes in various shapes and forms. A spot is a totally different object then say Volatility Surface. Hence, Non Structured database would be preffered to

  • Importantly we use name (name of the market data object, eg US_OIS) and as_of (observation date of the object) as a unique index.

How to Run

Prerequisites

  • docker

Steps

From the top level directory: docker-compose up --build - this builds two docker images (one from Dockerfile which is the backend server and another is the standard mongo image) and run them.

To check out swagger docs navigate to: http://localhost:8000/swagger-ui/ in your browser. You will see:

Ultima Logo

Windows PowerShell

  1. Upload Market Data:
curl.exe -H 'content-type: application/json' -X POST http://localhost:8000/api/marketdata -d '[ {\"name\":\"Brent\",\"as_of\":\"2021-12-01\",\"value\":95.6},
{\"name\":\"OIS\",\"as_of\":\"2021-12-01\",\"day_count_conv\":\"Act365\",\"compounding\":\"Continuous\",\"values\":[[\"2021-12-02\",0.001],[\"2021-12-15\",0.02],[\"2021-12-31\",0.03]]},
{\"name\":\"ImplVol_Brent_100\",\"as_of\":\"2021-12-01\",\"day_count_conv\":\"Act365\",\"compounding\":\"Continuous\",\"values\":[[\"2021-12-02\",0.05],[\"2021-12-15\",0.1],[\"2021-12-31\",0.2]]}
]'
  1. Review/Retrieve Market Data:
curl.exe -X GET 'http://localhost:8000/api/marketdata?name=Brent&as_of=2021-12-01'
  1. Price an Option:
curl.exe -H 'content-type: application/json' -X POST http://localhost:8000/api/price -d '{\"type\":\"PriceRequest\",\"instrument\":{\"type\":\"EurpoeanOption\",\"underlying\":\"Brent\",\"yield_curve\":\"OIS\",\"implied_vol\":\"ImplVol_Brent_100\",\"strike\":100.0,\"direction\":\"Call\",\"exp\":\"2023-11-30\"},\"date\": \"2021-12-01\"}'
  1. Delete Market Data:
curl.exe -X DELETE 'http://localhost:8000/api/marketdata?name=Brent&as_of=2021-12-01'

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.