Holdings Data#
- morningstar_data.direct.portfolio.get_holdings(
- portfolio_ids: List[str],
- date: str | None = None,
- start_date: str | None = None,
- end_date: str | None = None,
Returns holdings for the given portfolio and date range.
- Parameters:
portfolio_ids (
list
) – List of portfolio IDs. The maximum number is 5. Use the get_portfolios function to discover saved portfolios.date (
str
, optional) – Holdings date. When this value is provided, start_date and end_date parameters are ignored. Use the get_holding_dates function to discover available holding dates.start_date (
str
, optional) – Start date of the date range.end_date (
str
, optional) – End date of the date range.
- Returns:
A DataFrame object with portfolio holdings data. DataFrame columns include:
ObjectId
Portfolio Date
HoldingId
Weight
Name
Currency
ISIN
Ticker
- Return type:
DataFrame
Examples
Get holdings by portfolio ID and date.
import morningstar_data as md df = md.direct.portfolio.get_holdings( portfolio_ids=['de21828b-91b7-4fe1-b66e-760fd5e657bc;BM'], # Replace with valid portfolio ID date = "2017-09-30") df
- Output:
ObjectId
Portfolio Date
HoldingId
Weight
Name
Currency
ISIN
Ticker
de21828b-91b7-4fe1-b66e-760fd5e657bc;BM
2017-09-30
FOUSA00DFS;F
100
BlackRock Global Allocation Inv A
USD
US09251T1034
MDLOX
…
- Errors:
AccessDeniedError: Raised when the user is not authenticated.
BadRequestError: Raised when the user does not provide a properly formatted request.
ForbiddenError: Raised when the user does not have permission to access the requested resource.
InternalServerError: Raised when the server encounters an unhandled error.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
ResourceNotFoundError: Raised when the requested resource does not exist in Direct.
- morningstar_data.direct.portfolio.get_holding_dates(
- portfolio_ids: List[str] | str | None = None,
Returns portfolio holdings dates for the given portfolios.
- Parameters:
portfolio_ids (
list
, optional) –A portfolio ID or list of portfolio IDs. If no ID is specified, the function will return data for all portfolios saved in the user’s account. Use the get_portfolios function to discover saved portfolios.
- Returns:
A DataFrame object with all portfolio holdings dates. DataFrame columns include:
portfolioId
date
- Return type:
DataFrame
Examples
Get portfolio holdings dates for the given portfolio ID.
import morningstar_data as md df = md.direct.portfolio.get_holding_dates( portfolio_ids=['07c317df-a4a7-4297-afc3-0c18bb79a672;UA']) # Replace with a valid portfolio ID df
- Output:
PortfolioId
Date
07c317df-a4a7-4297-afc3-0c18bb79a672;UA
2021-10-01
07c317df-a4a7-4297-afc3-0c18bb79a672;UA
2021-09-01
…
- Errors:
AccessDeniedError: Raised when the user is not authenticated.
BadRequestError: Raised when the user does not provide a properly formatted request.
ForbiddenError: Raised when the user does not have permission to access the requested resource.
InternalServerError: Raised when the server encounters an unhandled error.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
ResourceNotFoundError: Raised when the requested resource does not exist in Direct.
- morningstar_data.direct.get_lookthrough_holdings(
- portfolio_id: str,
-
Returns look-through holdings for a user-created portfolio.
- Parameters:
portfolio_id (
str
) –Portfolio ID. Use the get_portfolios function to discover saved portfolios.
- Returns:
A DataFrame object with holdings data. 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.
import morningstar_data as md df = md.direct.get_lookthrough_holdings(portfolio_id='7b9cb5db-e3da-414e-8f75-b52b02222b5a') # Replace with a valid Portfolio ID df
- Output:
investment_id
…
primary_performance_id
morningstar_instrument_type_name
E0USA00462
0P000000YM
Equity
F00000Q5HQ
0P0000Z4DP
Equity
F00000UMZ1
0P00014J84
Equity
B10002POBD
None
Bond - Asset Backed
- Errors:
InternalServerError: Raised when the server encounters an unhandled error.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
TimeoutError: Raised when the fund of fund calculation takes too long.
ResourceNotFoundError: Raised when portfolio_id does not exist in Direct.
BadRequestException: Raised when portfolio_id is an invalid UUID.
UnavailableExternally: Raised when the function is not available for external Python package callers.