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
17 1 1 1

Refinitiv Eikon retriving bond historical prices.

Dear fellow developers

I am a pretty new person for the Eikon API code session.

I here to ask a simple (may stupid) question for my recent work on data collections using Eikon API codes with R. I need to retrieve the historical price information of over 100 bonds for my study. Typically, I am interested in the ask price, bid price, ask yield and bid yield for the selected bonds. Please see the reputable code below:

library("devtools")
library("eikonapir") # load Eikon API 
eikonapir::set_proxy_port(9000L)
eikonapir::set_app_id('xxxxxxxxxxxxxxxxxxxxxxx')

# I am interested following bond pricing information: Ask price, Bid price, Ask yield and Bid yields.

Bond_fields <- list("TR.ASKPRICE", "TR.BIDPRICE", "TR.ASKYIELDS", "TR.BIDYIELDS")# 

#I use following six bonds for my example. 

Bond_RICs <- list("CN1920029=","CN1720052=","CN1720012=","CN1920001=", "CN1702002=","CN101751004=","CN101901057=") 

# using get_data( ) funciton for data retrive

get_data(Bond_Rics, Bond_fields) 

I tried to use the get_data( ) to retrieve data, however, it gives rows for most recently updated data information which is not enough for me to do the analysis (See table below). What I want is the entire time-series of all available historical data.

> get_data(Bond_Rics, Bond_fields)
    Instrument Ask Price Bid Price Bid Yield Ask Yield
1   CN1920029=   100.424   100.291    3.3681    3.2681
2   CN1720052=    101.85    101.69    3.4089    3.3089
3   CN1720012=    101.77   101.634    3.3582    3.2582
4   CN1920001=   100.286   100.179    3.3273    3.2273
5   CN1702002=   101.331    101.29    3.2194    3.1894
6 CN101751004=   101.517   101.385    3.8501    3.7501
7 CN101901057=    99.541    99.382     3.919     3.819

I know that we can use get_timeseries() function to retrieve historical price information. But the function requires me to put the start date and end date for the retrieve. Since each of the selected bonds has a different starting date and maturity date, I would like to know if there exists a simple function that allows me to retrieve all available historical data (given RICs codes) without specifying the starting date and ending date?

Thank you for your time and kind assistance.

Best regards

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apieikon-data-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.

Upvote
Accepted
10.1k 18 6 9

@Student-10 The following call will work - i'll put it in python and you can convert into R:

Bond_fields = ["TR.ASKPRICE.date","TR.ASKPRICE", "TR.BIDPRICE", "TR.ASKYIELD", "TR.BIDYIELD"]

Bond_RICs = ["CN1920029=","CN1720052=","CN1720012=","CN1920001=", "CN1702002=","CN101751004=","CN101901057="] 

df, err = ek.get_data(Bond_RICs, Bond_fields,{'SDate':'2015-01-01','EDate':'2020-12-06'}) 

df

Basically you need to correct the last two fieldnames as they were not valid, then you need to add SDate and EDate Parameters to make the request return a timeeseries. I have also added a "TR.ASKPRICE.date" field so you have the appropriate datetime for the data. As far as knowing the start dates for individual bonds you can probably do something like : last_valid_index() in python using a groupby equivalent. Apols I have forgotten most of my R! I hope this can help.


1607360725860.png (111.3 KiB)
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.

Upvote
17 1 1 1

Hi @jason.ramchandani Thank you for your kind support :) . It works perfectly fine. You saved my life.

Best regards

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.