Comments (2)
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?
from quantlib.jl.
Hi @pazzo83 ,
I'm curious about the units that you mention, do you have a separate type for that?
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 :)
from quantlib.jl.
Related Issues (16)
- Build Yield Term Structure Fitting Methods with ZeroCouponBonds HOT 1
- Unsatisfiable requirements detected for package StatsFuns HOT 4
- Register as official Julia package HOT 2
- Precompile error in Julia 1.3. HOT 7
- Price bond with yield
- Correct Julia patterns?
- Use expm1 HOT 2
- Backwards schedule bug?
- test error at test/swaptions.jl:93
- ERROR: Unsatisfiable requirements detected for package StatsBase
- Issue with Dierckx
- main2 in bond_test_code.jl HOT 2
- getting started, Failed to precompile Distributions HOT 1
- error on runtest HOT 2
- Is this project still being maintained? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quantlib.jl.