Hello dears,
Would you please review the herebelow piece of code w.r.t the style, the way of doing things, performance-wise if possible… not necessarily task specific, but as a Julia programmer in general, how do you feel about this code, what would be your advice if any.
Thank you.
piece of code
function _evaluate(
::HullWhite1F,
::Type{Swaption},
t::T,
strike::R1,
expiry::T,
inception::T,
paydates::AbstractVector{T},
cvgs::AbstractVector{<:Real},
r::R2,
yc::YieldCurve,
θ::R3,
σ::R4,
ispayer::Bool=true,
notional::Real=1,
dcc::DayCountConventions=ActAct(),
f::Function=getcurve(yc,t,what=:forwardcurve,dcc=dcc),
low::R5=0.0,
upp::R5=5.0
) where {T<:TimePoint,R1<:Real,R2<:Real,R3<:Real,R4<:Real,R5<:Real}
@assert isequal(length(paydates),length(cvgs))
_r=_find_hw1f_rstar(paydates,cvgs,strike,yc,expiry,t,θ,σ,dcc,f,dcc,low,upp)
xi = map(paydates) do x
_dummy_hw1f_zcb_price(
yc, x, expiry, θ, σ, _r, first(gettimes(yc)),
dcc,notional,f,low,upp
)
end
ci = strike * cvgs
ci[end] += 1
ocol = ifelse(ispayer,Put,Call)
_pee = map(ci, paydates, xi) do a,b,c
a * _evaluate(
HullWhite1F(), EuropeanOption{ZeroBond}, t, c, expiry,
ocol, b, inception, 1, r, θ, σ, yc, dcc
)
end
notional * sum(_pee)
end