-
-
Notifications
You must be signed in to change notification settings - Fork 571
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
Always treat price data as pd.DataFrame, never as pd.Series #642
Comments
I agree fully, there's an entire argument in the pro version called |
This issue is stale because it has been open for 90 days with no activity. |
@polakowo Any chance that issue will be solved in the near future/at all? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I realized that
vectorbt
is treating price data differently depending on the number of symbols provided.When providing a single symbol,
vectorbt
is returning apd.Series
, while it returns apd.DataFrame
when providign multiple symbols.The following
get
function is responsible for this distinction.vectorbt/vectorbt/data/base.py
Lines 699 to 718 in f78d1fd
It might look reasonable to treat a single column as a pd.Series, however, this will possibly create problems/issues in downstream code.
For example, I m further processing the data that I retrive when applying the
get
method in my code. I need to ALWAYS get back apd.DataFrame
with the same column level names no matter how many symbols I provide.There MIGHT be a quick solution for this issue. I changed part of the function in the following way:
With this small change my downstream code seems to work properly, no matter if I provide a single or multiple symbols (fingers crossed).
Having said that, I would be more confident, if you were to change and test the library code.
In my experience, mixing
pd.Series
andpd.DataFrame
causes trouble more often than not. I always go withpd.DataFrame
no matter how many columns.The text was updated successfully, but these errors were encountered: