From f6d6beb84fd45dc01947a3894272954720cca5c6 Mon Sep 17 00:00:00 2001 From: Ralf Waldukat Date: Sun, 18 Sep 2022 10:25:45 +0200 Subject: [PATCH] added support for Symbol Change --- tw-pnl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tw-pnl.py b/tw-pnl.py index 458e1c5..687b6e5 100755 --- a/tw-pnl.py +++ b/tw-pnl.py @@ -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}') @@ -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 @@ -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. @@ -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)