[WSAPI-10] Resolve security symbol + market price for held positions #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature/WSAPI-10"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Ticket
WSAPI-10 Resolve security symbol + market price for held positions
Summary
lib/wealthsimple/balances(WSAPI-4) returns raw{ securityId, quantity }holdings with no ticker/symbol and no price, so/positions' quantities couldn't become a dollar value. This addslib/wealthsimple/securities—fetchSecurityQuotes(securityIds)— which batches a securityId list through Wealthsimple'sFetchIdentityPositionsGraphQL query (ported verbatim fromgboudreau/ws-api-python) and resolves each to{ securityId, symbol, price, currency }.includeSecurity: true,first/cursor/aggregated) deliberately diverges from upstream's own usage of the query, so thesecurity/stock/quoteV2sub-shape it parses is unverified against any real Wealthsimple response — flagged in code (queries.tsandsecurities/index.ts) alongside the existingcurrency: 'CAD'assumption, for a downstream ticket exercising live data to confirm.stockandquoteV2.currencywere non-nullable in the zod schema, so a single non-equity or no-currency security in a page threw for the entire batch instead of being dropped the way an unpriced security already was. Both are now nullable with a symmetric drop guard, plus a defensive dedupe-by-securityIdguarding the unverifiedaggregated: trueassumption. Covered by 10 tests (request shape, full-page mapping, four independent null-field drop cases, empty-list short-circuit, two-page pagination, dedupe).lib/wealthsimple/CLAUDE.mdand the rootCLAUDE.mdupdated for the new operation module.Test plan
bun run type-checkbun run lintbun run format:checkbun test lib/wealthsimple/securities/.test.ts(10 pass)bun test): 318 pass / 1 fail — the one failure (lib/config/.test.ts) is pre-existing and unrelated to this branch (caused by this environment's local.envleaking a realWS_EMAILintoprocess.env; reproduced identically onmain)🤖 Generated with Claude Code
fetchSecurityQuotes(securityIds) batches a securityId list through FetchIdentityPositions and resolves each to { securityId, symbol, price, currency }, closing the gap balances/ left: raw holdings had no way to become a dollar value. Paginated like accounts/, tolerant of an unpriced or delisted security like balances/ is tolerant of a missing balance key. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>