Black Scholes Formula in Rust

Our team at Hack Reactor is building a web framework in Rust and for the first day, we took a step back and had a one day hackathon to get sped up. Naturally I wanted to benchmark calculators and that afternoon I tested Rust against Python and Javascript. Results below.

Black Scholes Merton

Introduced in 1973, in a paper entitled, “The Pricing of Options and Corporate Liabilities,” the professors put forth a derivatives pricing model that led to the Nobel Prize in Economics. This pricing formula gives a theoretical estimate of the price of European call and put options and makes many assumptions to achieve this. I am using this as a fair way to compare the three languages.

Why Rust?

Rust is a systems programming language that runs blazingly fast, prevents almost all crashes and eliminates data races. It features pattern matching, closures and type inference while providing guaranteed memory safety and optional garbage collection. But most importantly… its blazingly fast.

Rust is ready to roll


Python has been increasingly gaining in popularity in Finance for the benefit of developers. Its got amazing statistics libraries and its nice to read. After testing 1M iterations of Rust, it handedly beat Python by 26.87% with each operation taking 3.57 seconds to calculate Black Scholes. If speed is your concern but you still want high level functionality, check out Rust!

Javascript 7.22222 seconds
Python 4.88832 seconds
Rust 3.57484 seconds

*Rust and Python are run with no optimizations. and Javascript was run in console. Node was much faster and the optimized versions are much faster
Code is here

Leave a Reply

Your email address will not be published. Required fields are marked *