Schwab's workplace-RSU confirmation emails have 5 data td elements
with class='dark-background-body' align='right': date, direction, qty,
ticker, price-with-currency-sign. One email → one Activity.
- parse_schwab_email(raw_html) -> list[Activity] (1-item or empty)
- Empty on any parse failure (IMAP batch shouldn't crash on one bad mail)
- Deterministic external_id ('schwab📅ticker:type:qty') — stable
across re-pulls so dedup works
- Hardcoded to account 'schwab-workplace' / AccountType.GIA / USD
- 6 unit tests: SELL + BUY happy path, malformed, missing cells,
external-id stability, commas in price
Dropped from the original finance port:
- msg_timestamp-based external id (non-deterministic — would re-import
on every IMAP walk). Replaced with a hash-stable key.
- Currency.from_sign() currency hack. Schwab US is USD-only; we'll add
FX when that changes.
poetry run pytest -q → 109 passed, 1 skipped
poetry run mypy → clean (added types-python-dateutil)
poetry run ruff check → clean
50 lines
1.1 KiB
TOML
50 lines
1.1 KiB
TOML
[tool.poetry]
|
|
name = "broker-sync"
|
|
version = "0.1.0"
|
|
description = "Sync UK brokerage activity (Trading212, InvestEngine, Schwab, CSV) into Wealthfolio"
|
|
authors = ["Viktor Barzin <viktorbarzin@meta.com>"]
|
|
readme = "pyproject.toml"
|
|
packages = [{ include = "broker_sync" }]
|
|
|
|
[tool.poetry.dependencies]
|
|
python = ">=3.11,<3.13"
|
|
httpx = "^0.27"
|
|
beautifulsoup4 = "^4.12"
|
|
python-dateutil = "^2.9"
|
|
typer = "^0.12"
|
|
click = "<8.2" # typer 0.12 uses make_metavar() without ctx; click 8.2 made ctx required
|
|
|
|
[tool.poetry.group.dev.dependencies]
|
|
pytest = "^8.3"
|
|
pytest-asyncio = "^0.23"
|
|
mypy = "^1.11"
|
|
ruff = "^0.6"
|
|
yapf = "^0.43"
|
|
types-python-dateutil = "^2.9.0.20260408"
|
|
|
|
[tool.poetry.scripts]
|
|
broker-sync = "broker_sync.cli:app"
|
|
|
|
[build-system]
|
|
requires = ["poetry-core"]
|
|
build-backend = "poetry.core.masonry.api"
|
|
|
|
[tool.pytest.ini_options]
|
|
asyncio_mode = "auto"
|
|
testpaths = ["tests"]
|
|
|
|
[tool.mypy]
|
|
python_version = "3.11"
|
|
strict = true
|
|
files = ["broker_sync", "tests"]
|
|
|
|
[tool.ruff]
|
|
line-length = 100
|
|
target-version = "py311"
|
|
|
|
[tool.ruff.lint]
|
|
select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF"]
|
|
|
|
[tool.yapf]
|
|
based_on_style = "pep8"
|
|
column_limit = 100
|