Portfolio Data#
- morningstar_data.direct.portfolio.get_benchmark_settings(
- portfolio_id: str,
Returns a portfolio’s benchmark settings.
- Parameters:
portfolio_id (
str
) – Portfolio ID. Use the get_portfolios function to discover saved portfolios.- Returns:
A DataFrame object containing the portfolio settings.
- Return type:
DataFrame
- Examples:
Get portfolio settings for a custom model portfolio.
import morningstar_data as md df = md.direct.portfolio.get_settings( portfolio_id="d38b96dd-fbe1-4750-b05d-fa7cf4b6e35a;MD") # Replace with a valid portfolio ID df
- Output:
Portfolio ID
Risk Free Proxy ID
Benchmark 1 ID
Benchmark 1 Name
Benchmark 1 SecurityId
Benchmark 2 ID
Benchmark 2 Name
Benchmark 2 SecurityId
Internal Portfolio ID
d38b96dd-fbe1-4750-b05d-fa7cf4b6e35a;MD
e9b23e21-9c6f-4696-9583-3b3729b4ad99
fcff80f8-2fbc-4211-bbce-45252008a9cc
S&P 500 TR USD
XIUSA04G92;XI
None
None
None
None
- 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_data(
- portfolio_id: str,
- data_set_id: str | PortfolioDataSet | None = None,
- currency: str | None = None,
- start_date: str | None = None,
- end_date: str | None = None,
- data_point_settings: DataFrame | None = None,
Returns data for the given portfolio and data points.
- Parameters:
portfolio_id (
str
) –Portfolio ID. Use the get_portfolios function to discover saved portfolios.
data_set_id (
str
, optional) – Saved portfolio data set, e.g., “1”. Use the get_data_sets function to discover available data sets.currency (
str
, optional) – Currency setting for the data point values, when applicable. Use the currency_codes function to discover available currency codes.start_date (
str
, optional) – Start date of a date range for retrieving data. The format is YYYY-MM-DD, e.g., ‘2020-01-01’.end_date (
str
, optional) – End date of a date range for retrieving data. If no value is provided for end_date, current date will be used. The format is YYYY-MM-DD, e.g., ‘2020-01-01’.data_point_settings (
DataFrame
, optional) – A DataFrame of data points with all defined settings. Each row represents a data point. Each column is a configurable setting. Users can get this DataFrame by using get_data_set_data_points or get_data_point_settings for a given data point ID(s). Users can update setting values in this DataFrame if desired. Additionally, the priority of currency/start_date/end_date in data_point_settings is lower than the currency/start_date/end_date function parameters.
- Returns:
A DataFrame object with portfolio data.
- Return type:
DataFrame
Examples
Get portfolio data for the given portfolio and data set.
import morningstar_data as md df = md.direct.portfolio.get_data( portfolio_id="8c6de08f-a668-4e78-a688-3d809aeb29b7;UA", # Replace with a valid portfolio ID data_set_id="1") df
- Output:
Id
Name
Base Currency
Portfolio Date
…
Total Ret Annlzd 10 Yr (Year-End)
Total Ret Annlzd 15 Yr (Year-End)
8c6de08f-a668-4e78-a688-3d809aeb29b7;UA
test1
US Dollar
2022-02-28
…
None
None
…
- 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.