mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Merge pull request #3964 from northern-64bit/hotfix/bug-#3960
Fix portfolio/summary command (issue #3960)
This commit is contained in:
@@ -768,6 +768,17 @@ def get_summary(
|
||||
portfolio_engine.benchmark_returns, window
|
||||
)
|
||||
|
||||
r2_portfolio_returns = portfolio_returns.copy()
|
||||
r2_benchmark_returns = benchmark_returns.copy()
|
||||
if len(portfolio_returns) > len(benchmark_returns):
|
||||
r2_portfolio_returns = r2_portfolio_returns[
|
||||
r2_portfolio_returns.index.isin(r2_benchmark_returns.index)
|
||||
]
|
||||
elif len(portfolio_returns) < len(benchmark_returns):
|
||||
r2_benchmark_returns = r2_benchmark_returns[
|
||||
r2_benchmark_returns.index.isin(r2_portfolio_returns.index)
|
||||
]
|
||||
|
||||
metrics = {
|
||||
"Volatility": [portfolio_returns.std(), benchmark_returns.std()],
|
||||
"Skew": [
|
||||
@@ -791,8 +802,8 @@ def get_summary(
|
||||
metrics_model.sortino_ratio(benchmark_returns, risk_free_rate),
|
||||
],
|
||||
"R2 Score": [
|
||||
r2_score(portfolio_returns, benchmark_returns),
|
||||
r2_score(portfolio_returns, benchmark_returns),
|
||||
r2_score(r2_portfolio_returns, r2_benchmark_returns),
|
||||
r2_score(r2_portfolio_returns, r2_benchmark_returns),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user