-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-currency swap #1
Comments
Thanks @EricForgy! I haven't gotten to cross-currency swaps yet, but I will definitely take into account that design flaw in QuantLib itself (I wasn't aware of it). I'm curious about the units that you mention, do you have a separate type for that? |
Hi @pazzo83 ,
I've been thinking of this problem for a while and it recently came up on julia-users group here: For the time being, I decided not go that route, i.e. implement each unit as a type and handle dispatch through parameters, and instead implemented a type: Units = Union{Currency,Identifier}
type Holding{Q<:Number,U<:Units}
quantity::Q
units::U
end
Holding() = Holding{Int64,Currency}(0,HKD)
Holding(quantity,units) = Holding{typeof(quantity),typeof(units)}(quantity,units) My Currency type is an enum, so I would define hkd = Holding(1,HKD) and then define arithmetic operators so that julia> 10hkd
Holding:
Quantity: 10
Units: HKD
julia> 10hkd + 20hkd
Holding:
Quantity: 30
Units: HKD
julia> 10hkd + 5usd
ERROR: Unit mismatch I haven't done any benchmarking yet, so I don't know if this is a horrible idea, but at least I'm able to make progress :) |
Hi @pazzo83
This package looks great and will be a good inspiration for me and my team.
I also considered QuantLib originally, but we are based in Asia and one of the most important swaps in this part of the world for institutional investors would be cross-currency swaps. I may have misunderstood, but it wasn't clear how QuantLib would handle cross-currency swaps. For example, see the "Further Developments" sections here:
It indicates an initial design flaw with QuantLib. Could this (or has this) been corrected with JQuantLib?
For our internal work, we value instruments not with a simple float, but with a type that has units, e.g. 10usd, 20sgd, etc.
Best regards,
Eric
The text was updated successfully, but these errors were encountered: