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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted

How to get close price in USD eikon data API

Hi

I´ve read the other post, but my code doesn't work, could you tell me what is wrong?

I am using the following code?

'''

pko,e = ek.get_data("PALK-MYID-P1",["TR.PriceClose(SDate='2020-09-01', EDate='2020-09-14').Date"

,"TR.PriceClose(SDate='2020-09-01', EDate='2020-09-14', curn='USD')"])

pko

'''

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythonapi
screenshot-2.jpg (33.4 KiB)
icon clock
10 |1500

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

Upvote
Accepted
39.2k 75 11 27

Field TR.PriceClose does not exist for RIC PALK-MYID-P1. Try

ek.get_data('PALK-MYID-P1',['TR.CLOSEPRICE.date','TR.CLOSEPRICE'],
            {'SDate':'2020-09-01', 'EDate':'2020-09-14'})

For a brief explanation of the difference between TR.PriceClose and TR.CLOSEPRICE see the answer on this thread.

icon clock
10 |1500

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

Upvotes

Hi Alex

It doen´t work to change from MYR price to USD.

'''

bmd,e = ek.get_data('FCPOc3',['TR.CLOSEPRICE.date','TR.CLOSEPRICE'],

{'SDate':'2020-09-01', 'EDate':'2020-09-14', curn="USD"})

bmd

'''

icon clock
10 |1500

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

Upvote
39.2k 75 11 27

Correct. As mentioned in the answer on the thread I referenced, currency conversion is not available for TR.CLOSEPRICE. To convert timeseries of close prices for this future to another currency you need to retrieve the timeseries of exchange rate, merge the two timeseries and apply the exchange rate to the close price of the future.

df1, err = ek.get_data("FCPOc1",
                       ["TR.CLOSEPRICE.date","TR.CLOSEPRICE"],
                       {'SDate':'2020-09-01', 'EDate':'2020-09-14'})
df2, err = ek.get_data("MYR=",
                       ["TR.BIDPRICE.date","TR.BIDPRICE"],
                       {'SDate':'2020-09-01', 'EDate':'2020-09-14'})
df = df1.merge(df2, how='left', on='Date')
df['Date'] = pd.to_datetime(df['Date'])
df.set_index('Date', inplace=True)
df.rename(columns={'Bid Price':'USDMYR Exch rate'}, inplace=True)
df.drop(['Instrument_x', 'Instrument_y'], axis=1, inplace=True)
df['Close Price USD'] = df['Close Price'] / df['USDMYR Exch rate']
df
icon clock
10 |1500

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

Click below to post an Idea Post Idea