pytr icon indicating copy to clipboard operation
pytr copied to clipboard

AssertionError while running dl_docs

Open S-T1 opened this issue 6 months ago • 2 comments

Description of the bug While executing "dl_docs" an AssertionError appears in the step "Exporting transactions" "

To Reproduce Steps to reproduce the behavior:

  1. Ran the command `pytr dl_docs /home/folder1

Expected behavior No error. The data is exported in the mentioned folder1

Error log

Exporting transactions ...
Traceback (most recent call last):
  File "/home/stefan/.local/bin/pytr", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/main.py", line 354, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/dl.py", line 88, in dl_loop
    self.tl.process_timelineDetail(response, self)
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/timeline.py", line 206, in process_timelineDetail
    self.check_if_done(dl)
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/timeline.py", line 210, in check_if_done
    self.finish_timeline_details(dl)
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/timeline.py", line 237, in finish_timeline_details
    ).export(
      ^^^^^^^
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/transactions.py", line 172, in export
    writer.writerows(transactions)
  File "/usr/lib/python3.12/csv.py", line 167, in writerows
    return self.writer.writerows(map(self._dict_to_list, rowdicts))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/transactions.py", line 164, in <genexpr>
    transactions = (txn for event in events for txn in self.from_event(event))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stefan/.local/share/pipx/venvs/pytr/lib/python3.12/site-packages/pytr/transactions.py", line 122, in from_event
    assert event.value is not None, event
           ^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Event(date=datetime.datetime(2024, 2, 9, 15, 45, 28), title='Long 32,5572 $', event_type=<ConditionalEventType.TRADE_INVOICE: 2>, fees=1.0, isin='DE000HG4NGP4', note=None, shares=100.0, taxes=None, value=None)

Environment

  • OS: Ubuntu 24.04.2 on virtualbox
  • pytr version: 0.4.2

Thanks for any help!

S-T1 avatar Jun 03 '25 20:06 S-T1

Can this be reproduced with the just published v0.4.3 as well?

RealCLanger avatar Jul 20 '25 06:07 RealCLanger

Yes, the assertion error still exists on v.0.4.3. My Guess: TR somehow returns value = None when the derivative reached its KO threshold (at least that was my event which triggered this bug). In that Case the Value should be 0,001 €

Error log

Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/bin/pytr", line 7, in <module>
    sys.exit(main())
             ^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/main.py", line 354, in main
    asyncio.get_event_loop().run_until_complete(dl.dl_loop())
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/dl.py", line 85, in dl_loop
    await self.tl.process_timelineDetail(response, self)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/timeline.py", line 270, in process_timelineDetail
    self.finish_if_done(dl)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/timeline.py", line 285, in finish_if_done
    self.finish_timeline_details(dl)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/timeline.py", line 312, in finish_timeline_details
    ).export(
      ^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/transactions.py", line 172, in export
    writer.writerows(transactions)
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/csv.py", line 167, in writerows
    return self.writer.writerows(map(self._dict_to_list, rowdicts))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/transactions.py", line 164, in <genexpr>
    transactions = (txn for event in events for txn in self.from_event(event))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Caskroom/miniconda/base/envs/DataScience/lib/python3.12/site-packages/pytr/transactions.py", line 122, in from_event
    assert event.value is not None, event
AssertionError: Event(date=datetime.datetime(2025, 10, 6, 15, 11, 49), title='Long 1.899,6595 €', event_type=<ConditionalEventType.TRADE_INVOICE: 2>, fees=1.0, isin='DE000FC04RY6', note=None, shares=1000.0, taxes=None, value=None)

OS: MacOS 15.6.1 (25G90) pytr version: 0.4.3

EDIT: The respective row itself in all_events.json has no issue nor None values

x-CDT avatar Nov 02 '25 22:11 x-CDT

Does the issue still exist on latest code?

RealCLanger avatar Dec 05 '25 15:12 RealCLanger

Does the issue still exist on latest code?

Sorry, I overlooked your comment. I tried again yesterday with version 0.4.4 and still got the following error:

site-packages/pytr/transactions.py", line 131, in from_event assert event.value is not None, event ^^^^^^^^^^^^^^^^^^^^^^^ AssertionError: Event( date=datetime.datetime(2024, 2, 9, 15, 45, 28), title='Long 32.5572 $', event_type=<ConditionalEventType.TRADE_INVOICE: 4>, isin='DE000HG4NGP4', isin2=None, shares=100.0, shares2=None, value=None, fees=1.0, taxes=None, note=None )

Thanks in advance for your help!

S-T1 avatar Dec 05 '25 21:12 S-T1

Heyy there, thanks for this great package! I stumbled across a weird transaction which breaks this package.

The transaction is a "Verkaufsorder" but with

"amount": {
      "currency": "EUR",
      "value": 0.0,
      "fractionDigits": 2
    },

This correctly reflects what I find in the app.

The problem is that this leads to event.py (line 529) to set event.value as none which leads to before in here mentioned assert event.value is not None, event


Is there a reason to specifically overwrite 0.0 to None ?


Edit: At least for me it works after https://github.com/pytr-org/pytr/compare/master...M123-dev:pytr:master

M123-dev avatar Dec 17 '25 22:12 M123-dev