{"id":177,"date":"2014-04-14T14:47:37","date_gmt":"2014-04-14T05:47:37","guid":{"rendered":"http:\/\/www.fsquare.co.kr\/?p=177"},"modified":"2014-04-14T14:48:35","modified_gmt":"2014-04-14T05:48:35","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-4","status":"publish","type":"post","link":"https:\/\/www.fsquare.co.kr\/?p=177","title":{"rendered":"\ucc44\uad8c\uac00\uaca9\uacc4\uc0b0 library \uac1c\ubc1c-4"},"content":{"rendered":"<p>\ucc44\uad8c \uac00\uaca9 \uacc4\uc0b0 \ub77c\uc774\ube0c\ub7ec \uac1c\ubc1c\uc744 \uc704\ud574 \uc77c\ubc18 \ucc44\uad8c \uc911 \uac00\uc7a5 \uae30\ubcf8\uc774 \ub418\ub294 \ud560\uc778\ucc44\uc640 \uc774\ud45c\ucc44\uc5d0 \ub300\ud55c \uc124\uba85\uc744 \ud55c\ub370 \uc774\uc5b4 \ub2e8\ub9ac\ucc44\uc640 \ubcf5\ub9ac\ucc44\uc5d0 \ub300\ud55c \uc124\uba85\uc744 \ud558\uace0\uc790 \ud55c\ub2e4.<\/p>\n<p>\ub2e8\ub9ac\ucc44\ub294 \ub9e4\ub144 \ucc44\uad8c\uc758 \ud45c\uba74 \uc774\uc790\uc728\ub85c \uacc4\uc0b0\ud55c \uc774\uc790\ub97c \ub204\uc801\ud558\uc5ec \ub9cc\uae30\uc5d0 \uc77c\uc2dc \uc0c1\ud658\ud558\ub294 \ucc44\uad8c\uc774\ub2e4. \uc989 \ub9e4\ub144 \uc774\uc790 \uc5bc\ub9c8 ( \uc6d0\uae08 X \ud45c\uba74\uc774\uc790\uc728 )\ub97c \uacc4\uc0b0\ud574\uc11c \ub9cc\uae30\uc5d0\ub294 &#8220;\uc6d0\uae08 + \uadf8\ub3d9\uc548\uc758 \ub204\uc801\uc774\uc790&#8221; \ub85c \uc9c0\uae09\ud55c\ub2e4.<br \/>\n\ubcf5\ub9ac\ucc44\ub294 \ucc44\uad8c\uc758 \uc774\uc790\ub97c \ubcf5\ub9ac\ub85c \uacc4\uc0b0\ud574\uc11c \ub9cc\uae30\uc77c\uc5d0 \uc77c\uc2dc \uc0c1\ud658\ud558\ub294 \ucc44\uad8c\uc774\ub2e4. \uc989, \ucc44\uad8c\uc758 \uc6d0\uae08\uc744 \uc9c0\uae09\ud558\ub294 \ub9cc\uae30\uc5d0 \uc774\uc790\uae4c\uc9c0 \ud55c\uaebc\ubc88\uc5d0 \uc9c0\uae09\ud558\ub294\ub370 \uc774 \ub54c \uccab \ud574\ubd80\ud130 \uc9c0\uae09\ub418\ub294 \uc774\uc790\uac00 \ubcf5\ub9ac\ub85c \uacc4\uc18d \uc313\uc778\ub2e4\ub294 \uc870\uac74\uc774\ub2e4. ( \ubcf5\ub9ac\ub77c \ud568\uc740 \uc774\uc790\uc5d0\ub3c4 \uc774\uc790\uac00 \ubd99\ub294 \uac1c\ub150 )<\/p>\n<p>\ubcf5\ub9ac\ucc44\uc758 \ub85c\uc9c1\uc740 \ud06c\uac8c \uc5b4\ub824\uc6b8 \uac83\uc774 \uc5c6\ub2e4. \ub2e8\ub9ac\ucc44\uc640 \ub3d9\uc77c\ud55c\ub370 \uc774\uc790\ub97c \ub204\uc801\ud574\uc11c \uadf8 \ub204\uc801\ub41c \uc774\uc790\uc5d0\ub3c4 \uc774\uc790 \uacc4\uc0b0\uc744 \ud574\uc11c \ub2e4\uc2dc \ub204\uc801\ud574 \uc8fc\uc5b4\uc57c \ud55c\ub2e4.<\/p>\n<pre>\/*-----------------------------------------------------------------------------\r\n * fnSBCompoundBond : \ubcf5\ub9ac\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 * total_coupon : total_year + days from issue to first coupon day\r\n *\r\n *---------------------------------------------------------------------------*\/\r\n\r\nUINT fnSBCompoundBond( 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\tnTotalCoupon;\r\n\tUINT \t\tnResidueYear;\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\tDOUBLE\t\tnIntRatio;\r\n\tUINT\t\tnNextCouponRemDay;\r\n\tUINT\t\tnCouponTermDay;\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\tnIntRatio  = pBondInfo-&gt;nIntMonth \/ 12.0;\r\n\r\n\t\/*------------------------------------------------------\r\n\t * cashflow = face * \ub9cc\uae30\uc0c1\ud658\uc728 + coupon \/ \ud69f\uc218 * ( rem \/ term + N - 1 )\r\n\t *-----------------------------------------------------*\/\r\n\r\n\tnResidueYear = 0;\r\n\r\n\tprevCouponDate = pBondInfo-&gt;dtDueDay;\r\n        while ( fnDatetoInt( prevCouponDate ) &gt;= fnDatetoInt( dtPriceDay ) ) {\r\n\t\tnextCouponDate = prevCouponDate;\r\n\t\tprevCouponDate = fnAddDateInt( prevCouponDate, YEAR, -1 );\r\n\t\tnResidueYear++;\r\n\t}\r\n\r\n\tif ( nResidueYear &gt; 0 ) nResidueYear--;\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\tnTotalCoupon = fnCountDate( pBondInfo-&gt;dtIssueDay, pBondInfo-&gt;dtDueDay, MONTH) \/ pBondInfo-&gt;nIntMonth;\r\n\r\n\tnBondPrice = 0.0;\r\n\r\n\tnDaysToMaturity = fnCountDate( dtPriceDay, pBondInfo-&gt;dtDueDay, DAY );\r\n\r\n        \/* \ud574\ub2f9 \uc218\uc775\ub960\uc774 \ud558\ub098\ub9cc \uc785\ub825\ub418\ub294 \uacbd\uc6b0 \ud558\ub098\uc758 YTM\uc744 \uc774\uc6a9 *\/\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\/* \uc5ec\ub7ec\uac1c\uc758 YTM\uc774 \uc785\ub825\ub418\ub294 \uacbd\uc6b0 \ud574\ub2f9 \uc794\uc874\ub9cc\uae30\uc758 \uc218\uc775\ub960\uc744 \uc120\ud615\ubcf4\uac04\uc73c\ub85c \uac00\uc838\uc634  *\/\r\n\t\tpBondPrice-&gt;nYtm = fnGetRate( pCurve, nDaysToMaturity , LINEAR );\r\n\t}\r\n        \/* Spot \ucee4\ube0c\uc5d0 \ub300\ud55c \ubd80\ubd84\uc740 \uc0dd\ub7b5 *\/\r\n\tnBondPrice = nFace * pBondInfo-&gt;nReturnRate \/ 100.0 + nFace * pow( 1 + pBondInfo-&gt;nCouponRate * nIntRatio, nTotalCoupon ) - nFace;\r\n\tnBondPrice = floor(nBondPrice) \/ ( (1 + pBondPrice-&gt;nYtm * nDiscountToday ) * pow( 1.0 + pBondPrice-&gt;nYtm, nResidueYear  ) ); \r\n\r\n\tnDuration = nDaysToMaturity \/ 365.0;\r\n\tnMD = Math_Round( nDuration \/ ( 1 + pBondPrice-&gt;nYtm ), 5 );\r\n\tnConvexity = Math_Round( ( Math_Round( nDuration, 6 ) * ( Math_Round( nDuration, 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>&nbsp;<\/p>\n<p>&nbsp;<br \/>\n\ub2e8\ub9ac\ucc44\ub294 \ucc44\uad8c \uac00\uaca9 \uacc4\uc0b0 \ubd80\ubd84\uc774 \ub2e4\uc74c\uacfc \uac19\uc774 \ubcc0\uacbd\ub418\uba74 \ub41c\ub2e4.<\/p>\n<pre>\r\n\r\n\tnBondPrice = floor( nFace * ( pBondInfo->nReturnRate \/ 100.0 + pBondInfo->nCouponRate \/ nCouponPerYear * (nTotalYear * nCouponPerYear + nRemDay \/ nLastCouponTermDay ) ) );\r\n\tnBondPrice = nBondPrice \/ ( pow( 1.0 + pBondPrice->nYtm, nResidueYear ) * ( 1.0 + pBondPrice->nYtm * nDiscountToday ));\r\n\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ucc44\uad8c \uac00\uaca9 \uacc4\uc0b0 \ub77c\uc774\ube0c\ub7ec \uac1c\ubc1c\uc744 \uc704\ud574 \uc77c\ubc18 \ucc44\uad8c \uc911 \uac00\uc7a5 \uae30\ubcf8\uc774 \ub418\ub294 \ud560\uc778\ucc44\uc640 \uc774\ud45c\ucc44\uc5d0 \ub300\ud55c \uc124\uba85\uc744 \ud55c\ub370 \uc774\uc5b4 \ub2e8\ub9ac\ucc44\uc640 \ubcf5\ub9ac\ucc44\uc5d0 \ub300\ud55c \uc124\uba85\uc744 \ud558\uace0\uc790 \ud55c\ub2e4. \ub2e8\ub9ac\ucc44\ub294 \ub9e4\ub144 \ucc44\uad8c\uc758 \ud45c\uba74 \uc774\uc790\uc728\ub85c \uacc4\uc0b0\ud55c \uc774\uc790\ub97c \ub204\uc801\ud558\uc5ec \ub9cc\uae30\uc5d0 \uc77c\uc2dc \uc0c1\ud658\ud558\ub294 \ucc44\uad8c\uc774\ub2e4. \uc989 \ub9e4\ub144 \uc774\uc790 \uc5bc\ub9c8 ( \uc6d0\uae08 X \ud45c\uba74\uc774\uc790\uc728 )\ub97c \uacc4\uc0b0\ud574\uc11c \ub9cc\uae30\uc5d0\ub294 &#8220;\uc6d0\uae08 + \uadf8\ub3d9\uc548\uc758 \ub204\uc801\uc774\uc790&#8221; \ub85c \uc9c0\uae09\ud55c\ub2e4. \ubcf5\ub9ac\ucc44\ub294 \ucc44\uad8c\uc758 [&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-177","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\/177","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=177"}],"version-history":[{"count":2,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions"}],"predecessor-version":[{"id":179,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/177\/revisions\/179"}],"wp:attachment":[{"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fsquare.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}