Python: How to get just the number out of a TR.Formula using Eikon API?
Hello everyone, I have the following short code in which I acquire local returns:
import eikon as ek #import Eikon module
ek.set_app_id('someID') #setting AppID
df = ek.get_data('B1FJ0C0','TR.TotalReturn', {'SDate': '2017-02-03'})
print(df)
print (df[0])
The outcome goes as follows:
What I desire is to acquire just the numeric value of the return, I don't want to know about the instrument or any other field/value, just the value of the Total Return.
Does anybody know how? I'd be happy to know.
Thanks!
Best Answer
-
To acquire just the numeric value of the return, you can do this:
First thing to note is that the call to get_data() returns a tuple containing the dataframe and error (if any).
1
Answers
-
Thanks a lot Nick. Is this a pandas dateframe, btw? The way the information is organized when I request information for a bigger list of identifiers does seem to give that appearance.
0 -
Yes, the default output is a Pandas DataFrame. For more details see the documentation for get_data method in Eikon Python API Reference Guide
https://developers.thomsonreuters.com/eikon-data-apis/docs1 -
I have an additional question Alex, it's somehow related to the post.
Can I call TR formulas from the get_timeseries function? My guess from the reference guide you provided is "No", I can't do that. Since I'd like daily returns given a range of dates.
0 -
Due to an outage of the Thomson Reuters Developer
Community email notification system from 2:30 PM CDT on November 29th until
9:00 AM CDT on November 30th we are posting to all questions updated during
this timeframe in order to ensure all customers receive all relevant email
updates. Please review this question, and its associated answers, in order to
ensure you are aware of any possible updates that may have occurred during this
outage. We apologize for the delay and any inconvenience this has caused.Matthew Logterman, J.D.
Sr. Product Manager, Thomson Reuters Developer Community
0 -
You're correct. You'd have to calculate the returns yourself, which is pretty easy to do.
0 -
I'm getting AttributeError: 'tuple' object has no attribute 'iloc'
0 -
@victor.delima
If you have a question it's always best to start a new thread rather than posting an answer on an existing thread. I'm guessing, and this is only a guess, that what you did is something likedf = ek.get_data('TRI.N','TR.Revenue')
df.iloc[0],[1]instead of correct
df, err = ek.get_data('TRI.N','TR.Revenue')
df.iloc[0],[1]If this helps, great. If not, and you need further assistance, please start a new thread and provide detailed description of the issue you're experiencing.
0 -
Thanks man. That did the trick.
0
Categories
- All Categories
- 6 AHS
- 39 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛