How can I pull historical data using eikon in python
Here is the answer I got from customer support. I tried to pull the value using the same data item code in python3 but I get none for all of them. How should I get the data in python3 using eikon data api? One example ric is US240421348=.
Best Answer
-
Hi @vuk.magdelinic,
Not all historical data from RHistory is available through Python API. You can take a look at Data Item Browser in Eikon and see which fields support history and other supported parameters.
For this instrument, I can see that only daily yields are available through Python. Try something along these lines -
>>> df, err = ek.get_data('US240421348=', ['TR.BIDYIELD', 'TR.MIDYIELD', 'TR.ASKYIELD', 'TR.BIDYIELD.date'], {'SDate':'0', 'EDate':'-20', 'Frq': 'D', 'Points': 20})
>>> df
Instrument Bid Yield Mid Yield Ask Yield Date
0 US240421348= 1.045 1.03 1.02 2022-02-11T00:00:00Z
1 US240421348= 1.031 1.02 1.006 2022-02-10T00:00:00Z
2 US240421348= 0.96 0.95 0.935 2022-02-09T00:00:00Z
3 US240421348= 1.023 1.01 0.998 2022-02-08T00:00:00Z
4 US240421348= 1.01 1.0 0.985 2022-02-07T00:00:00Z
5 US240421348= 0.94 0.93 0.915 2022-02-04T00:00:00Z
6 US240421348= 0.797 0.78 0.772 2022-02-03T00:00:00Z
7 US240421348= 0.681 0.67 0.656 2022-02-02T00:00:00Z
8 US240421348= 0.688 0.68 0.664 2022-02-01T00:00:00Z
9 US240421348= 0.658 0.64 0.633 2022-01-31T00:00:00Z
10 US240421348= 0.597 0.58 0.572 2022-01-28T00:00:00Z
11 US240421348= 0.566 0.55 0.541 2022-01-27T00:00:00Z
12 US240421348= 0.553 0.54 0.529 2022-01-26T00:00:00Z
13 US240421348= 0.538 0.53 0.513 2022-01-25T00:00:00Z
14 US240421348= 0.518 0.51 0.493 2022-01-24T00:00:00ZPlease see data item browser (DIB) in Eikon about various parameters.
1
Answers
-
You can use the Refinitiv Data Platform Python library with the desktop session.
import refinitiv.dataplatform as rdp
rdp.open_desktop_session(APP_KEY)Then, use the get_historical_price_summaries method to get daily historical data.
rdp.get_historical_price_summaries(
universe = 'US240421348=',
interval = rdp.Intervals.DAILY, # Supported intervals: DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY.
count = 20,
fields = ['B_YLD_1','A_YLD_1','MID_YLD_1','BID','ASK','MID_PRICE']
)The output is:
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 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
- 370 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛