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:
DataFrame: A DataFrame object with portfolio holdings data. DataFrame columns include:
ObjectId
Portfolio Date
HoldingId
Weight
Name
Currency
ISIN
Ticker
- 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: str | List[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:
DataFrame: A DataFrame object with all portfolio holdings dates. DataFrame columns include:
portfolioId
date
- 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.