Incorporate portfolio class into SDK (#3401)

* create functions to interact with portfolio

* fix some docstrings

* view docstrings

* make portfolio loading available in sdk

* reorder some methods

* fix bug

* update controller

* update website

* remove import

* change input name

* regenerate website

* change portfolio arg name

* fix metrics bugs

* fix report

* refactor assets alloc

* refactor assets sectors alloc

* remove unecessary attributes

* refactor allocaasset sector

* reorganize class

* first refactor alloc

* refactor portfolio alloc

* black

* fix alloc bug

* regenerate sdk website

* fix alloc bugs

* forgot this exception

* some refactor on portfolio alloc country region

* fix some allocation bugs

* add examples

* regenerate website

Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
montezdesousa
2022-11-14 16:27:34 +00:00
committed by GitHub
parent 2b60a1cf38
commit 8e9e6bd57f
112 changed files with 3138 additions and 1629 deletions

4
CONTRIBUTING.md vendored
View File

@@ -681,7 +681,7 @@ With:
transactions = Portfolio.read_orderbook("../../portfolio/holdings/example.csv")
P = Portfolio(transactions)
P.generate_portfolio_data()
P.load_benchmark()
P.set_benchmark()
# SDK endpoint access
openbb.portfolio.gaintopain(P)
@@ -695,7 +695,7 @@ With:
<td>
```python
def get_gaintopain_ratio(portfolio: PortfolioModel) -> pd.DataFrame:
def get_gaintopain_ratio(portfolio: PortfolioEngine) -> pd.DataFrame:
"""..."""

View File

@@ -295,36 +295,42 @@ forex.oanda.listorders,openbb_terminal.forex.oanda.oanda_model.order_history_req
forex.oanda.orderbook,openbb_terminal.forex.oanda.oanda_model.orderbook_plot_data_request,openbb_terminal.forex.oanda.oanda_view.get_order_book
forex.oanda.pending,openbb_terminal.forex.oanda.oanda_model.pending_orders_request,openbb_terminal.forex.oanda.oanda_view.get_pending_orders
forex.oanda.positionbook,openbb_terminal.forex.oanda.oanda_model.positionbook_plot_data_request,openbb_terminal.forex.oanda.oanda_view.get_position_book
portfolio.load,openbb_terminal.portfolio.portfolio_model.generate_portfolio,
portfolio.show,openbb_terminal.portfolio.portfolio_model.get_transactions,
portfolio.bench,openbb_terminal.portfolio.portfolio_model.set_benchmark,
portfolio.holdv,openbb_terminal.portfolio.portfolio_model.get_holdings_value,openbb_terminal.portfolio.portfolio_view.display_holdings_value
portfolio.holdp,openbb_terminal.portfolio.portfolio_model.get_holdings_percentage,openbb_terminal.portfolio.portfolio_view.display_holdings_percentage
portfolio.yret,openbb_terminal.portfolio.portfolio_model.get_yearly_returns,openbb_terminal.portfolio.portfolio_view.display_yearly_returns
portfolio.mret,openbb_terminal.portfolio.portfolio_model.get_monthly_returns,openbb_terminal.portfolio.portfolio_view.display_monthly_returns
portfolio.yret,openbb_terminal.portfolio.portfolio_model.get_yearly_returns,openbb_terminal.portfolio.portfolio_view.display_yearly_returns
portfolio.dret,openbb_terminal.portfolio.portfolio_model.get_daily_returns,openbb_terminal.portfolio.portfolio_view.display_daily_returns
portfolio.max_drawdown_ratio,openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown,openbb_terminal.portfolio.portfolio_view.display_maximum_drawdown_ratio
portfolio.distr,openbb_terminal.portfolio.portfolio_model.get_distribution_returns,openbb_terminal.portfolio.portfolio_view.display_distribution_returns
portfolio.maxdd,openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown,openbb_terminal.portfolio.portfolio_view.display_maximum_drawdown
portfolio.rvol,openbb_terminal.portfolio.portfolio_model.get_rolling_volatility,openbb_terminal.portfolio.portfolio_view.display_rolling_volatility
portfolio.rsharpe,openbb_terminal.portfolio.portfolio_model.get_rolling_sharpe,openbb_terminal.portfolio.portfolio_view.display_rolling_sharpe
portfolio.rsortino,openbb_terminal.portfolio.portfolio_model.get_rolling_sortino,openbb_terminal.portfolio.portfolio_view.display_rolling_sortino
portfolio.rsort,openbb_terminal.portfolio.portfolio_model.get_rolling_sortino,openbb_terminal.portfolio.portfolio_view.display_rolling_sortino
portfolio.rbeta,openbb_terminal.portfolio.portfolio_model.get_rolling_beta,openbb_terminal.portfolio.portfolio_view.display_rolling_beta
portfolio.summary,openbb_terminal.portfolio.portfolio_model.get_summary,
portfolio.skew,openbb_terminal.portfolio.portfolio_model.get_skewness,
portfolio.kurtosis,openbb_terminal.portfolio.portfolio_model.get_kurtosis,
portfolio.volatility,openbb_terminal.portfolio.portfolio_model.get_volatility,
portfolio.sharpe,openbb_terminal.portfolio.portfolio_model.get_sharpe_ratio,
portfolio.sortino,openbb_terminal.portfolio.portfolio_model.get_sortino_ratio,
portfolio.maxdrawdown,openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown_ratio,
portfolio.rsquare,openbb_terminal.portfolio.portfolio_model.get_r2_score,
portfolio.gaintopain,openbb_terminal.portfolio.portfolio_model.get_gaintopain_ratio,
portfolio.trackerr,openbb_terminal.portfolio.portfolio_model.get_tracking_error,
portfolio.information,openbb_terminal.portfolio.portfolio_model.get_information_ratio,
portfolio.tail,openbb_terminal.portfolio.portfolio_model.get_tail_ratio,
portfolio.commonsense,openbb_terminal.portfolio.portfolio_model.get_common_sense_ratio,
portfolio.jensens,openbb_terminal.portfolio.portfolio_model.get_jensens_alpha,
portfolio.calmar,openbb_terminal.portfolio.portfolio_model.get_calmar_ratio,
portfolio.kelly,openbb_terminal.portfolio.portfolio_model.get_kelly_criterion,
portfolio.payoff,openbb_terminal.portfolio.portfolio_model.get_payoff_ratio,
portfolio.profitfactor,openbb_terminal.portfolio.portfolio_model.get_profit_factor,
portfolio.alloc.assets,openbb_terminal.portfolio.portfolio_model.get_assets_allocation,
portfolio.alloc.sectors,openbb_terminal.portfolio.portfolio_model.get_sectors_allocation,
portfolio.alloc.countries,openbb_terminal.portfolio.portfolio_model.get_countries_allocation,
portfolio.alloc.regions,openbb_terminal.portfolio.portfolio_model.get_regions_allocation,
portfolio.metric.volatility,openbb_terminal.portfolio.portfolio_model.get_volatility,
portfolio.metric.sharpe,openbb_terminal.portfolio.portfolio_model.get_sharpe_ratio,
portfolio.metric.sortino,openbb_terminal.portfolio.portfolio_model.get_sortino_ratio,
portfolio.metric.maxdrawdown,openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown_ratio,
portfolio.metric.rsquare,openbb_terminal.portfolio.portfolio_model.get_r2_score,
portfolio.metric.skew,openbb_terminal.portfolio.portfolio_model.get_skewness,
portfolio.metric.kurtosis,openbb_terminal.portfolio.portfolio_model.get_kurtosis,
portfolio.metric.gaintopain,openbb_terminal.portfolio.portfolio_model.get_gaintopain_ratio,
portfolio.metric.trackerr,openbb_terminal.portfolio.portfolio_model.get_tracking_error,
portfolio.metric.information,openbb_terminal.portfolio.portfolio_model.get_information_ratio,
portfolio.metric.tail,openbb_terminal.portfolio.portfolio_model.get_tail_ratio,
portfolio.metric.commonsense,openbb_terminal.portfolio.portfolio_model.get_common_sense_ratio,
portfolio.metric.jensens,openbb_terminal.portfolio.portfolio_model.get_jensens_alpha,
portfolio.metric.calmar,openbb_terminal.portfolio.portfolio_model.get_calmar_ratio,
portfolio.metric.kelly,openbb_terminal.portfolio.portfolio_model.get_kelly_criterion,
portfolio.metric.payoff,openbb_terminal.portfolio.portfolio_model.get_payoff_ratio,
portfolio.metric.profitfactor,openbb_terminal.portfolio.portfolio_model.get_profit_factor,
portfolio.perf,openbb_terminal.portfolio.portfolio_model.get_performance_vs_benchmark,
portfolio.var,openbb_terminal.portfolio.portfolio_model.get_var,
portfolio.es,openbb_terminal.portfolio.portfolio_model.get_es,
1 trail model view
295 forex.oanda.orderbook openbb_terminal.forex.oanda.oanda_model.orderbook_plot_data_request openbb_terminal.forex.oanda.oanda_view.get_order_book
296 forex.oanda.pending openbb_terminal.forex.oanda.oanda_model.pending_orders_request openbb_terminal.forex.oanda.oanda_view.get_pending_orders
297 forex.oanda.positionbook openbb_terminal.forex.oanda.oanda_model.positionbook_plot_data_request openbb_terminal.forex.oanda.oanda_view.get_position_book
298 portfolio.load openbb_terminal.portfolio.portfolio_model.generate_portfolio
299 portfolio.show openbb_terminal.portfolio.portfolio_model.get_transactions
300 portfolio.bench openbb_terminal.portfolio.portfolio_model.set_benchmark
301 portfolio.holdv openbb_terminal.portfolio.portfolio_model.get_holdings_value openbb_terminal.portfolio.portfolio_view.display_holdings_value
302 portfolio.holdp openbb_terminal.portfolio.portfolio_model.get_holdings_percentage openbb_terminal.portfolio.portfolio_view.display_holdings_percentage
portfolio.yret openbb_terminal.portfolio.portfolio_model.get_yearly_returns openbb_terminal.portfolio.portfolio_view.display_yearly_returns
303 portfolio.mret openbb_terminal.portfolio.portfolio_model.get_monthly_returns openbb_terminal.portfolio.portfolio_view.display_monthly_returns
304 portfolio.yret openbb_terminal.portfolio.portfolio_model.get_yearly_returns openbb_terminal.portfolio.portfolio_view.display_yearly_returns
305 portfolio.dret openbb_terminal.portfolio.portfolio_model.get_daily_returns openbb_terminal.portfolio.portfolio_view.display_daily_returns
portfolio.max_drawdown_ratio openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown openbb_terminal.portfolio.portfolio_view.display_maximum_drawdown_ratio
306 portfolio.distr openbb_terminal.portfolio.portfolio_model.get_distribution_returns openbb_terminal.portfolio.portfolio_view.display_distribution_returns
307 portfolio.maxdd openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown openbb_terminal.portfolio.portfolio_view.display_maximum_drawdown
308 portfolio.rvol openbb_terminal.portfolio.portfolio_model.get_rolling_volatility openbb_terminal.portfolio.portfolio_view.display_rolling_volatility
309 portfolio.rsharpe openbb_terminal.portfolio.portfolio_model.get_rolling_sharpe openbb_terminal.portfolio.portfolio_view.display_rolling_sharpe
310 portfolio.rsortino portfolio.rsort openbb_terminal.portfolio.portfolio_model.get_rolling_sortino openbb_terminal.portfolio.portfolio_view.display_rolling_sortino
311 portfolio.rbeta openbb_terminal.portfolio.portfolio_model.get_rolling_beta openbb_terminal.portfolio.portfolio_view.display_rolling_beta
312 portfolio.summary openbb_terminal.portfolio.portfolio_model.get_summary
313 portfolio.skew portfolio.alloc.assets openbb_terminal.portfolio.portfolio_model.get_skewness openbb_terminal.portfolio.portfolio_model.get_assets_allocation
314 portfolio.kurtosis portfolio.alloc.sectors openbb_terminal.portfolio.portfolio_model.get_kurtosis openbb_terminal.portfolio.portfolio_model.get_sectors_allocation
315 portfolio.volatility portfolio.alloc.countries openbb_terminal.portfolio.portfolio_model.get_volatility openbb_terminal.portfolio.portfolio_model.get_countries_allocation
316 portfolio.sharpe portfolio.alloc.regions openbb_terminal.portfolio.portfolio_model.get_sharpe_ratio openbb_terminal.portfolio.portfolio_model.get_regions_allocation
317 portfolio.sortino portfolio.metric.volatility openbb_terminal.portfolio.portfolio_model.get_sortino_ratio openbb_terminal.portfolio.portfolio_model.get_volatility
318 portfolio.maxdrawdown portfolio.metric.sharpe openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown_ratio openbb_terminal.portfolio.portfolio_model.get_sharpe_ratio
319 portfolio.rsquare portfolio.metric.sortino openbb_terminal.portfolio.portfolio_model.get_r2_score openbb_terminal.portfolio.portfolio_model.get_sortino_ratio
320 portfolio.gaintopain portfolio.metric.maxdrawdown openbb_terminal.portfolio.portfolio_model.get_gaintopain_ratio openbb_terminal.portfolio.portfolio_model.get_maximum_drawdown_ratio
321 portfolio.trackerr portfolio.metric.rsquare openbb_terminal.portfolio.portfolio_model.get_tracking_error openbb_terminal.portfolio.portfolio_model.get_r2_score
322 portfolio.information portfolio.metric.skew openbb_terminal.portfolio.portfolio_model.get_information_ratio openbb_terminal.portfolio.portfolio_model.get_skewness
323 portfolio.tail portfolio.metric.kurtosis openbb_terminal.portfolio.portfolio_model.get_tail_ratio openbb_terminal.portfolio.portfolio_model.get_kurtosis
324 portfolio.commonsense portfolio.metric.gaintopain openbb_terminal.portfolio.portfolio_model.get_common_sense_ratio openbb_terminal.portfolio.portfolio_model.get_gaintopain_ratio
325 portfolio.jensens portfolio.metric.trackerr openbb_terminal.portfolio.portfolio_model.get_jensens_alpha openbb_terminal.portfolio.portfolio_model.get_tracking_error
326 portfolio.calmar portfolio.metric.information openbb_terminal.portfolio.portfolio_model.get_calmar_ratio openbb_terminal.portfolio.portfolio_model.get_information_ratio
327 portfolio.kelly portfolio.metric.tail openbb_terminal.portfolio.portfolio_model.get_kelly_criterion openbb_terminal.portfolio.portfolio_model.get_tail_ratio
328 portfolio.payoff portfolio.metric.commonsense openbb_terminal.portfolio.portfolio_model.get_payoff_ratio openbb_terminal.portfolio.portfolio_model.get_common_sense_ratio
329 portfolio.profitfactor portfolio.metric.jensens openbb_terminal.portfolio.portfolio_model.get_profit_factor openbb_terminal.portfolio.portfolio_model.get_jensens_alpha
330 portfolio.metric.calmar openbb_terminal.portfolio.portfolio_model.get_calmar_ratio
331 portfolio.metric.kelly openbb_terminal.portfolio.portfolio_model.get_kelly_criterion
332 portfolio.metric.payoff openbb_terminal.portfolio.portfolio_model.get_payoff_ratio
333 portfolio.metric.profitfactor openbb_terminal.portfolio.portfolio_model.get_profit_factor
334 portfolio.perf openbb_terminal.portfolio.portfolio_model.get_performance_vs_benchmark
335 portfolio.var openbb_terminal.portfolio.portfolio_model.get_var
336 portfolio.es openbb_terminal.portfolio.portfolio_model.get_es

View File

@@ -1,5 +1,5 @@
import logging
from typing import Dict
from typing import Dict, Tuple
import pandas as pd
import requests
@@ -12,22 +12,61 @@ logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def get_assets_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
"""Obtain the assets allocation of the benchmark and portfolio [Source: Yahoo Finance]
def get_allocation(
category: str, benchmark_info: Dict, portfolio_trades: pd.DataFrame
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Get category allocation for benchmark and portfolio
Parameters
----------
category: str
Chosen category: Asset, Sector, Country or Region
benchmark_info: Dict
Dictionary containing Yahoo Finance information
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio
Returns
-------
pd.DataFrame
DataFrame with the top 10 of the benchmark's asset allocations
pd.DataFrame
DataFrame with the portfolio's asset allocations
"""
if category == "Asset":
return get_assets_allocation(benchmark_info, portfolio_trades)
if category == "Sector":
return get_sectors_allocation(benchmark_info, portfolio_trades)
if category == "Country":
return get_countries_allocation(benchmark_info, portfolio_trades)
if category == "Region":
return get_regions_allocation(benchmark_info, portfolio_trades)
console.print(
"Category not available. Choose from: Asset, Sector, Country or Region."
)
return pd.DataFrame(), pd.DataFrame()
@log_start_end(log=logger)
def get_assets_allocation(
benchmark_info: Dict, portfolio_trades: pd.DataFrame
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Get assets allocation for benchmark and portfolio [Source: Yahoo Finance]
Parameters
----------
benchmark_info: Dict
Dictionary containing Yahoo Finance information.
Dictionary containing Yahoo Finance information
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio.
Object containing trades made within the portfolio
Returns
-------
benchmark_assets_allocation: dict
Dictionary with the top 10 of the benchmark's asset allocations.
portfolio_assets_allocation: dict
Dictionary with the portfolio's asset allocations
pd.DataFrame
DataFrame with the top 10 of the benchmark's asset allocations
pd.DataFrame
DataFrame with the portfolio's asset allocations
"""
benchmark_assets_allocation = pd.DataFrame(benchmark_info["holdings"])
benchmark_assets_allocation.rename(
@@ -51,26 +90,26 @@ def get_assets_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
@log_start_end(log=logger)
def get_sector_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
"""Obtain the sector allocation of the benchmark and portfolio [Source: Yahoo Finance]
def get_sectors_allocation(
benchmark_info: Dict, portfolio_trades: pd.DataFrame
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Get sector allocation for benchmark and portfolio [Source: Yahoo Finance]
Parameters
----------
benchmark_info: Dict
Dictionary containing Yahoo Finance information.
Dictionary containing Yahoo Finance information
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio.
Object containing trades made within the portfolio
Returns
-------
regional_allocation: dict
Dictionary with regional allocations.
country_allocation: dict
Dictionary with country allocations
pd.DataFrame
DataFrame with regional allocations.
pd.DataFrame
DataFrame with country allocations
"""
p_bar = tqdm(range(3), desc="Loading sector data")
benchmark_sectors_allocation = (
pd.DataFrame.from_dict(
data={
@@ -91,6 +130,9 @@ def get_sector_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
]
benchmark_sectors_allocation.index = prettified
benchmark_sectors_allocation = pd.DataFrame(benchmark_sectors_allocation)
benchmark_sectors_allocation.reset_index(inplace=True)
benchmark_sectors_allocation.columns = ["Sector", "Benchmark"]
# Define portfolio sector allocation
# Aggregate sector value for stocks and crypto
@@ -99,11 +141,9 @@ def get_sector_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
.groupby(by="Sector")
.agg({"Portfolio Value": "sum"})
)
p_bar.n += 1
p_bar.refresh()
# Aggregate sector value for ETFs
# Start by getting value by isin/ticker
# Start by getting value by isin/symbol
etf_ticker_value = (
portfolio_trades[portfolio_trades["Type"].isin(["ETF"])]
.groupby(by="Ticker")
@@ -111,48 +151,45 @@ def get_sector_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
)
etf_global_sector_alloc = pd.DataFrame()
# Loop through each etf and multiply sector weights by current value
for item in etf_ticker_value.index.values:
if not etf_ticker_value.empty:
# Loop through each etf and multiply sector weights by current value
for item in tqdm(etf_ticker_value.index.values, desc="Loading ETF data"):
# TODO: This can be improved by caching this info similar to what is done in stocks
etf_info = yf.Ticker(item).info
# TODO: This can be improved by caching this info similar to what is done in stocks
etf_info = yf.Ticker(item).info
try:
etf_sector_weight = pd.DataFrame.from_dict(
data={
sector_name: allocation
for sector in etf_info["sectorWeightings"]
for sector_name, allocation in sector.items()
},
orient="index",
columns=["Portfolio Value"],
try:
etf_sector_weight = pd.DataFrame.from_dict(
data={
sector_name: allocation
for sector in etf_info["sectorWeightings"]
for sector_name, allocation in sector.items()
},
orient="index",
columns=["Portfolio Value"],
)
except Exception:
# If ETF has no sectors like VIX for example or it was not found, add to Other
etf_sector_weight = pd.DataFrame.from_dict(
data={"Other": 1}, orient="index", columns=["Portfolio Value"]
)
etf_ticker_sector_alloc = (
etf_sector_weight * etf_ticker_value["Portfolio Value"][item]
)
except Exception:
# If ETF has no sectors like VIX for example or it was not found, add to Other
etf_sector_weight = pd.DataFrame.from_dict(
data={"Other": 1}, orient="index", columns=["Portfolio Value"]
# Aggregate etf sector allocation by value
etf_global_sector_alloc = pd.concat(
[etf_global_sector_alloc, etf_ticker_sector_alloc], axis=1
)
etf_global_sector_alloc.fillna(0, inplace=True)
etf_global_sector_alloc = etf_global_sector_alloc.sum(axis=1)
etf_value = etf_ticker_value["Portfolio Value"][item]
etf_ticker_sector_alloc = etf_sector_weight * etf_value
# Aggregate etf sector allocation by value
etf_global_sector_alloc = pd.concat(
[etf_global_sector_alloc, etf_ticker_sector_alloc], axis=1
etf_global_sector_alloc = pd.DataFrame(
etf_global_sector_alloc, columns=["Portfolio Value"]
)
etf_global_sector_alloc.fillna(0, inplace=True)
etf_global_sector_alloc = etf_global_sector_alloc.sum(axis=1)
p_bar.n += 1
p_bar.refresh()
etf_global_sector_alloc = pd.DataFrame(
etf_global_sector_alloc, columns=["Portfolio Value"]
)
console.print("\n")
# Rename columns to match stock and crypto classification
etf_global_sector_alloc.index.name = "Sector"
@@ -175,51 +212,101 @@ def get_sector_allocation(benchmark_info: Dict, portfolio_trades: pd.DataFrame):
portfolio_sectors_allocation, columns=["Portfolio Value"]
)
portfolio_sectors_allocation = (
portfolio_sectors_allocation.div(portfolio_trades["Portfolio Value"].sum())
.squeeze(axis=1)
.sort_values(ascending=False)
)
portfolio_sectors_allocation = portfolio_sectors_allocation.div(
portfolio_trades["Portfolio Value"].sum()
).sort_values(by="Portfolio Value", ascending=False)
portfolio_sectors_allocation.fillna(0, inplace=True)
p_bar.n += 1
p_bar.refresh()
p_bar.disable = True
console.print("\n")
portfolio_sectors_allocation = pd.DataFrame(portfolio_sectors_allocation)
portfolio_sectors_allocation.reset_index(inplace=True)
portfolio_sectors_allocation.columns = ["Sector", "Portfolio"]
return benchmark_sectors_allocation, portfolio_sectors_allocation
@log_start_end(log=logger)
def get_region_country_allocation(
ticker: str, region_test: list = None, country_test: list = None
):
"""Obtain the region and country allocation for ETF ticker. [Source: Fidelity.com]
def get_countries_allocation(
benchmark_info: Dict, portfolio_trades: pd.DataFrame
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Get countries allocation for benchmark and portfolio [Source: Yahoo Finance]
Parameters
----------
benchmark_ticker: str
The ticker, e.g. "SPY"
region_test: list
This includes a list of region names that should be used to discover
which list on the Fidelity page is the correct one
country_test: list
This includes a list of country names that should be used to discover
which list on the Fidelity page is the correct one
benchmark_info: Dict
Dictionary containing Yahoo Finance information
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio
Returns
-------
region_allocation: dict
Dictionary with regional allocations.
country_allocation: dict
pd.DataFrame
DataFrame with regional allocations.
pd.DataFrame
DataFrame with country allocations
"""
benchmark_allocation = get_symbol_allocation(
symbol=benchmark_info["symbol"], category="Country", col_name="Benchmark"
)
portfolio_allocation = get_portfolio_allocation(
category="Country", portfolio_trades=portfolio_trades
)
return benchmark_allocation, portfolio_allocation
@log_start_end(log=logger)
def get_regions_allocation(
benchmark_info: Dict, portfolio_trades: pd.DataFrame
) -> Tuple[pd.DataFrame, pd.DataFrame]:
"""Get regions allocation for benchmark and portfolio [Source: Yahoo Finance]
Parameters
----------
benchmark_info: Dict
Dictionary containing Yahoo Finance information
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio
Returns
-------
pd.DataFrame
DataFrame with regional allocations.
pd.DataFrame
DataFrame with country allocations
"""
benchmark_allocation = get_symbol_allocation(
symbol=benchmark_info["symbol"], category="Region", col_name="Benchmark"
)
portfolio_allocation = get_portfolio_allocation(
category="Region", portfolio_trades=portfolio_trades
)
return benchmark_allocation, portfolio_allocation
def get_symbol_allocation(
symbol: str, category: str, col_name: str = "Weight"
) -> pd.DataFrame:
"""Get benchmark allocation [Source: Fidelity]
Parameters
----------
symbol: str
ETF symbol to get allocation
category: str
Chosen category: Country or Region
Returns
-------
pd.DataFrame
Dictionary with country allocations
"""
# Initialize variables
if not region_test:
region_test = [
if category == "Region":
category_list = [
"North America",
"Europe",
"Asia",
@@ -227,8 +314,9 @@ def get_region_country_allocation(
"Africa",
"Middle East",
]
if not country_test:
country_test = [
if category == "Country":
category_list = [
"United States",
"United Kingdom",
"Japan",
@@ -236,189 +324,129 @@ def get_region_country_allocation(
"China",
]
region_list = 0
country_list = 0
item_list = 0
# Collect data from Fidelity about the portfolio composition of the benchmark
URL = f"https://screener.fidelity.com/ftgw/etf/goto/snapshot/portfolioComposition.jhtml?symbols={ticker}"
URL = f"https://screener.fidelity.com/ftgw/etf/goto/snapshot/portfolioComposition.jhtml?symbols={symbol}"
html = requests.get(URL).content
df_list = pd.read_html(html)
# Find the ones that contain regions and countries
for index, item in enumerate(df_list):
for region in region_test:
if region in item.values:
region_list = index
break
for country in country_test:
if country in item.values:
country_list = index
for category_item in category_list:
if category_item in item.values:
item_list = index
break
if region_list:
region_allocation = {
if item_list:
allocation = {
row[1]: float(row[2].strip("%")) / 100
for _, row in df_list[region_list].dropna(axis="columns").iterrows()
for _, row in df_list[item_list].dropna(axis="columns").iterrows()
}
region_allocation = pd.DataFrame.from_dict(
region_allocation, orient="index"
).squeeze()
allocation_df = pd.DataFrame.from_dict(allocation, orient="index")
allocation_df.reset_index(inplace=True)
allocation_df.columns = [category, col_name]
else:
region_allocation = pd.DataFrame()
allocation_df = pd.DataFrame(columns=[category, col_name])
if country_list:
country_allocation = {
row[1]: float(row[2].strip("%")) / 100
for _, row in df_list[country_list].dropna(axis="columns").iterrows()
}
country_allocation = pd.DataFrame.from_dict(
country_allocation, orient="index"
).squeeze()
else:
country_allocation = pd.DataFrame()
return region_allocation, country_allocation
return allocation_df
@log_start_end(log=logger)
def get_portfolio_region_country_allocation(portfolio_trades: pd.DataFrame):
"""Obtain the regional and country allocation of the portfolio.
def get_portfolio_allocation(
category: str, portfolio_trades: pd.DataFrame
) -> pd.DataFrame:
"""Get portfolio allocation
Parameters
----------
category: str
Chosen category: Country or Region
portfolio_trades: pd.DataFrame
Object containing trades made within the portfolio.
Object containing trades made within the portfolio
Returns
------
portfolio_regional_allocation: pd.DataFrame
Dictionary with regional allocations.
portfolio_country_allocation: pd.DataFrame
-------
pd.DataFrame
Dictionary with country allocations
"""
p_bar = tqdm(range(3), desc="Loading country/region data")
# Define portfolio regional allocation
if not portfolio_trades["Region"].isnull().any():
portfolio_region_allocation = (
# Define portfolio allocation
if not portfolio_trades[category].isnull().any():
allocation = (
portfolio_trades[portfolio_trades["Type"].isin(["STOCK", "CRYPTO"])]
.groupby(by="Region")
.groupby(by=category)
.agg({"Portfolio Value": "sum"})
)
else:
portfolio_region_allocation = pd.DataFrame()
# Define portfolio country allocation
if not portfolio_trades["Country"].isnull().any():
portfolio_country_allocation = (
portfolio_trades[portfolio_trades["Type"].isin(["STOCK", "CRYPTO"])]
.groupby(by="Country")
.agg({"Portfolio Value": "sum"})
)
else:
portfolio_country_allocation = pd.DataFrame()
p_bar.n += 1
p_bar.refresh()
allocation = pd.DataFrame()
# Aggregate sector value for ETFs
# Start by getting value by ticker
# Start by getting value by symbol
etf_ticker_value = (
portfolio_trades[portfolio_trades["Type"].isin(["ETF"])]
.groupby(by="Ticker")
.agg({"Portfolio Value": "sum"})
)
etf_global_region_alloc = pd.DataFrame()
etf_global_country_alloc = pd.DataFrame()
etf_global_alloc = pd.DataFrame(columns=[category, "Portfolio Value"])
# Loop through each etf and multiply sector weights by current value
for item in etf_ticker_value.index.values:
if not etf_ticker_value.empty:
etf_region_weight, etf_country_weight = get_region_country_allocation(item)
no_info = []
# Loop through each etf and multiply sector weights by current value
for item in tqdm(etf_ticker_value.index.values, desc="Loading ETF data"):
if etf_region_weight.empty:
# If ETF has no sectors like VIX for example or it was not found, add to Other
etf_region_weight = pd.DataFrame.from_dict(
data={"Other": 1}, orient="index", columns=["Portfolio Value"]
etf_weight = get_symbol_allocation(
symbol=item, category=category, col_name="Portfolio Value"
)
if etf_country_weight.empty:
etf_country_weight = pd.DataFrame.from_dict(
data={"Other": 1}, orient="index", columns=["Portfolio Value"]
if etf_weight.empty:
etf_weight = pd.DataFrame.from_dict(
data={"Other": 1}, orient="index", columns=["Portfolio Value"]
)
etf_weight.index.name = category
no_info.append(item)
else:
etf_weight.set_index(category, inplace=True)
# Aggregate etf allocation by value
etf_ticker_alloc = etf_weight
etf_ticker_alloc["Portfolio Value"] = (
etf_ticker_alloc["Portfolio Value"]
* etf_ticker_value["Portfolio Value"][item]
)
etf_global_alloc = pd.concat([etf_global_alloc, etf_ticker_alloc], axis=1)
etf_global_alloc.fillna(0, inplace=True)
etf_global_alloc = etf_global_alloc.sum(axis=1)
etf_global_alloc = pd.DataFrame(etf_global_alloc, columns=["Portfolio Value"])
console.print("")
if no_info:
console.print(
f"[red]No data found for: {', '.join(no_info)}. Included in 'Other'.[/red]\n"
)
etf_value = etf_ticker_value["Portfolio Value"][item]
# Aggregate etf region allocation by value
etf_ticker_region_alloc = etf_region_weight * etf_value
etf_global_region_alloc = pd.concat(
[etf_global_region_alloc, etf_ticker_region_alloc], axis=1
)
etf_global_region_alloc.fillna(0, inplace=True)
etf_global_region_alloc = etf_global_region_alloc.sum(axis=1)
# Aggregate etf country allocation by value
etf_ticker_country_alloc = etf_country_weight * etf_value
etf_global_country_alloc = pd.concat(
[etf_global_country_alloc, etf_ticker_country_alloc], axis=1
)
etf_global_country_alloc.fillna(0, inplace=True)
etf_global_country_alloc = etf_global_country_alloc.sum(axis=1)
p_bar.n += 1
p_bar.refresh()
etf_global_region_alloc = pd.DataFrame(
etf_global_region_alloc, columns=["Portfolio Value"]
)
etf_global_country_alloc = pd.DataFrame(
etf_global_country_alloc, columns=["Portfolio Value"]
)
# Aggregate region allocation for stocks and crypto with ETFs
portfolio_region_allocation = pd.merge(
portfolio_region_allocation,
etf_global_region_alloc,
# Aggregate allocation for stocks and crypto with ETFs
allocation = pd.merge(
allocation,
etf_global_alloc,
how="outer",
left_index=True,
right_index=True,
).sum(axis=1)
# Aggregate country allocation for stocks and crypto with ETFs
portfolio_country_allocation = pd.merge(
portfolio_country_allocation,
etf_global_country_alloc,
how="outer",
left_index=True,
right_index=True,
).sum(axis=1)
allocation = pd.DataFrame(allocation, columns=["Portfolio Value"])
portfolio_region_allocation = pd.DataFrame(
portfolio_region_allocation, columns=["Portfolio Value"]
)
portfolio_country_allocation = pd.DataFrame(
portfolio_country_allocation, columns=["Portfolio Value"]
allocation = allocation.div(portfolio_trades["Portfolio Value"].sum()).sort_values(
by="Portfolio Value", ascending=False
)
portfolio_region_allocation = (
portfolio_region_allocation.div(portfolio_trades["Portfolio Value"].sum())
.squeeze(axis=1)
.sort_values(ascending=False)
)
allocation.fillna(0, inplace=True)
portfolio_country_allocation = (
portfolio_country_allocation.div(portfolio_trades["Portfolio Value"].sum())
.squeeze(axis=1)
.sort_values(ascending=False)
)
allocation.reset_index(inplace=True)
portfolio_region_allocation.fillna(0, inplace=True)
portfolio_country_allocation.fillna(0, inplace=True)
allocation.columns = [category, "Portfolio"]
p_bar.n += 1
p_bar.refresh()
p_bar.disable = True
console.print("\n")
return portfolio_region_allocation, portfolio_country_allocation
return allocation

View File

@@ -22,7 +22,7 @@ from openbb_terminal.helper_funcs import (
from openbb_terminal.menu import session
from openbb_terminal.core.config.paths import MISCELLANEOUS_DIRECTORY
from openbb_terminal.parent_classes import BaseController
from openbb_terminal.portfolio import portfolio_model
from openbb_terminal.portfolio.portfolio_model import generate_portfolio
from openbb_terminal.portfolio import statics
from openbb_terminal.portfolio import portfolio_view
from openbb_terminal.portfolio import portfolio_helper
@@ -139,9 +139,7 @@ class PortfolioController(BaseController):
self.original_benchmark_name = ""
self.risk_free_rate = 0
self.portlist: List[str] = os.listdir(self.DEFAULT_HOLDINGS_PATH)
self.portfolio: portfolio_model.PortfolioModel = (
portfolio_model.PortfolioModel()
)
self.portfolio = None
if session and obbff.USE_PROMPT_TOOLKIT:
self.update_choices()
@@ -442,33 +440,26 @@ class PortfolioController(BaseController):
else:
file_location = ns_parser.file # type: ignore
transactions = portfolio_model.PortfolioModel.read_transactions(
str(file_location)
self.portfolio = generate_portfolio(
transactions_file_path=str(file_location),
benchmark_symbol="SPY",
risk_free_rate=ns_parser.risk_free_rate / 100,
)
self.portfolio = portfolio_model.PortfolioModel(transactions)
self.benchmark_name = ""
if ns_parser.name:
self.portfolio_name = ns_parser.name
else:
self.portfolio_name = ns_parser.file
# Generate holdings from trades
self.portfolio.generate_portfolio_data()
# Add in the Risk-free rate
self.portfolio.set_risk_free_rate(ns_parser.risk_free_rate / 100)
self.risk_free_rate = ns_parser.risk_free_rate / 100
# Load benchmark
self.call_bench(["-b", "SPDR S&P 500 ETF Trust (SPY)"])
console.print(
f"\n[bold][param]Portfolio:[/param][/bold] {self.portfolio_name}"
)
self.benchmark_name = "SPDR S&P 500 ETF Trust (SPY)"
console.print(
f"[bold][param]Risk Free Rate:[/param][/bold] {self.risk_free_rate:.2%}"
)
self.risk_free_rate = ns_parser.risk_free_rate / 100
console.print(
f"[bold][param]Benchmark:[/param][/bold] {self.benchmark_name}\n"
)
@@ -538,19 +529,10 @@ class PortfolioController(BaseController):
else:
benchmark_ticker = chosen_benchmark
self.portfolio.load_benchmark(benchmark_ticker, ns_parser.full_shares)
self.portfolio.set_benchmark(benchmark_ticker, ns_parser.full_shares)
self.benchmark_name = chosen_benchmark
# Make it so that there is no chance of there being a difference in length between
# the portfolio and benchmark return DataFrames
(
self.portfolio.returns,
self.portfolio.benchmark_returns,
) = portfolio_helper.make_equal_length(
self.portfolio.returns, self.portfolio.benchmark_returns
)
else:
console.print(
"[red]Please first load transactions file using 'load'[/red]\n"
@@ -596,41 +578,26 @@ class PortfolioController(BaseController):
self.portfolio_name, self.benchmark_name
):
if ns_parser.agg == "assets":
if self.portfolio.portfolio_assets_allocation.empty:
self.portfolio.calculate_allocations("asset")
portfolio_view.display_assets_allocation(
self.portfolio.portfolio_assets_allocation,
self.portfolio.benchmark_assets_allocation,
self.portfolio,
ns_parser.limit,
ns_parser.tables,
)
elif ns_parser.agg == "sectors":
if self.portfolio.portfolio_sectors_allocation.empty:
self.portfolio.calculate_allocations("sector")
portfolio_view.display_category_allocation(
self.portfolio.portfolio_sectors_allocation,
self.portfolio.benchmark_sectors_allocation,
ns_parser.agg,
portfolio_view.display_sectors_allocation(
self.portfolio,
ns_parser.limit,
ns_parser.tables,
)
elif ns_parser.agg == "countries":
if self.portfolio.portfolio_country_allocation.empty:
self.portfolio.calculate_allocations("country")
portfolio_view.display_category_allocation(
self.portfolio.portfolio_country_allocation,
self.portfolio.benchmark_country_allocation,
ns_parser.agg,
portfolio_view.display_countries_allocation(
self.portfolio,
ns_parser.limit,
ns_parser.tables,
)
elif ns_parser.agg == "regions":
if self.portfolio.portfolio_region_allocation.empty:
self.portfolio.calculate_allocations("region")
portfolio_view.display_category_allocation(
self.portfolio.portfolio_region_allocation,
self.portfolio.benchmark_region_allocation,
ns_parser.agg,
portfolio_view.display_regions_allocation(
self.portfolio,
ns_parser.limit,
ns_parser.tables,
)
@@ -909,7 +876,7 @@ class PortfolioController(BaseController):
)
else:
portfolio_view.display_var(
portfolio=self.portfolio,
portfolio_engine=self.portfolio,
use_mean=ns_parser.use_mean,
adjusted_var=ns_parser.adjusted,
student_t=ns_parser.student_t,
@@ -966,7 +933,7 @@ class PortfolioController(BaseController):
if ns_parser and self.portfolio is not None:
if self.portfolio_name:
portfolio_view.display_es(
portfolio=self.portfolio,
portfolio_engine=self.portfolio,
use_mean=ns_parser.use_mean,
distribution=ns_parser.distribution,
percentile=ns_parser.percentile,
@@ -1277,7 +1244,7 @@ class PortfolioController(BaseController):
self.portfolio_name, self.benchmark_name
):
portfolio_view.display_rolling_sortino(
portfolio=self.portfolio,
portfolio_engine=self.portfolio,
risk_free_rate=ns_parser.risk_free_rate / 100,
window=ns_parser.period,
export=ns_parser.export,

View File

@@ -1046,7 +1046,7 @@ def get_kelly_criterion(
if (not period_return.empty) and (not period_portfolio_tr.empty):
w = len(period_return[period_return > 0]) / len(period_return)
r = len(
period_portfolio_tr[period_portfolio_tr["% Portfolio Return"] > 0]
period_portfolio_tr[period_portfolio_tr["Portfolio % Return"] > 0]
) / len(
period_portfolio_tr[period_portfolio_tr["Type"].str.upper() != "CASH"]
)
@@ -1086,10 +1086,10 @@ def get_payoff_ratio(portfolio_trades: pd.DataFrame) -> pd.DataFrame:
period_portfolio_tr = filter_df_by_period(portfolio_trades, period)
if not portfolio_trades.empty:
portfolio_wins = period_portfolio_tr[
period_portfolio_tr["% Portfolio Return"] > 0
period_portfolio_tr["Portfolio % Return"] > 0
]
portfolio_loses = period_portfolio_tr[
period_portfolio_tr["% Portfolio Return"] < 0
period_portfolio_tr["Portfolio % Return"] < 0
]
if portfolio_loses.empty:
vals.append(["-"])
@@ -1140,10 +1140,10 @@ def get_profit_factor(portfolio_trades: pd.DataFrame) -> pd.DataFrame:
period_portfolio_tr = filter_df_by_period(portfolio_trades, period)
if not portfolio_trades.empty:
portfolio_wins = period_portfolio_tr[
period_portfolio_tr["% Portfolio Return"] > 0
period_portfolio_tr["Portfolio % Return"] > 0
]
portfolio_loses = period_portfolio_tr[
period_portfolio_tr["% Portfolio Return"] < 0
period_portfolio_tr["Portfolio % Return"] < 0
]
if portfolio_loses.empty:
vals.append(["-"])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -35,8 +35,7 @@
"\n",
"from openbb_terminal.reports import widget_helpers as widgets\n",
"from openbb_terminal.sdk import openbb\n",
"from openbb_terminal.sdk import openbb import helper\n",
"from openbb_terminal.sdk import openbb import Portfolio\n",
"from openbb_terminal.sdk import helper\n",
"from openbb_terminal.helper_classes import TerminalStyle\n",
"from openbb_terminal.core.config.paths import REPOSITORY_DIRECTORY\n",
"\n",
@@ -90,7 +89,7 @@
"source": [
"# Parameters that will be replaced when calling this notebook\n",
"# Do not leave parameters blank as notebook will not run otherwise\n",
"transactions = \"Public_Equity_Orderbook.xlsx\"\n",
"transactions = \"market.csv\"\n",
"report_name = \"Portfolio Report\""
]
},
@@ -138,11 +137,8 @@
"outputs": [],
"source": [
"try:\n",
" transactions = Portfolio.read_transactions(transactions_path)\n",
" P = Portfolio(transactions)\n",
" P.generate_portfolio_data()\n",
" P.load_benchmark()\n",
" P.get_transactions()\n",
" P = openbb.portfolio.load(transactions_path)\n",
" openbb.portfolio.show(P)\n",
"except ValueError:\n",
" raise ValueError(\n",
" \"Failed to load the transactions. Is this file inside the 'holdings' folder?\"\n",
@@ -205,7 +201,7 @@
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(11, 5), dpi=150)\n",
"openbb.portfolio.rsortino(P, chart=True, external_axes=[ax])\n",
"openbb.portfolio.rsort(P, chart=True, external_axes=[ax])\n",
"\n",
"fig.tight_layout()\n",
"f = io.BytesIO()\n",
@@ -236,19 +232,17 @@
"metadata": {},
"outputs": [],
"source": [
"P.calculate_allocations(\"country\")\n",
"country_allocation = openbb.portfolio.alloc.countries(P)\n",
"\n",
"country_allocation = pd.DataFrame(\n",
" [P.portfolio_country_allocation, P.benchmark_country_allocation]\n",
").T\n",
"country_allocation.columns = [\"Portfolio\", \"Benchmark\"]\n",
"country_allocation.fillna(\"-\", inplace=True)\n",
"country_allocation[\"Portfolio\"] = (country_allocation[\"Portfolio\"] * 100).map(\n",
" \"{:.3}%\".format\n",
")\n",
"country_allocation[\"Benchmark\"] = (country_allocation[\"Benchmark\"] * 100).map(\n",
" \"{:.3}%\".format\n",
")\n",
"country_allocation[\"Difference\"] = (country_allocation[\"Difference\"] * 100).map(\n",
" \"{:.3}pp\".format\n",
")\n",
"\n",
"country_allocation"
]
@@ -260,19 +254,17 @@
"metadata": {},
"outputs": [],
"source": [
"P.calculate_allocations(\"sector\")\n",
"sector_allocation = openbb.portfolio.alloc.sectors(P)\n",
"\n",
"sector_allocation = pd.DataFrame(\n",
" [P.portfolio_sectors_allocation, P.benchmark_sectors_allocation]\n",
").T\n",
"sector_allocation.columns = [\"Portfolio\", \"Benchmark\"]\n",
"sector_allocation.fillna(\"-\", inplace=True)\n",
"sector_allocation[\"Portfolio\"] = (sector_allocation[\"Portfolio\"] * 100).map(\n",
" \"{:.3}%\".format\n",
")\n",
"sector_allocation[\"Benchmark\"] = (sector_allocation[\"Benchmark\"] * 100).map(\n",
" \"{:.3}%\".format\n",
")\n",
"sector_allocation[\"Difference\"] = (sector_allocation[\"Difference\"] * 100).map(\n",
" \"{:.3}pp\".format\n",
")\n",
"\n",
"sector_allocation"
]
@@ -413,24 +405,24 @@
")\n",
"\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Tracking Error\") + openbb.portfolio.trackerr(P)[0].to_html()]\n",
" [widgets.h(3, \"Tracking Error\") + openbb.portfolio.metric.trackerr(P)[0].to_html()]\n",
")\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Information Ratio\") + openbb.portfolio.information(P).to_html()]\n",
" [widgets.h(3, \"Information Ratio\") + openbb.portfolio.metric.information(P).to_html()]\n",
")\n",
"\n",
"htmlcode += widgets.row([widgets.h(3, \"Beta Chart\") + beta_chart])\n",
"\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Sharpe Ratio\") + openbb.portfolio.sharpe(P).to_html()]\n",
" [widgets.h(3, \"Sharpe Ratio\") + openbb.portfolio.metric.sharpe(P).to_html()]\n",
")\n",
"htmlcode += widgets.row([widgets.h(3, \"Sharpe Ratio Chart\") + sharpe_chart])\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Volatility\") + openbb.portfolio.volatility(P).to_html()]\n",
" [widgets.h(3, \"Volatility\") + openbb.portfolio.metric.volatility(P).to_html()]\n",
")\n",
"htmlcode += widgets.row([widgets.h(3, \"Volatility Chart\") + volatility_chart])\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Sortino Ratio\") + openbb.portfolio.sortino(P).to_html()]\n",
" [widgets.h(3, \"Sortino Ratio\") + openbb.portfolio.metric.sortino(P).to_html()]\n",
")\n",
"htmlcode += widgets.row([widgets.h(3, \"Sortino Chart\") + sortino_chart])\n",
"\n",
@@ -443,12 +435,12 @@
"htmlcode = widgets.row([widgets.h(3, \"Distribution\") + distr_chart])\n",
"htmlcode += widgets.row([widgets.h(3, \"Daily Returns\") + dret_chart])\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Volatility\") + openbb.portfolio.volatility(P).to_html()]\n",
" [widgets.h(3, \"Volatility\") + openbb.portfolio.metric.volatility(P).to_html()]\n",
")\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Kurtosis\") + openbb.portfolio.kurtosis(P).to_html()]\n",
" [widgets.h(3, \"Kurtosis\") + openbb.portfolio.metric.kurtosis(P).to_html()]\n",
")\n",
"htmlcode += widgets.row([widgets.h(3, \"Skew\") + openbb.portfolio.skew(P).to_html()])\n",
"htmlcode += widgets.row([widgets.h(3, \"Skew\") + openbb.portfolio.metric.skew(P).to_html()])\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Value at Risk (VaR)\") + openbb.portfolio.var(P).to_html()]\n",
")\n",
@@ -474,7 +466,7 @@
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3.10.4 ('obb')",
"display_name": "Python 3.9.13 ('obb')",
"language": "python",
"name": "python3"
},
@@ -488,11 +480,11 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.9.13"
},
"vscode": {
"interpreter": {
"hash": "1a8cc6b6e60740679b24fc1ea93bdeb94d949a22102a80c99b7fd3f0d572afd6"
"hash": "e784374cc4f9a84ed6af2983247aaf351b155c82bcc2188134a65f3c99031000"
}
}
},

View File

@@ -3,9 +3,6 @@ from openbb_terminal.config_terminal import theme # noqa: F401
from openbb_terminal.helper_classes import TerminalStyle
from openbb_terminal import helper_funcs as helper # noqa: F401
from openbb_terminal.reports import widget_helpers as widgets # noqa: F401
from openbb_terminal.portfolio.portfolio_model import ( # noqa: F401
PortfolioModel as Portfolio,
)
from openbb_terminal.cryptocurrency.due_diligence.pycoingecko_model import ( # noqa: F401
Coin,
)

View File

@@ -17,7 +17,7 @@ crypto.dd.active(
symbol: str,
interval: str = '24h',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -60,7 +60,7 @@ crypto.dd.active(
crypto.dd.active(
symbol: str,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
interval: str = '24h',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -17,7 +17,7 @@ crypto.dd.change(
symbol: str,
exchange: str = 'binance',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -61,7 +61,7 @@ crypto.dd.change(
symbol: str,
exchange: str = 'binance',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -14,7 +14,7 @@
crypto.dd.close(
symbol: str,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
print_errors: bool = True,
chart: bool = False,
) -> pandas.core.frame.DataFrame

View File

@@ -17,7 +17,7 @@ crypto.dd.eb(
symbol: str,
exchange: str = 'binance',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -61,7 +61,7 @@ crypto.dd.eb(
symbol: str,
exchange: str = 'binance',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
percentage: bool = False,
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -17,8 +17,8 @@ crypto.dd.gh(
symbol: str,
dev_activity: bool = False,
interval: str = '1d',
start_date: str = '2021-11-10T20:12:25Z',
end_date: str = '2022-11-10T20:12:25Z',
start_date: str = '2021-11-14T14:32:50Z',
end_date: str = '2022-11-14T14:32:50Z',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -63,9 +63,9 @@ crypto.dd.gh(
{{< highlight python >}}
crypto.dd.gh(
symbol: str,
start_date: str = '2021-11-10T20:12:25Z',
start_date: str = '2021-11-14T14:32:50Z',
dev_activity: bool = False,
end_date: str = '2022-11-10T20:12:25Z',
end_date: str = '2022-11-14T14:32:50Z',
interval: str = '1d',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -16,8 +16,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
crypto.dd.mcapdom(
symbol: str,
interval: str = '1d',
start_date: str = '2021-11-10',
end_date: str = '2022-11-10',
start_date: str = '2021-11-14',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -59,8 +59,8 @@ crypto.dd.mcapdom(
{{< highlight python >}}
crypto.dd.mcapdom(
symbol: str,
start_date: str = '2021-11-10',
end_date: str = '2022-11-10',
start_date: str = '2021-11-14',
end_date: str = '2022-11-14',
interval: str = '1d',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -17,8 +17,8 @@ crypto.dd.mt(
symbol: str,
timeseries_id: str,
interval: str = '1d',
start_date: str = '2021-11-10',
end_date: str = '2022-11-10',
start_date: str = '2021-11-14',
end_date: str = '2022-11-14',
chart: bool = False,
) -> Tuple[pandas.core.frame.DataFrame, str]
{{< /highlight >}}
@@ -65,8 +65,8 @@ crypto.dd.mt(
crypto.dd.mt(
symbol: str,
timeseries_id: str,
start_date: str = '2021-11-10',
end_date: str = '2022-11-10',
start_date: str = '2021-11-14',
end_date: str = '2022-11-14',
interval: str = '1d',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -16,7 +16,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
crypto.dd.nonzero(
symbol: str,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -57,7 +57,7 @@ crypto.dd.nonzero(
crypto.dd.nonzero(
symbol: str,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -73,7 +73,7 @@ crypto.dd.oi(
interval : int
Frequency (possible values are: 0 for ALL, 2 for 1H, 1 for 4H, 4 for 12H), by default 0
export : str
Export dataframe data to csv,json,xlsx fil
Export dataframe data to csv,json,xlsx file
chart: bool
Flag to display chart

View File

@@ -13,12 +13,10 @@
{{< highlight python >}}
crypto.load(
symbol: 'str',
start_date: 'Optional[Union[datetime, str]]' = None,
interval: 'str' = '1440',
start_date: 'datetime | str | None' = None, interval: 'str' = '1440',
exchange: 'str' = 'binance',
vs_currency: 'str' = 'usdt',
end_date: 'Optional[Union[datetime, str]]' = None,
source: 'str' = 'CCXT',
end_date: 'datetime | str | None' = None, source: 'str' = 'CCXT',
chart: bool = False,
) -> 'pd.DataFrame'
{{< /highlight >}}

View File

@@ -38,7 +38,7 @@ crypto.onchain.btc_supply() -> pandas.core.frame.DataFrame
{{< highlight python >}}
crypto.onchain.btc_supply(
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -38,7 +38,7 @@ crypto.onchain.btc_transac() -> pandas.core.frame.DataFrame
{{< highlight python >}}
crypto.onchain.btc_transac(
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -17,7 +17,7 @@ crypto.onchain.hr(
symbol: str,
interval: str = '24h',
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -60,7 +60,7 @@ crypto.onchain.hr(
crypto.onchain.hr(
symbol: str,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
interval: str = '24h',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -16,7 +16,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
crypto.ov.altindex(
period: int = 30,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -59,7 +59,7 @@ crypto.ov.altindex(
crypto.ov.altindex(
period: int = 365,
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -15,7 +15,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
crypto.ov.btcrb(
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
)
{{< /highlight >}}
@@ -49,7 +49,7 @@ crypto.ov.btcrb(
{{< highlight python >}}
crypto.ov.btcrb(
start_date: str = '2010-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -13,8 +13,8 @@
{{< highlight python >}}
economy.events(
countries: Union[List[str], str] = '',
start_date: str = '2022-11-10',
end_date: str = '2022-11-10',
start_date: str = '2022-11-14',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}

View File

@@ -19,7 +19,7 @@ economy.macro(
transform: str = '',
start_date: str = '1900-01-01',
end_date=datetime.date(
2022, 11, 10, chart: bool = False,
2022, 11, 14, chart: bool = False,
), symbol: str = '',
chart: bool = False,
) -> Tuple[Any, Dict[Any, Dict[Any, Any]], str]
@@ -72,7 +72,7 @@ economy.macro(
countries: list = None,
transform: str = '',
start_date: str = '1900-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
symbol: str = '',
raw: bool = False,
external_axes: Optional[List[axes]] = None,

View File

@@ -18,7 +18,7 @@ economy.treasury(
maturities: list = None,
frequency: str = 'monthly',
start_date: str = '1900-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -65,7 +65,7 @@ economy.treasury(
maturities: list = None,
frequency: str = 'monthly',
start_date: str = '1900-01-01',
end_date: str = '2022-11-10',
end_date: str = '2022-11-14',
raw: bool = False,
external_axes: Optional[List[axes]] = None,
export: str = '',

View File

@@ -19,9 +19,9 @@ etf.candle(
add_trend: bool = False,
ma: Optional[Iterable[int]] = None,
asset_type: str = '',
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06',
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-10',
interval: int = 1440,
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10',
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-14',
prepost: bool = False,
source: str = 'YahooFinance',
iexrange: str = 'ytd',

View File

@@ -13,9 +13,9 @@
{{< highlight python >}}
etf.load(
symbol: str,
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06',
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-10',
interval: int = 1440,
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10',
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-14',
prepost: bool = False,
source: str = 'YahooFinance',
iexrange: str = 'ytd',

View File

@@ -16,7 +16,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
etf.news(
query: str,
limit: int = 10,
start_date: str = '2022-11-03',
start_date: str = '2022-11-07',
show_newest: bool = True,
sources: str = '',
chart: bool = False,
@@ -60,7 +60,7 @@ etf.news(
etf.news(
query: str,
limit: int = 3,
start_date: str = '2022-11-03',
start_date: str = '2022-11-07',
show_newest: bool = True,
sources: str = '',
export: str = '',

View File

@@ -17,5 +17,5 @@ forex.get_currency_list() -> List
.. raw:: html
<p>
Load AV currency codes from a local file
Load AV currency codes from a local file.
</p>

View File

@@ -16,7 +16,7 @@ forex.load(
from_symbol: str,
resolution: str = 'd',
interval: str = '1day',
start_date: str = '2021-11-10',
start_date: str = '2021-11-14',
source: str = 'YahooFinance',
verbose: bool = False,
chart: bool = False,

View File

@@ -53,7 +53,7 @@ futures.historical(
futures.historical(
symbols: List[str],
expiry: str = '',
start_date: str = '2019-11-11',
start_date: str = '2019-11-15',
raw: bool = False,
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,

View File

@@ -1,7 +1,7 @@
---
title: Introduction to Portfolio
keywords: "portfolio, attribution, optimization, pnl, benchmark, return, volatility, metrics, broker, integration, report"
excerpt: "The Introduction to Portfolio explains how to use the
excerpt: "The Introduction to Portfolio explains how to use the
menu and provides a brief description of its sub-menus"
geekdocCollapseSection: true
---
@@ -33,7 +33,7 @@ The SDK commands of the the menu:
<openbb>.portfolio.maxdd
<openbb>.portfolio.rvol
<openbb>.portfolio.rsharpe
<openbb>.portfolio.rsortino
<openbb>.portfolio.rsort
<openbb>.portfolio.rbeta
<openbb>.portfolio.summary
<openbb>.portfolio.skew
@@ -50,7 +50,7 @@ in the following:
from openbb_terminal.sdk import Portfolio
# Define your own orderbook location here
orderbook_path = "Public_Equity_Orderbook.xlsx"
orderbook_path = "Public_Equity_Orderbook.xlsx"
# Load in the transactions
transactions = Portfolio.read_orderbook(orderbook_path)
@@ -58,7 +58,7 @@ P = Portfolio(transactions)
P.generate_portfolio_data()
# Load in the benchmark, by default this is the SPY ETF
P.load_benchmark()
P.set_benchmark()
```
Note that the Excel sheet requires the following columns:
@@ -134,7 +134,7 @@ takes a bit longer to load.
from openbb_terminal.sdk import Portfolio
# Define your own orderbook location here
orderbook_path = "Public_Equity_Orderbook_No_Categorization.xlsx"
orderbook_path = "Public_Equity_Orderbook_No_Categorization.xlsx"
# Load in the transactions
transactions = Portfolio.read_orderbook(orderbook_path)
@@ -142,7 +142,7 @@ P = Portfolio(transactions)
P.generate_portfolio_data()
# Load in the benchmark, by default this is the SPY ETF
P.load_benchmark()
P.set_benchmark()
```
Then, we can show our performance compared to that of the benchmark.

View File

@@ -0,0 +1,6 @@
---
title: alloc
keywords: ""
excerpt: ""
geekdocCollapseSection: true
---

View File

@@ -0,0 +1,52 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.alloc.assets(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
tables: bool = False,
limit: int = 10,
recalculate: bool = False,
chart: bool = False,
) -> Union[pandas.core.frame.DataFrame, Tuple[pandas.core.frame.DataFrame, pandas.core.frame.DataFrame, pandas.core.frame.DataFrame]]
{{< /highlight >}}
.. raw:: html
<p>
Display portfolio asset allocation compared to the benchmark
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
tables: bool
Whether to include separate allocation tables
limit: int
The amount of assets you wish to show, by default this is set to 10
recalculate: bool
Flag to force recalculate allocation if already exists
* **Returns**
Union[pd.DataFrame, Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]]
DataFrame with combined allocation plus individual allocation if tables is `True`.
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.alloc.assets(P)
{{< /highlight >}}

View File

@@ -0,0 +1,51 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.alloc.countries(
portfolio_engine=None, limit: int = 10,
tables: bool = False,
recalculate: bool = False,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Display portfolio country allocation compared to the benchmark
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
tables: bool
Whether to include separate allocation tables
limit: int
The amount of assets you wish to show, by default this is set to 10
recalculate: bool
Flag to force recalculate allocation if already exists
* **Returns**
Union[pd.DataFrame, Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]]
DataFrame with combined allocation plus individual allocation if tables is `True`.
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.alloc.countries(P)
{{< /highlight >}}

View File

@@ -0,0 +1,51 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.alloc.regions(
portfolio_engine=None, limit: int = 10,
tables: bool = False,
recalculate: bool = False,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Display portfolio region allocation compared to the benchmark
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
tables: bool
Whether to include separate allocation tables
limit: int
The amount of assets you wish to show, by default this is set to 10
recalculate: bool
Flag to force recalculate allocation if already exists
* **Returns**
Union[pd.DataFrame, Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]]
DataFrame with combined allocation plus individual allocation if tables is `True`.
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.alloc.regions(P)
{{< /highlight >}}

View File

@@ -0,0 +1,51 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.alloc.sectors(
portfolio_engine=None, limit: int = 10,
tables: bool = False,
recalculate: bool = False,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Display portfolio sector allocation compared to the benchmark
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
tables: bool
Whether to include separate allocation tables
limit: int
The amount of assets you wish to show, by default this is set to 10
recalculate: bool
Flag to force recalculate allocation if already exists
* **Returns**
Union[pd.DataFrame, Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]]
DataFrame with combined allocation plus individual allocation if tables is `True`.
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.alloc.sectors(P)
{{< /highlight >}}

View File

@@ -0,0 +1,44 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.bench(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
symbol: str,
full_shares: bool = False,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Load benchmark into portfolio
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine object
symbol: str
Benchmark symbol to download data
full_shares: bool
Whether to mimic the portfolio trades exactly (partial shares) or round down the
quantity to the nearest number
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.bench(P, symbol="SPY")
{{< /highlight >}}

View File

@@ -1,39 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.calmar(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
window: int = 756,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get calmar ratio
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
window: int
Interval used for rolling values
* **Returns**
pd.DataFrame
DataFrame of calmar ratio of the benchmark and portfolio during different time periods
pd.Series
Series of calmar ratio data

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.commonsense(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get common sense ratio
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame of the portfolios and the benchmarks common sense ratio during different time periods

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.distr(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
chart: bool = False,
)
@@ -28,14 +28,23 @@ portfolio.distr(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
chart: bool
Flag to display chart
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.distr(P)
{{< /highlight >}}
|
.. raw:: html
@@ -46,7 +55,7 @@ portfolio.distr(
{{< highlight python >}}
portfolio.distr(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
raw: bool = False,
export: str = '',

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.dret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -28,8 +28,9 @@ portfolio.dret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
chart: bool
@@ -39,6 +40,15 @@ portfolio.dret(
* **Returns**
pd.DataFrame
DataFrame with daily returns
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.dret(P)
{{< /highlight >}}
|
@@ -50,7 +60,7 @@ portfolio.dret(
{{< highlight python >}}
portfolio.dret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
raw: bool = False,
limit: int = 10,
@@ -68,8 +78,9 @@ portfolio.dret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
raw : False

View File

@@ -12,7 +12,7 @@
{{< highlight python >}}
portfolio.es(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
use_mean: bool = False,
distribution: str = 'normal',
percentile: float = 99.9,
@@ -28,8 +28,9 @@ portfolio.es(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
use_mean:
if one should use the data mean return
distribution: str
@@ -40,3 +41,12 @@ portfolio.es(
* **Returns**
pd.DataFrame
DataFrame with portfolio expected shortfall
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.es(P)
{{< /highlight >}}

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.gaintopain(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get Pain-to-Gain ratio based on historical data
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame of the portfolio's gain-to-pain ratio

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.holdp(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
@@ -27,12 +27,21 @@ portfolio.holdp(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
chart: bool
Flag to display chart
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.holdp(P)
{{< /highlight >}}
|
.. raw:: html
@@ -43,7 +52,7 @@ portfolio.holdp(
{{< highlight python >}}
portfolio.holdp(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
unstack: bool = False,
raw: bool = False,
limit: int = 10,
@@ -61,8 +70,9 @@ portfolio.holdp(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
unstack: bool
Individual assets over time
raw : bool

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.holdv(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -27,8 +27,9 @@ portfolio.holdv(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
chart: bool
Flag to display chart
@@ -38,6 +39,14 @@ portfolio.holdv(
pd.DataFrame
DataFrame of holdings
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.holdv(P)
{{< /highlight >}}
|
.. raw:: html
@@ -48,7 +57,7 @@ portfolio.holdv(
{{< highlight python >}}
portfolio.holdv(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
unstack: bool = False,
raw: bool = False,
limit: int = 10,
@@ -66,8 +75,9 @@ portfolio.holdv(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
unstack: bool
Individual assets over time
raw : bool

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.information(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get information ratio
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame of the information ratio during different time periods

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.kelly(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets kelly criterion
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame of kelly criterion of the portfolio during different time periods

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.kurtosis(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves kurtosis for portfolio and benchmark selected
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame with kurtosis for portfolio and benchmark for different periods

View File

@@ -0,0 +1,51 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.load(
transactions_file_path: str,
benchmark_symbol: str = 'SPY',
full_shares: bool = False,
risk_free_rate: float = 0,
chart: bool = False,
) -> openbb_terminal.portfolio.portfolio_model.PortfolioEngine
{{< /highlight >}}
.. raw:: html
<p>
Get PortfolioEngine object
</p>
* **Parameters**
transactions_file_path : str
Path to transactions file
benchmark_symbol : str
Benchmark ticker to download data
full_shares : bool
Whether to mimic the portfolio trades exactly (partial shares) or round down the
quantity to the nearest number
risk_free_rate : float
Risk free rate in float format
* **Returns**
PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
{{< /highlight >}}

View File

@@ -1,79 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
To obtain charts, make sure to add :python:`chart = True` as the last parameter.
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.max_drawdown_ratio(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
is_returns: bool = False,
chart: bool = False,
) -> pandas.core.series.Series
{{< /highlight >}}
.. raw:: html
<p>
Calculate the drawdown (MDD) of historical series. Note that the calculation is done
on cumulative returns (or prices). The definition of drawdown is
DD = (current value - rolling maximum) / rolling maximum
</p>
* **Parameters**
data: pd.Series
Series of input values
is_returns: bool
Flag to indicate inputs are returns
chart: bool
Flag to display chart
* **Returns**
pd.Series
Holdings series
pd.Series
Drawdown series
|
.. raw:: html
<h3>
> Getting charts
</h3>
{{< highlight python >}}
portfolio.max_drawdown_ratio(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
export: str = '',
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Display maximum drawdown for multiple intervals
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
export : str
Export data format
chart: bool
Flag to display chart

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.maxdd(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
is_returns: bool = False,
chart: bool = False,
) -> pandas.core.series.Series
@@ -46,6 +46,14 @@ portfolio.maxdd(
pd.Series
Drawdown series
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.maxdd(P)
{{< /highlight >}}
|
.. raw:: html
@@ -56,7 +64,7 @@ portfolio.maxdd(
{{< highlight python >}}
portfolio.maxdd(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,
@@ -71,8 +79,8 @@ portfolio.maxdd(
* **Parameters**
portfolio : PortfolioModel
Portfolio object
portfolio : PortfolioEngine
PortfolioEngine object
export: str
Format to export data
external_axes: plt.Axes

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.maxdrawdown(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves maximum drawdown ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame with maximum drawdown for portfolio and benchmark for different periods

View File

@@ -0,0 +1,6 @@
---
title: metric
keywords: ""
excerpt: ""
geekdocCollapseSection: true
---

View File

@@ -0,0 +1,48 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.calmar(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: int = 756,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get calmar ratio
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window: int
Interval used for rolling values
* **Returns**
pd.DataFrame
DataFrame of calmar ratio of the benchmark and portfolio during different time periods
pd.Series
Series of calmar ratio data
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.calmar(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.commonsense(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get common sense ratio
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame of the portfolios and the benchmarks common sense ratio during different time periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.commonsense(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.gaintopain(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get Pain-to-Gain ratio based on historical data
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame of the portfolio's gain-to-pain ratio
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.gaintopain(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.information(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get information ratio
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame of the information ratio during different time periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.information(P)
{{< /highlight >}}

View File

@@ -11,8 +11,8 @@
</h3>
{{< highlight python >}}
portfolio.jensens(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio.metric.jensens(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
chart: bool = False,
@@ -27,8 +27,9 @@ portfolio.jensens(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window: str
Interval used for rolling values
risk_free_rate: float
@@ -40,3 +41,11 @@ portfolio.jensens(
DataFrame of jensens's alpha during different time windows
pd.Series
Series of jensens's alpha data
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.jensens(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.kelly(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets kelly criterion
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame of kelly criterion of the portfolio during different time periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.kelly(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.kurtosis(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves kurtosis for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame with kurtosis for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.kurtosis(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.maxdrawdown(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves maximum drawdown ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame with maximum drawdown for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.maxdrawdown(P)
{{< /highlight >}}

View File

@@ -0,0 +1,48 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.payoff(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets payoff ratio
Returns
-------
pd.DataFrame
DataFrame of payoff ratio of the portfolio during different time periods
Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.payoff(P)
</p>
* **Returns**
pd.DataFrame
DataFrame of payoff ratio of the portfolio during different time periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.payoff(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.profitfactor(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets profit factor
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame of profit factor of the portfolio during different time periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.profitfactor(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.rsquare(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves R2 Score for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame with R2 Score between portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.rsquare(P)
{{< /highlight >}}

View File

@@ -0,0 +1,46 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.sharpe(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves sharpe ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
risk_free_rate: float
Risk free rate value
* **Returns**
pd.DataFrame
DataFrame with sharpe ratio for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.sharpe(P)
{{< /highlight >}}

View File

@@ -0,0 +1,52 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.skew(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves skewness for portfolio and benchmark selected
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
Returns
-------
pd.DataFrame
DataFrame with skewness for portfolio and benchmark for different periods
Examples
--------
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.skew(P)
</p>
* **Returns**
pd.DataFrame
DataFrame with skewness for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.skew(P)
{{< /highlight >}}

View File

@@ -0,0 +1,46 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.sortino(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves sortino ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
risk_free_rate: float
Risk free rate value
* **Returns**
pd.DataFrame
DataFrame with sortino ratio for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.sortino(P)
{{< /highlight >}}

View File

@@ -11,8 +11,8 @@
</h3>
{{< highlight python >}}
portfolio.tail(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio.metric.tail(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: int = 252,
chart: bool = False,
)
@@ -26,9 +26,9 @@ portfolio.tail(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window: int
Interval used for rolling values
@@ -40,3 +40,11 @@ portfolio.tail(
Series of the portfolios rolling tail ratio
pd.Series
Series of the benchmarks rolling tail ratio
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.tail(P)
{{< /highlight >}}

View File

@@ -0,0 +1,48 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.trackerr(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: int = 252,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get tracking error
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window: int
Interval used for rolling values
* **Returns**
pd.DataFrame
DataFrame of tracking errors during different time windows
pd.Series
Series of rolling tracking error
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.trackerr(P)
{{< /highlight >}}

View File

@@ -0,0 +1,43 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.metric.volatility(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Method that retrieves volatility for portfolio and benchmark selected
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
* **Returns**
pd.DataFrame
DataFrame with volatility for portfolio and benchmark for different periods
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.metric.volatility(P)
{{< /highlight >}}

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.mret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -28,8 +28,9 @@ portfolio.mret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
chart: bool
@@ -39,6 +40,15 @@ portfolio.mret(
* **Returns**
pd.DataFrame
DataFrame with monthly returns
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.mret(P)
{{< /highlight >}}
|
@@ -50,7 +60,7 @@ portfolio.mret(
{{< highlight python >}}
portfolio.mret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
raw: bool = False,
show_vals: bool = False,
@@ -68,8 +78,9 @@ portfolio.mret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
raw : False

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.om(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
threshold_start: float = 0,
threshold_end: float = 1.5,
chart: bool = False,
@@ -29,8 +29,9 @@ portfolio.om(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
threshold_start: float
annualized target return threshold start of plotted threshold range
threshold_end: float
@@ -42,6 +43,15 @@ portfolio.om(
* **Returns**
pd.DataFrame
DataFrame with portfolio omega ratio
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.om(P)
{{< /highlight >}}
|
@@ -53,7 +63,7 @@ portfolio.om(
{{< highlight python >}}
portfolio.om(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
threshold_start: float = 0,
threshold_end: float = 1.5,
chart: bool = False,
@@ -68,8 +78,9 @@ portfolio.om(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
threshold_start: float
annualized target return threshold start of plotted threshold range
threshold_end: float

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.payoff(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets payoff ratio
Returns
-------
pd.DataFrame
DataFrame of payoff ratio of the portfolio during different time periods
</p>
* **Returns**
pd.DataFrame
DataFrame of payoff ratio of the portfolio during different time periods

View File

@@ -12,7 +12,7 @@
{{< highlight python >}}
portfolio.perf(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
show_all_trades: bool = False,
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -26,11 +26,21 @@ portfolio.perf(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
show_all_trades: bool
Whether to also show all trades made and their performance (default is False)
* **Returns**
pd.DataFrame
DataFrame with portfolio performance vs the benchmark
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.perf(P)
{{< /highlight >}}

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.profitfactor(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Gets profit factor
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame of profit factor of the portfolio during different time periods

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.rbeta(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = '1y',
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -28,8 +28,8 @@ portfolio.rbeta(
* **Parameters**
portfolio : PortfolioModel
Portfolio object
portfolio : PortfolioEngine
PortfolioEngine object
window: string
Interval used for rolling values.
Possible options: mtd, qtd, ytd, 1d, 5d, 10d, 1m, 3m, 6m, 1y, 3y, 5y, 10y.
@@ -42,6 +42,14 @@ portfolio.rbeta(
pd.DataFrame
DataFrame of the portfolio's rolling beta
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.rbeta(P)
{{< /highlight >}}
|
.. raw:: html
@@ -52,7 +60,7 @@ portfolio.rbeta(
{{< highlight python >}}
portfolio.rbeta(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = '1y',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
@@ -68,8 +76,8 @@ portfolio.rbeta(
* **Parameters**
portfolio : PortfolioModel
Portfolio object
portfolio : PortfolioEngine
PortfolioEngine object
window: str
interval for window to consider
Possible options: mtd, qtd, ytd, 1d, 5d, 10d, 1m, 3m, 6m, 1y, 3y, 5y, 10y.

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.rsharpe(
portfolio: pandas.core.frame.DataFrame,
portfolio_engine: pandas.core.frame.DataFrame,
risk_free_rate: float = 0,
window: str = '1y',
chart: bool = False,
@@ -45,6 +45,14 @@ portfolio.rsharpe(
pd.DataFrame
Rolling sharpe ratio DataFrame
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.rsharpe(P)
{{< /highlight >}}
|
.. raw:: html
@@ -55,7 +63,7 @@ portfolio.rsharpe(
{{< highlight python >}}
portfolio.rsharpe(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
export: str = '',
@@ -72,8 +80,8 @@ portfolio.rsharpe(
* **Parameters**
portfolio : PortfolioModel
Portfolio object
portfolio : PortfolioEngine
PortfolioEngine object
risk_free_rate: float
Value to use for risk free rate in sharpe/other calculations
window: str

View File

@@ -0,0 +1,95 @@
.. role:: python(code)
:language: python
:class: highlight
|
To obtain charts, make sure to add :python:`chart = True` as the last parameter.
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.rsort(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Get rolling sortino
</p>
* **Parameters**
portfolio : PortfolioEngine
PortfolioEngine object
window: str
interval for window to consider
Possible options: mtd, qtd, ytd, 1d, 5d, 10d, 1m, 3m, 6m, 1y, 3y, 5y, 10y
risk_free_rate: float
Value to use for risk free rate in sharpe/other calculations
chart: bool
Flag to display chart
* **Returns**
pd.DataFrame
Rolling sortino ratio DataFrame
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.rsortino(P)
{{< /highlight >}}
|
.. raw:: html
<h3>
> Getting charts
</h3>
{{< highlight python >}}
portfolio.rsort(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Display rolling sortino
</p>
* **Parameters**
portfolio : PortfolioEngine
PortfolioEngine object
risk_free_rate: float
Value to use for risk free rate in sharpe/other calculations
window: str
interval for window to consider
export: str
Export to file
external_axes: Optional[List[plt.Axes]]
Optional axes to display plot on
chart: bool
Flag to display chart

View File

@@ -13,8 +13,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
</h3>
{{< highlight python >}}
portfolio.rsortino(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio.rsort(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
chart: bool = False,
@@ -29,7 +29,7 @@ portfolio.rsortino(
* **Parameters**
portfolio : PortfolioModel
portfolio : PortfolioEngine
Portfolio object
window: str
interval for window to consider
@@ -54,8 +54,8 @@ portfolio.rsortino(
</h3>
{{< highlight python >}}
portfolio.rsortino(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio.rsort(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
risk_free_rate: float = 0,
window: str = '1y',
export: str = '',
@@ -72,7 +72,7 @@ portfolio.rsortino(
* **Parameters**
portfolio : PortfolioModel
portfolio : PortfolioEngine
Portfolio object
risk_free_rate: float
Value to use for risk free rate in sharpe/other calculations
@@ -84,4 +84,3 @@ portfolio.rsortino(
Optional axes to display plot on
chart: bool
Flag to display chart

View File

@@ -12,7 +12,7 @@
{{< highlight python >}}
portfolio.rsquare(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.rvol(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = '1y',
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -28,8 +28,9 @@ portfolio.rvol(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
Rolling window size to use
Possible options: mtd, qtd, ytd, 1d, 5d, 10d, 1m, 3m, 6m, 1y, 3y, 5y, 10y
@@ -37,6 +38,14 @@ portfolio.rvol(
Flag to display chart
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.rvol(P)
{{< /highlight >}}
|
.. raw:: html
@@ -47,7 +56,7 @@ portfolio.rvol(
{{< highlight python >}}
portfolio.rvol(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = '1y',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
@@ -63,8 +72,8 @@ portfolio.rvol(
* **Parameters**
portfolio : PortfolioModel
Portfolio object
portfolio : PortfolioEngine
PortfolioEngine object
interval: str
interval for window to consider
export: str

View File

@@ -1,37 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.sharpe(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
risk_free_rate: float = 0,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves sharpe ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
risk_free_rate: float
Risk free rate value
* **Returns**
pd.DataFrame
DataFrame with sharpe ratio for portfolio and benchmark for different periods

View File

@@ -0,0 +1,42 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.show(
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Get portfolio transactions
</p>
* **Parameters**
portfolio_engine: PortfolioEngine
PortfolioEngine object
* **Returns**
pd.DataFrame
Portfolio transactions
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.show(P)
{{< /highlight >}}

View File

@@ -1,37 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.skew(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves skewness for portfolio and benchmark selected
portfolio: Portfolio
Portfolio object with trades loaded
Returns
-------
pd.DataFrame
DataFrame with skewness for portfolio and benchmark for different periods
</p>
* **Returns**
pd.DataFrame
DataFrame with skewness for portfolio and benchmark for different periods

View File

@@ -1,37 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.sortino(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
risk_free_rate: float = 0,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves sortino ratio for portfolio and benchmark selected
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
risk_free_rate: float
Risk free rate value
* **Returns**
pd.DataFrame
DataFrame with sortino ratio for portfolio and benchmark for different periods

View File

@@ -12,7 +12,7 @@
{{< highlight python >}}
portfolio.summary(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
risk_free_rate: float = 0,
chart: bool = False,
@@ -22,13 +22,14 @@ portfolio.summary(
.. raw:: html
<p>
Get summary portfolio and benchmark returns
Get portfolio and benchmark returns summary
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
risk_free_rate : float
@@ -37,3 +38,12 @@ portfolio.summary(
* **Returns**
pd.DataFrame
DataFrame with portfolio and benchmark returns summary
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.summary(P)
{{< /highlight >}}

View File

@@ -1,39 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.trackerr(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
window: int = 252,
chart: bool = False,
)
{{< /highlight >}}
.. raw:: html
<p>
Get tracking error
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
window: int
Interval used for rolling values
* **Returns**
pd.DataFrame
DataFrame of tracking errors during different time windows
pd.Series
Series of rolling tracking error

View File

@@ -12,7 +12,7 @@
{{< highlight python >}}
portfolio.var(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
use_mean: bool = False,
adjusted_var: bool = False,
student_t: bool = False,
@@ -29,8 +29,9 @@ portfolio.var(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
use_mean: bool
if one should use the data mean return
adjusted_var: bool
@@ -43,3 +44,12 @@ portfolio.var(
* **Returns**
pd.DataFrame
DataFrame with portfolio VaR
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.var(P)
{{< /highlight >}}

View File

@@ -1,34 +0,0 @@
.. role:: python(code)
:language: python
:class: highlight
|
.. raw:: html
<h3>
> Getting data
</h3>
{{< highlight python >}}
portfolio.volatility(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
<p>
Class method that retrieves volatility for portfolio and benchmark selected
</p>
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
* **Returns**
pd.DataFrame
DataFrame with volatility for portfolio and benchmark for different periods

View File

@@ -14,10 +14,10 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
portfolio.yret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
chart: bool = False,
)
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
.. raw:: html
@@ -28,14 +28,28 @@ portfolio.yret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
chart: bool
Flag to display chart
* **Returns**
pd.DataFrame
DataFrame with yearly returns
* **Examples**
{{< highlight python >}}
>>> from openbb_terminal.sdk import openbb
>>> P = openbb.portfolio.load("openbb_terminal/miscellaneous/portfolio_examples/holdings/example.csv")
>>> openbb.portfolio.yret(P)
{{< /highlight >}}
|
.. raw:: html
@@ -46,7 +60,7 @@ portfolio.yret(
{{< highlight python >}}
portfolio.yret(
portfolio: openbb_terminal.portfolio.portfolio_model.PortfolioModel,
portfolio_engine: openbb_terminal.portfolio.portfolio_model.PortfolioEngine,
window: str = 'all',
raw: bool = False,
export: str = '',
@@ -63,8 +77,9 @@ portfolio.yret(
* **Parameters**
portfolio: Portfolio
Portfolio object with trades loaded
portfolio_engine: PortfolioEngine
PortfolioEngine class instance, this will hold transactions and perform calculations.
Use `portfolio.load` to create a PortfolioEngine.
window : str
interval to compare cumulative returns and benchmark
raw : False

View File

@@ -13,8 +13,8 @@
{{< highlight python >}}
stocks.ba.cnews(
symbol: str,
start_date: str = '2022-10-11',
end_date: str = '2022-11-10',
start_date: str = '2022-10-15',
end_date: str = '2022-11-14',
chart: bool = False,
) -> List[Dict]
{{< /highlight >}}

View File

@@ -15,8 +15,8 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
stocks.ba.hist(
symbol: str,
start_date: str = '2022-11-03',
end_date: str = '2022-11-10',
start_date: str = '2022-11-07',
end_date: str = '2022-11-14',
number: int = 100,
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -61,8 +61,8 @@ stocks.ba.hist(
{{< highlight python >}}
stocks.ba.hist(
symbol: str,
start_date: str = '2022-11-03',
end_date: str = '2022-11-10',
start_date: str = '2022-11-07',
end_date: str = '2022-11-14',
number: int = 100,
raw: bool = False,
limit: int = 10,

View File

@@ -14,7 +14,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
stocks.ba.trend(
start_date: str = '2022-11-10',
start_date: str = '2022-11-14',
hour: int = 0,
number: int = 10,
chart: bool = False,
@@ -58,7 +58,7 @@ stocks.ba.trend(
{{< highlight python >}}
stocks.ba.trend(
start_date: str = '2022-11-10',
start_date: str = '2022-11-14',
hour: int = 0,
number: int = 10,
limit: int = 10,

View File

@@ -15,7 +15,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
stocks.ca.hcorr(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
candle_type: str = 'a',
chart: bool = False,
)
@@ -52,7 +52,7 @@ stocks.ca.hcorr(
{{< highlight python >}}
stocks.ca.hcorr(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
candle_type: str = 'a',
display_full_matrix: bool = False,
raw: bool = False,

View File

@@ -15,7 +15,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
stocks.ca.hist(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
candle_type: str = 'a',
chart: bool = False,
) -> pandas.core.frame.DataFrame
@@ -57,7 +57,7 @@ stocks.ca.hist(
{{< highlight python >}}
stocks.ca.hist(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
candle_type: str = 'a',
normalize: bool = True,
export: str = '',

View File

@@ -15,7 +15,7 @@ To obtain charts, make sure to add :python:`chart = True` as the last parameter.
{{< highlight python >}}
stocks.ca.volume(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
chart: bool = False,
) -> pandas.core.frame.DataFrame
{{< /highlight >}}
@@ -49,7 +49,7 @@ stocks.ca.volume(
{{< highlight python >}}
stocks.ca.volume(
similar: List[str],
start_date: str = '2021-11-09',
start_date: str = '2021-11-13',
export: str = '',
external_axes: Optional[List[matplotlib.axes._axes.Axes]] = None,
chart: bool = False,

View File

@@ -19,9 +19,9 @@ stocks.candle(
add_trend: bool = False,
ma: Optional[Iterable[int]] = None,
asset_type: str = '',
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-06',
start_date: Union[datetime.datetime, str, NoneType] = '2019-11-10',
interval: int = 1440,
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-10',
end_date: Union[datetime.datetime, str, NoneType] = '2022-11-14',
prepost: bool = False,
source: str = 'YahooFinance',
iexrange: str = 'ytd',

Some files were not shown because too many files have changed in this diff Show More