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


Best Answer

  • 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)

Answers

  • 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

  • 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