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
Best Answer
-
@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'})
dfBasically 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.
1
Answers
-
Hi @jason.ramchandani Thank you for your kind support . It works perfectly fine. You saved my life.
Best regards
1
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛