-
Notifications
You must be signed in to change notification settings - Fork 6
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
Considering swap data as inputs #1
Comments
Hi @DFallet, correct, I built it only with zeroized risk free rates in mind. Do you have any documentation or pointers what would need to be updated so it also takes swaps? |
hi Simicd, SW_code_excel.txt |
Hi @DFallet, first of all apologies for the late reply, my day job keeps me super busy these days. Thank you for investigating, indeed that sounds like a very promising avenue! When I did the initial development I also used the documentation provided by EIOPA (e.g. see Appendix C) Given my limited availability at the moment, I would highly appreciate your help. Writing the mathematical operation(s) from Excel/doc as matrix operations is probably the first step. Would you have time for that? Example smith-wilson-py/smithwilson/core.py Lines 89 to 96 in a21b773
All calculations are vectorized and use smith-wilson-py/smithwilson/core.py Line 117 in a21b773
Or here the Wilson matrix (with t1, t2 being vectors): smith-wilson-py/smithwilson/core.py Lines 50 to 52 in a21b773
with numpy: smith-wilson-py/smithwilson/core.py Lines 82 to 83 in a21b773
I expect that for swap rates/coupon bonds there will be again...
... which might or might not be similar or even the same as the ones for zero-coupon bonds. Once that's done the next step will be to extend the functions in core.py but as you can see in the examples, writing it in numpy will be very close to the mathematical notation. In any case I can help you with that once we get there. |
Hi Dejan, |
Hi @blah-crusader, Thanks for sharing! For some reason I received an e-mail notification but I can't see your comment in this thread so here the reference: I had a look at one of the sources and I think you're right, by introducing Estimator for special case of zero-coupon bonds (p. 17): Estimator for swaps/coupon bonds (p. 20): So with smith-wilson-py/smithwilson/core.py Lines 108 to 117 in a21b773
I checked out the official site but couldn't find an example of swap rates, could you point out where I can find a sample with real number? This would help to try out the approach and benchmark the implementation. |
Hi! Thanks for the elaborate reply. I have indeed accomodated the function as you say, and removed my question because i've been able to get it to work (using the example at the very end of http://janroman.dhis.org/finance/Smith%20Wilson/A_Technical_Note_on_the_Smith-Wilson_Method_100701.pdf). Here is a picture of my function. It is written inside a SmithWilsonCalibrator class, so it looks a little bit different but very based on your initial code. Note that the way I calculate the C matrix is quite lame, there is certainly a better way to do it but currently don't see how :) I've crosschecked, and using EURO swaps + the alpha shared by EIOPA I also obtain the exact same EURO curves, so it seems to work! Maybe as a last question; I saw a GIT repo (https://github.com/qnity/bisection_alpha_python) with very similar functions for smithwilson, where the EIOPA algo is developed to determine the optimal alpha convergence parameter for specific settings. I have tried that code to determine the optimal alpha for EURO curves, but am getting a slight different alpha compared to the ones shared by EIOPA. I probably also have to adapt the alpha-seeking algo to accomodate it for swaps as well. Did you also consider this already in the past, and if yes do you have some tips / references that might help you? :) Many thanks! |
Nice! Thank you @blah-crusader for sharing your implementation, I'll try and give it a go in the package in the course of this week. Two questions I'd have:
|
For the convergence alpha: No haven't investigated before but did some research now. As you highlighted, the documentation states that its iterative (p. 40). I couldn't find any analytical formula for alpha elsewhere. The scipy package has some optimization & numerical search algorithms. I haven't tested this but that's how it could work: from scipy import optimize
input_rates = [...]
input_t = [...]
ufr = 0.036
llp = 25
def minimize(alpha):
rates = sw.fit_smithwilson_rates(rates_obs=input_rates, # Input rates to be fitted
t_obs=input_t, # Maturities of these rates
t_target=[max(llp + 40, 60)], # Just obtain one fitted rate - namely for the maturity at which curve is supposed to converge to UFR
alpha=alpha, # The only parameter that will change during optimization
ufr=ufr) # Input
# Since t_target is only one maturity the rates will be a vector with just one element - get the first one
rate = rates[0]
# scipy's root finding algorithm tries to vary inputs such that the output converges to zero
# Hence express the result as fitted rate minus UFR which should be zero (or <0.00001) at the convergence maturity max(llp + 40, 60)
return rate - ufr
# Pass minimization function into scipy's optimize
# a & b are the bisection intervals within which alpha will be searched (0.05 is the minimum specified in the documentation)
# xtol governs the precision at which iterations will stop
root = optimize.bisect(minimize, a=0.05, b=1.0, xtol=0.00001) There are various optimization methods in scipy, bisect is just one of them. Not sure how they compare performance-wise, could be that there are faster ones! The code above assumes zero-coupon rates using |
Hi Both, |
@DFallet, thanks for the share, will certainly have a look! I think I am also quite close to developing it from my side. Were you already able to retrieve the same Alpha as EIOPA for one specific curve? |
Ah and indeed, they are vectors, correct. |
Thanks both of you! @blah-crusader That would be fantastic, could you send it to this e-mail address: equal.sand2038@fastmail.com? Euro swaps for whatever date you've been using to verify your code works! |
Just merged the convergence factor estimation into
Next I'll try and add the curve estimation from swaps. |
Hi guys, just saw the EIOPA upcoming S2 review, and apparently the extrapolation method is going more vacisek-style, seemingly a lot easier. Check from p14 https://www.eiopa.europa.eu/sites/default/files/solvency_ii/eiopa-bos-20-749-opinion-2020-review-solvency-ii.pdf . For me, this means this part of my programming project will probably get a bit less of attention for now. I personally think its a good thing, since if you look in the vba code of the alpha scanning algo, and the irregularity of the optimization for alpha using different algo’s, i was having doubts.. what do you think on the change? |
P.s. simicd i forgot to send you swap data, are you still interested? |
@blah-crusader Yes, still interested! |
Didn't know there was a review ongoing, thanks for sharing. I share your view, the iterative estimation of alpha makes it unnecessarily hard to reproduce the results. Having a simpler approach with known parameters would be an improvement relative to the current method. Would you know if (and when) this will become effective? |
Hello,
i was just looking at the program, and it seems that only allows for spot rates as inputs. but i was wondering how to input swap rates instead and make the formula work. i think that would be useful
The text was updated successfully, but these errors were encountered: