- Home
- Article Catalog
- Get Coronavirus Cases Latest And Timeseries Statistic with Eikon Data API(Python)

It is undeniable that Coronavirus has a global impact on everyone.
For detail information on the Coronavirus, please visit the World Health Organization website at https://www.who.int/emergencies/diseases/novel-coronavirus-2019
Eikon provides a dashboard to see coronavirus statistics on each country.
To see this information on Eikon, Type in "MACROVIT" on Eikon Search Bar and press enter to launch the app.
Go to "Case Tracker" tab
This article demonstrates how to find RIC(Refinitiv Identifier Code) for each country/territory statistic and how to retrieve the latest statistic and timeseries statistic using Eikon Data API(Python)
Step 1 - Find out what are RICs for Coronavirus statistic
1. Launch "Economic Indicator Chart" application by typing in "ECOC" on Eikon Search Bar and press enter.
2. Select a country on the dropdown list
3. Type in "covid" on the indicator and select any indicator of your interest.
4. Select Indicator 1 or 2 or 3 or 4 which is available and Click "Add" to add selected the indicator (or you can click "Replace" if the Indicator 1 to 4 which you selected is occupied by other indicators)
5. You can repeat steps 2. to 4. to add any indicator from any country of your interest.
6. You can hover the mouse pointer on each color instrument detail on the chart to see its RIC. Repeat this for as many indicators that you want to know its RIC.
After repeating steps 1. to 6. for all COVID-19 indicator for Hong Kong (as an example), here is the RIC list
['HKCCOV=ECI',#Total cases
'HKNCOV=ECI', #New cases
'HKACOV=ECI', #Active cases
'HKRCOV=ECI', #Recovered cases
'HKDCOV=ECI'] #Deaths cases
The RIC list is also available at this GitHub Repository.
Step 2 - Getting Coronavirus latest statistic
1. From step 1, you should be able to identify RIC for the country of your interest.
This sample code will use RICs from CoronavirusRICs.csv
Please download the CoronavirusRICs.csv to your working folder.
import csv
rics = []
with open("CoronavirusRICs.csv", "r") as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
for lines in csv_reader:
rics.append(lines[0])
rics.pop(0) #remove header row
#rics is now carrying Coronavirus statistic RICs
print(len(rics))
The output is the number of RIC in the list:
1288
2. You need to know field names carrying the information.
fields = ['DSPLY_NMLL', #Display Name
'COUNTRY', #Country code
'CF_DATE', #Announcement Date
'ECON_ACT', #Actual value
'ECON_PRIOR' #Prior value
]
3. Retrieves the latest Coronavirus statistic
From 1. and 2., we already prepared RICs and Fields into rics and fields variable.
#import Eikon Library
import eikon as ek
#Set app key
ek.set_app_key('<a_valid_app_key>')
#Make an API call using get_data()
df,e = ek.get_data(rics, fields)
#Rename dataframe column names
df.rename(columns={'DSPLY_NMLL':'Display Name',
'CF_DATE':'Announcement Date',
'ECON_ACT':'Actual Value',
'ECON_PRIOR':'Prior Value'
},inplace=True)
#print out first 10 rows from df variable
df.head(10)
Output:
Step 3 - Getting Coronavirus timeseries statistic
1. Let's focus on "Hong Kong" statistic
#select only Hong Kong RICs
HKRICs = df[df['COUNTRY'] == 'HKG']['Instrument'].to_list()
#print out HKRICs
HKRICs
Output:
['HKACOV=ECI', 'HKCCOV=ECI', 'HKDCOV=ECI', 'HKNCOV=ECI', 'HKRCOV=ECI']
2. Retrieve timeseries data for the last 6 months
#Make an API call
df = ek.get_timeseries(HKRICs, start_date='20200101', end_date='20200705', interval='daily')
#Print out the last 5 rows
df.tail(5)
Output:
3. Using plotly to plot a line chart on Jupyter Notebook.
(The sample code for multi_plot() is available on the GitHub.)
multi_plot(df)
Output:
References
Downloads