Python: Can I call a TR Formula inside the function get_timeseries?
Hello guys,
I'm trying to get TR.TotalReturn using Eikon Scripting API for Python, but I'd like to minimize the amount of calls I do to the API. So far, using a list of the identifiers helps minimizing the amount of calls. On the other hand, I want daily returns for a given range of dates. And I believe the only function can provide that kind of thing is get_timeseries.
Is it possible to use TR.TotalReturn combined with get_timeseries to acquire returns (or any other TR formula) into a timeseries? I readed the manual, and it doesn't seem to be a way https://developers.thomsonreuters.com/tr-eikon-scripting-apis/python-thin-library-pyeikon#get_timeseries
Do you know if there's any chance of doing it this way?
Thanks for your time!
Best Answer
-
I am afraid not.
get_timeseries support the following fields: 'TIMESTAMP', 'VALUE', 'VOLUME', 'HIGH', 'LOW', 'OPEN', 'CLOSE', 'COUNT'.
However, you can use Build Formula in Eikon Excel to create a formula to retrieve TR.TotalReturn and then apply it to get_data function.
For example:
df = ek.get_data(["AAPL.O", "IBM.N"],
["TR.TotalReturn.Date","TR.TotalReturn",],
{"SDate":"2017-10-23","EDate":"2017-11-29","Frq":"D","CH":"Fd", "RH":"IN"});It returns:
( Instrument Date Total Return
0 AAPL.O 2017-11-29T00:00:00Z -2.074305
1 AAPL.O 2017-11-28T00:00:00Z -0.585904
2 AAPL.O 2017-11-27T00:00:00Z -0.502943
3 AAPL.O 2017-11-24T00:00:00Z 0.005716
4 AAPL.O 2017-11-22T00:00:00Z 1.051172
5 AAPL.O 2017-11-21T00:00:00Z 1.859042
6 AAPL.O 2017-11-20T00:00:00Z -0.099912
7 AAPL.O 2017-11-17T00:00:00Z -0.555231
...1
Answers
-
Thanks a lot for your valuable help.
Is there a way to make the dates appear as column headers and place the corresponding returns in them?0 -
It can return JSON instead of data frame by setting raw_output parameter to True.
df = ek.get_data(["AAPL.O"], ["TR.Close.Date","TR.CLose",],{"SDate":"2015-08-01","EventType":"ALL", "EDate":"2017-11-20","CH":"Fd","RH":"IN"}, raw_output=True);
The output is:
{'columnHeadersCount': 1,
'data': [['AAPL.O', '2015-08-03T00:00:00Z', 118.44],
...
['AAPL.O', '2017-11-20T00:00:00Z', 169.98]],
'headerOrientation': 'horizontal',
'headers': [[{'displayName': 'Instrument'},
{'displayName': 'Date', 'field': 'TR.CLOSE.DATE'},
{'displayName': 'Price Close', 'field': 'TR.CLOSE'}]],
...
}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 中文论坛