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

Schwab award report dates should always takes precedence over activity dates #411

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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