-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Fix portfolio and benchmark length matching #4218
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC we are assuming that if DataFrames share the same length the dates match, this might not be always the case, right?
Or even if they have different length is it guaranteed that the smallest is a subset of the largest?
I tried this example and the resulting DataFrames don't share the same length
from openbb_terminal.portfolio.portfolio_helper import make_equal_length
import pandas as pd
df0 = pd.DataFrame({'returns': [0.4, 0.6, 0.8]}, index=[1, 3, 4])
df1 = pd.DataFrame({'returns': [0.3, 0.5]}, index=[2, 3])
df0_new, df1_new = make_equal_length(df0, df1)
df0_new, df1_new
If the case above is an issue we might use pandas inner merge and then provide each DataFrame individually.
So I think the tricky part is holidays on one exchange. I am not sure what the correct way to report that would be. My gut says to do an outer join and then just backfill (and just assume that a couple days of 0 returns doesnt mess with statistics or correlations) |
sounds good |
It has now been fixed by applying outer join and just replacing all NaNs with zeros. |
Loading the example portfolio is now invalid:
|
Fixed :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are commands breaking for some reason, like summary
, some on metrics
, yret
Run python terminal.py -t 33 -v
to check. alloc
is broken, but apparently it's on develop
branch already
Hello @montezdesousa! Can you please review the PR so that we can merge it. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry must have missed this one, tks for reminding
Description
Closes #4201 by fixing the length matching performed in the "bench" command.
How has this been tested?
Running the command and making sure the results stay the same
Checklist:
feature/feature-name
orhotfix/hotfix-name
.Others