From c5da28623c9075b0ff59a7e9f52f79e073b9bb50 Mon Sep 17 00:00:00 2001 From: Gianluigi Davassi Date: Sat, 14 Jun 2025 12:16:31 +0200 Subject: [PATCH] Add Black-Scholes example --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index f5e83dc..5dd8d99 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,21 @@ There are a few predefined math constants available: gamma -> 0.57721566... ``` +## Example: Black-Scholes Option Pricing + +Using Yarer, the Black–Scholes formula for a European call option can be evaluated straight from the CLI. + +```rust + $ yarer + Yarer v.0.1.7 - Yet Another Rust Expression Resolver. + License MIT OR Apache-2.0 + > S=100;K=100;T=1;r=0.05;sigma=0.2; + > d1=(ln(S/K)+(r+sigma^2/2)*T)/(sigma*sqrt(T)) + > d2=d1-sigma*sqrt(T) + > S*cdf(d1)-K*exp(-r*T)*cdf(d2) + 10.450583572185565 +``` + ## Execute To run it from cargo, just type: