Get quote price in time order

I'm using the Eikon API in python. Especially I'm trying the get_data method to extract data.
Question 1:
I want to get the close price for an instrument for 1 year and two years ago.
I've tried two calls:
- getData('DANSKE.CO', 'TR.PriceClose', 'SDate'='0D', 'EDate'='-2AY', 'Frq'='AY')
- This returns data in unordered timestamps.
- getData('DANSKE.CO', 'TR.PriceClose.date', 'SDate'='0D', 'EDate'='-2AY', 'Frq'='AY')
- This returns 'None'.
What should I use if I want control over the data returned and not send to many calls to Eikon?
Question :
I have tried to get total return data from Eikon but her I get None in return.
- getData('DANSKE.CO', 'TR.PriceClose')
- This gives data.
- getData('DANSKE.CO', 'TR.TotalReturn')
- This gives 'None'.
Why?
Most thankful for som help
Best Answer
-
I just tried the following:
ek.get_data('DANSKE.CO',fields=['TR.PriceClose','TR.PriceClose.date'] , parameters={'SDate':'0D', 'EDate':'-2AY', 'Frq':'AY'})
and I get back:
( Instrument Price Close Date 0
DANSKE.CO 91.80 2019-11-01T00:00:00Z 1
DANSKE.CO 132.55 2018-11-01T00:00:00Z, None)I repeated the call several times and I got back the same order - i.e. 2019 and then 2018.
I also tried for 5yrs and I again got back an ordered list:
0 DANSKE.CO 91.80 2019-11-01T00:00:00Z
1 DANSKE.CO 132.55 2018-11-01T00:00:00Z
2 DANSKE.CO 242.50 2017-11-01T00:00:00Z
3 DANSKE.CO 206.70 2016-11-01T00:00:00Z
4 DANSKE.CO 186.50 2015-10-30T00:00:00ZIs the above ok for you - or have I misunderstood your question?
Also, I tried the following:
ek.get_data('DANSKE.CO',fields=['TR.PriceClose','TR.PriceClose.date', 'TR.TotalReturn'])
and I get back:
Instrument Price Close Date Total Return
DANSKE.CO 91.8 2019-11-01T00:00:00Z -3.954802Is this what you are after?
0
Answers
-
Hi Umer!
Yes it is exaclty what I'm looking for.
But somehow I can't get data for the fields 'TR.PriceClose.date' and 'TR.TotalReturn'.I'm trying just:
ek.get_data('DANSKE.CO',fields=['TR.TotalReturn'])
Returns None
Switching to:
ek.get_data('DANSKE.CO',fields=['TR.PriceClose'])
Returns 91,8
Having trouble to understand why one thing works but not the other.
(Using python on a windows computer with Eikon running.)
0 -
I am fairly new to Python and I don't know what your level of Python is - so apologies if the following is patronising, but can you confirm how you are extracting the actual values from the return objects?
In the example code below, the get_date returns a tuple, from which I extract the dataframe and then the series which contains the actual value.
tp = ek.get_data('DANSKE.CO',fields=[ 'TR.TotalReturn'])
type(tp)
tuple
tp
( Instrument Total Return
0 DANSKE.CO -3.954802, None)
tr = tp[0]
type(tr)
pandas.core.frame.DataFrame
tr
Instrument Total Return
0 DANSKE.CO -3.954802
ab = tr['Total Return']
type(ab)
pandas.core.series.Series
ab[0]
-3.95480225988701If you are already aware of the above, please provide similar output so we can try and help diagnose where the issue lies.
Alternatively, you can use the raw_output parameter to access the JSON payload and parse out the data yourself e.g.
tp = ek.get_data('DANSKE.CO',fields=[ 'TR.TotalReturn'],raw_output=True)
tp
{'columnHeadersCount': 1,
'data': [['DANSKE.CO', -3.95480225988701]],
'headerOrientation': 'horizontal',
'headers': [[{'displayName': 'Instrument'},
{'displayName': 'Total Return', 'field': 'TR.TOTALRETURN'}]],
'rowHeadersCount': 1,
'totalColumnsCount': 2,
'totalRowsCount': 2}
tp['data'][0][1]
-3.95480225988701If the above also returns a None value, then I recommend you contact our Eikon helpdesk to help diagnose further.
0 -
Thank you again!
Printing out the response from the raw_output version, gave me some error messages to help me find the problem.
It turned out I had put the 'Scale' parameter to default to 0 in a bad way, causing None answers.0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 683 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 626 Refinitiv Data Platform Libraries
- 5 LSEG Due Diligence
- 1 LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 84 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛