JuliaQuant / FinancialDerivatives.jl

Financial derivatives modeling and pricing in Julia.
https://juliaquant.github.io/FinancialDerivatives.jl/dev/
Other
57 stars 13 forks source link

Derivatives require too-strict type signatures #8

Closed millerjoey closed 1 year ago

millerjoey commented 2 years ago

It seems like your dispatching for derivatives is too strict. Terms like

struct AmericanOption{T<:Number} <: Option
    s::T
    k::T
    r::T
    σ::T
    t::T
    call::Int64
end

mean that you can't create an option with mixed Ints and Floats like AmericanOption(10, 12, 0.05, 0.4, 1, 1). Also, I don't think you use the parameterization {T} when you dispatch on it later in evaluate(...), so I'd suggest modifying the definitions to:

struct AmericanOption <: Option
    s::Real
    k::Real
    r::Real
    σ::Real
    t::Real
    call::Int64
end

I can make a PR and run tests to make sure when I get a chance. Let me know if I'm missing anything obvious though!