Skip to content

Commit

Permalink
added support for Symbol Change
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf Waldukat committed Sep 18, 2022
1 parent 27427a5 commit f6d6beb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tw-pnl.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def check_tcode(tcode, tsubcode, description):
if tsubcode not in ('Sell to Open', 'Buy to Close', 'Buy to Open', 'Sell to Close',
'Expiration', 'Assignment', 'Exercise', 'Forward Split', 'Reverse Split',
'Special Dividend', 'Cash Settled Assignment', 'Cash Settled Exercise',
'Futures Settlement', 'Transfer'):
'Futures Settlement', 'Transfer', 'Symbol Change'):
raise ValueError(f'Unknown Receive Deliver tsubcode: {tsubcode}')
if tsubcode == 'Assignment' and description != 'Removal of option due to assignment':
raise ValueError(f'Assignment with description {description}')
Expand Down Expand Up @@ -774,7 +774,7 @@ def check(all_wk, output_summary, output_csv, output_excel, tax_output, show, ve
raise
(amount, fees) = (float(amount), float(fees))
# option/stock splits are tax neutral, so zero out amount/fees for it:
if tcode == 'Receive Deliver' and tsubcode in ('Forward Split', 'Reverse Split'):
if tcode == 'Receive Deliver' and tsubcode in ('Forward Split', 'Reverse Split', 'Symbol Change'):
(amount, fees) = (.0, .0)
conv_usd = get_eurusd(date)
cash_total += amount - fees
Expand All @@ -791,7 +791,7 @@ def check(all_wk, output_summary, output_csv, output_excel, tax_output, show, ve
tax_free = True
# Stillhalterpraemien gelten als Zufluss und nicht als Anschaffung
# und sind daher steuer-neutral:
# XXX We use "Sell-to-Open" to find all "Stillhaltergeschäfte". This works
# TODO: We use "Sell-to-Open" to find all "Stillhaltergeschäfte". This works
# ok for me, but what happens if we have one long option and sell two? Will
# Tastyworks split this into two transactions or keep this? With keeping this
# as one transaction, we should split the currency gains transaction as well.
Expand Down Expand Up @@ -821,12 +821,12 @@ def check(all_wk, output_summary, output_csv, output_excel, tax_output, show, ve
if isnan(quantity):
quantity = 1
else:
if tcode == 'Receive Deliver' and tsubcode in ('Forward Split', 'Reverse Split'):
if tcode == 'Receive Deliver' and tsubcode in ('Forward Split', 'Reverse Split', 'Symbol Change'):
pass # splits might have further data, not quantity
elif int(quantity) != quantity:
# Hardcode AssetType.Crypto here again:
if symbol[-4:] != '/USD':
raise
raise ValueError('Symbol must end with /USD for crypto')
else:
quantity = int(quantity)

Expand Down

0 comments on commit f6d6beb

Please sign in to comment.