The script counts all ingoing and outgoing HIVE and HBD. Only when the balance is correct after checking the last history item, It can be used further.
65.316 HIVE, 0.063 HBD is my current HIVE/HBD liquid balance.
6279 entries are history items that have modified my balance.
I'm working on a second script that writes an excel file, I will post this as well.
Does this include staking rewards?