Code Monkey home page Code Monkey logo

hebiv's Introduction

hebiv

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil1

A multithreaded Python package for computing option implied volatilities.

Migration in progress.

Includes a demo script2 that performs a comparison of execution speed for the iterative computation of Black and Bachelier implied volatility using Halley's and Newton's methods. The script compares the time taken to solve the Black and Bachelier implied volatilities of ~1 million European option prices for a pure Python implementation using scipy.optimize.newton, a mixed implementation where a minimalistic C implementation of Halley's/Newton's method is used to solve for the price but iteration through prices is still done in Python, and a ctypes wrapped pure C implementation. The script illustrates the difference in speed between converting data types and looping directly in C versus iterating through the prices in Python and using ctypes to call the C function for each price3.

There is a small test suite that can be run with pytest after installation.

Installation

Note:

The following sections are out of date and foremly from the c_npy_demo README.rst. They will change in the future.

From source

Building from this (unstable) repo will probably only work on Linux systems. Local extension builds are done on WSL Ubuntu 18.04 with gcc 9.3 while builds on Travis CI virtual machines are done on Ubuntu 18.04 with gcc 7.4. There is also an implicit dependency on the gcc version being high enough such that an OpenMP implementation is included4. For example, I have libgomp.so.1.0.0 in /usr/lib/x86_64-linux-gnu/, with appropriate symbolic links.

From PyPI

Although this package is not on PyPI (yet), I have successfully built manylinux1 wheels using Travis CI on the manylinux1 Docker images provided by PyPA, of which more information can be found at the manylinux GitHub.

Contents

TBA. Currently looks like some pure Python code, pytest test suite, demo module to run benchmarks, separate C shared library for implied volatility calculations, and a Python extension module written in C.

Documentation

In progress, and will be eventually be hosted on Read the Docs. For now, the doc directory probably only has conf.py and index.rst.


  1. Attributed to Sir Tony Hoare, popularized by Donald Knuth.

  2. This does not exist yet.

  3. Should include a demo of how multithreading helps with large inputs.

  4. Fun exercise: Find where I have (sparingly) used OpenMP directives.

hebiv's People

Contributors

phetdam avatar

Watchers

James Cloos avatar  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.