From a formula
A pricing formula is translated into typed Chelis, and each line links to its span in the source.
C = S N(d1) - K e-rT N(d2)
def call_price(
spot: f32, strike: f32, rate: f32, sigma: f32, tenor: f32
) -> f32 = {
d_1 = d1(spot, strike, rate, sigma, tenor)
d_2 = d2(spot, strike, rate, sigma, tenor)
discount = rate |> mul(tenor) |> neg |> exp
spot_leg = spot |> mul(normal_cdf(d_1))
strike_leg = strike |> mul(discount) |> mul(normal_cdf(d_2))
sub(spot_leg, strike_leg)
}