Recent Questions - Quantitative Finance Stack Exchange most recent 30 from quant.stackexchange.com 2023-12-01T13:34:30Z https://quant.stackexchange.com/feeds https://creativecommons.org/licenses/by-sa/4.0/rdf https://quant.stackexchange.com/q/77567 0 Is there a relationship formula between Bond YTM, ZSpread ( to OIS ) and OIS rate? daniel https://quant.stackexchange.com/users/70153 2023-12-01T12:50:38Z 2023-12-01T12:58:58Z <p>It seems to me that : <span class="math-container">\begin{aligned} P_{Dirty} &amp;= \sum_i(\text{cashflow}_i * \exp( - \text{yield} * t_i ) ) \\ &amp;= \sum_i( \text{cashflow}_i * \exp( - ( \text{OIS}_i + \text{Zsprd} ) * t_i ) \end{aligned}</span> Than should we have some approximation like : <span class="math-container">$\text{Yld} = \text{OIS}_{t=duration} + \text{Zsprd}$</span> ?</p> https://quant.stackexchange.com/q/77565 0 Calculating key dates for a Forward Starting Interest Rate Swap versus a Spot IRS Simon Wiltshire https://quant.stackexchange.com/users/70152 2023-12-01T11:23:40Z 2023-12-01T12:13:29Z <p>How are the Effective Dates and Maturity Dates of a forward starting IRS (eg: EURIBOR3M 5Y5Y) handled when the forward starting term ends on a non-business day? And if that date is adjusted, how does that impact the maturity date of the forward starting IRS? For example if I trade on 6th Jan 2023, the T+2 spot date becomes Monday because I am trading on a Friday. For a EURIBOR 10Y that would result in a maturity date of <strong>9th Jan 2033</strong>. For the matching 5Y 5Y traded on the same day, the Effective Date falls on a Sunday (9th Jan 2028) which I presume would be adjusted to the Monday (10th Jan 2028)...which would then imply a maturity date of <strong>10th Jan 2033</strong>. Which is mismatched vs the 10Y. If, however, the Effective Date remains unadjusted, the maturity of the 10Y would match the 5Y5Y but the forward term would be less than 5 years. How does the market get around this issue?</p> https://quant.stackexchange.com/q/77561 0 Any other ways to hedge a bond portfolio against interest rate risk? l337n00b https://quant.stackexchange.com/users/70147 2023-11-30T22:30:37Z 2023-12-01T00:28:06Z <p>I'm currently taking a (gentle) intro to derivatives class. One of the exercises asked me to discuss duration as a risk measure and to provide alternative methods of hedging a bond portfolio against interest rate risks (other than using bond futures). While I managed to answer the first part, I'm wondering: what other methods could there be? I did some googling and stumbled upon other interest rate derivatives such as swaps and interest rate options but unfortunately none of them really include a proper explanation of how such a hedge would work so I'm a bit stuck right now.</p> https://quant.stackexchange.com/q/77559 1 QuantLib Python - Discount Factor Interpolation within curve nodes Mike https://quant.stackexchange.com/users/70146 2023-11-30T19:38:57Z 2023-12-01T10:44:54Z <p>Generated a discount curve, dCurve.PiecewiseLogLinearDiscount() using input par rate for terms (.5Y, 1Y, 2Y, 3Y, 5Y, 7Y, 10Y, 15Y, 20Y, 30Y) and output discount curve matching the input term structure. Any suggestions on how to output the discount factor curve on a .5Y interval term structure up to 30Y?</p> https://quant.stackexchange.com/q/77558 0 QuantLib: Latin American FixedFloat Swap pricing with multiple payment frequency specification John83 https://quant.stackexchange.com/users/51416 2023-11-30T18:59:45Z 2023-11-30T18:59:45Z <p>With reference to the post of <a href="https://quant.stackexchange.com/questions/65584/how-to-compute-npv-of-latin-american-swap-clp-tna-chilean-using-quantlib">latin american swap</a>, I am valuing the FixedFloat CLP swap.The specifications of this swaps has payment frequency upto 18 months as Zero coupon(1T) and after that Semiannual(6M). I want to apply this logic in my current code as mentioned below. I made a function for curve construction using discount factors, discount curve and constructed swap. Please help me to apply the aforesaid logic and schedules to get the pricing done.</p> <pre><code>df = [1, 0.955, 0.9786] # discount factors dates = [ ql.Date(1, 1, 2021), ql.Date(1, 1, 2022), ql.Date(1, 1, 2023), ] # maturity dates of the discount factors #curve construction def CurveConstruction(key): curve_data = raw_dta[raw_data.Curve == key] curve_data[&quot;Maturity Date&quot;] = pd.to_datetime(curve_data[&quot;MaturityDate&quot;]) dates = list(map(ql.Date().from_date, curve_data[&quot;Maturity Date&quot;])) curve_data['Df'] = curve_data['Df'].astype(float) dfs = list(curve_data[&quot;Df&quot;]) day_counter = ql.Actual360() calendar = ql.JointCalendar(ql.UnitedStates(), ql.UnitedKingdom()) yieldcurve = ql.DiscountCurve(dates, dfs, day_counter, calendar) yieldcurve_handle = ql.YieldTermStructureHandle(yieldcurve) return yieldcurve_handle def SwapConstruction(row): effectiveDate = ql.Date(s_day, s_month, s_year) terminationDate = ql.Date(m_day, m_month, m_year) fixedRate = row[&quot;Fixed_Rate&quot;] notional = row[&quot;Notional&quot;] floatindex = row[&quot;Float_Index_Name&quot;].lower() fixed_leg_tenor = ql.Period('6M') original_tenor = terminationDate - effectiveDate fixed_leg_daycount = ql.Actual360() float_leg_daycount = ql.Actual360() index = ql.OvernightIndex('CLICP', 0, ql.CLPCurrency(), ql.WeekendsOnly(), ql.Actual360(), yieldcurve_handle) fixingCalendar = index.fixingCalendar() fixed_schedule = ql.MakeSchedule(EffectiveDate, terminationDate, ql.Once) float_schedule = ql.MakeSchedule (EffectiveDate, terminationDate, ql.Once, calendar, ql.ModifiedFollowing, False) #using overnightindexed swap class for fixedfloat swap = ql.OvernightIndexedSwap(swapType, nominal, schedule, 0.0, dayCount, index) engine = ql.DiscountingSwapEngine(yieldcurve_handle) swap.setPricingEngine(engine) return swap curves = {} for key in zeros.Curve.unique(): curves[key] = CurveConstruction(key) swaps = pd.read_csv(xyz.csv) ## Process a swaps file for idx, row in swaps.iterrows(): swap = makeSwap(row) npv = swap.NPV() </code></pre> https://quant.stackexchange.com/q/77557 0 How to get the fair value for an option with variable strike? Ismael2829 https://quant.stackexchange.com/users/70144 2023-11-30T17:22:52Z 2023-11-30T23:50:24Z <p>I'm dealing with a plain vanilla written put but my strike is linked to this formula:</p> <p><span class="math-container">$$K=(7 \cdot EBITDA\cdot Net Debt)\cdot [\%P]$$</span></p> <p>where</p> <p>EBITDA = EBITDA of the company as of the last closed and audited accounts prior to the put exercise notice and the resulting EBITDA will be multiplied by 7</p> <p>Net Debt = Net debt of the company as of the last closed and audited accounts prior to the put option exercise notice</p> <p>%P = percentage interest of the minority shareholders at the date of exercise of the put option right</p> https://quant.stackexchange.com/q/77553 1 Fama-MacBeth regressions to predict stock returns; confusion on which steps to use Julien Maas https://quant.stackexchange.com/users/69640 2023-11-30T15:25:46Z 2023-11-30T16:05:24Z <p>When following <a href="https://doi.org/10.1561/104.00000024" rel="nofollow noreferrer">Lewellen (2015)</a> (open access <a href="https://faculty.tuck.dartmouth.edu/images/uploads/faculty/jonathan-lewellen/ExpectedStockReturns.pdf" rel="nofollow noreferrer">here</a>), I am confused as to whether I need to estimate any lambdas. As I already have values for lagged firm characteristics such as ROA and accruals etc. that I can multiply with their respective betas based on rolling return windows. Do I then need to still regress returns on these betas to get lambdas for each month? In other words, what are the in- and out-of-sample FM slopes? And how should I calculate the predicted returns?</p> <p><strong>References</strong></p> <ul> <li>Lewellen, J. (2015). The cross-section of expected stock returns. Critical Finance Review, 4(1), 1–44. <a href="https://doi.org/10.1561/104.00000024" rel="nofollow noreferrer">https://doi.org/10.1561/104.00000024</a></li> </ul> https://quant.stackexchange.com/q/77552 0 Downloading historic yield curve data from bloomberg [closed] s5s https://quant.stackexchange.com/users/17776 2023-11-30T14:20:08Z 2023-11-30T14:20:08Z <p>I am a PhD student and I have a couple of problems:</p> <ol> <li>I want to get the US yield curve but I don't know which curve I need.</li> <li>Once I have identified the curve, I want to download historic data for it.</li> </ol> <p>I am not sure which yield curve I need - I just want the most popular yield curve that is used when journalists (e.g. CNBC) talk about the 2Y vs 5Y vs 10Y yields. I suspect this would be composed of US notes and treasuries from 1W to 30 (or even 50) years.</p> <p>Once I identify the yield curve, I want to download this curve for a period of time. I am not sure how to do this. Can I download the curve as an object between dates or do I need to download history for every point on the curve? How would this work, because today, the 30Y point is a bond expiring in 2053 but 10 years ago the 30Y was a different bond expiring 2043.</p> <p>Any keywords or tips would be much appreciated. I can take it from there and investigate but I don't even have any an anchor at the moment.</p> https://quant.stackexchange.com/q/77550 0 FM regressions for size groups when examining a cross section of expected stock returns Julien Maas https://quant.stackexchange.com/users/69640 2023-11-30T10:57:38Z 2023-11-30T16:02:58Z <p>When doing FM regressions for size groups similar to <a href="https://doi.org/10.1561/104.00000024" rel="nofollow noreferrer">Lewellen (2015)</a> (open access <a href="https://faculty.tuck.dartmouth.edu/images/uploads/faculty/jonathan-lewellen/ExpectedStockReturns.pdf" rel="nofollow noreferrer">here</a>), should I obtain the cross sectional rolling return window betas using only the size group? (E.g only use large stocks to estimate the betas that will be used to calculate the expected returns for stocks within this group.) Or should I obtain the cross sectional rolling return window betas using the entire sample? (E.g use all stocks to estimate betas and then calculate the expected return for each stock and then look at the averages of each size group separately.)</p> <p><strong>References</strong></p> <ul> <li>Lewellen, J. (2015). The cross-section of expected stock returns. Critical Finance Review, 4(1), 1–44. <a href="https://doi.org/10.1561/104.00000024" rel="nofollow noreferrer">https://doi.org/10.1561/104.00000024</a></li> </ul> https://quant.stackexchange.com/q/77547 0 Difference in interpretation between credit ratings from different agencies user309669 https://quant.stackexchange.com/users/56945 2023-11-30T08:51:04Z 2023-11-30T13:08:19Z <p>i got this question at work from a client and my answer was not satisfying so here I am. if i have a portfolio of corporate bonds and govies, i collect all credit ratings from BBG terminal and by procedure, i fetch those from S&amp;P, Moodys and Fitch Ratings. There is an equivalence table so one can check what a Moodys A2 corresponds on a Fitch scale, and that's okay. but what about interpretation?</p> <p>I kinda remember-ish that Moodys focuses more on LGD than the other two. so in practice, if I have a Moody's A2 and equivalent S&amp;P A ratings on a corporate bond, what are the basic observations one can do? i think all this stems from the model each rating agency use (which seems to be proprietary so could not find any detailed info whatsoever).</p> https://quant.stackexchange.com/q/77546 0 Neural network time series prediction tool [closed] Hans https://quant.stackexchange.com/users/6686 2023-11-30T05:49:00Z 2023-11-30T15:31:04Z <p>What are some of the state of the art time series prediction tool with neural network?</p> https://quant.stackexchange.com/q/77545 0 Why do the Greeks not converge to the strike as the volatility tends to zero? [closed] Mr. Ivan https://quant.stackexchange.com/users/67266 2023-11-29T22:14:46Z 2023-11-30T15:43:42Z <p>So, I was playing around with the Greeks in Python with some made up data for a European call option assuming the Black-Scholes model. I plotted the graphs to see what happens to the Greeks when either the Time to Maturity or the Volatility change, other things being equal. You can see the graphs below:</p> <p><a href="https://i.stack.imgur.com/h0lA9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h0lA9.png" alt="enter image description here" /></a></p> <p>I noticed that as the Time to maturity tends to zero, all the Greeks &quot;converge&quot; to the strike price. However, the same is not true for the Volatility. The Greeks seem to &quot;converge&quot; to the value just to the left of the strike. I am not sure if that's intended or if my code isn't correct. Would love to see either a confirmation of the result (and an explanation as to where the Greeks &quot;converge&quot;) or a suggestion on where I might have gone wrong here. The code below shows the Python code for the Greeks:</p> <pre><code>def vega(S_t, K, r, q, T, t, sigma): # vega d_1 = (np.log(S_t / K) + (r - q + sigma**2 / 2) * (T - t)) / (sigma * np.sqrt(T - t)) return S_t * np.exp(-q * (T - t)) * phi(d_1) * np.sqrt(T - t) def delta(S_t, K, r, q, T, t, sigma, type = 'call'): # delta d_1 = (np.log(S_t / K) + (r - q + sigma**2 / 2) * (T - t)) / (sigma * np.sqrt(T - t)) if type == 'call': sign = 1 elif type == 'put': sign = -1 return sign * N(sign * d_1) * np.exp(-q * (T - t)) def gamma(S_t, K, r, q, T, t, sigma): # gamma d_1 = (np.log(S_t / K) + (r - q + sigma**2 / 2) * (T - t)) / (sigma * np.sqrt(T - t)) return np.exp(-q * (T - t)) * phi(d_1) / (S_t * sigma * np.sqrt(T - t)) def theta(S_t, K, r, q, T, t, sigma, type = 'call'): # theta d_1 = (np.log(S_t / K) + (r - q + sigma**2 / 2) * (T - t)) / (sigma * np.sqrt(T - t)) d_2 = d_2 = d_1 - sigma * np.sqrt(T - t) if type == 'call': sign = 1 elif type == 'put': sign = -1 return -np.exp(-q * (T - t)) * S_t * sigma * phi(d_1) / (2 * np.sqrt(T - t)) - sign * np.exp(-r * (T - t)) * r * K * N(d_2 * sign) + sign * q * S_t * np.exp(-q * (T - t)) * N(sign * d_1) </code></pre> https://quant.stackexchange.com/q/77544 0 Ito Process: How to calculate expected return? user546106 https://quant.stackexchange.com/users/66641 2023-11-29T18:57:42Z 2023-11-29T18:57:42Z <p>On page 300 of Hull's <em>Options, Futures and Other Derivatives</em></p> <blockquote> <p>It is tempting to suggest that a stock price follows a generalized Wiener process; that is, that it has a constant expected drift rate and a onstant variance rate. However, this model fails to capture a key aspect of stock prices. This is that the expected percentage return required by investors from a stock is independent of the stock’s price. If investors require a 14% per annum expected return when the stock price is <span class="math-container">\\\$$</span> 10, then, ceteris paribus, they will also require a 14% per annum expected return when it is 50.</p> </blockquote> <blockquote> <p>Clearly, the assumption of constant expected drift rate is inappropriate and needs to be replaced by the assumption that the <strong>expected return</strong> (i.e., <strong>expected drift</strong> divided by the stock price) is constant. If <span class="math-container">S</span> is the stock price at time <span class="math-container">t</span>, then the expected drift rate in <span class="math-container">S</span> should be assumed to be <span class="math-container">\mu S</span> for some constant parameter m. This means that in a short interval of time, <span class="math-container">\Delta t</span>, the expected increase in S is <span class="math-container">\mu S \Delta t</span>. The parameter m is the expected rate of return on the stock.</p> </blockquote> <p>An Ito process can be written as <span class="math-container">dx = a(x,t)dt + b(x,t)dz</span>, <span class="math-container">dz</span> is a basic Wiener process that has a drift rate of zero and a variance of <span class="math-container">1.0</span>. I thought <span class="math-container">a(x,t)</span> is the drift of the Ito process <span class="math-container">dx</span>, but after reading this, I know it is also the expected drift. Do we not need any calculation to get the expected drift of <span class="math-container">dx</span>? If we need some calculation, how? Why does the expected return equal the expected drift divided by the stock price?</p> https://quant.stackexchange.com/q/77541 1 Testing one asset pricing model against another a la Cochrane via change in \hat\alpha' \text{cov}(\hat\alpha,\hat\alpha')^{-1}\hat\alpha Richard Hardy https://quant.stackexchange.com/users/19645 2023-11-29T15:10:54Z 2023-11-29T15:10:54Z <p>I am reading section section 14.6 of John Cochrane's <a href="https://static1.squarespace.com/static/5e6033a4ea02d801f37e15bb/t/5f5bfc30caafb27f44aeebd2/1599863856646/week_5_notes.pdf" rel="nofollow noreferrer">lectures notes</a> for the course <em>Business 35150 Advanced Investments</em>. On p. 239-240, he discusses testing one asset pricing model against another. Here is the essence:</p> <blockquote> <ol> <li>Example. FF3F. <span class="math-container">$$ E(R^{ei}) = \alpha_i + b_i\lambda_{rmrf} + h_i\lambda_{hml} + s_i\lambda_{smb} \tag{i} $$</span> Do we really need the size factor? Or can we write <span class="math-container">$$ E(R^{ei}) = \alpha_i + b_i\lambda_{rmrf} + h_i\lambda_{hml} \tag{ii} $$</span> and do as well? (<span class="math-container">\alpha</span> will rise, but will they rise “much”?)</li> </ol> </blockquote> <blockquote> <ol start="2"> <li>A common misconception: Measure <span class="math-container">\lambda_{smb} = E(smb)</span>. If <span class="math-container">\lambda_{smb} = 0</span> (and “small”) we can drop it. Why is this wrong? Because if you drop <span class="math-container">smb</span> from the regression, <span class="math-container">b_i</span> and <span class="math-container">h_i</span> also change!</li> </ol> </blockquote> <blockquote> <p>&lt;...&gt;</p> </blockquote> <blockquote> <ol start="4"> <li>Solution: (a) First run a regression of <span class="math-container">smb_t</span> on <span class="math-container">rmrf_t</span> and <span class="math-container">hml_t</span> and take the residual, <span class="math-container">$$ smb_t = \alpha_{smb} + b_s rmrf_t + h_s hml_t + \varepsilon_t \tag{iii} $$</span> Now, we can drop <span class="math-container">smb</span> from the three factor model if and only <span class="math-container">\alpha_{smb}</span> is zero. Intuitively, if the other assets are enough to price <span class="math-container">smb</span>, then they are enough to price anything that <span class="math-container">smb</span> prices.<br /> (b) “Drop smb” means the 25 portfolio alphas are the same with or without <span class="math-container">smb</span><br /> (c) *Equivalently, we are forming an “orthogonalized factor” <span class="math-container">$$ smb_t^* = \alpha_{smb} + \varepsilon_t = smb_t − b_s rmrf_f − h_s hml_t </span> This is a version of <span class="math-container">smb</span> purged of its correlation with <span class="math-container">rmrf</span> and <span class="math-container">hml</span>. Now it is OK to drop <span class="math-container">smb</span> if <span class="math-container">E(smb^{*})</span> is zero, because the <span class="math-container">b</span> and <span class="math-container">h</span> are not aﬀected if you drop <span class="math-container">smb^*</span><br /> (d) *Why does this work? Think about rewriting the original model in terms of <span class="math-container">smb^{*}</span>, <span class="math-container">\begin{align*} R_t^{ei} &amp;= \alpha_i + b_i rmrf_t + h_i hml_t + s_i smb_t + \varepsilon_t^i \\ &amp;= \alpha_i + (b_i+s_i b_s) rmrf_t + (h_i+s_i h_s) hml_t + s_i (smb_t - b_s rmrf_t - h_s hml_t) + \varepsilon_t^i \\ &amp;= \alpha_i + (b_i+s_i b_s) rmrf_t + (h_i+s_i h_s) hml_t + s_i smb_t^* + \varepsilon_t^i \end{align*}</span> The other factors would now get the betas that were assigned to <span class="math-container">smb</span> merely because <span class="math-container">smb</span> was correlated with the other factors. <em>This part of the <span class="math-container">smb</span> premium can be captured by the other factors, we don’t need <span class="math-container">smb</span> to do it. The only part that we need <span class="math-container">smb</span> for is the last part. Thus average returns can be explained without <span class="math-container">smb</span> if and only if <span class="math-container">E(smb_t^{*}) = 0</span>.</em></li> </ol> </blockquote> <blockquote> <ol start="5"> <li>*Other solutions (equivalent)<br /> (a) Drop <span class="math-container">smb</span>, redo, test if <span class="math-container">\alpha' \text{Cov}(\alpha)^{-1}\alpha</span> rises “too much.”<br /> (b) Express the model as <span class="math-container">m = a − b_1 rmrf − b_2 hml − b_3 smb, 0 = E(m R^e)</span>. A test on <span class="math-container">b_x</span> is a test of “can you drop the extra factor.”</li> </ol> </blockquote> <p><strong>How exactly can we do 5.a?</strong> On p. 238, Cochrane indicates that <span class="math-container">\hat\alpha' \text{cov}(\hat\alpha,\hat\alpha')^{-1}\hat\alpha\sim\chi^2_{N-1}</span> in the Fama-MacBeth approach and on p. 236 it is <span class="math-container">\sim\chi^2_{N-K-1}</span> in the cross-sectional approach. (<span class="math-container">N</span> is the number of assets or test portfolios, <span class="math-container">K</span> is the number of pricing factors.) If <span class="math-container">\chi^2_{full}:=\hat\alpha' \text{cov}(\hat\alpha,\hat\alpha')^{-1}\hat\alpha</span> corresponds to the full model and <span class="math-container">\chi^2_{restricted}:=\tilde\alpha' \text{cov}(\tilde\alpha,\tilde\alpha')^{-1}\tilde\alpha</span> corresponds to the restricted model, will the test statistic be <span class="math-container">\chi^2_{restricted}-\chi^2_{full}\sim\chi^2_{1}</span> or something similar? Is there a reference for this that I could look up?</p> <h3>References</h3> <ul> <li>Cochrane, J. H. (2014). <a href="https://static1.squarespace.com/static/5e6033a4ea02d801f37e15bb/t/5f5bfc30caafb27f44aeebd2/1599863856646/week_5_notes.pdf" rel="nofollow noreferrer">Week 5 Empirical methods notes</a>. <em>Business 35150 Advanced Investments</em>, 225-247.</li> </ul> https://quant.stackexchange.com/q/77540 0 Scaling variables (Fraction vs % vs log) when regressing twelve month returns Julien Maas https://quant.stackexchange.com/users/69640 2023-11-29T14:08:17Z 2023-11-29T14:08:17Z <p>Dear Stack community,</p> <p>My question is the following;</p> <p>If my dependent variable is twelve month returns.</p> <p>And as independent variables I have fiscal year variables like ROA and log variables like the log of the market value.</p> <p>Where ROA = Net income / total assets</p> <p>Should I scale ROA either as a fraction (e.g 0.05), a log (e.g -1.30) or a % (e.g 5%).</p> <p>And similarly how should I scale returns?</p> <p>I guess the anwser depends on what change I want to analyze.</p> <p>However if I want to fit both slopes in a graph over time and interpret their coefficients for a cross section of stocks, would it make most sense to use a fraction, % or log for ROA?</p> <p>Any clear intuition for this...?</p> https://quant.stackexchange.com/q/77539 0 Testing one asset pricing model against another a la Cochrane: why this works Richard Hardy https://quant.stackexchange.com/users/19645 2023-11-29T13:59:06Z 2023-11-29T14:13:06Z <p>I am reading section section 14.6 of John Cochrane's <a href="https://static1.squarespace.com/static/5e6033a4ea02d801f37e15bb/t/5f5bfc30caafb27f44aeebd2/1599863856646/week_5_notes.pdf" rel="nofollow noreferrer">lectures notes</a> for the course <em>Business 35150 Advanced Investments</em>. On p. 239-240, he discusses testing one asset pricing model against another. I have quite some trouble following his arguments. Here is the essence:</p> <blockquote> <ol> <li>Example. FF3F. <span class="math-container"> E(R^{ei}) = \alpha_i + b_i\lambda_{rmrf} + h_i\lambda_{hml} + s_i\lambda_{smb} \tag{i} $$</span> Do we really need the size factor? Or can we write <span class="math-container">$$ E(R^{ei}) = \alpha_i + b_i\lambda_{rmrf} + h_i\lambda_{hml} \tag{ii} $$</span> and do as well? (<span class="math-container">\alpha</span> will rise, but will they rise “much”?)</li> </ol> </blockquote> <blockquote> <ol start="2"> <li>A common misconception: Measure <span class="math-container">\lambda_{smb} = E(smb)</span>. If <span class="math-container">\lambda_{smb} = 0</span> (and “small”) we can drop it. Why is this wrong? Because if you drop <span class="math-container">smb</span> from the regression, <span class="math-container">b_i</span> and <span class="math-container">h_i</span> also change!</li> </ol> </blockquote> <blockquote> <p>&lt;...&gt;</p> </blockquote> <blockquote> <ol start="4"> <li>Solution: (a) First run a regression of <span class="math-container">smb_t</span> on <span class="math-container">rmrf_t</span> and <span class="math-container">hml_t</span> and take the residual, <span class="math-container">$$ smb_t = \alpha_{smb} + b_s rmrf_t + h_s hml_t + \varepsilon_t \tag{iii} $$</span> Now, we can drop <span class="math-container">smb</span> from the three factor model if and only <span class="math-container">\alpha_{smb}</span> is zero. Intuitively, if the other assets are enough to price <span class="math-container">smb</span>, then they are enough to price anything that <span class="math-container">smb</span> prices.<br /> (b) “Drop smb” means the 25 portfolio alphas are the same with or without <span class="math-container">smb</span><br /> (c) *Equivalently, we are forming an “orthogonalized factor” <span class="math-container">$$ smb_t^* = \alpha_{smb} + \varepsilon_t = smb_t − b_s rmrf_f − h_s hml_t </span> This is a version of <span class="math-container">smb</span> purged of its correlation with <span class="math-container">rmrf</span> and <span class="math-container">hml</span>. Now it is OK to drop <span class="math-container">smb</span> if <span class="math-container">E(smb^{*})</span> is zero, because the <span class="math-container">b</span> and <span class="math-container">h</span> are not aﬀected if you drop <span class="math-container">smb^*</span><br /> (d) *Why does this work? Think about rewriting the original model in terms of <span class="math-container">smb^{*}</span>, <span class="math-container">\begin{align*} R_t^{ei} &amp;= \alpha_i + b_i rmrf_t + h_i hml_t + s_i smb_t + \varepsilon_t^i \\ &amp;= \alpha_i + (b_i+s_i b_s) rmrf_t + (h_i+s_i h_s) hml_t + s_i (smb_t - b_s rmrf_t - h_s hml_t) + \varepsilon_t^i \\ &amp;= \alpha_i + (b_i+s_i b_s) rmrf_t + (h_i+s_i h_s) hml_t + s_i smb_t^* + \varepsilon_t^i \end{align*}</span> The other factors would now get the betas that were assigned to <span class="math-container">smb</span> merely because <span class="math-container">smb</span> was correlated with the other factors. <em>This part of the <span class="math-container">smb</span> premium can be captured by the other factors, we don’t need <span class="math-container">smb</span> to do it. The only part that we need <span class="math-container">smb</span> for is the last part. Thus average returns can be explained without <span class="math-container">smb</span> if and only if <span class="math-container">E(smb_t^{*}) = 0</span>.</em></li> </ol> </blockquote> <p>Part 4. is unclear to me. I do not get why <span class="math-container">\text{(iii)}</span> is the relevant regression to run and <span class="math-container">\alpha_{smb}</span> in it the relevant coefficient to test. (Attempting to show that this approach fails, I provide a counterexample <a href="https://quant.stackexchange.com/questions/77531">here</a>.) I think I need a formal proof in addition to the intuition. I guess once I see the proof, Cochrane's intuition will become more intuitive to me, too. Could you help me understand this?</p> <p>Also, does this apply as is if the factor we consider kicking out of the model is actually a characteristic, not a factor (such as the size of the firm rather than the firm's sensitivity to the <span class="math-container">smb</span> factor)?</p> <h3>References</h3> <ul> <li>Cochrane, J. H. (2014). <a href="https://static1.squarespace.com/static/5e6033a4ea02d801f37e15bb/t/5f5bfc30caafb27f44aeebd2/1599863856646/week_5_notes.pdf" rel="nofollow noreferrer">Week 5 Empirical methods notes</a>. <em>Business 35150 Advanced Investments</em>, 225-247.</li> </ul> https://quant.stackexchange.com/q/77538 0 Price spread or ratio for mean reversion pair trading user70121 https://quant.stackexchange.com/users/70121 2023-11-29T12:24:48Z 2023-11-29T12:24:48Z <p>I am slightly confused as to whether I should use price spread or ratio for mean reversion in pair trading. I have seen some work on testing stationarity for the price spread and then use the price ratio instead for entry/exit. For example: <a href="https://medium.com/analytics-vidhya/statistical-arbitrage-with-pairs-trading-and-backtesting-ec657b25a368" rel="nofollow noreferrer">https://medium.com/analytics-vidhya/statistical-arbitrage-with-pairs-trading-and-backtesting-ec657b25a368</a></p> <p>My question is, how does one justify the use of price ratio if we only tested the stationarity of the price spread? Or is it the case that once we know the price spread is stationary, it matters little if we use price ratio or price spread since the price ratio can be regarded as stationary once we know the spread is stationary?</p> https://quant.stackexchange.com/q/77515 0 Calculation of break-even correlation for diversification effect in N-assets case? T123 https://quant.stackexchange.com/users/57516 2023-11-28T10:55:57Z 2023-11-30T12:09:53Z <p>I'm thinking about a generalization of the following case: for 2 assets, there is a diversification effect as soon as i obtain a positive weight for the minimum-variance portfolio in the asset with the higher volatility.</p> <p>If <span class="math-container">\rho_{12}</span> is the correlation coefficient and <span class="math-container">\sigma_1 &lt; \sigma_2</span> then for <span class="math-container">\rho_{12}&lt;\frac{\sigma_1}{\sigma_2}</span> we obtain a positive weight on <span class="math-container">\omega_2</span> in the minimum variance portfolio where <span class="math-container"> \omega_2 = \frac{\sigma_1^2 - \sigma_1\sigma_2\rho_{12}}{\sigma_1^2+\sigma_2^2-2\sigma_1\sigma_2\rho_{12}} $$</span> My question: regarding the correlation coefficient (-matrix), what is the general case for N-assets w.r.t <span class="math-container">\rho_{i,j}</span> and how to interpret this given the expression for the minimum variance portfolio weights vector as:</p> <p><span class="math-container">$$\boldsymbol{w}_{MV} = \frac{\boldsymbol{\Sigma}^{-1} \boldsymbol{1} }{\boldsymbol{1}' \boldsymbol{\Sigma}^{-1} \boldsymbol{1}}</span></p> <p>where <span class="math-container">\boldsymbol{1}</span> is the usual unity vector and <span class="math-container">\boldsymbol{\Sigma}^{-1}</span> is the inverse of the covariance matrix.</p> <p>EDITED: I guess similar to the 2-asset case, i have to start with the nominator <span class="math-container">\boldsymbol{\Sigma}^{-1} \boldsymbol{1}</span>?</p> <p>Thank you for your help</p> <p>Thomas</p> https://quant.stackexchange.com/q/77496 1 Floor vs Receiver Swaption with Equal Strike lambda111 https://quant.stackexchange.com/users/70055 2023-11-26T17:07:49Z 2023-11-30T05:30:05Z <p>Let's say we have the following two instruments.</p> <ol> <li>A 5x10 floor (5-year floor, five years forward) with a 4% strike on 1-year SOFR and</li> <li>A 5 into 5 European receiver swaption (right to enter into a 5-year swap, starting in 5 years) with a 4% strike on 1-year SOFR.</li> </ol> <p>In other words, the instruments are otherwise identical (strike, underlying and maturity), except one is a floor and one is a receiver.</p> <p><strong>Can we say definitively which one is worth more?</strong></p> <p>Intuitively, it makes sense that the floor should be worth at least as much as the receiver swaption. But can we say for example that the floor is <em>always</em> worth more?</p> https://quant.stackexchange.com/q/77447 1 Why stock beta is not equal to its index weight? Kreol https://quant.stackexchange.com/users/48290 2023-11-22T17:38:56Z 2023-11-29T19:38:13Z <p>Index is a linear combination of stock prices with known weights. In case index is equally weighted, the weights are fixed. Beta measures stock sensitivity to index - by how much stock moves when index moves by 1%. So we regress one component of that linear combination onto the linear combination itself. Shouldnt the corresponding regression coefficient be equal to the stock weight in the index ?</p> <p>My own explanation why this might not be the case:</p> <ol> <li>When regressing single stock on index we do not take into account for confounding effects - correlation of this single stock with other stocks. Hence, if we orthogonalize a single stock returns to all other stock returns and then run regression of residuals on index returns than beta should be equal to index weight ?</li> <li>Index is weighted based on prices while beta is calculated on returns. So if we create a returns based index with equal weights and perform orthogonalization as in 1) then beta should be equal to index weight then ?</li> </ol> https://quant.stackexchange.com/q/77191 1 Why the biz day convention of OIS Rate helper is hard coded as Modified Following in QL? Nick https://quant.stackexchange.com/users/69648 2023-10-29T20:46:11Z 2023-11-29T13:04:00Z <p>I am using QuantLib OIS Rate Helpers, and traced schedule creation back to the following function, and noticed that the business convention is hard coded as MF. Is the biz day convention hard coded because OIS is always MF. Or anyway I can create schedule by argument?</p> <pre><code>MakeOIS::operator ext::shared_ptr&lt;OvernightIndexedSwap&gt;() const { ... Schedule schedule(startDate, endDate, Period(paymentFrequency_), calendar_, ModifiedFollowing, ModifiedFollowing, rule_, usedEndOfMonth); ... } </code></pre> https://quant.stackexchange.com/q/76179 1 Garch Model with Vix as external regressor un dummy rugarch r studio fabdellar https://quant.stackexchange.com/users/68284 2023-07-20T17:03:07Z 2023-11-29T15:00:55Z <p>I would like to try to replicate this variance dummied model in r studio, to try to compare garch vs i.v in forecasting vol: Data : S&amp;P 500 log-return from 03.01.2020 to 31.12.2022 Ext regressor : Vix from 03.01.2020 to 31.12.2022.</p> <p><a href="https://i.stack.imgur.com/S7zJn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S7zJn.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/6xETS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6xETS.png" alt="enter image description here" /></a></p> <p>Have you some idea of how to replicate this with the rugarch package?</p> <p>I tought about computing the various garch with vixt-1 as external regressor and then regress the arch vol as dipendent variable. If you have some insight let me know</p> https://quant.stackexchange.com/q/76011 4 Stochastic process for modelling correlation? Lucas Morin https://quant.stackexchange.com/users/5052 2023-07-03T10:28:12Z 2023-11-30T18:58:30Z <p>This question relates to Financial Machine Learning, and more specifically to competitions like <a href="https://numer.ai/home" rel="nofollow noreferrer">Numerai</a>.</p> <p>In this competition we have a dataset X and a target y (return over a given horizon). The dataset contains some features (say feature_0 to feature_n) and time. Different stocks are available each time.</p> <p>One important metric is the correlation bewteen features and the target. Correlation can be either spearman or pearson. We can observe past correlations. I was wondering if there is a standard way to model this kind of correlation over time.</p> <p>The correlations seems very random, changing signs quite often, oscillating around 0. I was thinking about some mean reverting process, centered at some value near 0. I was thinking about an OU process with a small drift and a high reversion coefficient.</p> <p>However, as they are correlations, they would be capped by -1 / +1. I don't know how to deal with this. As the correlation are oscillating around 0, I am tempted to ignore this constraint. But it might be better to add some logistic function somewhere.</p> <p>Any idea of a standard approach to model correlation over time ?</p> https://quant.stackexchange.com/q/60286 1 Is "Information Coefficient" correlation or rank correlation? stevew https://quant.stackexchange.com/users/28571 2021-01-02T09:14:15Z 2023-11-30T09:17:28Z <p>From the textbook, <em>information coefficient (IC)</em> is a measure of the depth of an active manager’s skill. On a more formal basis, IC measures the “correlation” between actual returns and those predicted by the portfolio manager (Grinold &amp; Kahn, 2000; Fabozzi &amp; Markowitz, 2011). Cross-checking <a href="https://www.investopedia.com/terms/i/information-coefficient.asp" rel="nofollow noreferrer">Investopedia</a> suggests the same thing. That is, it's the <em>pearson correlation</em> between returns and scores. However, my colleague is adamant that it's the <em>rank correlation</em> not the pearson correlation. Which one is correct?</p> https://quant.stackexchange.com/q/51730 0 Show that a zero-coupon bond discounted by a bond with mautrity T is a martingale under the T-Forward measure R. Rayl https://quant.stackexchange.com/users/44871 2020-03-20T17:44:16Z 2023-12-01T06:01:40Z <p><strong>Here's the exact question:</strong></p> <p>Show that for any <span class="math-container">s&gt;0</span>, <span class="math-container">\frac{P(t,s)}{P(t,T)}</span> is a <span class="math-container">Q^T</span>-martingale.</p> <p><strong>Here's my attempt:</strong></p> <p>Let <span class="math-container">t^\prime &lt; t</span>. First consider the case <span class="math-container">s&gt;T</span>. <span class="math-container">\begin{aligned} \mathbb{E}_{Q^T}\Big[\frac{P(t,s)}{P(t,T)} \lvert \mathcal{F}_{t^\prime}\Big] &amp;= \mathbb{E}_{Q^T}\Big[P(T,s) \lvert \mathcal{F}_{t^\prime}\Big] \\ &amp;= \mathbb{E}_{Q^T}\Big[\frac{P(t^\prime,s)}{P(t^\prime,T)} \lvert \mathcal{F}_{t^\prime}\Big] \\ &amp;= \frac{P(t^\prime,s)}{P(t^\prime,T)} \end{aligned}</span> And then you can use a similar argument for when <span class="math-container">T &gt; s</span>. But this argument has to be wrong surely, as this is not specific to <span class="math-container">Q_T</span>. Could anyone help and point out where I've gone wrong?</p> https://quant.stackexchange.com/q/44932 8 American put option. Exercise time is a random variable, calculation of expected payoff Makina https://quant.stackexchange.com/users/36637 2019-04-04T17:37:35Z 2023-11-29T19:03:15Z <p>I got an American put option, where the payoff is <span class="math-container">V_\tau = \max(K - X_{\tau}, 0)</span> and <span class="math-container">X_{\tau}</span> is the price of an underlying at the stopping time <span class="math-container">\tau &lt; T</span>. The underlying follows a standard GBM with <span class="math-container">r = q = 0</span>; <span class="math-container">X_0</span> is given.</p> <p>I need to calculate the expectation <span class="math-container">E[V]</span> under the assumption that <span class="math-container">\tau</span> has exponential distribution with intensity <span class="math-container">\lambda = 0.025</span>.</p> <hr> <p>I tried transforming this equation into: <span class="math-container">\int_0^\infty (K - X_0e^{-\frac{1}{2}\sigma^2 \tau + \sigma \sqrt{\tau}Z})^+\lambda e^{-\lambda \tau}d\tau$$</span> but then I'm just completely lost with how to proceed with the square root. I know that by definition <span class="math-container">E[\tau] = \frac{1}{\lambda}</span> but can I use this as an answer? As in, can I claim that: <span class="math-container">$$E[V] = V\left(X_{\frac{1}{\lambda}}, \frac{1}{\lambda}\right) \text{ ?}$$</span></p> https://quant.stackexchange.com/q/33047 1 forecast using rugarch in r user27014 https://quant.stackexchange.com/users/27014 2017-03-16T03:13:06Z 2023-11-29T14:06:30Z <p>After fit the GARCH model, I want to plot the volatility forecast sigma series. I use ugarchforecast as follow: </p> <pre><code>fit = ugarchfit(spec, return) fore &lt;- ugarchforecast(fit, n.ahead=1, n.roll = 2517, out.sample = 2517) sigma &lt;- fore@forecastsigmaFor </code></pre> <p>But there always an error: </p> <pre><code>Error in .sgarchforecast(fitORspec = fitORspec, data = data, n.ahead = n.ahead, : ugarchforecast--&gt;error: n.roll must not be greater than out.sample! </code></pre> <p>what's wrong with it?</p> https://quant.stackexchange.com/q/30619 4 Valuation of a swap where both parties can cancel (not settle at market) with accrual method instead of present-value? Sargera https://quant.stackexchange.com/users/8230 2016-10-18T16:19:25Z 2023-11-29T14:17:16Z <p>Consider a single-name total return swap (TRS) on some reference asset S. For concreteness, suppose the length of the contract is one year with quarterly resets, and the performance of S is exchanged for LIBOR.</p> <p>Then the TRS value resets at 0 at each reset date, so for some t in some period that ends at time T, the value of the agreement assuming there is no cancellation feature is simply$$V_{t}=\mp(S_{t}-P_{t}^{T})\pm P_{t}^{T}S_{0}L_{0}^{T}T$$where P_{t}^{T} is the discount factor observed at time t for the period [t,T] and L_{0}^{T} is the period LIBOR (simple) rate set at time 0 (beginning of the period) for the period [0,T].</p> <p>However, if at any time in the performance period of the contract either party can terminate the agreement (not settle at the market value V_{t}), I have seen it claimed that an accrual valuation method is appropriate and that the contract can be valued for any t as$$V_{t}=\mp(S_{t}-S_{0})\pm S_{0}L_{0}^{T}(T-t).$</p> <p>I don't understand the justification for this formula. Since the bi-cancellable feature can be modeled as a long (short) call and short (long) put position (depending on the side of the contract you are on), some sort of put-call parity should be applicable, which leads to the accrual formula above, but I could not get this to quite work out (perhaps someone with more practice with these types of derivations would more easily be able to do it).</p> <p>Another argument is that the hedging strategy employed by a desk selling this TRS would be to overnight repo$S$, and thus the cumulative borrowing cost upto time$t$is in some sense$S_{0}L_{0}^{T}(T-t)$, and so if the counterparty wanted to cancel, the desk could just not roll over the repo and sell the asset to cover the position and repo loan. But besides the assumption of constant interest rates, if the term of the contract is set to$T$at the beginning of the performance period, then ostensibly the desk takes out a$T$-period loan of$S_{0}$, charges the client the interest on this loan, and then liquidates the position at time$T$to cover the loan and the performance gain or loss on$S$(i.e.,$S_{T}-S_{0}\$). This hedging argument is how the first valuation formula is obtained (although it can also be obtained in a straight forward manner using risk-neutral pricing methods).</p> https://quant.stackexchange.com/q/27450 4 Trader Workstation on Ubuntu cannot be connected to via the API [closed] user3064222 https://quant.stackexchange.com/users/22033 2016-06-05T16:49:38Z 2023-11-29T17:01:45Z <p>I am using ibPy to connect to TWS on a fairly fresh ubuntu machine. I have been successful in logging into the paper trading account and submitting buy and sell orders programatically via the ibPy interface.</p> <p>However, I am now trying to do more than simply submit orders. Namely, I am trying to obtain position updated from TWS. I am interested in successfully running the following code:</p> <pre><code>from time import sleep from ib.opt import ibConnection, message def error_handler(msg): print(msg) def acct_update(msg): print(msg) con = ibConnection(clientId=100) con.register(acct_update, message.updateAccountValue, message.updateAccountTime, message.updatePortfolio) con.register(error_handler, "Error") con.connect() con.reqAccountUpdates(True, 'DU000000') sleep(1) con.disconnect() </code></pre> <p>When executed however I obtain the following error:</p> <pre><code>&lt;error id=-1, errorCode=502, errorMsg=Couldn't connect to TWS. Confirm that "Enable ActiveX and Socket Clients" is enabled on the TWS "Configure-&gt;API" menu.&gt; </code></pre> <p>I have ensured that indeed ActiveX and socket clients are enabled in the TWS preferences, so that is not the issue. It surprises me that I would be able to submit orders successfully but not obtain account updates from TWS. Does anyone know why this could be happening?</p> https://quant.stackexchange.com/q/7599 6 Where can I get historical ticker change database? Zack Burt https://quant.stackexchange.com/users/5004 2013-03-25T03:42:04Z 2023-11-29T12:38:12Z <p>There's 30 days worth of data at <a href="http://www.otcmarkets.com/marketActivity/symbol-changes" rel="noreferrer">http://www.otcmarkets.com/marketActivity/symbol-changes</a> - but I'm really looking for the past 10 years, or 5 years if only that is possible. Any dice?</p> <p>The closest I've come, and this is not really cutting it, is looking up a stock via Yahoo! Finance and seeing "TICKER is no longer valid. It has changed to NEWTICKER". </p> <p>But that's not helpful; for example in the case of Skye industries, it used to trade as SKYY. But now SKYY tracks some sort of cloud computing ETF.</p> <p>Happy to pay for the data.</p>