BOK (Bank of Korea) administrates ECOS database for economic ststistics/market data and provides Open API for this database. ECOS API also supports several popular programming language such as R, Python. In this post, we use R programming to download data through ECOS API. This work can really help you avoid a time-consuming and tedious data collection job.
ECOS (http://ecos.bok.or.kr/) economic statistics database provide the open API to download economic time series using ticker. (http://ecos.bok.or.kr/jsp/openapi/OpenApiController.jsp) It is easy to use.
At first, you need to get your own license key from ECOS Open API homepage. This key is used as a input variable. Next, find the statistics and item codes at
The above figures show how to find statistics code and its item code for Quarterly Real GDP (seasonal-adjusted).
Now we can code R script for which we input key for authorization, codes(statistics, items), search period(begin, end), etc.
This R code download Korean quarterly real GDP from 2000 to 2019, calculate year-on-year growth rate, and draw it.
Since most empirical analysis use multiple time series, we can modify the above R code to handle it.
The contents of R code are as follows.
1) make an array for ststistics and items code
2) use for loop to download each time series successively
3) m.data라는 matrix 객체에 저장한다는 것이다. save multiple time series data as m.data which is matrix object
It is better to use cbind() to concatenate each time series into one matrix than direct substitution.
Multiple time series (Real GDP, CPI, Call rate) is printed out as follows.
From this post, we can use ECOS API for download useful data for empirical analysis. \(\blacksquare\)