Python: How to get just the number out of a TR.Formula using Eikon API?

Hello everyone, I have the following short code in which I acquire local returns:

import eikon as ek #import Eikon module
ek.set_app_id('someID') #setting AppID
df = ek.get_data('B1FJ0C0','TR.TotalReturn', {'SDate': '2017-02-03'})

print(df)
print (df[0])

The outcome goes as follows:

image

What I desire is to acquire just the numeric value of the return, I don't want to know about the instrument or any other field/value, just the value of the Total Return.

Does anybody know how? I'd be happy to know.

Thanks!

Welcome!

It looks like you're new here. Sign in or register to get started.

Best Answer

  • nick.zincone
    nick.zincone admin
    Answer ✓

    Hi @aquilesjlp300,

    To acquire just the numeric value of the return, you can do this:

    image

    First thing to note is that the call to get_data() returns a tuple containing the dataframe and error (if any).

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.