Does anyone know how to download historical data of futures contracts ( for example: FW20Z1520 or FW20H1620 ) to R and convert it to xts? I need it to do some analysis. Please help.
If you have a website where this information is available, you can scrape it or just download it and load it into R. Otherwise look for an API to your broker software. Here is an article on how to use Yahoo Finance.
And these future contracts are not available on Yahoo. These are Polish contracts. It looks like biznez.onet.pl has the download capabilities you need.
Edit:
Based on your website, I had a look. There is a link available for downloads. This piece of code will download the data directly into R.
# fill in contract
contract <- "FW20H1620"
# paste url to include contract
url <- paste0("http://stooq.com/q/d/l/?s=", contract, "&i=d")
#read it into R.
df <- read.csv(url, stringsAsFactors = FALSE)
str(df)
'data.frame': 110 obs. of 7 variables:
$ Date : chr "2015-03-23" "2015-03-24" "2015-03-25" "2015-03-26" ...
$ Open : int 2359 2363 2366 2353 2344 2355 2353 2358 2351 2363 ...
$ High : int 2359 2368 2366 2353 2350 2360 2359 2360 2360 2395 ...
$ Low : int 2343 2362 2357 2340 2341 2355 2340 2355 2347 2363 ...
$ Close : int 2359 2368 2358 2341 2349 2357 2356 2355 2360 2393 ...
$ Volume : int 15 43 15 31 16 7 70 6 10 16 ...
$ OpenInt: int 11 19 28 50 51 57 67 69 72 78 ...