Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix portfolio and benchmark length matching #4218

Merged
merged 22 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
83bfffe
Fix portfolio and benchmark length matching
northern-64bit Feb 11, 2023
1018249
Fix linting
northern-64bit Feb 11, 2023
5dada2e
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 13, 2023
a4e81c1
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 14, 2023
b87aeed
Merge branch 'develop' into hotfix/bug-#4201
montezdesousa Feb 14, 2023
4440e98
Merge branch 'develop' into hotfix/bug-#4201
montezdesousa Feb 14, 2023
2a34689
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 14, 2023
99d0965
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 19, 2023
2389d4f
Fix make_equal_length
northern-64bit Feb 19, 2023
ab9b8c2
Merge branch 'develop' into hotfix/bug-#4201
jmaslek Feb 20, 2023
df7fe61
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 20, 2023
549a023
Handling pd.Series input
northern-64bit Feb 20, 2023
398e01e
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 20, 2023
15bc81e
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 21, 2023
ee6a308
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 23, 2023
04a49d8
Fix alloc command
northern-64bit Feb 24, 2023
4523ffa
Fix metrics, yret and summary errors
northern-64bit Feb 24, 2023
9953a70
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 25, 2023
8016aa8
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Feb 28, 2023
c8b1fda
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Mar 6, 2023
8b9c353
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Mar 8, 2023
ef886f8
Merge branch 'develop' into hotfix/bug-#4201
northern-64bit Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions openbb_terminal/portfolio/allocation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def get_assets_allocation(
benchmark_assets_allocation = stockanalysis_model.get_etf_holdings(
benchmark_ticker
).reset_index()
if benchmark_assets_allocation.empty: # if not an etf or no data is available
benchmark_assets_allocation = pd.DataFrame(
data={
"symbol": [benchmark_ticker],
"Name": [benchmark_ticker],
"% Of Etf": ["100%"],
"Shares": [1],
},
index=[0],
)
benchmark_assets_allocation.rename(
columns={"symbol": "Symbol", "% Of Etf": "Benchmark"}, inplace=True
)
Expand Down
18 changes: 13 additions & 5 deletions openbb_terminal/portfolio/portfolio_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,20 @@ def make_equal_length(df1: pd.DataFrame, df2: pd.DataFrame):
Both DataFrames returned
"""
# Match the DataFrames so they share a similar length
if len(df1.index) > len(df2.index):
df1 = df1.loc[df2.index]
elif len(df2.index) > len(df1.index):
df2 = df2.loc[df1.index]
if isinstance(df1, pd.Series):
df1 = df1.to_frame()
if isinstance(df2, pd.Series):
df2 = df2.to_frame()
df2.columns = [str(i) + "2" for i in df2.columns]
df_merged = df1.join(df2, how="outer")
df_merged = df_merged.fillna(0)

return df1, df2
df1 = df_merged[df1.columns]
df2 = df_merged[df2.columns]

df2.columns = [i[:-1] for i in df2.columns]

return df1.iloc[:, 0], df2.iloc[:, 0]


def get_region_from_country(country: str) -> str:
Expand Down