stefan-jansen / machine-learning-for-trading

Code for Machine Learning for Algorithmic Trading, 2nd edition.
https://ml4trading.io
12.57k stars 4.03k forks source link

No object named P in the file #310

Open Impesud opened 7 months ago

Impesud commented 7 months ago

Describe the bug Hi, unfortunately I saw two errors in the code of chapter 2 and I can't find a solution.

In the file "01_parse_itch_order_flow_messages.ipynb" I see:

1."Cannot serialize the column [primary_market_maker] because its data contents are not [string] but [integer] object dtype L" , processes the binary file and produces the parsed orders stored by message type.

  1. "'No object named P in the file'", in the last section of the code.

Screenshots Screenshot 2023-12-10 143240

Environment VsCode v1.85 Python v1.8.10 JupytervVsCode extension v2023.11.1003402403

Impesud commented 7 months ago

Hi! I put the the solution here: https://github.com/Impesud/machine-learning-for-trading/blob/main/02_market_and_fundamental_data/01_NASDAQ_TotalView-ITCH_Order_Book/01_parse_itch_order_flow_messages.ipynb

View "Impesud Note" rows.

2f2a commented 7 months ago

Hi! I put the the solution here: https://github.com/Impesud/machine-learning-for-trading/blob/main/02_market_and_fundamental_data/01_NASDAQ_TotalView-ITCH_Order_Book/01_parse_itch_order_flow_messages.ipynb

View "Impesud Note" rows.

I had the same issue: "..Cannot serialize.." But your ("Impesud Note") version solved it.

Im on Linux, and use uptodate modules also, just had to rewrite the "Path".

Another difference: "store.append" vs "store._append", <- pandas.HDFStore last line, uhg, so the fix doesn't fix rollback versions of modules, that are suggested to use..

Impesud commented 7 months ago

Hi @2f2a In fact, store._append does not completely solve the problem. We should try again with the concat method, as I did, and find the right way to keep the Q column with the table format, eliminating the fixed one.