0
$\begingroup$

I need to download bonds yields using R.

I tried, as usual, I did for stocks:

spc <- new.env()

setDefaults(getSymbols,src="FRED")

getSymbols("^AT0000386198", env = spc, from = "2010-01-01", to = "2012-03-01", return.class = "xts")

But it doesn't work. How should I proceed?

Many thanks!

$\endgroup$
0
$\begingroup$

You can search for certain yield curves in the FRED database with the following query:

require('Quandl')
Quandl.search(query = 'yield') # searching for the term 'yield'

You get the unique identifier for each search result, e.g. the code "USTREASURY/YIELD" for US-Yield Curve Rates. You can proceed with

data <- Quandl('USTREASURY/YIELD', type = 'xts',
              start_date = '2010-01-01', end_date = '2012-03-01')

to get your data frame.

If you get error messages, there are several possible reasons. First, you should check if your required data is available in your database. You can use the query above to check, if a certain ISIN is provided in FRED. I looked your ISIN and got the result:

In Quandl.search(query = "AT0000386198") : No datasets found

Therefore i recommend alternative databases, wich are discussed here.

Other common errors are due to a missing authentication:

To make more than 50 calls in a day, or to access a premium database, you will need to authenticate your R session by telling us your API key.

To do this, you need to create a Quandl account (free) and use the api key wich can be found on the account settings page before running further commands:

Quandl.api_key("YOUR_API_KEY")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.