Skip to content
All library documents

Downloading Country-Specific Stock Data with quantmod

Article Quant Q&A · Author: user19265

Summary

The document discusses whether quantmod can retrieve all equities for a particular country by matching a market suffix, using Finnish listings as the example. The responses explain that the package does not itself supply a country-wide symbol search in the described workflow; users first need an instrument list, which may be collected from an exchange or prepared in a file.

Once symbols are available, the suggested approach is to loop over them, download historical prices from Yahoo, and optionally save each series as a CSV. A second response shows passing a vector of symbols to the retrieval function. These are practical data-acquisition patterns rather than a complete country-level market-data solution. The document gives no coverage, reliability, or provider-availability checks, and its sample relies on a particular historical data source and a manually maintained symbol list.

Key ideas

  • The described workflow requires obtaining the relevant exchange symbols before downloading prices.
  • A list of symbols can be processed one at a time or passed as a group.
  • Historical series can be saved locally for later analysis.
  • The examples use Yahoo as the data source and do not establish its current coverage or reliability.
  • The approach does not automatically discover every listing in a country.

Tags

Full text
# Is it possible to download stock-data countrywise with quantmod package for R?


# Is it possible to download stock-data countrywise with quantmod package for R?












### Is it possible to download stock-data countrywise with quantmod package for R ?

Hi, I'm wondering if it's possible to download equities countrywise.

Let's say i want all data from the Finnish market.

All Finnish stock symbols ends with .HE, so what I want is

```
getSymbols("all stocks that ends with .HE", ...)
```

Thanks !

## Answer by Atul Agarawal (score 2)

https://quant.stackexchange.com/a/27984

I don't have perfect solution for above problem, I but can help you out with the alternative. As far as my information you can't download the data country wise. I was also looking for the same. You should have all the symbols first in place. I have prepared a small code which loop through the all available symbols and get historical data from Yahoo.

```
library(quantmod)
startDate = "2000-01-01"
thePath = " * "
source(paste(thePath,"code\\listOfInstruments.r",sep=""))

for (ii in theInstruments){
  print(ii)
  data = getSymbols(Symbols = ii, 
                    src = "yahoo", 
                    from = startDate, 
                    auto.assign = FALSE)
  colnames(data) = c("open","high","low","close","volume","adj.")
  write.zoo(data,paste(thePath,ii,".csv",sep=""),sep=",",row.names=FALSE)
}
```

Regarding symbols that you can easily download from exchange and save it, It's a one time job. Rest you can use the above code to get the data life long. I have created database using above code only.

## Answer by Ridzuan Noor (score 0)

https://quant.stackexchange.com/a/24785

A way is to loop through a list of symbols.

lisym <- c("ELI1V.HE", "KRA1V.HE") getSymbols(lisym) ELI1V <- get("ELI1V.HE") barChart(ELI1V)

or prepare the symbol names in csv file n loop thru it.

lisym <- readLines("stocks.csv")

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.