Giter Club home page Giter Club logo

kquantlib's Introduction

kquantlib

A kdb library to call Quantlib C++ library via embedpy with a simple interface (similar to R Quantlib interface)

Example

Price an European Option

q).ql.EuropeanOption[`call; 100; 120; 0.0; 0.0; 1f; 0.2; ()!()]
NPV  | 2.107961
delta| 0.2065062
gamma| 0.01436687
vega | 28.34013
theta| -2.873374
rho  | 18.28865

Implied vol from option prices

q).ql.EuropeanOptionImpliedVolatility[`call; 2.107961; 100; 120; 0.0; 0.0; 1f; .25]
0.2

Vol Curves

DATE: 2020.12.31;
EXP:  2021.01.15;
spot: first exec CLOSE from .ek.getOhlc[`SPY.P; 2020.12.31; 2020.12.31;`daily]
strikes:  `int$spot + til[51] - 20

/option market prices
options: .ek.getOption[`SPY; `c; EXP; ] each strikes
opt_prices: update strike: strikes from .ek.getOhlc[options; 2020.12.31; 2020.12.31;`daily]
vols: {.ql.EuropeanOptionImpliedVolatility[`call; first x`CLOSE; spot; first x`strike; 0.0; 0.0; (EXP-DATE)%360; .1]} each  opt_prices

/plot
plt: .p.import`matplotlib.pyplot
plt[`:plot][strikes; vols; `label pykw `vol];
plt[`:vlines][spot; min vols; max vols; `label pykw `spot; `colors pykw `r];
plt[`:title] "SPY Jan 15 2021 Vol Curve";
plt[`:xlabel]`strike;
plt[`:legend][];
plt[`:show][];

img

kquantlib's People

Contributors

kaizeng avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

moussazeghida

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.