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 based on portfolio ID and date range.
- Parameters:
portfolio_ids (
list
) – A list of portfolio IDs. The maximum number of portfolio IDs that can be passed in is 5.date (
str
, optional) – The exact portfolio date. When this value is provided, start_date and end_date parameters are ignored.start_date (
str
, optional) – The start date of the data range.end_date (
str
, optional) – The end date of the data range.
- Returns:
A DataFrame object with portfolio holdings data. The 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'], 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 user lacks authentication.
BadRequestError: Raised when the user does not provide a properly formatted request.
ForbiddenError: Triggered when user lacks permission to access a resource.
InternalServerError: Raised when the server encounters an error it does not know how to handle.
NetworkError: 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 a list of portfolio IDs.
If no portfolio ID is specified, the function will return the data for all portfolios saved in user’s account.
- Parameters:
portfolio_ids (
list
, optional) – A portfolio ID or a list of portfolio IDs.- Returns:
A DataFrame object with all portfolio holdings dates. The 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']) 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 user lacks authentication.
BadRequestError: Raised when the user does not provide a properly formatted request.
ForbiddenError: Triggered when user lacks permission to access a resource.
InternalServerError: Raised when the server encounters an error it does not know how to handle.
NetworkError: 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.