Skip to main content

show

Show portfolio optimization results

Source Code: [link]

openbb.portfolio.po.show(portfolio_engine: portfolio_optimization.po_engine.PoEngine, category: str = None)

Parameters

NameTypeDescriptionDefaultOptional
portfolio_enginePoEnginePortfolio optimization engine
Use portfolio.po.load to load a portfolio engine
NoneFalse
categorystrCategory to show, by default None
After loading a portfolio with portfolio.po.load you can use
the object method get_available_categories() to get a list of available categories.
You can also use the object method set_categories_dict() to set a custom dictionary
of categories. The dictionary must contain "CURRENT_INVESTED_AMOUNT" and "CURRENT_WEIGHTS"
as keys as shown in the example below.
NoneTrue

Returns

TypeDescription
Union[pd.DataFrame, Tuple[pd.DataFrame, pd.DataFrame]]Portfolio weights and categories

Examples

from openbb_terminal.sdk import openbb
p = openbb.portfolio.po.load(symbols=["AAPL", "MSFT", "AMZN"])
d = {
"SECTOR": {
"AAPL": "INFORMATION TECHNOLOGY",
"MSFT": "INFORMATION TECHNOLOGY",
"AMZN": "CONSUMER DISCRETIONARY",
},
"CURRENT_INVESTED_AMOUNT": {
"AAPL": "100000.0",
"MSFT": "200000.0",
"AMZN": "300000.0",
},
"CURRENCY": {
"AAPL": "USD",
"MSFT": "USD",
"AMZN": "USD",
},
}
p.set_categories_dict(categories=d)
weights, performance = openbb.portfolio.po.equal(portfolio_engine=p)
p.get_available_categories()
['SECTOR']
weights_df, category_df = openbb.portfolio.po.show(portfolio_engine=p, category="SECTOR")
from openbb_terminal.sdk import openbb
p = openbb.portfolio.po.load(symbols_file_path="~/openbb_terminal/miscellaneous/portfolio_examples/allocation/60_40_Portfolio.xlsx")
weights, performance = openbb.portfolio.po.equal(portfolio_engine=p)
p.get_available_categories()
['ASSET_CLASS',
'SECTOR',
'INDUSTRY',
'COUNTRY',
'CURRENT_INVESTED_AMOUNT',
'CURRENCY']
weights_df, category_df = openbb.portfolio.po.show(portfolio_engine=p, category="ASSET_CLASS")