L.Zingg
L.Zingg

Reputation: 85

Can Only Get 5 Days of Data on Stock Index R

I have a script to download data from yahoo-finance into R. It works well for every stock, but has a hard time with indexes. I am trying to run the index TNX, but It only gives me data from 5 consecutive days.

I've tried putting a "^" before the index, because that is what yahoo finance uses as a variable for indexes, and it doesn't work.

ticker <- "TNX"
start.date <- as.Date('2016-09-01')
getSymbols(ticker, src='yahoo', from=start.date)
Adj.Close <- get(ticker)[,6]
daily.returns <- ROC(Adj.Close, n=1, type='continuous')

When I put this in I get no errors, but when I view daily. returns I get this:

2019-04-22  NA
2019-04-23  -0.03306086
2019-04-24  0.00000000
2019-04-25  -0.03419136
2019-04-26  0.00000000

That's all. Of course, this code works very well on any other stocks, but I just can't figure out this one.

Thank you for your time, and even if you can't help, your desire to help is appreciated.

Upvotes: 0

Views: 103

Answers (1)

OgreZed
OgreZed

Reputation: 41

You're getting all the data that Yahoo has:

https://finance.yahoo.com/quote/TNX/history

You are using a ticker symbol that has been delisted that Yahoo hasn't completely unplugged.

Upvotes: 1

Related Questions