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

[Bug] Portfolio/Load - "Cash" as Type Crashes Terminal #3584

Closed
deeleeramone opened this issue Nov 25, 2022 · 2 comments
Closed

[Bug] Portfolio/Load - "Cash" as Type Crashes Terminal #3584

deeleeramone opened this issue Nov 25, 2022 · 2 comments
Assignees
Labels
bug Fix bug portfolio Portfolio menu

Comments

@deeleeramone
Copy link
Contributor

Trying to add "Cash", as described in the Portfolio guide, but it just crashes to terminal.

Here's the portfolio loaded without cash:

Screenshot 2022-11-25 at 11 06 36 AM

Then with a Cash Deposit.

Screenshot 2022-11-25 at 11 09 18 AM

Then trying to add the yFinance symbol to see if it makes a difference:

Screenshot 2022-11-25 at 10 56 20 AM

Attempting to re-enter the portfolio menu and load the portfolio file crashes the terminal in what looks like debug mode.

(🦋) /portfolio/ $ load -f crypto_demo.csv

Preprocessing transactions:  21%|██████████████████████▌                                                                                  | 3/14 [00:00<00:00, 549.26it/s]
Could not preprocess transactions.
Preprocessing transactions:  21%|██████████████████████▌                                                                                  | 3/14 [00:00<00:00, 461.89it/s]
        Loading price data: 0it [00:00, ?it/s]
Traceback (most recent call last):
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3803, in get_loc
    return self._engine.get_loc(casted_key)
  File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc
  File "pandas/_libs/hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item
  File "pandas/_libs/hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'Close'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/danglewood/GitHub/OpenBBTerminal/terminal.py", line 4, in <module>
    parse_args_and_run()
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/terminal_controller.py", line 1251, in parse_args_and_run
    main(
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/terminal_controller.py", line 1156, in main
    terminal()
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/terminal_controller.py", line 904, in terminal
    t_controller.queue = t_controller.switch(an_input)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/parent_classes.py", line 364, in switch
    getattr(
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/terminal_controller.py", line 454, in call_portfolio
    self.queue = self.load_class(PortfolioController, self.queue)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/parent_classes.py", line 220, in load_class
    return class_ins(*args, **kwargs).menu()
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/parent_classes.py", line 885, in menu
    self.queue = self.switch(an_input)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/parent_classes.py", line 364, in switch
    getattr(
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/portfolio/portfolio_controller.py", line 346, in call_load
    self.portfolio = generate_portfolio(
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/portfolio/portfolio_model.py", line 60, in generate_portfolio
    portfolio_engine.generate_portfolio_data()
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/portfolio/portfolio_engine.py", line 565, in generate_portfolio_data
    self.populate_historical_trade_data()
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/decorators.py", line 64, in wrapper
    value = func(*args, **kwargs)
  File "/Users/danglewood/GitHub/OpenBBTerminal/openbb_terminal/portfolio/portfolio_engine.py", line 683, in populate_historical_trade_data
    trade_data["Close"] = trade_data["Close"].fillna(method="ffill")
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/frame.py", line 3803, in __getitem__
    return self._getitem_multilevel(key)
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/frame.py", line 3854, in _getitem_multilevel
    loc = self.columns.get_loc(key)
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2916, in get_loc
    loc = self._get_level_indexer(key, level=0)
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 3263, in _get_level_indexer
    idx = self._get_loc_single_level_index(level_index, key)
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/indexes/multi.py", line 2849, in _get_loc_single_level_index
    return level_index.get_loc(key)
  File "/Users/danglewood/GitHub/GST1/miniconda3/envs/obb4/lib/python3.9/site-packages/pandas/core/indexes/base.py", line 3805, in get_loc
    raise KeyError(key) from err
KeyError: 'Close'

Leaving the Country field blank does the same error.

Switching Cash to Currency yields this result. It doesn't quit, just boots you out of the menu.

Screenshot 2022-11-25 at 10 50 10 AM

@jmaslek
Copy link
Collaborator

jmaslek commented Jan 18, 2023

@montezdesousa - this still open?

@montezdesousa
Copy link
Contributor

@montezdesousa - this still open?

It was fixed in #3931

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fix bug portfolio Portfolio menu
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants