Skip to content

v1.8.0: Sync from Edge Trader for Schwab - #52

Merged
simonro merged 9 commits into
mainfrom
feature/edge-trader-sync
Nov 10, 2026
Merged

simonro merged 9 commits into
mainfrom
feature/edge-trader-sync

Conversation

@simonro

@simonro simonro commented Nov 10, 2026

Copy link
Copy Markdown
Owner

Adds POST /api/sync/edge-trader so Edge Trader for Schwab v1.5.0 can send its fills, per-trade notes, order timeline and day notes to the journal, only on the user's Sync and Apply.

Backend

  • Dry run returns a state token bound to the request and the journal's state; Apply sends the same payload; backup first, all or nothing, 409 if anything changed since the preview.
  • Fills deduplicated against earlier syncs and statement imports (exact, then merged statement fills with tracked allocation); a moved trade takes its sync record along.
  • Two option fills of one order in one second become one vertical; kept as legs when the journal already holds a leg on its own.
  • Only Edge Trader's server can call it: requests with a browser Origin or Sec-Fetch-Site are refused (403). Non-finite numbers and conflicting duplicate ids are refused (422).
  • Execution add, edit and delete wait for a running sync or import.

Frontend

  • Trade View timeline (hover shows the event on the chart, click pins it), stop and target history lines, Edge Trader day note on the Diary and Day Review; chart window uses the real Eastern offset.

Review
Independent ChatGPT audit, 3 passes (6 + 3 + 2 high, 2 medium, 2 low), each finding reproduced with a failing test before the fix. Backend 453 passed, frontend 106 passed, CI=true npm run build clean. End-to-end test with Edge Trader's real client on a throwaway database.

Version 1.8.0.

🤖 Generated with Claude Code

tapetoedge and others added 9 commits November 10, 2026 12:14
Edge Trader for Schwab sends Schwab fills, per-trade entries, timed notes, order events and a
day note only when the trader clicks Apply on a preview. The dry run runs the whole sync in one
transaction and rolls it back, returning a state token; Apply backs the database up, then applies
all or nothing, or answers 409 with a fresh preview if the journal changed since. A journal edit
wins over Edge Trader. Fills route per instrument or per trade picked in the preview and are
deduped against statement imports (a fill the journal split at a reversal counts once).
Two option fills of one order in one second become one vertical at the net price.

The import and the sync share trade_store.py (one lock, never overwriting a stored trade the batch
did not rebuild); sync rows follow a regroup, and deleting or moving a trade or an account
releases them. Clearing a day's diary keeps the Edge Trader day note. The chart window uses the
real Eastern offset (EST in winter).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Trade Details lists a trade's synced stop, target and note events in US Eastern time. Hovering
or focusing an event shows it on the chart (a guide at its bar, a price line for stops and
targets on stock charts); a click keeps it there until clicked again. Stock charts draw the stop
and target history as stepped lines, with note pins over the bars. The Diary and Day Review show
the Edge Trader day note above the uploaded diaries, and clearing a day leaves it. Candles use each
day's real Eastern offset, so fills, events and bars line up in winter too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on the trade chart

What the sync sends, that it is opt-in and click-only, the preview and Apply, the backup before
writing, how to point Edge Trader at the journal's address, and what the optional AI feedback sends
to Anthropic.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e access

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
They read, change and rewrite a trade's whole fill list, so they now hold the same lock as the
Edge Trader sync and the CSV import: a sync committing in between can no longer be overwritten
by a list read before it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oken, no browser calls)

- A fill a sync already stored or matched no longer covers a later fill at the same price that
  day, and a fill covered by a merged statement fill keeps its share across syncs.
- A transaction repeated in one request counts once; two different ones under one id are refused.
- A vertical whose leg an earlier sync stored on its own stays as single legs.
- A covered fill belongs to the account holding the statement fill, not the route.
- The state token binds the request, the journal tables the sync reads, and the plan: Apply with a
  changed note or event, or after any journal change, is refused (409). The preview lists every
  trade Apply changes, including an open vertical the sync closes in place.
- POST /api/sync/edge-trader refuses requests from web pages (Origin or a cross-site
  Sec-Fetch-Site), 403; Edge Trader posts from its server and sends neither.
- NaN and Infinity in transactions, events and annotations are refused (422).
- The moved-trade test now syncs, moves the trade in Trade View and syncs again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Upgrading a database: new and stored rows get their qty and lead key back; rows covered by a
  merged statement fill before this version keep an unknown share, so that day's merged pool never
  covers a new fill (it is added as new and named in the preview).
- Moving a trade moves the sync's record of its fills, so they never act as a merged statement
  fill in the new account.
- A vertical whose contracts the journal holds as open single legs is kept as legs, so a closing
  vertical closes each leg with its own P&L.
- The execution-edit lock tests check the answer and the stored fills for add, update and delete,
  and a sync committing a close while the edit waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n a move)

- Whether a vertical is kept as single legs is decided in the account the fill goes to (its pick,
  else the option route); an open vertical there on the same two contracts keeps it a vertical, so
  a single leg in another account never splits it.
- Moving a trade moves the sync record of a reversal fill only with its first half, the half that
  stands for the whole fill, so moving either side never lets it cover a later fill.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@simonro
simonro merged commit 46f5690 into main Nov 10, 2026
3 checks passed
@simonro
simonro deleted the feature/edge-trader-sync branch November 10, 2026 18:09
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.

2 participants