Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 1 2

Do you have some python code for downloading data and save the dataset to be read in R?

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apir
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
39.4k 77 11 27

In this sense I don't see any difference between using eikon library in Python and eikonapir library in R. In both cases the API documentation describes only the methods available in the library. And metadata discovery (finding field names and parameters to retrieve specific data items) is done using GUI tools available in Eikon. Take a look at this tutorial, which talks at length about metadata discovery for use with Eikon Data APIs.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
39.4k 77 11 27

I'm not sure what the purpose of this exercise could possibly be. If you'd like to use data retrieved from Eikon in R, you could retrieve the data directly into R using this library.
If for whatever reason you need to retrieve data using Python and then use this data in R, you can easily save a pandas dataframe to a csv file and import the latter into R. This sounds like an obvious solution, which makes me feel I might be missing something here. Would you care to elaborate on what challenge you're trying to solve?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 2

I want to get data from Eikon API, which is python, but I'm more familiar coding in R. I tried to use eikonapir package in R, but seems like the data downloading capability is limited/not much documentation. For example, how do you convert the following python code to R using eikonapir?

data_grid, err = ek.get_data(

tickerString,

fields = ['TR.TotalReturn1Mo.date','TR.TotalReturn1Mo','TR.PE','TR.PriceToCFPerShare',

'TR.PriceToBVPerShare','TR.EVToEBITDA','TR.FwdPE','TR.FwdEVToEBITDA','TR.FwdNetDebtToEBITDA'],

parameters={'SDate':'2007-12-31','EDate':'2010-11-30','Frq':'M','CH':'Fd'})


Eventually, I learned to save the result to be read in R with the following:

path = 'C:/Users/.../eikon4.feather'

feather.write_dataframe(data_grid, path)


But if you could teach me how to download the above data directly with R, it would same me a lot of trouble.

Thanks!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
2 0 3 5

@helenyzha I use directly the R package `reticulate` to call the Python functions directly from R. It goes as follows:

```

library(reticulate)


ek <- import("eikon")

ek$set_app_key('YOURKEY')

```


Then you can use any function such as `get_data` directly: `ek$get_data(...)` with same parameters as in Python. You can then use `reticulate::py_to_r` to parse some Python datastructures to R. Data in R is parsed to the JSON format, see the library `jsonlite` for more details.


I suggest that you use this approach, then you can build your own library to query from Eikon from R.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 2

Thank you @melvin.kian ! I tried, the following worked:

library(reticulate)

ek <- import("eikon")

ek$set_app_key('YOURKEY')


But I still don't know how to make this following line to work:

data_grid, err = ek.get_data(

"IBM",

fields = ['TR.TotalReturn1D.date','TR.TotalReturn1D'],

parameters={'SDate':'2010-02-01','EDate':'2019-10-03','Frq':'M','CH':'Fd'})


I tried:

ek$get_data(

"IBM",

fields = ['TR.TotalReturn1D.date','TR.TotalReturn1D'],

parameters={'SDate':'2010-02-01','EDate':'2019-10-03','Frq':'M','CH':'Fd'})

but didn't work.


Thank you so much!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
2 0 3 5

Try


ek$get_data("IBM",

fields = list('TR.TotalReturn1D.date','TR.TotalReturn1D'),

parameters=list(SDate='2010-02-01',EDate='2019-10-03', Frq='M',CH='Fd')

)


Best!

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 2

It works!! Thank you so much!! @melvin.kian

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
39.4k 77 11 27

I don't think I understand what the challenge is in using eikonapir library. The design of the library follows very closely that of the eikon Python library. There are only minor differences in syntax mandated by the language conventions. The documentation for eikonapir library available on Github describes each method available in the library and illustrates it with examples. Here's how you can retrieve the history of 1 day total return for a stock on the last trading day of each month between two dates (which is what the Python example posted by @helenyzha earlier today does) using eikonapir.

library(eikonapir)
set_app_id('your_app_key')
get_data('IBM',list('TR.TotalReturn1D.date','TR.TotalReturn1D'),list(SDate='2010-02-01',EDate='2019-10-03', Frq='M'))
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
1 0 1 2

Thanks @Alex Putkov! My challenge with eikonapir is that there is not much documentation on it. I don't know how to write code to get data. All documentation I have is this https://github.com/ahmedmohamedali/eikonapir/tree/master/man, where I couldn't find how to set SDate and EDate. Thanks for teaching me this. Do you have more documentation or examples? Thanks!


icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.