Commit Graph
6 Commits
Author SHA1 Message Date
Scott HughesandClaude Opus 5 5bba880e66 Fix SnapTrade holdings by using the /positions/all endpoint (#3043)
* Fix SnapTrade holdings by using the /positions/all endpoint

SnapTrade returns HTTP 410 Gone on /positions, /holdings and /options for
apps registered after their 2026 cutoff, so newly connected accounts import
their balance but never any holdings. The importer rescues the error and the
sync still reports success, which makes it look like the brokerage simply
holds nothing.

Switch get_positions to the documented replacement, /positions/all, and teach
the shared payload helpers to read its flat `instrument` object alongside the
legacy nested `symbol.symbol` shape.

Fixes #3029

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* Filter unsupported instrument kinds before they reach the payload

Derivatives skipped by HoldingsProcessor still landed in
raw_holdings_payload, where calculate_holdings_value sums units * price
over every entry. Any non-zero sum then displaces SnapTrade's own figure
in calculate_total_balance, so an options-only account could report a
balance derived from per-contract units against a per-share price.

Move the denylist to Provider::Snaptrade#get_positions so unsupported
kinds never enter the payload at all, keeping holdings, balance, currency
detection and cash-equivalent handling consistent with one filter.

Also raise when the positions response carries no results array, so a
partial or schema-changed response leaves the previous snapshot in place
instead of overwriting it with nothing. An empty results array remains a
legitimately empty account.

Note that tax_lots[].cost_basis is documented as a whole-lot total,
unlike the per-share field this reads.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-08-17 06:00:43 +02:00
Rick Gray 39e9cf4e3d fix(snaptrade): don't double count cash-equivalent (money market) positions (#2696)
* fix snaptrade double count cash equivalent

* debug logging

* fix fallback edge case

* comments and no floor
2026-07-21 23:29:58 +02:00
dripsmvcp f7df709e6d fix(snaptrade): import non-primary-currency cash as cash holdings (#1979)
* fix(snaptrade): import non-primary-currency cash as cash holdings

Fixes #1809.

SnaptradeAccount#upsert_balances! picked a single cash entry (account
currency -> USD -> first) and stored only that in cash_balance; every
other currency's cash was discarded. A moomoo Canada account with CAD
$500 + USD $1000 imported only the CAD.

Persist the full balances snapshot (new raw_balances_payload column) and
surface each non-primary-currency cash entry as a synthetic per-currency
cash holding (Security.cash_for(account, currency:)), mirroring the
existing cash-security pattern. The primary currency stays in
cash_balance. HoldingsProcessor now also runs for cash-only balances, and
the Processor invokes it when there are holdings OR non-primary cash.
Cash holdings use a stable external_id so repeated syncs update rather
than duplicate.

* fix(snaptrade): encrypt raw_balances_payload and drop cash amount from log

Addresses PR #1979 review: Codex P1 (encrypt the newly persisted balances snapshot at rest, matching the other raw provider payloads) and CodeRabbit nitpick (do not log monetary amounts at info level).

* refactor(snaptrade): extract primary_cash_entry and harden balances test

PR #1979 review: extract the shared account-currency->USD->first cash selection into a private helper (CodeRabbit DRY nitpick); reorder the upsert_balances! test so the primary currency is not first, proving dig(:currency,:code) resolves it on string-keyed payloads rather than the entries.first fallback (jjmata).
2026-05-30 23:29:37 +02:00
Gian-Reto Tarnutzer ce5d7dd736 Add Interactive Brokers Provider (#1722)
* Display multi-currency holdings correctly

* Implement IBKR provider

* Fix: Use historical exchange rate for historical prices

* Add brokerage exchange rate for trades

* Sync historical balances from IBKR

* Add logos in activity history

* Fix privacy mode blur in account view

* Improve IBKR XML Flex report parser errors
2026-05-12 23:45:19 +02:00
Sure Admin (bot)andSureBot d943e32b15 fix: correct SnapTrade cash activity signs (#1634)
* fix: correct snaptrade cash activity signs

* test: update snaptrade withdrawal sign expectation

---------

Co-authored-by: SureBot <sure-bot@we-promise.com>
2026-05-12 00:55:46 +02:00
LPWandluckyPipewrench 6279bfc497 Add comprehensive tests for SnaptradeAccount processors and data helpers. (#742)
Co-authored-by: luckyPipewrench <luckypipewrench@proton.me>
2026-01-23 00:27:00 +01:00