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
52 1 2 6

Getting eikon api data in R

Hello,


I would like to translate the code below to R in order to get the data in R


import eikon as ek

EK_KEY = key
ek.set_app_key(EK_KEY)


ls = ['PETZ3.SA', 'QUAL3.SA']

start_dat = '2010-01-01'

df_price, err_price = ek.get_data(
    instruments=ls,
    fields=['TR.CLOSEPRICE',
            'TR.CLOSEPRICE.date'
            ],
    parameters=
    {
        'SDate': start_dat,
        'EDate': '0D',
        'Frq': 'D',
        'Curn': 'BRL'
    }
)

Could you help me?


Thanks in advance


eikon-data-apieikon-api-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.

1 Answer

· Write an Answer
Upvote
Accepted
6.8k 21 3 6

Hi @rafael01, I'd advise something like:




# Load the library
library(eikonapir)

# Set your Eikon key
eikonapir::set_app_key("your_key_here")

# Define the list of instruments
ls <- c("PETZ3.SA", "QUAL3.SA")

# Define the start date
start_date <- "2010-01-01"

# Get the data
df_price <- eikonapir::get_data(
  ls,
  c("TR.CLOSEPRICE", "TR.CLOSEPRICE.date"),
  parameters = list(
    SDate = start_date,
    EDate = "0D",
    Frq = "D",
    Curn = "BRL"
  )
)


Please replace "your_key_here" with your actual Eikon key. This code will give you a data frame df_price with the close price and date for the specified instruments.

Remember to install the eikonapir package before running this code. You can install it from GitHub using the devtools package


# Install devtools if not already installed
if (!require(devtools)) install.packages("devtools")

# Install eikonapir from GitHub
devtools::install_github("ahmedmohamedali/eikonapir")


Please note that the R package is community based and not made by LSEG. You can find more information about it here:

ahmedmohamedali/eikonapir (github.com)

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.

Thanks @jonathan.legrand for your response.

I'd like also to know how I can use the screener in R such as:


from screener import *
 
screen = SCREEN.express.universe('0#.BVSP').conditions(NOT_IN('TR.TRBCEconomicSector', 'Financials'),
                                                       NOT_IN('TR.TRBCEconomicSector', 'Real Estate')).currency(
    'BRL').query

The screener.txt attached contains the function in Python


Thanks in advance

screener.txt

screener.txt (32.2 KiB)

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.