我无法正确使用termstrc

时间:2018-06-26 11:39:34

标签: r finance quantitative-finance

我是一名学生,我正在尝试使用R中的“ termstrc”包提供的功能。但是,这样做的时候我发现了一些困难。

它要么弹出错误“ colnames<-*tmp*中的错误,值= group $ ISIN):   尝试在尺寸小于二维的对象上设置'colnames'”

或“在as.Date.default(group $ CASHFLOW $ DATE)中出现错误:   不知道如何将“ group $ CASHFLOW $ DATE”转换为“ Date”类”

我将发布代码以寻求帮助 预先感谢!

ISIN <- c("DE0001135358", 
                   "DE0001141679", "DE0001135374", "DE0001141687", "DE0001141695",
                   "DE0001135382", "DE0001141703", "DE0001135390", "DE0001030526",
                   "DE0001141729", "DE0001135457", "DE0001135465", "DE0001135473", 
                   "DE0001135499", "DE0001102309", "DE0001030542", "DE0001102317", 
                   "DE0001102325", "DE0001102333", "DE0001102358", "DE0001102366",
                   "DE0001102374", "DE0001102382", "DE0001102390", "DE0001030567",
                   "DE0001102424", "DE0001135069", "DE0001102440", "DE0001135143",
                   "DE0001030559", "DE0001135275", "DE0001135481", "DE0001102432")
MATURITYDATE <- structure(c(17716, 17816, 17900, 17949, 17998, 18081, 18180, 18265, 18367,
                        18551, 18874, 18996, 19177, 19239, 19403, 19462, 19492, 19584, 
                        19768, 19858, 19950, 20134, 20315, 20499, 20558, 21045, 21187,
                        21229, 21918, 22019, 24475, 27213, 28716), class = "Date")


ISSUEDATE <-structure(c(14029, 15954, 14197, 16087, 16172, 14386, 16318, 14561, 14349, 
                    16619, 15212, 15303, 15443, 15587, 15723, 15422, 15840, 15932, 
                    16101, 16205, 16297, 16451, 16633, 16815, 16506, 17361, 10230,
                    17543,10960, 16170, 12787, 15457, 17393), class = "Date")

COUPONRATE <- c(0.0425, 0.01, 0.0375, 0.01, 0.005, 0.035, 0.0025, 0.0325, 0.01945,
            0.0025, 0.025, 0.02, 0.0175, 0.015, 0.015, 0.00105, 0.015, 0.02, 
            0.0175, 0.015, 0.01, 0.005, 0.01, 0.005, 0.00102, 0.005, 0.05625, 
            0.005, 0.0625, 0.00513, 0.04, 0.025, 0.0125)

PRICE <- c(100.285, 100.55, 102.535, 101.19, 100.99, 104.48, 101.27, 106.235, 106.26, 
       102, 108.85, 108.67, 108.58, 107.7, 108.14, 107.89, 108.33, 111.11, 110.29, 
       109.04, 106.09, 102.82, 106.16, 102.22, 110.36, 100.91, 149.074, 100.34, 164.07, 
       116.8, 152.38, 131.28, 101.51)

ACCRUED <- c(3.889,0.641, 1.541, 0.2767,0.0712, 3.2027, 0.1609, 1.3356, 0.2349, 0.1575,
         1.6767, 0.8219,1.6013, 1.1178, 0.4438, 0.0134, 0.078, 1.6, 0.5178, 0.078, 0.8,
         0.1479, 0.8, 0.1479, 0.0134, 0.4438, 2.3116, 0.1945, 2.5684,
         0.0671, 1.7315, 2.3424, 0.8972)
CFISIN <- c("DE0001135358", "DE0001141679", "DE0001135374",
                     "DE0001141687", "DE0001141695", "DE0001135382", "DE0001135382",
                     "DE0001141703", "DE0001141703", "DE0001135390", "DE0001135390",
                     "DE0001030526", "DE0001030526", "DE0001141729", "DE0001141729",
                     "DE0001141729", "DE0001135457", "DE0001135457", "DE0001135457",
                     "DE0001135457", "DE0001135465", "DE0001135465", "DE0001135465",
                     "DE0001135465", "DE0001135473", "DE0001135473", "DE0001135473",
                     "DE0001135473", "DE0001135499", "DE0001135499", "DE0001135499",
                     "DE0001135499", "DE0001135499", "DE0001102309", "DE0001102309",
                     "DE0001102309", "DE0001102309", "DE0001102309", "DE0001030542",
                     "DE0001030542", "DE0001030542", "DE0001030542", "DE0001030542",
                     "DE0001102317", "DE0001102317", "DE0001102317", "DE0001102317",
                     "DE0001102317", "DE0001102325", "DE0001102325", "DE0001102325",
                     "DE0001102325", "DE0001102325", "DE0001102325", "DE0001102333",
                     "DE0001102333", "DE0001102333", "DE0001102333", "DE0001102333",
                     "DE0001102333", "DE0001102358", "DE0001102358", "DE0001102358",
                     "DE0001102358", "DE0001102358", "DE0001102358", "DE0001102366",
                     "DE0001102366" ,"DE0001102366", "DE0001102366", "DE0001102366",
                     "DE0001102366", "DE0001102366", "DE0001102374", "DE0001102374",
                     "DE0001102374", "DE0001102374", "DE0001102374", "DE0001102374",
                     "DE0001102374", "DE0001102382", "DE0001102382", "DE0001102382",
                     "DE0001102382", "DE0001102382", "DE0001102382", "DE0001102382",
                     "DE0001102382", "DE0001102390", "DE0001102390", "DE0001102390",
                     "DE0001102390", "DE0001102390", "DE0001102390", "DE0001102390",
                     "DE0001102390", "DE0001030567", "DE0001030567", "DE0001030567",
                     "DE0001030567", "DE0001030567", "DE0001030567", "DE0001030567",
                     "DE0001030567", "DE0001102424", "DE0001102424", "DE0001102424",
                     "DE0001102424", "DE0001102424", "DE0001102424", "DE0001102424",
                     "DE0001102424", "DE0001102424", "DE0001102424", "DE0001135069",
                     "DE0001135069", "DE0001135069", "DE0001135069", "DE0001135069",
                     "DE0001135069", "DE0001135069", "DE0001135069", "DE0001135069",
                     "DE0001135069", "DE0001102440", "DE0001102440", "DE0001102440",
                     "DE0001102440", "DE0001102440", "DE0001102440", "DE0001102440",
                     "DE0001102440", "DE0001102440", "DE0001102440", "DE0001135143",
                     "DE0001135143", "DE0001135143", "DE0001135143", "DE0001135143",
                     "DE0001135143", "DE0001135143", "DE0001135143", "DE0001135143",
                     "DE0001135143", "DE0001135143", "DE0001135143", "DE0001030559",
                     "DE0001030559", "DE0001030559", "DE0001030559", "DE0001030559",
                     "DE0001030559", "DE0001030559", "DE0001030559", "DE0001030559",
                     "DE0001030559", "DE0001030559", "DE0001030559", "DE0001135275",
                     "DE0001135275", "DE0001135275", "DE0001135275", "DE0001135275",
                     "DE0001135275", "DE0001135275", "DE0001135275", "DE0001135275",
                     "DE0001135275", "DE0001135275", "DE0001135275", "DE0001135275",
                     "DE0001135275", "DE0001135275", "DE0001135275", "DE0001135275",
                     "DE0001135275", "DE0001135275", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001135481", "DE0001135481", "DE0001135481",
                     "DE0001135481", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432",
                     "DE0001102432", "DE0001102432", "DE0001102432", "DE0001102432")

CF <- c(104.25, 101, 103.75, 101, 100.5, 3.5, 103.5, 0.25,  100.25,
    3.25, 103.25, 1.945, 101.945, 0.25, 0.25, 100.25, 2.5, 2.5, 2.5,
    102.5, 2, 2, 2, 102, 1.75, 1.75, 1.75, 101.75, 1.5, 1.5, 1.5, 1.5,
    101.5, 1.5, 1.5, 1.5, 1.5, 101.5, 0.105, 0.105, 0.105, 0.105, 100.105,
    1.5, 1.5, 1.5, 1.5, 101.5, 2, 2, 2, 2, 2, 102, 1.75, 1.75, 1.75, 1.75,
    1.75, 101.75, 1.5, 1.5, 1.5, 1.5, 1.5, 101.5, 1, 1, 1, 1, 1, 1, 101,
    0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 100.5, 1, 1, 1, 1, 1, 1, 1, 101, 0.5, 0.5,
    0.5, 0.5, 0.5, 0.5, 0.5, 100.5, 0.102, 0.102, 0.102, 0.102, 0.102,
    0.102, 0.102, 100.102, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
    100.5, 5.625, 5.625, 5.625, 5.625, 5.625, 5.625, 5.625, 5.625, 5.625,
    105.625, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 100.5, 6.25,
    6.25, 6.25, 6.25, 6.25, 6.25, 6.25, 6.25, 6.25, 6.25, 6.25, 106.25,
    0.513, 0.513, 0.513, 0.513, 0.513, 0.513, 0.513, 0.513, 0.513, 0.513,
    0.513, 100.513, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
    104, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5,
    2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 102.5,
    1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25,
    1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25,
    1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 101.25)
DATE <- structure(c(17716, 17816, 17900, 17949, 17998, 17716, 18081, 17815, 18180,
                17900, 18265, 18001, 18367, 17820, 18185, 18551, 17778, 18143,
                18509, 18874, 17900, 18265, 18631, 18996, 18081, 18447, 18812,
                19177, 17778, 18143, 18509, 18874, 19239, 17942, 18307, 18673,
                19038, 19403, 18001, 18367, 18732, 19097, 19462, 18031, 18397,
                18762, 19127, 19492, 17758, 18123, 18489, 18854, 19219, 19584, 
                17942, 18307, 18673, 19038, 19403, 19768, 18031, 18397, 18762, 
                19127, 19492, 19858, 17758, 18123, 18489, 18854, 19219, 19584, 
                19950, 17942, 18307, 18673, 19038, 19403, 19768, 20134, 17758, 
                18123, 18489, 18854, 19219, 19584, 19950, 20315, 17942, 18307, 
                18673, 19038, 19403, 19768, 20134, 20499, 18001, 18367, 18732, 
                19097, 19462, 19828, 20193, 20558, 17758, 18123, 18489, 18854, 
                19219, 19584, 19950, 20315, 20680, 21045, 17900, 18265, 18631, 
                18996, 19361, 19726, 20092, 20457, 20822, 21187, 17942, 18307, 
                18673, 19038, 19403, 19768, 20134, 20499, 20864, 21229, 17987, 
                18353, 18718, 19083, 19448, 19814, 20179, 20544, 20909, 21275, 
                21640, 22005, 18001, 18367, 18732, 19097, 19462, 19828, 20193, 
                20558, 20923, 21289, 21654, 22019, 17900, 18265, 18631, 18996, 
                19361, 19726, 20092, 20457, 20822, 21187, 21553, 21918, 22283, 
                22648, 23014, 23379, 23744, 24109, 24475, 17716, 18081, 18447, 
                18812, 19177, 19542, 19908, 20273, 20638, 21003, 21369, 21734, 
                22099, 22464, 22830, 23195, 23560, 23925, 24291, 24656, 25021, 
                25386, 25752, 26117, 26482, 26847, 27213, 17758, 18123, 18489, 
                18854, 19219, 19584, 19950, 20315, 20680, 21045, 21411, 21776, 
                22141, 22506, 22872, 23237, 23602, 23967, 24333, 24698, 25063, 
                25428, 25794, 26159, 26524, 26889, 27255, 27620, 27985, 28350, 
                28716), class = "Date")
CASHFLOWS <- list(CFISIN, CF, DATE)

名称(CASHFLOWS)<-c(“ CFISIN”,“ CF”,“ CFDATE”)

TODAY <- structure(17693, class = "Date")

GERMANY <- list(ISIN,MATURITYDATE,ISSUEDATE,
            COUPONRATE,PRICE,ACCRUED,CASHFLOWS,TODAY)

names(GERMANY) <- c("ISIN","MATURITYDATE","ISSUEDATE","COUPONRATE",
               "PRICE","ACCRUED","CASHFLOWS","TODAY")
mybonds <- list(GERMANY)

0 个答案:

没有答案