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:

imageError:

image

Could you please let me know where I did wrong ?

Thank You,

Priya

Best Answer

  • chavalit-jintamalit
    Answer ✓

    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.

    image


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


Answers