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
11 1 1 1

Getting UnicodeEncodeError when using get_data() function?

Hi all,

I have tried to get values for certain fields by using Eikon Data API. Please find below the code and respective error I got while execution.

Code:

Error:

Could you please let me know where I did wrong ?

Thank You,

Priya

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-api
1590083184037.png (16.2 KiB)
1590083373525.png (8.6 KiB)
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.

@priyanka

Are you using Python 2 and Eikon Data APIs 1.0.2?

Yes, Ia m using pyhton 2.7 and Eikon Data API 1.0.2

1 Answer

· Write an Answer
Upvote
Accepted
18.2k 21 13 21

Hi @priyanka

I just tested the API to retrieve fields in your question.

And I could get the data successfully.

I believe that the error is in your integration with MathLab.


By the way, please note that

TR.ClosePrice is from "Time Series Data" database
TR.InvestorFullName and TR.SharesHeld are from "Ownership" database
TR.Numshares is from "Period End Ratios" database

So you should be aware that when mixing fields from different databases, the date may not be aligned.


I suggest that you separate the API call for each database.

RIC = 'TWTR.K'
fields1 = ['TR.ClosePrice.date','TR.ClosePrice']
parameters = {'SDate':'20190406','EDate':'20190806','Frq':'W'}
df1,e1 = ek.get_data(RIC,fields1,parameters)
df1.head()


fields2 = ['TR.InvestorFullName.date','TR.InvestorFullName',
          'TR.SharesHeld.date','TR.SharesHeld']
df2,e2 = ek.get_data(RIC,fields2,parameters)
df2.head()


fields3 = ['TR.Numshares.calcdate','TR.Numshares']
df3,e3 = ek.get_data(RIC,fields3,parameters)
df3.head()



ahs.png (91.4 KiB)
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 chavalit ! I implemented the same in my code the way you suggested and i can able to retrieve the data.

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.