Class: Rupee::Benchmark
- Inherits:
-
Object
- Object
- Rupee::Benchmark
- Defined in:
- lib/rupee/benchmark.rb
Overview
Just for use in benchmarking the performance of Rupee code
Class Method Summary collapse
-
.black_scholes(call_put_flag, s, x, t, r, v) ⇒ Object
Black-Scholes option price valuation.
Class Method Details
.black_scholes(call_put_flag, s, x, t, r, v) ⇒ Object
Black-Scholes option price valuation
by Michael Neumann (with some revisions)
10 11 12 13 14 15 16 17 18 |
# File 'lib/rupee/benchmark.rb', line 10 def black_scholes(call_put_flag, s, x, t, r, v) d1 = (Math.log(s / x) + (r + v * v / 2.0) * t) / (v * Math.sqrt(t)) d2 = d1 - v * Math.sqrt(t) if call_put_flag == 'c' s * cnd(d1) - x * Math.exp(-r * t) * cnd(d2) else x * Math.exp(-r * t) * cnd(-d2) - s * cnd(-d1) end end |