Query to retrieve average FX Rates
In the financials tab of the company profiles on the Eikon webtool, the balance sheet, income statement, etc. can be converted from the reported currency to USD. When converting, the avg. FX rate is displayed. I'm able to query the financials of an instrument via the Eikon API Proxy in python, but not the avg. FX rate. I received these sample queries from the Refinitiv support, but they seem to be in a different format than what the Eikon API Proxy expects:
=TR("CNY=","AVG(1/TR.FxRateComposite)","Sdate=2019-01-01 Edate=2019-12-31")
=TR("CNY="," TR.FxRateComposite","Sdate=2019-12-31")
=TR("CNY="," 1/TR.FxRateComposite","Sdate=2019-12-31")
What is the correct translation of these queries in order to make them work via in python?
I'm looking for something like this:
ek.get_data('"CNY=","AVG(1/TR.FxRateComposite)"', '"Sdate=2019-01-01 Edate=2019-12-31"')
Best Answer
-
@christoph.b Is this the kind of thing you are looking for:
df, err = ek.get_data("CNY=",["TR.FxRateComposite.date","TR.FxRateComposite"], {'SDate':'2019-01-01', 'EDate':'2019-12-31'})
avgFX = 1/(df['FX Rate Last'].mean())
avgFX1
Answers
-
Thank you for the answer, works!
0 -
As an alternative to retrieving the timeseries and averaging it in the dataframe, you could use server side AVG function, as you originally intended. You just need to slightly amend the syntax:
df, err = ek.get_data('CNY=',
'AVG(TR.FxRateComposite(Sdate=20190101,Edate=20191231))')
avgFX = 1/df.iloc[0,1]
avgFXThe result of course comes up to the same figure as calculated using the method @jason.ramchandani suggested.
0 -
I have a follow-up question: I've tried out this query for various currencies and dates. I'm trying to reproduce the exact FX rate that I'm able to view in the Eikon Webtool in the Financial Tab of companies by converting from reported currency to USD. Do you know how to reproduce the exact values using the Eikon python API?
0 -
When asking a new question on these forums, please always start a new thread. Old threads with accepted answers are not monitored by forum moderators.
The best resource for content explanation questions, such as this one, is Refinitiv Helpdesk, which you can reach by using Contact Us capability in your Eikon application or by visiting MyRefinitiv. This forum is dedicated to software developers utilizing Refinitiv APIs. The moderators on this forum are technical experts and do not possess deep expertise in every type of content available through Refinitiv products required to answer specific content explanation questions.
I opened case 09412498 with Refinitiv Helpdesk on your behalf. You will be contacted by Refinitiv Support with the answer to your question or if they need any clarification from you before providing the answer.1 -
Understood, thank you!
0
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 中文论坛