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

Historical data for bid and ask price per minute

Hi,

I am looking for historical data (bid and ask price) regarding bonds.

I can retrieve the data when i use yearly, monthly and daily frequency. However, when I am trying to reload data per minute or 30 minutes i get the output of N/A.

Here is an example of the code i use :

import datetime
import eikon as ek
## Set the datetime
start_date = datetime.datetime(2023, 3, 1).strftime('%Y-%m-%d')
end_date = datetime.datetime(2023, 3, 2).strftime('%Y-%m-%d')
##Reload data from Refinitv
df, err = ek.get_data(
    instruments= =['NL188254462='],
    fields=['TR.ASKPRICE', 'TR.ASKYIELD', 'TR.BIDPRICE', 'TR.BIDYIELD'],
    parameters={'SDate': start_date, 'EDate': end_date, 'Frq': 'minute'})

print(df)

The problem seems that is the way i add the frequency.

Thank you in advance,

Kind regards,

Kyriakos

refinitiv-dataplatform-eikon#productpython apihistoricalrefinitiv-real-time
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.

Hi @kyriakos.eleftheriadis

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

Hi,

Please be informed that a reply has been verified as correct in answering the question, and marked as such.

Thanks,

AHS

Upvotes
Accepted
5k 16 2 7

Hi @kyriakos.eleftheriadis ,


Thank you for your question. For retrieving historical prices, I would advise using rd.get_history function from our latest RD Libraries (you can install via - pip install refinitiv-data) which will allow getting 1-year intraday historical data and 3-month tick data. Please see the code below:

import datetime
import refinitiv.data as rd
## Set the datetime
start_date = datetime.datetime(2022, 1, 1).strftime('%Y-%m-%d')
end_date = datetime.datetime(2023, 3, 2).strftime('%Y-%m-%d')
##Reload data from Refinitv
df = rd.get_history(
    universe= ['NL188254462='],
    fields=['ASK', 'ASK_YIELD', 'BID', 'BID_YIELD'],
    start = start_date,
    end = end_date,
    interval = '1min'
   )
df

screenshot-2023-04-03-at-120303.png


Hope this helps, let me know should you have any further questions.


Best regards,

Haykaz


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.

Upvotes

Dear Haykaz,

Thank you for your response@h.aramyan01 .

I did like this but now i have another issue regarding the app_key.

Should i change the set_app key function?


Thank you in advance,

Best,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


Here, in RD, instead of ek.set_app_key('') you need to run rd.open_session(). Please note, that as in Eikon you need to have workspace running on the background.


Best regards,

Haykaz


Upvotes

Hi @h.aramyan01,

Thank you for your response.

I tried to run the rd.open_session, however i am not sure which kind of app_key i need to use.

Could you please give me some more details on how this works?

Thank you,

Kind regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


You don't need to specify the APPKEY in case of RD, it will automatically get that from your Workspace which as I mentioned before need to be open on the background (as it is in case of Eikon API). So your final code should look like this:

import datetime
import refinitiv.data as rd
rd.open_session()

## Set the datetime
start_date = datetime.datetime(2022, 1, 1).strftime('%Y-%m-%d')
end_date = datetime.datetime(2023, 3, 2).strftime('%Y-%m-%d')
##Reload data from Refinitv
df = rd.get_history(
    universe= ['NL188254462='],
    fields=['ASK', 'ASK_YIELD', 'BID', 'BID_YIELD'],
    start = start_date,
    end = end_date,
    interval = '1min'
   )
df


Best regards,

Haykaz

Upvotes

Dear @h.aramyan01,

Thank you very much for your response.

Do I have to download the the refinitiv data workspace ? Or it works when i have the Eikon workspace running.

Sorry for the many questions, but i am not familiar with it, since i use it for the first time.

Thank you in advance,

Kind regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


No worries at all, happy to address those. Eikon should be fine.


Best regards,

Haykaz

Upvotes

Hi @h.aramyan01,

Thank you again for the help.

I have the Eikon workspace running, however, when i execute my code i receive this output:

Empty DataFrame

Columns: []

Index: []

Process finished with exit code 0

Although I am sure that the data exists, not sure what is the problem.

Thank you in advance,

Best regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


Could you please enable the logs for us to see if we are getting any errors by adding the following code after importing the RD lib?:

rd.get_config().set_param(
       param=f"logs.transports.console.enabled", value=True
)


Best regards,

Haykaz

Upvotes

Hi @h.aramyan01,

I added the code you mentioned but there are no errors.

The code runs and returns the values when i use one ISIN, for example from a bond.

However, when i try to add more (i use identifiers from Mongo) the output is as i described before. Fyi, I use a list of several bonds which is called 'identifiers'

Notice that when i used the Eikon function the same code with the identifiers worked.

That's my whole code:

import datetime
import refinitiv.data as rd
from tradingutils.db.connection import get_mongo_vm_db

##Set the app_key for refinitiv (must be logged in)
rd.open_session()

## get client from Mongo
mongo = get_mongo_vm_db()

audit_feed = mongo['audit_feed']['prod']

## Find the query
find_query = {
'TRADDESK': 'EUFFFI',
'last_modified': {'$gte': datetime.datetime.utcnow() - datetime.timedelta(days=90)}}

project_query = {'IDENTIFIER': 1}

##Retrieve identifiers from Mongo
identifiers = audit_feed.find(filter=find_query, projection=project_query)

identifiers = {doc.get('IDENTIFIER') for doc in identifiers}

print(identifiers)

## Set the datetime
start_date = datetime.datetime(2023, 3, 1).strftime('%Y-%m-%d')
end_date = datetime.datetime(2023, 3, 2).strftime('%Y-%m-%d')
##Reload data from Refinitv
df = rd.get_history(
    universe=  list(identifiers),
    fields=['TR.ASKPRICE', 'TR.ASKYIELD', 'TR.BIDPRICE', 'TR.BIDYIELD'],
    parameters={'SDate': start_date, 'EDate': end_date, 'Frq': '1Min'})

print(df)

Thank you,

Kind regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


It would be more helpful if you could share the identifies within list(identifiers) (at least some of those) for me to test on my end. Also the code I have suggested was the following not the one I can see in your current post. Could you please try with the code below?

df = rd.get_history(
    universe= ['NL188254462='],
    fields=['ASK', 'ASK_YIELD', 'BID', 'BID_YIELD'],
    start = start_date,
    end = end_date,
    interval = '1min'
   )
df

Best regards,

Haykaz

Upvotes

Hi @h.aramyan01,

When I try the code you described above it works and i get the data.

The only problem is when i add the list with the several identifiers. Then it gives me no values

To be more specific some examples of the bonds are : 'PTOTELOE0028', 'DE000HCB0BH9', 'XS2538778478', 'XS1887485032', 'FR0013429073', 'XS2558343476', 'FR0013231768', 'XS2200513070', 'XS2056395606', 'ES0413211873', 'NL0000102234', 'DE000A2GSLV6', 'IT0001444378', 'ZL0647897', 'XS1180256528'.

Is it possible that because the list is really huge that i cant get the data ?

Thank you again for your help.

Kind regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


Instead of using ISINs I would advice converting the ISINs into RICs first:

from refinitiv.data.content import symbol_conversion

symbol_list = ['PTOTELOE0028','DE000HCB0BH9', 
       'XS2538778478', 'XS1887485032', 'FR0013429073', 'XS2558343476', 'FR0013231768', 
       'XS2200513070', 'XS2056395606', 'ES0413211873', 'NL0000102234', 'DE000A2GSLV6', 
       'IT0001444378', 'ZL0647897', 'XS1180256528'
      ]
response = symbol_conversion.Definition(
    symbols= symbol_list,
).get_data()
 
response.data.df

17418-screenshot-2023-04-06-at-115915.png

Then you can retrieve the list of RICs and pass that to the get_history function:

rics = response.data.df['RIC'].values.dropna()
rics
 
## Set the datetime
start_date = datetime.datetime(2023, 3, 1).strftime('%Y-%m-%d')
end_date = datetime.datetime(2023, 3, 2).strftime('%Y-%m-%d')
##Reload data from Refinitv
df = rd.get_history(
    universe= rics,
    fields=['ASK', 'ASK_YIELD', 'BID', 'BID_YIELD'],
    start = start_date,
    end = end_date,
    interval = '1min'
   )
df

17419-screenshot-2023-04-06-at-120028.png

Best regards,

Haykaz

Upvotes

Hi @h.aramyan01,

Thank you very much, now it works from what i can see

Thank you again for the help,

Kind regards,

Kyriakos

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.

You are very welcome, happy to help!
Upvotes

Hi @h.aramyan01,

Hope you are doing fine.

Is it possible to get the historical data for bid and ask for an index ?

For instance, i have the ICE BofA Euro High Yield Index. Are the data available when it comes to an index?

Do i have to use another code to reload the data?

Thank you in advance,

Kind regards,

Kyriakos

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.

Hi @kyriakos.eleftheriadis ,


Sure, you can use the index's RIC (which is .MERHE00 I believe) for the "universe" parameter. You may comment out fields parameter also to get all available fields for the request.

Best regards,

Haykaz

Upvotes

Good morning @h.aramyan01,

Thank you for your answer.

I mean to get all the index constituents data. I think there are about 900 bonds.

Is this possible?

Thank you again for the help.

Kind regards,

Kyriakos

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.

Upvotes
5k 16 2 7

Hi @kyriakos.eleftheriadis ,


This is the code to get index constituents. Please see the example for FTSE:

df = rd.get_data('.FTSE', 
                      ['TR.IndexConstituentRIC' , 'TR.IndexConstituentName'])
df

screenshot-2023-04-25-at-113629.png

However, this code produces NAs for .MERHE00. I have checked in Workspace and there is no constituent data for that there as well. To learn more about the reasons, I would advise raising a content query via MyRefinitiv.


Best regards,

Haykaz


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.

Upvotes

Hi @h.aramyan01,

Thank you, this helps a lot.

Best,

Kyriakos

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.

Upvotes

Hi @h.aramyan01 ,

I hope you are doing well.

I have a question regarding how to retrieve tick historical data for bonds using pycharm.

To get historical time series data i used the following script which you provided me:

  
                
  1. df = rd.get_history(
  2. universe=rics,
  3. fields=['ASK', 'ASK_YIELD', 'BID', 'BID_YIELD'],
  4. start=start_date,
  5. end=end_date,
  6. interval='1M'

Does the same work or i need to adjust my script?

Thank you in advance,

Kind regards,

Kyriakos

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.

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.