|
From: philippe h. <pha...@ma...> - 2024-05-20 19:51:12
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto">Well technically spread 01 is not constant so you’re supposed to solve for the oas spread with path wise discounting.<div>Your question about scenario probabilities is not QuantLib specific. If you want market implied (treasury swaption vol surface) then you won’t get an exact number. A better approach is to define scenarios as combinations of parallel shift plus slope shift plus concavity change across the 3-5y point. Then from a calibrated MC model, sort of “cluster” the outcomes across the 3 principal components above form which you can derive some probabilities and correlations. But then you might as well use the MC model and forget about specific scenarios. My understanding is that mortgage desks tee hat do not use stochastic rate models set their own probabilities “somehow” but they don’t follow risk neutral because if you use risk neutral scenarios you need to do it consistently. There are also ways to adjust the drift of a stochastic process to go from Q-measure (risk neutral) to P-measure (real world) and if you want to do your own then might be better to do that.<br><div><br id="lineBreakAtBeginningOfSignature"><div dir="ltr">Regards<div><br></div><div>Philippe Hatstadt</div><div>+1-203-252-0408</div><div><br></div></div><div dir="ltr"><br><blockquote type="cite">On May 20, 2024, at 2:57 PM, Michael (DataDriven portal) <mi...@da...> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr">Hi Luigi/Philippe:<br><br>Thanks a lot for your very valuable feedback! <div><br></div><div>We have implemented scenario based OAS calculations as follows:<br><br>1. A user selects a number of interest rate scenarios (e.g. base, 2 rally, 2 selloff, etc)<br>2. For each scenario (in step 1) we calculate a bond Future Price (using a prepayment vector that corresponds to an interest rate scenario)<div>3. Scenario Based OAS = (Expected Price (across Future Prices in 2) - Initial Price)/Spread01<br><br>We are not sure how to calculate probabilities for the user input scenarios (in step 1) though that would reflect implied volatilities. <br><br>What would be the best way to do this in QuantLib?<br><br>Thanks, <br><br>Michael <br><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 20, 2024 at 9:33 AM Philippe Hatstadt <<a href="mailto:pha...@ma...">pha...@ma...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div><div>A few things:<br></div><div>1. For scenario based OAS, speed is really not an issue as you are un likely to compute more than a few dozens or even hundred prices per iteration of the OAS solver (also see my point below about massive increase on OAS solving algo)<br></div><div>2. For Monte-Carlo, speed obviously matters more. If you calibrate a stochastic model to swaption (or treasury swaptions as I've seen it called, deriving UST bond option volatility surface for SOFR swaption surface) then you don't need to compute path probabilities as they are equal under the RN measure.<br></div><div>3. As far as QL utilities to build curves from a given stochastic path and discount a given cash flow path, there are no such utilities. If you use a log-linear discount factor curve, you can get speed by only storing the x-y coordinates (monthly). Then use standard QL objects to discount the cash flows once generated.<br></div><div>4. One trick you can use for OAS speed is to consider that exp((-rf+ oas)(T-t)) = exp(-rf(T-t)) * exp(oas(T-t)). In turn, for each path, you can pre-calculate all cash flow vectors CF(T-t) on the risk-free curve, and for each iteration of OAS, only recompute exp(oas(T-t)) vectors and apply them to the more complex pre-computed CF(T-t) vectors. This "orthogonalization" is legit, because your prepayment model should only depend on the risk-free curve for a given path, and usually, the prepayment calculations are slow. Stated differently, you only need to apply the prepayment model once for each path and there is no need to call it again for other intermediate oas guess values.<br></div><div>5. Which brings us to the OAS discussion. If you feel comfortable (I do not) using a one factor model, then you should be able to find both the engine and the calibration routines in QL (HW 1F as suggested by Luigi). However, the slope of the curve is considered important, so a two-factor model is needed. The only one I am aware of in QL is the G2++ model, but unfortunately, there is no time-tested calibration routine for it, as the renowned quant who built it passed away and sadly never got to finish it. Luigi has a Python PR outstanding to verify the input compatibility of some calibration routines (which I do not have enough time to address - apologies Luigi). So as long as you are comfortable with a one factor model for the stochastic part of your endeavor, you should be ok, otherwise, not sure there is an easy approach unless you go to C++ and dig deep into existing calibration routines for g2++ which may or not have been tested.<br></div><div><br></div><div> Philippe Hatstadt<br></div><div><br></div></div><blockquote type="cite"><div>On May 20, 2024, at 4:49 AM, Luigi Ballabio <<a href="mailto:lui...@gm..." target="_blank">lui...@gm...</a>> wrote:<br></div><div><br></div><div><br></div><div><div dir="ltr"><div>Hi Michael,<br></div><div><br></div><div>1. a very interesting question but I'm not sure of the answer. I'm guessing you could use a root solver for the spread given the prices implied by the new curves, but I'm probably missing a lot of details.<br></div><div>2. I think the closest we have is the possibility to generate future interest-rate paths via Monte Carlo given a Hull-White process (which in turn would be calibrated from a volatility surface).<br></div><div>3. At the moment, I guess the best way would be to extend the swig wrappers and recompile the wheel to add a call taking a list of dates and this moving the loop to C++. I don't know how feasible that is for you, though...<br></div><div><br></div><div>Luigi<br></div><div><br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2024 at 3:53 PM Michael (DataDriven portal) <<a href="mailto:mi...@da..." target="_blank">mi...@da...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div>Hi Luigi:<br></div><div><br></div><div>Thanks for getting back to me!<br></div></div><div><br></div><div><div>To be specific, we use QuantLib for mortgage bond pricing e.g. calculate yields, spreads, durations given mortgage performance inputs (e.g. prepayments or default vectors). This works quite well for static metrics that rely on a single yield curve input. But we also would like to calculate option adjusted measures (e.g. OAS - option adjusted spread) that require inputs of many yield curves (e.g. with high/lower rates leves, flatter/steeper curve shapes). <br></div><div><br></div><div>So a few specific questions I have are as follows:<br></div><div><br></div><div>1. What is the best way to generate option adjusted metrics (e.g. OAS) in QuantLib if user inputs yield curves with associated probabilities? <br></div></div><div>2. Can QuantLIb generate future yield curves with associated probabilities based on current structure of term structure of interest rates and volatility surface? <br></div><div>3. What is the best way to retrieve the yield curve details for cash flows calculations (e.g. monthly discount factors for 360 months which is a typical number of cash flows for a mortgage bond)? We tried a <i>discount</i> method for each month separately but it takes too long.<br></div><div><br></div><div><div>Thanks, <br></div><div><br></div><div>Michael <br></div></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 3, 2024 at 4:06 AM Luigi Ballabio <<a href="mailto:lui...@gm..." target="_blank">lui...@gm...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Michael, apologies for the delay. I'm not sure what's the most effective way to do this. Well, no, scratch that—the most efficient way would be to do it in C++. From Python, if you have a process available (such as HullWhiteProcess, for instance) you can use the available PathGenerator class. What kind of simulation do you have in mind?<br></div><div><br></div><div>Luigi<br></div><div><br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 20, 2024 at 5:49 PM Michael (DataDriven portal) <<a href="mailto:mi...@da..." target="_blank">mi...@da...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Luigi:<br></div><div><br></div><div>Thank you for getting back to me! <br></div><div><br></div><div>What is the most efficient way to do Monte Carlo simulations in QuantLib when I need to obtain multiple paths of yield curves for different scenarios (they do not have to be vectors of DFs but could be FRAs or any other rate metrics)?<br></div><div><br></div><div>Thanks, <br></div><div><br></div><div>Michael <br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 20, 2024 at 10:59 AM Luigi Ballabio <<a href="mailto:lui...@gm..." target="_blank">lui...@gm...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hello Michael,<br></div><div> no, I'm afraid vector methods are not available.<br></div><div><br></div><div>Luigi<br></div><div><br></div></div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Apr 14, 2024 at 8:30 PM Michael (DataDriven portal) <<a href="mailto:mi...@da..." target="_blank">mi...@da...</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi All, <br></div><div><br></div><div>I am using a <i>discount</i> method on a curve to get a discount factor for a given maturity (like in shown in the Cookbook below). But I need to output discount factors for all monthly cash flows of a bond (in my case 360 cash flows) so it is time consuming to call the <i>discount</i> method 360 times.<br></div><div><div><br></div><div>Is there a way to get all discount factors (for all cash flows - 360 in my case) in a single call to a curve by passing all maturity dates (e.g. in a list) to speed up the calculations?<br></div><div><br></div><div>Thanks, <br></div><div><br></div><div>Michael <br></div></div><div><br></div><div><span><image.png></span><br></div></div><div>_______________________________________________<br></div><div> QuantLib-users mailing list<br></div><div> <a href="mailto:Qua...@li..." target="_blank">Qua...@li...</a><br></div><div> <a href="https://lists.sourceforge.net/lists/listinfo/quantlib-users" rel="noopener noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/quantlib-users</a><br></div></blockquote></div></blockquote></div></blockquote></div></blockquote></div></blockquote></div><div><div>Content-Type: text/plain; charset="us-ascii"<br></div><div>MIME-Version: 1.0<br></div><div>Content-Transfer-Encoding: 7bit<br></div><div>Content-Disposition: inline<br></div></div><div><span><untitled attachment></span><br></div></div></blockquote></div><div><br></div></div></blockquote></div> </div></blockquote></div></div></body></html> |