Coder Social home page Coder Social logo

fang_oost_option_rust's Introduction

Linux Codecov
lin-badge cov-badge

Fang-Oosterlee Option Pricing for Rust

Implements Fang-Oosterlee option pricing in Rust. Documentation is at docs.rs

Use

The crate is available on crates.io.

Import and use:

extern crate num_complex;
use num_complex::Complex;
extern crate fang_oost_option;
use rayon::prelude::*;
use fang_oost_option::option_pricing;
let num_u:usize = 256;
let asset = 50.0;
let strikes = vec![75.0, 50.0, 40.0];
// max_strike sets the domain of the empirical estimate.  
// This should be large enough to capture the potential
// dynamics of the underlying, but not too large or accuracy
// will sacrificed.  A good rule of thumb is to scale this
// in proportion to the volatility of the underlying.  For
// example, if the underlying is 50.0 and has a (log) 
// volatility of 0.3, then a good max strike would be
// exp(0.3*scale)*50.0.  I tend to use scale=10, yielding
// in this example ~1004.
let max_strike = 1004.0; 
let rate = 0.03;
let t_maturity = 0.5;
let volatility:f64 = 0.3; 
//As an example, cf is standard diffusion
let cf = |u: &Complex<f64>| {
    ((rate-volatility*volatility*0.5)*t_maturity*u+volatility*volatility*t_maturity*u*u*0.5).exp()
};
let prices: Vec<fang_oost::GraphElement>= option_pricing::fang_oost_call_price(
    num_u, asset, &strikes, max_strike,
    rate, t_maturity, &cf
).collect();

Speed

The benchmarks are comparable to my C++ implementation. To run the tests with benchmarking, use cargo bench. You can see the benchmarks at https://danielhstahl.github.io/fang_oost_option_rust/report/index.html.

fang_oost_option_rust's People

Contributors

changdaniel avatar danielhstahl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shabbirhasan1

fang_oost_option_rust's Issues

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.