... API)
Hello,
We have a problem with the Python refinitiv.data API and custom instruments inside portfolios. We believe this is an unintended behaviour of the API that must be fixed.
We know that with the following rd.get_data() call
rd.get_data(["PORTFOLIO('"+ portfolio_code +"')"], ['TR.PortfolioShares'])
We can retrieve the holdings as of date of a given portfolio (with portfolio code variable: portfolio_code)
We are also able to specify a position date. For example, with a date defined as variable position_date (format: yyyymmdd):
rd.get_data(["PORTFOLIO('"+ portfolio_code +"', '" + position_date + "')"], ['TR.PortfolioShares'])
We are able to get the holdings of a portfolio inside PAL for any date.
This works for all instruments, except for custom assets:
If we retrieve the portfolio without specifying the position date, the custom instruments appear in the holdings (as of date).
If we specify a date, the custom instruments do not appear, and this is clearly wrong. The holdings are incomplete.
In the following screenshot, we show you the two different holdings: one without specifying the date, and the one with the current date. The holdings are, correctly, all the same, except for the fact that the custom data disappeared (note the absence of P_XS1778816436 in the second Dataframe).
We think this is an error from your end, and we ask you how we could fix this in order to correctly get the complete holdings, inclusive of custom assets, for any date. Thank you.
We include a sample code, very barebones and to the point, to replicate the issue and the above screenshot.
The following code assumes that:
- You have a defined default Refinitiv session through which you may access the Data Platform.
- You have access to a Portfolio named “TEST_PORTFOLIO”, with at least one holding date: 2023-10-11 (today’s date)
- The holding date 2023-10-11 (today’s date) of “TEST_PORTFOLIO” has at least one custom security.
Expected behaviour of the code: The script will output two identical Dataframes of today’s holdings of “TEST_PORTFOLIO”.
The first Dataframe is generated without specifying a position date in get_data().
The second Dataframe is generated by specifying a position date.
Since the position date is set at today’s date, the second Dataframe should be the exact same as the first one.
Actual behaviour: While the script correctly fetches the holdings for a precise date, it ignores the custom security. All the other instruments are correctly noted, with their correct quantities, but the custom security in the second Dataframe is missing.
import refinitiv.data as rd
import pandas as pd
portfolio_code = "TEST_PORTFOLIO"
position_date = "20231011"
rd.open_session()
print("Holdings without specified date: ")
print(rd.get_data(["PORTFOLIO('"+ portfolio_code +"')"], ['TR.PortfolioShares']))
print()
print("With specified date: ")
print(rd.get_data(["PORTFOLIO('"+ portfolio_code +"', '" + position_date + "')"], ['TR.PortfolioShares']))
rd.close_session()