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

AssertionError: Premium is tax free, assignments not. Found "xx.x" EUR. #45

Open
NandeeshHD opened this issue Oct 27, 2024 · 5 comments

Comments

@NandeeshHD
Copy link

NandeeshHD commented Oct 27, 2024

I am facing this assertion error. Don't know much context about it. If I comment out this assertion will get error again somewhere. Looks like this tool only works only for IDEAL CASEs!

  File "/Users/nharalahalli/workspace_nd/tastyworks-pnl/tw-pnl.py", line 1418, in <module>
    main(sys.argv[1:])
  File "/Users/nharalahalli/workspace_nd/tastyworks-pnl/tw-pnl.py", line 1415, in main
    check(all_wk, output_summary, output_csv, output_excel, tax_output, show, verbose, debug)
  File "/Users/nharalahalli/workspace_nd/tastyworks-pnl/tw-pnl.py", line 1193, in check
    stats = get_summary(new_wk, orig_wk, tax_output, min_year, max_year)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nharalahalli/workspace_nd/tastyworks-pnl/tw-pnl.py", line 662, in get_summary
    raise AssertionError(f'Premium is tax free, assignments not. Found "{eur_amount}" EUR.')
AssertionError: Premium is tax free, assignments not. Found "-47.9" EUR.```
@laroche
Copy link
Owner

laroche commented Oct 27, 2024

The script does sanity checks, so you get notifications if your data might not be handled correctly.

The error message comes from line 662 in tw-pnl.py. If you disable this check, what error message comes next?

If you can give sample lines to reproduce this error, I might be able to help. If you don't mind, some people even
send in their input data via email to me, so I can try to reproduce the error.

Are you sure that your input data is complete from beginning of all your trades?

best regards,

Florian La Roche

@NandeeshHD
Copy link
Author

NandeeshHD commented Oct 27, 2024 via email

@laroche
Copy link
Owner

laroche commented Oct 27, 2024

Current checks about tax free EurUSD-conversion is wrong. Just disabling them should work fine, I'll check
this again the next days for a correct patch.

best regards,

Florian La Roche

--- a/tw-pnl.py
+++ b/tw-pnl.py
@@ -586,7 +586,8 @@ def get_summary(new_wk, orig_wk, tax_output, min_year, max_year):
         if type in ('Ein/Auszahlung', 'Aktie', 'Aktienfond', 'Mischfond',
             'Immobilienfond', 'Sonstiges', 'Long-Option', 'Future'):
             if bool(tax_free):
-                raise ValueError(f'tax_free is True for type "{type}". Full row: "{new_wk.iloc[i]}"')
+                pass
+                #raise ValueError(f'tax_free is True for type "{type}". Full row: "{new_wk.iloc[i]}"')
         # Währungsgewinne:
         stats.loc['Währungsgewinne USD', year] += float(usd_gains)
         stats.loc['Währungsgewinne USD (steuerfrei)', year] += float(usd_gains_notax)
@@ -659,7 +660,8 @@ def get_summary(new_wk, orig_wk, tax_output, min_year, max_year):
                     raise AssertionError(f'Premium is tax free, assignments not. Found "{eur_amount}" EUR.')
             else:
                 if eur_amount < .0:
-                    raise AssertionError(f'Premium is tax free, assignments not. Found "{eur_amount}" EUR.')
+                    pass
+                    #raise AssertionError(f'Premium is tax free, assignments not. Found "{eur_amount}" EUR.')
         elif type == 'Ordergebühr':
             stats.loc['zusätzliche Ordergebühren', year] += pnl
         elif type == 'Dividende':

@laroche
Copy link
Owner

laroche commented Oct 27, 2024

Just looked again more closely: Your input data has on 2023-12-27 8 lines with "Special Dividend".
My script parses this later on as option trade and then fails.

These are the failing lines:

2023-12-27T12:48:34+0100,Receive Deliver,Special Dividend,SELL_TO_OPEN,QQQ   240119P00384780,Equity Option,Special dividend: Open 1.0 QQQ   240119P00384780,123.00,1,123.00,--,0.00,100,QQQ,QQQ,1/19/24,384.78,PUT,,USD
2023-12-27T12:48:34+0100,Receive Deliver,Special Dividend,BUY_TO_CLOSE,QQQ   240119P00385000,Equity Option,Special dividend: Close 1.0 QQQ   240119P00385000,-123.00,1,-123.00,--,0.00,100,QQQ,QQQ,1/19/24,385,PUT,,USD
2023-12-27T12:48:21+0100,Receive Deliver,Special Dividend,BUY_TO_OPEN,QQQ   240119P00379780,Equity Option,Special dividend: Open 1.0 QQQ   240119P00379780,-91.00,1,-91.00,--,0.00,100,QQQ,QQQ,1/19/24,379.78,PUT,,USD
2023-12-27T12:48:21+0100,Receive Deliver,Special Dividend,SELL_TO_CLOSE,QQQ   240119P00380000,Equity Option,Special dividend: Close 1.0 QQQ   240119P00380000,91.00,1,91.00,--,0.00,100,QQQ,QQQ,1/19/24,380,PUT,,USD
2023-12-27T12:47:08+0100,Receive Deliver,Special Dividend,BUY_TO_OPEN,QQQ   240119C00429780,Equity Option,Special dividend: Open 1.0 QQQ   240119C00429780,-33.00,1,-33.00,--,0.00,100,QQQ,QQQ,1/19/24,429.78,CALL,,USD
2023-12-27T12:47:08+0100,Receive Deliver,Special Dividend,SELL_TO_CLOSE,QQQ   240119C00430000,Equity Option,Special dividend: Close 1.0 QQQ   240119C00430000,33.00,1,33.00,--,0.00,100,QQQ,QQQ,1/19/24,430,CALL,,USD
2023-12-27T12:47:03+0100,Receive Deliver,Special Dividend,SELL_TO_OPEN,QQQ   240119C00424780,Equity Option,Special dividend: Open 1.0 QQQ   240119C00424780,53.00,1,53.00,--,0.00,100,QQQ,QQQ,1/19/24,424.78,CALL,,USD
2023-12-27T12:47:03+0100,Receive Deliver,Special Dividend,BUY_TO_CLOSE,QQQ   240119C00425000,Equity Option,Special dividend: Close 1.0 QQQ   240119C00425000,-53.00,1,-53.00,--,0.00,100,QQQ,QQQ,1/19/24,425,CALL,,USD

Just deleting those 8 lines and then running the script should work ok. Not sure what those 8 lines should do, maybe
replacing all the option strike prices here? This needs further investigation. Can you check what happens with
these options in 2024?

best regards,

Florian La Roche

@NandeeshHD
Copy link
Author

Thank you very much Florian for looking into the issue!

I am not sure what do you mean by -

Can you check what happens with
these options in 2024?

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

No branches or pull requests

2 participants