Skip to content

Commit

Permalink
Schwab award report dates should always takes precedence over activit…
Browse files Browse the repository at this point in the history
…y date

Schwab excel reporting for stock activities date reports erroneous dates sometimes, for example the next day respect to what is actually exported  in the PDF statements.

This can potentially interfere with UK same day acquisition selling rule or bed and breakfast.

For example you can receive an award on the 15th and sell on 16th of the same month and the xls for activities will report both on the 16th.
  • Loading branch information
ivendor committed Sep 2, 2023
1 parent 6be662f commit 7f0e7f8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions cgt_calc/parsers/schwab.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AwardPrices:

award_prices: dict[datetime.date, dict[str, Decimal]]

def get(self, date: datetime.date, symbol: str) -> Decimal:
def get(self, date: datetime.date, symbol: str) -> tuple[datetime.date, Decimal]:
"""Get initial stock price at given date."""
# Award dates may go back for few days, depending on
# holidays or weekends, so we do a linear search
Expand All @@ -38,7 +38,7 @@ def get(self, date: datetime.date, symbol: str) -> Decimal:
to_search in self.award_prices
and symbol in self.award_prices[to_search]
):
return self.award_prices[to_search][symbol]
return (to_search, self.award_prices[to_search][symbol])
raise KeyError(f"Award price is not found for symbol {symbol} for date {date}")


Expand Down Expand Up @@ -161,7 +161,13 @@ def create(
symbol = transaction.symbol
if symbol is None:
raise SymbolMissingError(transaction)
transaction.price = awards_prices.get(transaction.date, symbol)
# Schwab transaction list contains sometimes incorrect date
# for awards which don't match the PDF statements.
# We want to make sure to match date and price form the awards
# spreadsheet.
transaction.date, transaction.price = awards_prices.get(
transaction.date, symbol
)
return transaction


Expand Down

0 comments on commit 7f0e7f8

Please sign in to comment.