Initial scaffold + canonical Activity model

Context
-------
New connector suite that syncs UK brokerage activity (Trading212,
InvestEngine, Schwab email-parsed, CSV drop-folder) into Wealthfolio.
Lives outside finance/ intentionally — finance/ is untouched per the
plan at ~/.claude/plans/let-s-work-on-linking-temporal-valiant.md.

This change
-----------
- Poetry project with httpx, typer, bs4, dev tools (pytest, mypy strict,
  ruff, yapf).
- Canonical Activity + Account models with the 6 UK tax wrappers
  (ISA/SIPP/GIA/LISA/JISA/WORKPLACE_PENSION) and the 12 Wealthfolio
  activity types from docs/activities/activity-types.md on the upstream.
- Validation invariants: BUY/SELL need qty+price, DIVIDEND/DEPOSIT/etc
  need amount — raises early so providers can't silently emit broken
  rows.
- to_wealthfolio_csv_row() shape matches Wealthfolio's CSV import;
  primary sink path per the plan.

Test plan
---------
## Automated
- poetry run pytest -q  →  7 passed in 0.03s
- poetry run mypy broker_sync tests  →  Success: no issues found in 4 source files
- poetry run ruff check .  →  All checks passed!
- poetry run yapf --diff --recursive broker_sync tests  →  no diff

## Manual Verification
Not applicable — pure data model, no runtime behaviour.

Closes: code-thw.1
This commit is contained in:
Viktor Barzin 2026-04-17 19:16:11 +00:00
commit a2aa7ec486
7 changed files with 958 additions and 0 deletions

48
pyproject.toml Normal file
View file

@ -0,0 +1,48 @@
[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"
[tool.poetry.group.dev.dependencies]
pytest = "^8.3"
pytest-asyncio = "^0.23"
mypy = "^1.11"
ruff = "^0.6"
yapf = "^0.43"
[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