Skip to content

Error in the last line of code 01_parse_itch_order_flow_messages.ipynb #330

@adanog

Description

@adanog

Describe the bug

KeyError Traceback (most recent call last)
Cell In[32], line 3
1 with pd.HDFStore(itch_store) as store:
2 stocks = store['R'].loc[:, ['stock_locate', 'stock']]
----> 3 trades = store['P'].append(store['Q'].rename(columns={'cross_price': 'price'}), sort=False).merge(stocks)
5 trades['value'] = trades.shares.mul(trades.price)
6 trades['value_share'] = trades.value.div(trades.value.sum())

File /opt/anaconda3/envs/stocks-env/lib/python3.12/site-packages/pandas/io/pytables.py:602, in HDFStore.getitem(self, key)
601 def getitem(self, key: str):
--> 602 return self.get(key)

File /opt/anaconda3/envs/stocks-env/lib/python3.12/site-packages/pandas/io/pytables.py:812, in HDFStore.get(self, key)
810 group = self.get_node(key)
811 if group is None:
--> 812 raise KeyError(f"No object named {key} in the file")
813 return self._read_group(group)

KeyError: 'No object named P in the file'

To Reproduce

  • In case you are not running the current version of the notebook/script as found on GitHub.

Steps to reproduce the behavior:

  1. Go to 01_parse_itch_order_flow_messages.ipynb'
  2. Scroll down to '6.2. Top Equities by Traded Value'
  3. Run the code bellow
  4. See error

Expected behavior

Must plot

Add any other context about the problem here.

The error message “No object named ‘P’ in the file” indicates that the key 'P' is not present in the HDF5 file. This key represents a dataset or a group in the file that is expected by your script but does not exist in the file structure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions