Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
0 0 0 1

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




eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@erik.wickman

Hi,

Thank you for your participation in the forum.

Are any of the replies below satisfactory in resolving your query?

If yes please click the 'Accept' text next to the most appropriate reply. This will guide all community members who have a similar question.

Otherwise please post again offering further insight into your question.

Thanks,

AHS

@erik.wickman

Hi,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS

Upvote
Accepted
25.3k 87 12 25

Hi @erik.wickman

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:00Z

Is 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.954802

Is this what you are after?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.)


Upvote
25.3k 87 12 25

Hi @erik.wickman

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.95480225988701

If 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.95480225988701

If the above also returns a None value, then I recommend you contact our Eikon helpdesk to help diagnose further.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.