PortfolioManager¶
- class PortfolioManager(portfolio_id)[source]¶
Portfolio Manager is used to manage Marquee portfolios (setting entitlements, running and retrieving reports, etc)
Methods
- __init__(portfolio_id)[source]¶
Initialize a Portfolio Manager
- Parameters:
portfolio_id (
str
) – Portfolio ID
- get_all_esg_data(measures=None, cards=None, pricing_date=None, benchmark_id=None)¶
Get all ESG Data :type measures:
Optional
[List
[ESGMeasure
]] :param measures: list of ESG Measures to include in results :type cards:Optional
[List
[ESGCard
]] :param cards: list of ESG Cards to include in results :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :type benchmark_id:Optional
[str
] :param benchmark_id: optional benchmark asset ID to include in results :rtype:Dict
:return: a dictionary of results
- get_all_fund_of_fund_tags()[source]¶
If the portfolio is a fund of funds, this function will retrieve a list of dictionaries of all the tag sets associated with the sub-portfolios in the portfolio.
- Return type:
List
- Returns:
a list of tags as dictionaries
- get_all_thematic_exposures(start_date=None, end_date=None, basket_ids=None, regions=None)¶
Deprecated since version 0.9.110: Please use the same function using the ThematicReport class
- Return type:
DataFrame
- get_aum(start_date, end_date)[source]¶
Get AUM data for portfolio
- Parameters:
start_date (
date
) – start dateend_date (
date
) – end date
- Returns:
dictionary of dates with corresponding AUM values
Deprecated since version 1.0.10: PortfolioManager.get_aum is now deprecated, please use PerformanceReport.get_aum instead.
- get_aum_source()[source]¶
Get portfolio AUM Source
- Return type:
RiskAumSource
- Returns:
aum source
Deprecated since version 1.0.10: PortfolioManager.get_aum_source is now deprecated, please use PerformanceReport.get_aum_source instead.
- get_bottom_five_thematic_exposures(start_date=None, end_date=None, basket_ids=None, regions=None)¶
Deprecated since version 0.9.110: Please use the same function using the ThematicReport class
- Return type:
DataFrame
- get_carbon_analytics(benchmark_id=None, reporting_year='Latest', currency=None, include_estimates=False, use_historical_data=False, normalize_emissions=False, cards=[<CarbonCard.COVERAGE: 'coverage'>, <CarbonCard.SBTI_AND_NET_ZERO_TARGETS: 'sbtiAndNetZeroTargets'>, <CarbonCard.EMISSIONS: 'emissions'>, <CarbonCard.ALLOCATIONS: 'allocations'>, <CarbonCard.ATTRIBUTION: 'attribution'>], analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
Dict
- get_carbon_attribution_table(benchmark_id, reporting_year='Latest', currency=None, include_estimates=False, use_historical_data=False, scope=CarbonScope.TOTAL_GHG, intensity_metric=CarbonEmissionsIntensityType.EI_ENTERPRISE_VALUE, analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
DataFrame
- get_carbon_coverage(reporting_year='Latest', include_estimates=False, use_historical_data=False, coverage_category=CarbonCoverageCategory.WEIGHTS, analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
DataFrame
- get_carbon_emissions(currency=None, include_estimates=False, use_historical_data=False, normalize_emissions=False, scope=CarbonScope.TOTAL_GHG, analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
DataFrame
- get_carbon_emissions_allocation(reporting_year='Latest', currency=None, include_estimates=False, use_historical_data=False, normalize_emissions=False, scope=CarbonScope.TOTAL_GHG, classification=CarbonEmissionsAllocationCategory.GICS_SECTOR, analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
DataFrame
- get_carbon_sbti_netzero_coverage(reporting_year='Latest', include_estimates=False, use_historical_data=False, target_coverage_category=CarbonTargetCoverageCategory.PORTFOLIO_EMISSIONS, analytics_view=CarbonAnalyticsView.LONG)¶
- Return type:
DataFrame
- get_custom_aum(start_date=None, end_date=None)[source]¶
Get AUM data for portfolio
- Parameters:
start_date (
Optional
[date
]) – start dateend_date (
Optional
[date
]) – end date
- Return type:
List
[CustomAUMDataPoint
]- Returns:
list of AUM data between the specified range
Deprecated since version 1.0.10: PortfolioManager.get_custom_aum is now deprecated, please use PerformanceReport.get_custom_aum instead.
- get_entitlements()¶
- Return type:
Entitlements
- get_esg_bottom_ten(measure, pricing_date=None)¶
Get entity constituents with the ten lowest ESG percentile values :type measure:
ESGMeasure
:param measure: ESG Measure :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :rtype:DataFrame
:return: a Pandas DataFrame with results
- get_esg_by_region(measure, pricing_date=None)¶
Get breakdown of entity by region, along with the weighted average score of the compositions in each region :type measure:
ESGMeasure
:param measure: ESG Measure :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :rtype:DataFrame
:return: a Pandas DataFrame with results
- get_esg_by_sector(measure, pricing_date=None)¶
Get breakdown of entity by sector, along with the weighted average score of the compositions in each sector :type measure:
ESGMeasure
:param measure: ESG Measure :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :rtype:DataFrame
:return: a Pandas DataFrame with results
- get_esg_quintiles(measure, pricing_date=None)¶
Get breakdown of entity by weight in each percentile quintile for requested ESG measure :type measure:
ESGMeasure
:param measure: ESG Measure :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :rtype:DataFrame
:return: a Pandas DataFrame with results
- get_esg_summary(pricing_date=None)¶
- Return type:
DataFrame
- get_esg_top_ten(measure, pricing_date=None)¶
Get entity constituents with the ten highest ESG percentile values :type measure:
ESGMeasure
:param measure: ESG Measure :type pricing_date:Optional
[date
] :param pricing_date: optional pricing date; defaults to last previous business day :return: a Pandas DataFrame with results
- get_factor_risk_report(risk_model_id=None, fx_hedged=None, benchmark_id=None, tags=None)¶
- Return type:
- get_factor_risk_reports(fx_hedged=None, tags=None)¶
- Return type:
List
[FactorRiskReport
]
- get_latest_position_set(position_type=PositionType.CLOSE)¶
- Return type:
- get_macro_exposure(model, date, factor_type, factor_categories=[], get_factors_by_name=True, tags=None, return_format=ReturnFormat.DATA_FRAME)[source]¶
Get portfolio and asset exposure to macro factors or macro factor categories
- Parameters:
model (
MacroRiskModel
) – the macro risk modeldate (
date
) – date for which to get exposurefactor_type (
FactorType
) – whether to get exposure to factor categories or factors.factor_categories (
List
[Factor
]) – Get portfolio exposure to these factor categories. Must be valid Factor Categories.
If factor_type is Factor, get exposure to factors that are grouped in these factor categories. If empty, return exposure to all factor categories/factors. :type get_factors_by_name:
bool
:param get_factors_by_name: whether to identify factors by their name or identifier :type tags:Optional
[Dict
] :param tags: If the portfolio is a fund of funds, pass in a dictionary corresponding to the tag values to retrieve results for a sub-portfolio :type return_format:ReturnFormat
:param return_format: whether to return a dict or a pandas dataframe :rtype:Union
[Dict
,DataFrame
] :return: a Pandas Dataframe or a Dict of portfolio exposure to macro factorsExamples
>>> model = MacroRiskModel.get("MODEL") >>> pm = PortfolioManager("PORTFOLIO ID") >>> exposure_dataframe = pm.get_macro_exposure( >>> model=model, >>> date=dt.date(2022, 1, 1), >>> factor_type=FactorType.Factor >>> ).sort_values( >>> by=["Total Factor Exposure"], >>> axis=1, >>> ascending=False >>> )
- get_performance_report(tags=None)[source]¶
Get performance report associated with a portfolio
- Parameters:
tags (
Optional
[Dict
]) – If the portfolio is a fund of funds, pass in a dictionary corresponding to the tag values
to retrieve results for a sub-portfolio :rtype:
PerformanceReport
:return: returns the PerformanceReport associated with portfolio if one exists
- get_pnl_contribution(start_date=None, end_date=None, currency=None, tags=None)[source]¶
Get PnL Contribution of your portfolio broken down by constituents
- Parameters:
start_date (
Optional
[date
]) – optional start dateend_date (
Optional
[date
]) – optional end datecurrency (
Optional
[Currency
]) – optional currency; defaults to your portfolio’s currencytags (
Optional
[Dict
]) – If the portfolio is a fund of funds, pass in a dictionary corresponding to the tag values
to retrieve results for a sub-portfolio :rtype:
DataFrame
:return: a Pandas DataFrame of resultsDeprecated since version 0.9.110: Please use the get_pnl_contribution on your portfolio’s performance report usingthe PerformanceReport class
- get_position_dates()¶
- Return type:
Tuple
[date
,...
]
- get_position_set_for_date(date, position_type=PositionType.CLOSE)¶
- Return type:
- get_position_sets(start=datetime.date(1952, 1, 1), end=datetime.date(2023, 8, 14), position_type=PositionType.CLOSE)¶
- Return type:
List
[PositionSet
]
- get_positions_data(start=datetime.date(1952, 1, 1), end=datetime.date(2023, 8, 14), fields=None, position_type=PositionType.CLOSE)¶
- get_schedule_dates(backcast=False)[source]¶
Get recommended start and end dates for a portfolio report scheduling job
- Parameters:
backcast (
bool
) – true if reports should be backcasted- Return type:
List
[date
]- Returns:
a list of two dates, the first is the suggested start date and the second is the suggested end date
- get_status_of_reports(tags=None)¶
- Return type:
DataFrame
- get_tag_name_hierarchy()[source]¶
Get the list of tags by name by which a portfolio’s fund of funds are structured in that order
- Return type:
List
- Returns:
a list of tag names
- get_thematic_beta(basket_identifier, start=datetime.date(1952, 1, 1), end=datetime.date(2023, 8, 14))¶
- Return type:
DataFrame
- get_thematic_breakdown(date, basket_id)¶
Get a by-asset breakdown of a portfolio or basket’s thematic exposure to a particular flagship basket on a particular date :type date:
date
:param date: date :type basket_id:str
:param basket_id: GS flagship basket’s unique Marquee ID :rtype:DataFrame
:return: a Pandas DataFrame with results
- get_thematic_exposure(basket_identifier, notional=10000000, start=datetime.date(1952, 1, 1), end=datetime.date(2023, 8, 14))¶
- Return type:
DataFrame
- get_thematic_report(tags=None)¶
- Return type:
- get_top_five_thematic_exposures(start_date=None, end_date=None, basket_ids=None, regions=None)¶
Deprecated since version 0.9.110: Please use the same function using the ThematicReport class
- Return type:
DataFrame
- poll_report(report_id, timeout=600, step=30)¶
- Return type:
ReportStatus
- run_reports(start_date=None, end_date=None, backcast=False, is_async=True, months_per_batch=None)[source]¶
Run all reports associated with a portfolio
- Parameters:
start_date (
Optional
[date
]) – start date of report jobend_date (
Optional
[date
]) – end date of report jobbackcast (
bool
) – true if reports should be backcasted; defaults to falseis_async (
bool
) – true if reports should run asynchronously; defaults to truemonths_per_batch (
Optional
[int
]) – batch size of historical report job schedules in number of months; defaults to false
if set, historical reports are scheduled in batches of size less than or equal to the given number of months :rtype:
List
[Union
[DataFrame
,ReportJobFuture
]] :return: if is_async is true, returns a list of ReportJobFuture objects; if is_async is false, returns a list of dataframe objects containing report results for all portfolio resultsExamples
>>> pm = PortfolioManager("PORTFOLIO ID") >>> report_results = pm.run_reports(backcast=True)
for longer hisotry, use months_per_batch to schedule reports in batches of 6 months >>> pm = PortfolioManager(“PORTFOLIO ID”) >>> pm.schedule_reports(backcast=False, months_per_batch=6)
- schedule_reports(start_date=None, end_date=None, backcast=False, months_per_batch=None)[source]¶
Schedule all reports associated with a portfolio. If months_per_batch is passed and reports are historical, then schedule them in batches of bathc_period months. Backcasted reported can’t be batched.
- Parameters:
start_date (
Optional
[date
]) – start date of report job (optional)end_date (
Optional
[date
]) – end date of report job (optional)backcast (
bool
) – true if reports should be backcasted; defaults to falsemonths_per_batch (
Optional
[int
]) – batch size of historical report job schedules in number of months; defaults to false
if set, historical reports are scheduled in batches of size less than or equal to the given number of months
Examples
>>> pm = PortfolioManager("PORTFOLIO ID") >>> pm.schedule_reports(backcast=False)
for a portfolio having hisotry greater than 1 yr, use months_per_batch to schedule reports in batches of 6 months >>> pm = PortfolioManager(“PORTFOLIO ID”) >>> pm.schedule_reports(backcast=False, months_per_batch=6)
- set_aum_source(aum_source)[source]¶
Set portfolio AUM Source
- Parameters:
aum_source (
RiskAumSource
) – aum source for portfolio- Returns:
aum source
Deprecated since version 1.0.10: PortfolioManager.set_aum_source is now deprecated, please use PerformanceReport.set_aum_source instead.
- set_currency(currency)[source]¶
Set the currency of a portfolio
- Parameters:
currency (
Currency
) – Currency
- set_entitlements(entitlements)[source]¶
Set the entitlements of a portfolio
- Parameters:
entitlements (
Entitlements
) – Entitlements object
Examples
>>> portfolio_admin_emails = ['LIST OF ADMIN EMAILS'] >>> portfolio_viewer_emails = ['LIST OF VIEWER EMAILS'] >>> admin_entitlements = EntitlementBlock(users=User.get_many(emails=portfolio_admin_emails)) >>> view_entitlements = EntitlementBlock(users=User.get_many(emails=portfolio_viewer_emails)) >>> >>> entitlements = Entitlements( >>> view=view_entitlements, >>> admin=admin_entitlements >>> ) >>> >>> pm = PortfolioManager("PORTFOLIO ID") >>> pm.set_entitlements(entitlements)
- set_tag_name_hierarchy(tag_names)[source]¶
Set the list of tags by name by which a portfolio’s fund of funds are structured in that order
- Parameters:
tag_names (
List
) – a list of tag names in order of the new fund of funds structure
- update_portfolio_tree()[source]¶
After a modification is made on your portfolio (reports are added/modified, the tag name hierarchy is changed, etc), run this function so those changes reflect across all the portfolio’s sub-portfolios
- update_positions(position_sets, net_positions=True)¶
- upload_custom_aum(aum_data, clear_existing_data=None)[source]¶
Add AUM data for portfolio
- Parameters:
aum_data (
List
[CustomAUMDataPoint
]) – list of AUM data to uploadclear_existing_data (
Optional
[bool
]) – delete all previously uploaded AUM data for the portfolio (defaults to false)
Deprecated since version 1.0.10: PortfolioManager.upload_custom_aum is now deprecated, please use PerformanceReport.upload_custom_aum instead.