ronniec95 / black_scholes Goto Github PK
View Code? Open in Web Editor NEWA SIMD based black scholes pricer using the http://crates.io/wide crate
A SIMD based black scholes pricer using the http://crates.io/wide crate
I just read your article about:
https://medium.com/@mushfaqueronniechowdhury/probably-the-fastest-black-scholes-pricer-in-world-34103e97f7eb
Thank you for enlightening me with some math I otherwise wouldn't be able to understand without your article.
You are a super-hero.
First off thank you so much for writing this crate! If it wasn't for this I wouldn't even know where to start. I'm working on trying to calculate some greeks and seeing if it matches data the nasdaq is producing. I'm using the $1000 2022-01-28 PUT for tesla as an example. Using the following code:
use black_scholes_pricer::put_greeks;
use chrono::NaiveDate;
let expiry = NaiveDate::from_ymd(2022, 1, 28);
let today = NaiveDate::from_ymd(2021, 12, 25);
let days_until_expire = expiry.signed_duration_since(today).num_days();
println!("Days until expire: {}", days_until_expire);
let greeks = put_greeks(
&[52.0],
&[1000.0],
&[days_until_expire as f32 / 252.0],
&[0.0],
&[0.62578],
&[0.0],
);
println!("{:?}", greeks);
I get this output:
Days until expire: 34
Greeks { pv: [948.0, NaN, NaN, NaN, NaN, NaN, NaN, NaN], delta: [-1.0, NaN, NaN, NaN, NaN, NaN, NaN, NaN], theta: [-3409717700000000000000000000000000000.0, NaN, NaN, NaN, NaN, NaN, NaN, NaN], gamma: [-6440186000000000000000000000000000.0, NaN, NaN, NaN, NaN, NaN, NaN, NaN], rho: [-134.92064, NaN, NaN, NaN, NaN, NaN, NaN, NaN], vega: [1470297200000000000000000000000000000.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }
If I modify the inputs and remove the division by 252 from the days_util_expire and actually gets pretty close to the nasdaq output.
Greeks { pv: [987.7166, NaN, NaN, NaN, NaN, NaN, NaN, NaN], delta: [-0.15524423, NaN, NaN, NaN, NaN, NaN, NaN, NaN], theta: [-1.8617551, NaN, NaN, NaN, NaN, NaN, NaN, NaN], gamma: [-0.0035164347, NaN, NaN, NaN, NaN, NaN, NaN, NaN], rho: [-33856.836, NaN, NaN, NaN, NaN, NaN, NaN, NaN], vega: [202.30647, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }
I'm likely not understanding something about how to use this function.
This test is failing when I try on aarch64 or x86_64 targets. Is this left intentionally broken, or otherwise? ๐ค
I'm currently investigating what's available in Rust for black scholes. Would be nice to be able to use your work but I'm not sure if it's too experimental at the moment ๐
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.