{"id":3590,"date":"2008-10-24T13:01:13","date_gmt":"2008-10-24T17:01:13","guid":{"rendered":"http:\/\/www.prefblog.com\/?p=3590"},"modified":"2008-10-24T13:01:13","modified_gmt":"2008-10-24T17:01:13","slug":"himipref-bug-fix-curveyield-calculation","status":"publish","type":"post","link":"https:\/\/prefblog.com\/?p=3590","title":{"rendered":"HIMIPref&#8482; Bug Fix: curveYield Calculation"},"content":{"rendered":"<p>As noted on <a href=\"http:\/\/www.prefblog.com\/?p=3530\">October 22<\/a><\/p>\n<blockquote><p>I\u2019ll explain in another post, because it\u2019s kind of funny, but basically there\u2019s a little loop used in the process of curve approximation that calculates a yield; in the case of YLD.PR.B, quoted at 1.60 with a stated annual dividend of $1.05 (currently suspended) until maturity 2012-2-1 at $15 [dubious], the little loop ran \u2019round 5,709,833 times [in the run where the problem was unequivocally isolated] before the WebService timed out and blew up the whole programme.<\/p><\/blockquote>\n<p>The function at fault (yieldApproximatorTypeCalc::getSemiAnnualYieldFromTable) calculates the yield to maturity of a set of cash flows defined in a table (the input is set up in much the same way as Excel&#8217;s XIRR() function) by successive approximations to the yield using the <a href=\"http:\/\/mathworld.wolfram.com\/NewtonsMethod.html\">Newton Method<\/a>.<\/p>\n<blockquote><p>Unfortunately, this procedure can be unstable near a horizontal asymptote or a local extremum.<\/p><\/blockquote>\n<p>When calculating the curveYield for YLD.PR.B on October 21, the function did not converge; instead, it oscillated between two highly incorrect numbers.<\/p>\n<p>The function has been adjusted such that:<\/p>\n<ul>\n<li>After 500 iterations, a successively smaller damping factor is applied to the yield change, and\n<li>After 1,000 iterations, status information is written to the errorOutput.txt file after each iteration, and\n<li>After 1,010 iterations the process aborts and returns <a href=\"http:\/\/www.prefshares.com\/glossary.html#ANALYTICAL_DOUBLE_NO_SOLUTION\">ANALYTICAL_DOUBLE_NO_SOLUTION<\/a><\/ul>\n<p>The function now converges for YLD.PR.B on October 21; other tests (prior to application of the damping factor) confirm that the &#8216;no solution&#8217; result is handled properly by the rest of the programme.<\/p>\n<p>It&#8217;s not often I find a crippling bug in HMIPref&trade; any more! That&#8217;s the only lack of convergence in this function in almost 15 years of daily data!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As noted on October 22 I\u2019ll explain in another post, because it\u2019s kind of funny, but basically there\u2019s a little loop used in the process of curve approximation that calculates a yield; in the case &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-3590","post","type-post","status-publish","format-standard","hentry","category-programme-bugs"],"_links":{"self":[{"href":"https:\/\/prefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prefblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prefblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prefblog.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3590"}],"version-history":[{"count":0,"href":"https:\/\/prefblog.com\/index.php?rest_route=\/wp\/v2\/posts\/3590\/revisions"}],"wp:attachment":[{"href":"https:\/\/prefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prefblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}