0

I am trying to get the return data for few stocks using getReturns function in stockPortfolio package. When I used the following code:

    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") 

I got the following error:

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

Any suggestions?

P.S: But it worked fine when the frequency of data was changed to freq="week".

Abhay Bhadani
  • 119
  • 1
  • 3
  • 13
  • 1
    The problem also occurs with `stocks <- c("GUJFLUORO.NS", "ASIANPAIN.NS", "PILIND.NS")` but not anymore if any of these 3 stocks is removed too. I wonder if this is a bug in `stockPortfolio`. – WhiteViking Oct 11 '15 at 09:52
  • @WhiteViking: I removed all these three stocks but even then I am getting the same error :( – Abhay Bhadani Oct 12 '15 at 01:45
  • I meant that `getReturns(c("GUJFLUORO.NS", "ASIANPAIN.NS", "PILIND.NS"), freq="month", start='2006-04-01', end='2013-12-31',"overlapOnly")` has the problem, but if I remove one more of *those* three stocks the problem disappears. For example this works fine: `getReturns(c("ASIANPAIN.NS", "PILIND.NS"), freq="month", start='2006-04-01', end='2013-12-31',"overlapOnly")` – WhiteViking Oct 12 '15 at 11:53
  • 1
    I had a look at the source code for `stockPortfolio` and I suspect it has a bug in code specific for the `freq="month"` case. It seems to be triggered by certain combinations of stocks where not every date has stock information for all selected stocks. I informed the maintainer of `stockPortfolio`. – WhiteViking Oct 12 '15 at 11:54
  • @WhiteViking: Thank you :) – Abhay Bhadani Oct 13 '15 at 00:43
  • @WhiteViking: I was wondering what is the maximum number of stock for which returns data is downloadable using `stockPortfolio` package. – Abhay Bhadani Nov 12 '15 at 02:31

0 Answers0