Holdings Data#
- morningstar_data.direct.get_holdings(
- investment_ids: List[str],
- date: str | None = None,
- start_date: str | None = None,
- end_date: str | None = None,
Returns holdings for a given investment or set of investments during a specified date or date range. If the date is not specified, the function returns the latest portfolio date by default.
- Parameters:
investment_ids (
list
) – An array of investment codes. The investment code format is secid;universe or just secid. For example: [“F00000YOOK;FO”,”FOUSA00CFV;FO”] or [“F00000YOOK”,”FOUSA00CFV”].date (
str
, optional) – The specific date on which to retrieve data. The format is YYYY-MM-DD. For example, “2020-01-01”. If a date is provided, then the start_date and end_date parameters are ignored. An exception is thrown if start_date or end_date is provided along with date.start_date (
str
, optional) – The beginning date of a data range for retrieving data. The format is YYYY-MM-DD. For example, “2020-01-01”. An exception is thrown if date is provided along with start_date.end_date (
str
, optional) – The end date of data range for retrieving data. If no value is provided for end_date, current date will be used. The format is YYYY-MM-DD. For example, “2020-01-01”. An exception is thrown if date is provided along with end_date.
- Returns:
A DataFrame object with holdings data. The DataFrame columns include:
investmentId
masterPortfolioId
portfolioDate
holdingId
bondId
name
secId
isin
cusip
weight
shares
marketValue
sharesChanged
currency
ticker
detailHoldingType
- Return type:
DataFrame
- Raises:
ValueErrorException – When investment_ids parameter is invalid, then an error will occur.
Examples
Search holdings of investment “FOUSA00KZH” on “2020-12-31”.
import morningstar_data as md df = md.direct.get_holdings(investment_ids=["FOUSA00KZH"], date="2020-12-31") df
- Output:
investmentId
masterPortfolioId
…
ticker
detailHoldingType
FOUSA00KZH
6079
…
CBRE
EQUITY
FOUSA00KZH
6079
…
GOOGL
EQUITY
…
- morningstar_data.direct.get_holding_dates(
- investment_ids: List[str],
Returns all portfolio dates of available holdings for a given investment or set of investments.
- Parameters:
investment_ids (
list
) – An array of investment codes. The investment code format is secid;universe or just secid. For example: [“F00000YOOK;FO”,”FOUSA00CFV;FO”] or [“F00000YOOK”,”FOUSA00CFV”].- Returns:
A DataFrame object with portfolio date data. The DataFrame columns include:
- Return type:
DataFrame
secId
masterPortfolioId
date
suppression
suppressionHoldingNumber
Examples
Search holdings of investment “FOUSA00KZH”.
import morningstar_data as md df = md.direct.get_holding_dates(investment_ids=["FOUSA06JNH"]) df
- Output:
secId
masterPortfolioId
date
suppression
suppressionHoldingNumber
FOUSA06JNH
210311
2021-08-31
False
None
FOUSA06JNH
210311
2021-07-31
False
None
…
- morningstar_data.direct.get_lookthrough_holdings(
- portfolio_id: str,
Returns look-through holdings for a specified user’s Direct portfolio :param portfolio_id: This is a users Direct portfolio id :type portfolio_id:
str
- Returns:
A DataFrame object containing fields for each holding. The DataFrame columns include
investment_id
isin
cusip
weight
market_value
security_name
currency
morningstar_instrument_type_code
entity_id
morningstar_entity_name
primary_performance_id
morningstar_instrument_type_name
- Return type:
DataFrame
Examples
Retrieve the look-through holdings for a portfolio with id 862a5b39-259f-432e-b7a4-333bacf0f044
import morningstar_data as md df = md.direct.get_lookthrough_holdings(portfolio_id='7b9cb5db-e3da-414e-8f75-b52b02222b5a') df
- Output:
- Errors:
InternalServerError: Raised when the server encounters an error it does not know how to handle.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
TimeoutError: Raised when Fund of Fund calculation takes more than 5 minutes.
ResourceNotFoundError: Raised when portfolio_id given does not exist in Direct.
BadRequestException: Raised when portfolio_id is invalid UUID
UnavailableExternally: When importing the package outside analytics lab