merz9b / optionpricing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option Pricing in kdb+/q

This repository contains q scripts which can be used to generates Asian and European option prices using Black Scholes, Monte Carlo and Quasi-Monte Carlo methods. The methods demonstrated follow the work presented in the paper S. Kucherenko et. al 2007. The scripts also include wrappers for the C++ pseudo-random and Sobol sequence number generators, along with the functions required to produce both cumulative and inverse cumulative normal distributions.

Requirements

  • JupyterQ - this produces a tree dependency for kdb+, Python and embedPy
  • Sobol C++ library - SobolSeq1024 function provided within the library, with max dimension of 1024.
  • matplotlib

Note: Before running any of the code, make sure that $QHOME is defined.

Installation

To create the shared object files for the number generators and distribution functions the below must be run:

Linux:

make && make install && make clean

Windows (within build):

call build.bat

Note: build.bat runs with Visual Studio 2017. To run with 2019 replace line 9 with:

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"

For other versions, please modify file accordingly.

Loading

Examples of option pricing using all of the techniques provided in the library can be run using the Jupyter notebook provided or by running the below script:

q)\l op.q
q)loadfile`:init.q
q)loadfile`:q/run.q

Note that run.q can be multi-threaded.

About


Languages

Language:HTML 46.8%Language:Jupyter Notebook 30.7%Language:C 22.0%Language:q 0.3%Language:C++ 0.1%Language:Makefile 0.1%Language:Batchfile 0.0%Language:HiveQL 0.0%