Skip to content

fix: wrong margin account selection + pending deposit triggers#83

Draft
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-bug-management-454b
Draft

fix: wrong margin account selection + pending deposit triggers#83
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-bug-management-454b

Conversation

@cursor

@cursor cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • Fix read_snaptrade_balances() to use the enabled taxable_margin SnapTrade account instead of syncable[0]. A cash/IRA account listed first was silently producing no_margin / wrong equity while real margin debt lived on another account.
  • Fix SimpleFIN deposit detection to ignore pending / posted=0 transactions before firing buy-ticket triggers. Unsettled deposits can reverse and must not enqueue ticket generation.
  • Link to related issue(s): n/a (critical-bug automation)

Test Plan

  • Focused margin metrics tests pass (uv run pytest tests/python/test_margin_metrics.py -q --cov-fail-under=0)
  • SimpleFIN trigger tests pass (bun test src/trigger.test.ts in apps/simplefin-sync)
  • Lint clean on touched Python (uv run ruff check + ruff format)
  • Full suite / mypy optional for this minimal fix PR

Review Checklist

  • No secrets or PII committed
  • Documentation updated (margin-management skill source note)
  • Test coverage maintained or improved (account-selection + pending-deposit cases)
Open in Web View Automation 

cursoragent and others added 3 commits July 18, 2026 17:15
Margin metrics used the first syncable account, so a cash/IRA account
listed ahead of taxable_margin silently produced no_margin / wrong equity
while real margin debt lived on another account.

Co-authored-by: Ossie Irondi <AojdevStudio@users.noreply.github.com>
pollDepositTriggers fetches pending transactions, but unsettled deposits
can reverse. Skip pending / posted=0 rows so buy-ticket smoke is not
fired against unavailable funds.

Co-authored-by: Ossie Irondi <AojdevStudio@users.noreply.github.com>
Co-authored-by: Ossie Irondi <AojdevStudio@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 51a6c17

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant