stockPortfolio - 下标超出范围

时间:2015-10-11 03:55:01

标签: r portfolio stocks

我正在尝试使用stockPortfolio包中的getReturns函数获取少数股票的返回数据。当我使用以下代码时:

    library(stockPortfolio)
    stocks <- c("GODFRYPHL.NS", "ITC.NS", "VSTIND.NS", "BANARISUG.NS", "ASSAMCO.NS", "TATAGLOBA.NS", "CMC.NS", "SHREERAMA.NS", "MAX.NS", "BATAINDIA.NS", "RUBYMILLS.NS", "GRASIM.NS", "NATIONALU.NS", "MAHSEAMLE.NS", "JSWSTEEL.NS", "TATASTEEL.NS", "JINDALSTE.NS", "FOSECOIND.NS", "GUJFLUORO.NS", "ASIANPAIN.NS", "PILIND.NS", "MAHLIFE.NS", "UNITECH.NS", "BSELINFRA.NS", "LT.NS", "NOIDATOLL.NS", "RIIL.NS", "KEC.NS", "OPTOCIRCU.NS", "DIVISLAB.NS", "DRREDDY.NS", "GLAXO.NS", "ZEEL.NS", "OFSS.NS", "FINANTECH.NS", "INFY.NS", "TCS.NS", "BHARTIART.NS", "MOTHERSUM.NS", "BOSCHLTD.NS","MAHSCOOTE.NS", "MRF.NS", "ACC.NS", "RAMCOCEM.NS", "JPASSOCIA.NS", "ASAHIINDI.NS","VESUVIUS.NS", "HOTELEELA.NS", "TAJGVK.NS", "IGL.NS", "EDUCOMP.NS", "CONCOR.NS",                "GDL.NS", "SHOPERSTO.NS", "DREDGECOR.NS", "GESHIP.NS", "KOTHARIPR.NS", "FAGBEARIN.NS", "HONAUT.NS", "BEL.NS", "AIAENG.NS", "THERMAX.NS", "AIL.NS", "ENGINERSI.NS", "TNTELE.NS", "ABB.NS", "BHEL.NS","SIEMENS.NS")

returns <- getReturns(stocks, freq="month", start='2006-04-01', end='2013-12-31',"overlapOnly") 

我收到以下错误:

Error in R[thisRow - nRemoved, j] : subscript out of bounds

有什么建议吗?

P.S:但当数据频率更改为freq="week"时,它工作正常。

0 个答案:

没有答案