How to get fx rate for a particular snaptime and date (london timezone)

Hi All, i am currently using the below piece of code to get fx rate using eikon API but it gives me the latest fx rate for the given ric, say I want to know fx rate for a specific timezone and date, how can I retrieve it ?


ek.set_app_key('************')
df, err = ek.get_data(
['JPY='],['TR.RIC','BID','ASK']
)
df['Mid']=df.mean(axis=1)
print(df)

Best Answer

  • Gurpreet
    Answer ✓

    You can look into get_timeseries API call to get granular timeseries data. The bar data can be rolled up into minutes using:

    df = ek.get_timeseries("JPY=", count = 5, start_date = "2022-05-12T15:00:00", interval="minute")

    other option for minutes parameter are:

    'tick', 'minute', 'hour', 'daily', 'weekly', 'monthly', 'quarterly', 'yearly'


Answers

  • Hi @Atul.Sanwal,

    The Eikon API only provides data in UTC. For other timezones, you will have to convert the local timezone into UTC before requesting the data.

    To get a data point at a particular point-in-time, use the fields which allow history. This can be seen from the Data Item Browser (DIB).

    Here is an example:

    df, err = ek.get_data(['JPY='],['TR.ASKPRICE', 'TR.BIDPRICE', 'TR.ASKPRICE.Timestamp'], {'SDate': '2022-05-01'})
    display(df)

    Response:

    1652387066769.png

  • Hi Gurpreet, Thanks for the help, sorry a bit confused how can i search the fx rate based on UTC timezone, where do i need to input the timestamp ? say i want to see UTC 15:00:00 for 12th May
  • df, err = ek.get_data(['JPY='],['TR.ASKPRICE', 'TR.BIDPRICE', 'TR.ASKPRICE.Timestamp'], {'SDate': '2022-05-12T15:00:00'})

    i tried the above but getting NAN values