-
Notifications
You must be signed in to change notification settings - Fork 10
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
Smith Wilson yield #37
Smith Wilson yield #37
Conversation
Added the Smith-Wilson curve with a simple test.
Adds CalibrationInstruments that can be used for calibrating a SmithWilsonYield
Add quote structs for different instrument types with conversion to CalibrationInstruments
This looks like a great start, and I apprciate already addings tests. I think to be most effective in reviewing and figuring out how this fits in with the rest of the package, I need to first follow what SW is doing and found the following resources which could be sources of additional information and test cases: I translated the linked example above into Julia to help me follow along. I still need to digest what each step was doing, as thus far it was more of a translation exercise. |
Codecov Report
@@ Coverage Diff @@
## master #37 +/- ##
==========================================
+ Coverage 95.26% 96.29% +1.03%
==========================================
Files 1 1
Lines 169 243 +74
==========================================
+ Hits 161 234 +73
- Misses 8 9 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
src/smith_wilson.jl
Outdated
struct CalibrationInstruments | ||
t # Column vector of maturities | ||
cf # Matrix of cash flow for each [maturity, instrument] | ||
p # Row vector of instrument prices | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to be used aside from constructing a SW curve, nor is it used for dispatch. Would it be simpler or easier to remember to pass a tuple or named arguments instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original intent was that there would be an AbstractCalibrationInstruments
where you could also do things like iterate over the cash flows and put that into a bootstrapping algorithm. But I agree that until that exists, it's going to look over-engineered to have a struct for just the sw curve.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it brings up the question about pulling basic asset instruments into its own set of types and/or package? There's a lot more that could be explored there, like basic asset modeling. I don't think we have to hold up SW yields for that, but it could be a near term feature to build out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's probably not a bad idea, it'd be quite useful to have that (and fun to make, hopefully 😃 ). But I'll focus on wrapping this up as a minimal stand-alone pr and address your feedback. Thanks for comments and thoughts so far!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick status: I reviewable PR is not far away now, expected to be 300-400 lines of code + a bit of README. I suppose it's best to put it back into Yields.jl
and runtests.jl
. I think I can better find my way around those files now 😃.
My understanding is that one of the key advantages of SW is that it's analytically solved with no boostrapping. When would this be combined with bootstrapping? Some things to do before merging:
|
src/smith_wilson.jl
Outdated
export InstrumentQuotes, ZeroCouponQuotes, SwapQuotes, BulletBondQuotes | ||
|
||
""" | ||
SmithWilsonYield(ufr,alpha,u,qb) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be better to just call this SmithWilson
. I don't think there's an ambiguity issue, and reads better when imported elsewhere, e.g.:
import Yields
Yields.SmithWilson(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, the literature seems to be so consistent in the use of α
and Julia make it so easy to enter unicode, I think we should just use α
instead of alpha
Another area I'd like to consider: should the rest of the package just reference the instruments defined here? E.g. instead of: curve = Yields.Zero(rates,maturities) it would be the following for bootstrapping: curve = boostrap(zcp::ZeroCouponPrices) #change the current ZeroCouponQuotes to Prices
curve = bootstrap(zcp::ZeroCouponRates) # using a set of market rates instead of prices or SW curve = SmithWilson(ufr,alpha,zcp) |
This is sparking a lot of really great ideas, thanks for the PR again! |
Brings the addition of the Smith-Wilson yield curve up to a reviewable state.
I've tried to keep it as unsurprising as possible based on above discussions. Main changes
I get lots of code reviews in my day job, so please go ahead and review in whatever style you like 😄. |
src/Yields.jl
Outdated
""" | ||
SmithWilson(ufr, α, u, qb) | ||
|
||
Create a yield curve object that implements the Smith-Wilson interpolation/extrapolation scheme. | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind document what the meaning of each of the arguments is?
…ies.jl; use dispatch on `cashflows`
A few tweaks:
One solid request and then a question before merging:
|
Thanks for tweaking, much appreciated ❤️.
Commit on it's way. I can also see I missed a little test coverage, so I'll add that too. |
Made alpha and ufr keyword arguments in convenience constructors for Yields.SmithWilson
…ntly keywordargs
I made a few final tweaks to docstrings and made the |
Now Registered as available package update! Also now mentioned on the JuliaActuary.org site: https://juliaactuary.org/#yieldsjl |
Example of the Smith-Wilson yield curve included into Yields.jl. This is a draft for discussing ideas, so it's a little light on testing, doc and performance optimizations.
It thrown together from code I had lying around, and I didn't make a big effort to make it look Yields.jl'ish. The
CalibrationInstruments
struct makes a lot of sense for the SW curve, since the calibration neatly reduces to a linear algebra problem, but for e.g. bootstrapping, the structure would have to be different (as a start, you would want instruments ordered by expiry).