To obtain data on forwards, exchange rates, interest rates and price indices you can either make use of Bloomberg or Datastream. You can find both of these terminals in the main library. In addition, there is also a single terminal within the School of Economics in the computer laboratory.

In what follows, I describe how to extract data from Bloomberg into R, which is relatively convenient. You will need to execute this script on a computer that has Bloomberg installed on it and you should be able to follow the link to the Google drive, Bloomberg_Data.R. You will then need to download this to the hard-drive or flash-drive so that you can access the file Bloomberg_Data.R. If you right-click on this file and select to open it with RStudio then you should be able to run it without too many issues.

You will note that the file starts off with a general cleanup of the working environment and graphics objects.

rm(list = ls())
graphics.off()

Thereafter, you need to change the path to where you want to work and save files. This could be your flash-drive or your My Documents folder. To set the working directory you would just need to change the directory that is stored in the path object, within the following colons:

path <- "C:/Users/"
setwd(path)

Please take note of the way in which the above file separators slant. To link R to Bloomberg we need to rund the following lines, which may take about 20 seconds.

system("C:/blp/DAPI/bbcom.exe")
library(Rblpapi)
con <- blpConnect()

Once this is complete, you could set the starting date and frequency for the data that you’d like to extract. In this case, we’d like the data to start on 1 January 1990 and it should be downloaded at a monthly frequency.

begin <- as.Date("1990-01-01")
opt <- c(periodicitySelection = "MONTHLY")

Thereafter, to retrieve the one month forward rates for the USDZAR we need to make use of the Bloomberg code. In this case the code is ZAR1M for the one month forward relative to the USD. Since this is a currency quote, we use the Bloomberg accronym CURNCY. The field that we are looking to download is the closing value at month end, which is denoted PX_LAST.

forward <- bdh(securities = "ZAR1M CURNCY", fields = "PX_LAST", 
    start.date = begin, options = opt)

To retrieve the exchange rate for the USDZAR we need to make use of the Bloomberg code USDZAR and since this is also a currency quote, we use the accronym CURNCY once again.

exch <- bdh(securities = "USDZAR CURNCY", fields = "PX_LAST", 
    start.date = begin, options = opt)

To retrieve the one month interest rate in South Africa we can make use of the Bloomberg code for the REPO rate, which is SARPRT. This is represented as an index, so we make use of the accronym INDEX.

domint <- bdh(securities = "SARPRT INDEX", fields = "PX_LAST", 
    start.date = begin, options = opt)

To retrieve the one month interest rate in the United States we can make use of the Bloomberg code for the Federal Funds rate, which is FDFD. This is also represented as an index, so we make use of the accronym INDEX.

forint <- bdh(securities = "FDFD INDEX", fields = "PX_LAST", 
    start.date = begin, options = opt)

Now that we have downloaded all the data from Bloomberg, we can save it in an excel worksheet. To do so we can ensure that all the time series are of the same length. This involves finding the maximum length of the respective vectors, with the aid of the following command:

maxobs <- max(c(dim(forward)[1], dim(exch)[1], dim(domint)[1], 
    dim(forint)[1]))

Thereafter, if there are vectors that have missing observations then we need to insert the vale NA into these vectors. This could be achieved with the following code:

missing <- data.frame(rep(NA, maxobs), rep(NA, maxobs))
colnames(missing) <- colnames(forward)

if (maxobs - dim(forward)[1] > 0) {
    dat1 <- rbind(missing[1:(maxobs - dim(forward)[1]), 
        ], forward)
} else {
    dat1 <- forward
}

if (maxobs - dim(exch)[1] > 0) {
    dat2 <- rbind(missing[1:(maxobs - dim(exch)[1]), ], 
        exch)
} else {
    dat2 <- exch
}

if (maxobs - dim(domint)[1] > 0) {
    dat3 <- rbind(missing[1:(maxobs - dim(domint)[1]), ], 
        domint)
} else {
    dat3 <- domint
}

if (maxobs - dim(forint)[1] > 0) {
    dat4 <- rbind(missing[1:(maxobs - dim(forint)[1]), ], 
        forint)
} else {
    dat4 <- forint
}

All that remains is for us to combine the relevant vectors and save the result as a comma separatored file (which one could open in Excel. To combine the data into a data.frame object that has appropriate headings:

dat <- cbind(dat1, dat2, dat3, dat4)
colnames(dat)[seq(2, 8, by = 2)] <- c("Forward", "Exchange", 
    "Dom_int", "For_int")

Then to write the file to the location that was defined in the path object:

write.csv(dat, file = "MyData.csv")

We can then disconnect from Bloomberg using the following command.

blpDisconnect(con)

Then finally, note that forward points are the number of basis points added to or subtracted from the current spot rate of a currency pair to determine the forward rate for delivery on a specific value date.