{"id":158,"date":"2014-03-14T09:40:18","date_gmt":"2014-03-14T00:40:18","guid":{"rendered":"http:\/\/www.fsquare.co.kr\/?p=158"},"modified":"2014-04-10T14:22:00","modified_gmt":"2014-04-10T05:22:00","slug":"%ec%b1%84%ea%b6%8c%ea%b0%80%ea%b2%a9%ea%b3%84%ec%82%b0-library-%ea%b0%9c%eb%b0%9c-3","status":"publish","type":"post","link":"https:\/\/www.fsquare.co.kr\/?p=158","title":{"rendered":"\ucc44\uad8c\uac00\uaca9\uacc4\uc0b0 library \uac1c\ubc1c-3"},"content":{"rendered":"<p>\uc774\ud45c\ucc44\uc5d0 \uc774\uc5b4 \ucc44\uad8c\uc758 \uae30\ubcf8\uc774 \ub418\ub294 \ud560\uc778\ucc44\uc5d0 \ub300\ud574 \uc0b4\ud3b4 \ubcf4\uaca0\ub2e4. \ud560\uc778\ucc44\uc758 \uc218\uc775\ub960\uc740 \uadf8 \uc790\uccb4\ub85c spot rate\uc774\ubbc0\ub85c \ud558\ub098\uc758 \uc218\uc775\ub960\ub85c \ud558\ub098\uc758 cashflow\ub97c \ud560\uc778\ud558\uc5ec \ucc44\uad8c \uac00\uaca9\uc744 \uc0b0\ucd9c\ud558\ub294 \uac04\ub2e8\ud55c \ub85c\uc9c1\uc774\ub2e4.<\/p>\n<p><strong>\ub9cc\uae30 \uc0c1\ud658\ub9cc \uc874\uc7ac\ud558\ub294 \ud560\uc778\ucc44<\/strong><br \/>\n\ud560\uc778\ucc44\ub294 \ub9cc\uae30\uc5d0 \uc6d0\uae08\uc744 \uc0c1\ud658\ud558\uae30\ub85c \ud558\uace0 \ud45c\uba74\uae08\ub9ac\ub85c \ud560\uc778\ub41c \ud604\uc7ac \uac00\uce58\ub85c \ucc44\uad8c\uc774 \ubc1c\ud589\ub41c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 3\ub144 \ud6c4(\ub9cc\uae30)\uc5d0 10,000\uc6d0\uc744 \ubc1b\uae30\ub85c \ud558\uace0 \ud604\uc7ac \ud560\uc778\ub41c 9,700\uc6d0\uc73c\ub85c \ucc44\uad8c\uc744 \ub9e4\uc785\ud558\ub294 \uac83\uc774\ub2e4. \uc774 \ub54c, 300\uc6d0\uc774 \ucc44\uad8c\uc758 \uc774\uc790\uac00 \ub418\uace0 \uc6d0\uae08\uc740 10,000\uc6d0\uc774\uba70 300\uc6d0\uc744 3\ub144\uac04 \ub098\ub208 \uac83\uc774 \ud560\uc778\uc728, \uc989 \uc218\uc775\ub960\uc774 \ub418\uaca0\ub2e4.<br \/>\n\uc774\ub97c \ud568\uc218\ub85c \ub9cc\ub4e0\uac83\uc774 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre>\/*----------------------------------------------------------------------------- \u00a0\r\n * fnSBDiscountBond : \ud560\uc778\ucc44\uc5d0 \ub300\ud55c \uac00\uaca9 \uacc4\uc0b0 \ud568\uc218\r\n *\t\tSpot\/YTM \ubaa8\ub450 \uc0ac\uc6a9\uac00\ub2a5\r\n *\t\tYTM\uc758 \uac2f\uc218\ub97c 1\uac1c\ub9cc \uc9c0\uc815\ud558\ub294 \uacbd\uc6b0 \ud574\ub2f9 YTM\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc73c\uba70,\r\n *\t\tYTM\uc758 \uac2f\uc218\uac00 \uc5ec\ub7ec\uac1c\uc778 \uacbd\uc6b0 \ubcf4\uac04 \ud558\uc5ec \ud574\ub2f9 YTM \uc0ac\uc6a9\r\n *\r\n * \ubbf8\uacb0\uc0ac\ud56d :\r\n *\u00a0\r\n *---------------------------------------------------------------------------*\/\r\nUINT fnSBDiscountBond( DATETYPE dtPriceDay,     \/* \uacc4\uc0b0\uc77c              *\/\r\n                       BONDINFO *pBondInfo,   \/* Bond Info Structure   *\/\r\n                       CURVE  *pCurve,        \/* ytm\/sport curve      *\/\r\n                       BONDPRICE *pBondPrice, \/* Price Info Structure  *\/\r\n                       INT    *error_code)\r\n{\r\n\tDATETYPE\tnextCouponDate;\r\n\tDATETYPE\tprevCouponDate;\r\n\tUINT \t\tnTotalYear;\r\n\tUINT\t\tnDaysToMaturity;\r\n\tDOUBLE\t\tnBondPrice;\r\n\tDOUBLE\t\tnDuration;\r\n\tDOUBLE\t\tnMD;\r\n\tDOUBLE\t\tnConvexity;\r\n\tDOUBLE\t\tnFace;\r\n\tDOUBLE\t\tnDiscountToday;\r\n\tUINT\t\tnNextCouponRemDay;\r\n\tUINT\t\tnCouponTermDay;\r\n\r\n...\r\n\uc911\ub7b5\r\n...\r\n\r\n\tnDuration  = 0.0;\r\n\tnMD        = 0.0;\r\n\tnConvexity = 0.0;\r\n\r\n\tnFace = 10000.0;\r\n\r\n\t\/\/ \uc0c1\ud658\uc77c \uae30\uc900 \uc774\uc790\uc9c0\uae09\ucc44\uad8c\uacfc \ub3d9\uc77c\ud558\uac8c \ub0a0\uc9dc \uacc4\uc0b0\r\n\tprevCouponDate = pBondInfo-&gt;dtDueDay;\r\n\tnTotalYear = 0.0;\r\n\twhile ( fnDatetoInt( prevCouponDate ) &gt;= fnDatetoInt( dtPriceDay ) ) {\r\n\t\tnextCouponDate = prevCouponDate;\r\n\t\tprevCouponDate = fnAddDateInt( prevCouponDate, YEAR, -1 );\r\n\t\tnTotalYear++;\r\n\t}\r\n\r\n\tnBondPrice = 0.0;\r\n\tnNextCouponRemDay = fnCountDate( dtPriceDay, nextCouponDate, DAY );\r\n\tnCouponTermDay    = fnCountDate( prevCouponDate, nextCouponDate, DAY ) ;\r\n\tnDiscountToday = (DOUBLE) nNextCouponRemDay \/ (DOUBLE) nCouponTermDay;\r\n\r\n\t\/*----------------------------------------------------------------------\r\n\t * YTM : yield\uac00 \ud558\ub098\uc77c\uacbd\uc6b0 \uadf8\ub0e5 \uc0ac\uc6a9, \uc5ec\ub7ec\uac1c\uc77c\uacbd\uc6b0 linear\/spline \ubcf4\uac04\r\n\t *---------------------------------------------------------------------*\/\r\n\r\n\tnDaysToMaturity = fnCountDate( dtPriceDay, pBondInfo-&gt;dtDueDay, DAY );\r\n\r\n\tif ( pCurve-&gt;nYieldCount == 1 )\r\n\t{\r\n\t\tpBondPrice-&gt;nYtm = pCurve-&gt;nYield[ 0 ];\r\n\t}\r\n\telse\r\n\t{\r\n\t\t\/* \ud574\ub2f9 \uc794\uc874\ub9cc\uae30\uc758 \uc218\uc775\ub960\uc744 \uc120\ud615\ubcf4\uac04 *\/\r\n\t\tpBondPrice-&gt;nYtm = fnGetRate( pCurve, nDaysToMaturity , LINEAR );\r\n\t}\r\n\r\n        \/\/ \ucc44\uad8c \uac00\uaca9\uc744 \uacc4\uc0b0\ud558\ub294 \ubd80\ubd84\r\n\tnBondPrice = nFace \/ pow( 1.0 + pBondPrice-&gt;nYtm, nTotalYear - 1 );\r\n\tnBondPrice \/= ( 1.0 + pBondPrice-&gt;nYtm * nDiscountToday );\r\n\r\n\tnDuration = (DOUBLE) nDaysToMaturity \/ 365.0;\r\n\tnMD = Math_Round( nDuration \/ ( 1 + pBondPrice-&gt;nYtm ), 5 );\r\n\tnConvexity = Math_Round( nDuration, 6 )* ( Math_Round( nDuration, 6) + 1 );\r\n\tnConvexity = Math_Round( nDuration \/ pow( 1.0 + pBondPrice-&gt;nYtm * pBondInfo-&gt;nIntMonth \/ 12.0, 2 ), 5 );\r\n\r\nnDuration, 6) + 1 ) \/ pow( 1.0 + pBondPrice-&gt;nYtm * pBondInfo-&gt;nIntMonth \/ 12.0, 2 ), 5 );\r\n\r\n\tpBondPrice-&gt;nPrice = nBondPrice;\r\n\tpBondPrice-&gt;nDuration = Math_Round( nDuration, 5 );\r\n\tpBondPrice-&gt;nMD = nMD;\r\n\tpBondPrice-&gt;nConvexity = nConvexity;\r\n\r\n\treturn SUCCESS;\r\n}<\/pre>\n<p>\uc0ac\uc2e4 \ubcc4\ub85c \uc5b4\ub824\uc6b8 \uac83\ub3c4 \uc5c6\uc774 \uac04\ub2e8\ud55c \uacc4\uc0b0\uc774\ub2e4. \uc774\ud45c\ucc44\uc758 \uc5ec\ub7ec cashflow\uc911 \ub9cc\uae30\uc5d0 \ud574\ub2f9\ud558\ub294 \uac83 \ud55c \uac74\ub9cc \uacc4\uc0b0\ud558\uba74 \ub41c\ub2e4.<\/p>\n<p>\uc704\uc5d0\uc11c \uc598\uae30\ud55c \ubc14\uc640 \uac19\uc774 \ud560\uc778\ucc44\ub294 \uadf8 \uc790\uccb4\uc758 \uc218\uc775\ub960\uc774 spot rate\uc774\ubbc0\ub85c \uc2dc\uc7a5\uc5d0\uc11c \uad00\ucc30\ub41c spot\uc744 \uadf8\ub300\ub85c \uc0ac\uc6a9\ud574\uc11c \ucc44\uad8c \uac00\uaca9\uc744 \uacc4\uc0b0\ud558\uba74 \ub418\uba70 spot\uc774 \uc544\ub2cc \uacf5\uc2dc \uc218\uc775\ub960\uacfc \uac19\uc740 ytm\uc73c\ub85c \uc218\uc775\ub960\uc744 \uc785\ub825\ud558\ub294 \uacbd\uc6b0 \uc0ac\uc804\uc801\uc73c\ub85c bootstrapping \ubc29\ubc95 \ub4f1\uc744 \ud1b5\ud574 spot rate\uc744 \uc0b0\ucd9c\ud558\uba74 \ub41c\ub2e4.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc774\ud45c\ucc44\uc5d0 \uc774\uc5b4 \ucc44\uad8c\uc758 \uae30\ubcf8\uc774 \ub418\ub294 \ud560\uc778\ucc44\uc5d0 \ub300\ud574 \uc0b4\ud3b4 \ubcf4\uaca0\ub2e4. \ud560\uc778\ucc44\uc758 \uc218\uc775\ub960\uc740 \uadf8 \uc790\uccb4\ub85c spot rate\uc774\ubbc0\ub85c \ud558\ub098\uc758 \uc218\uc775\ub960\ub85c \ud558\ub098\uc758 cashflow\ub97c \ud560\uc778\ud558\uc5ec \ucc44\uad8c \uac00\uaca9\uc744 \uc0b0\ucd9c\ud558\ub294 \uac04\ub2e8\ud55c \ub85c\uc9c1\uc774\ub2e4. \ub9cc\uae30 \uc0c1\ud658\ub9cc \uc874\uc7ac\ud558\ub294 \ud560\uc778\ucc44 \ud560\uc778\ucc44\ub294 \ub9cc\uae30\uc5d0 \uc6d0\uae08\uc744 \uc0c1\ud658\ud558\uae30\ub85c \ud558\uace0 \ud45c\uba74\uae08\ub9ac\ub85c \ud560\uc778\ub41c \ud604\uc7ac \uac00\uce58\ub85c \ucc44\uad8c\uc774 \ubc1c\ud589\ub41c\ub2e4. \uc608\ub97c \ub4e4\uc5b4 3\ub144 \ud6c4(\ub9cc\uae30)\uc5d0 10,000\uc6d0\uc744 \ubc1b\uae30\ub85c \ud558\uace0 \ud604\uc7ac \ud560\uc778\ub41c 9,700\uc6d0\uc73c\ub85c \ucc44\uad8c\uc744 \ub9e4\uc785\ud558\ub294 \uac83\uc774\ub2e4. \uc774 \ub54c, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-158","post","type-post","status-publish","format-standard","hentry","category-asset-pricing"],"_links":{"self":[{"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=158"}],"version-history":[{"count":4,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions"}],"predecessor-version":[{"id":174,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/158\/revisions\/174"}],"wp:attachment":[{"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}