Fix: read orders from the list that isn't stale after a partial fill - #11
Merged
Merged
Conversation
Raw-verified against the live API (2026-07-29), same orderId after 1 of 3
tokens filled:
GET /orders?propertyId=X -> quantity 3 (the ORIGINAL size, stale)
GET /orders?all=true -> quantity 2 (what remains)
GET /orders/{id} -> quantity 2 (authoritative, agrees)
The property-scoped list keeps reporting the original quantity, so the quote
primitives — its only readers — sized and covered against a position that no
longer existed: a recenter would re-post the original 3 rather than the
remaining 2, quietly re-growing a position a fill had just reduced.
Two of three endpoints agree on the remainder, so this is upstream rather than
our parsing — confirmed through the raw passthrough before concluding anything,
per the LOF-8/9 lesson.
fetch_state now uses `all=true` filtered client-side, matching what `account
coverage` and `rewards eligibility` already do — which is why those two
disagreed with `quote recenter` about the same live order.
Claude-Session: https://claude.ai/code/session_01J7bz8aijn2Uwv1yF5rUenW
piekstra-dev
approved these changes
Jul 29, 2026
piekstra-dev
left a comment
Collaborator
There was a problem hiding this comment.
Automated PR Review
Reviewed commit: 3ed610054eab
Profile: reviewer - Posting as: piekstra-dev
Summary
| Severity | Findings |
|---|---|
| blocking | 0 |
| major | 0 |
| minor | 0 |
| nits | 0 |
0 PR discussion threads considered. 0 summarized; 0 resolved.
Completed in 32s | $0.41 | claude-sonnet-5 | cr 0.10.268
| Field | Value |
|---|---|
| Model | claude-sonnet-5 |
| Reviewers | unavailable |
| Engine | claude_cli · claude-sonnet-5 |
| Reviewed by | cr · piekstra-dev |
| Duration | 32s wall · 29s compute |
| Cost | $0.41 |
| Tokens | 12 in / 1.8k out |
Per-workstream usage
| Workstream | Model | In | Out | Cache read | Cache create | Cost | Duration |
|---|---|---|---|---|---|---|---|
| orchestrator-selection | claude-sonnet-5 | 6 | 1.5k | 22.3k | 35.4k | $0.24 | 20s |
| orchestrator-rollup | claude-sonnet-5 | 6 | 377 | 47.8k | 24.9k | $0.17 | 9s |
piekstra
added a commit
that referenced
this pull request
Jul 29, 2026
Ships the mutating quote family and the stale-quantity fix: - `lofty quote recenter` — move a resting quote safely (#9) - `lofty quote provision` — post a fresh two-sided quote, refusing to leave you one-sided (#10) - `lofty quote pull` — stand down, `--keep-above` protecting recovery asks (#10) - fix: read orders from the list that isn't stale after a partial fill (#11) All three are a DRY RUN unless `--execute`, and share one implementation of the rails: never cross the market, never exceed cover, never go under minContracts, stay in the reward band, and touch only the sides given a price. Exercised against a live account before release — a there-and-back recenter restored the exact starting state, and every rail was confirmed refusing a real attempt. Claude-Session: https://claude.ai/code/session_01J7bz8aijn2Uwv1yF5rUenW
piekstra
added a commit
that referenced
this pull request
Jul 30, 2026
Raw-verified against the live API (2026-07-29), same orderId after 1 of 3
tokens filled:
GET /orders?propertyId=X -> quantity 3 (the ORIGINAL size, stale)
GET /orders?all=true -> quantity 2 (what remains)
GET /orders/{id} -> quantity 2 (authoritative, agrees)
The property-scoped list keeps reporting the original quantity, so the quote
primitives — its only readers — sized and covered against a position that no
longer existed: a recenter would re-post the original 3 rather than the
remaining 2, quietly re-growing a position a fill had just reduced.
Two of three endpoints agree on the remainder, so this is upstream rather than
our parsing — confirmed through the raw passthrough before concluding anything,
per the LOF-8/9 lesson.
fetch_state now uses `all=true` filtered client-side, matching what `account
coverage` and `rewards eligibility` already do — which is why those two
disagreed with `quote recenter` about the same live order.
piekstra
added a commit
that referenced
this pull request
Jul 30, 2026
Ships the mutating quote family and the stale-quantity fix: - `lofty quote recenter` — move a resting quote safely (#9) - `lofty quote provision` — post a fresh two-sided quote, refusing to leave you one-sided (#10) - `lofty quote pull` — stand down, `--keep-above` protecting recovery asks (#10) - fix: read orders from the list that isn't stale after a partial fill (#11) All three are a DRY RUN unless `--execute`, and share one implementation of the rails: never cross the market, never exceed cover, never go under minContracts, stay in the reward band, and touch only the sides given a price. Exercised against a live account before release — a there-and-back recenter restored the exact starting state, and every rail was confirmed refusing a real attempt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
After a partial fill,
GET /public/v1/orders?propertyId=Xkeeps reporting the order's original quantity. Raw-verified on the live API — sameorderId, after 1 of 3 tokens filled:GET /orders?propertyId=XGET /orders?all=trueGET /orders/{id}(authoritative)Two of three agree on the remainder, so this is upstream, not our parsing — checked through the raw passthrough before concluding anything, per the LOF-8/9 lesson where two filed "API bugs" turned out to be ours.
Why it matters
The
quoteprimitives were the only readers of that endpoint, so they sized and covered against a position that no longer exists:recenterdefaults size to the resting quantity, so it would re-post the original 3 rather than the remaining 2 — quietly re-growing a position a fill had just reduced, and spending capital to do it.It also explains a concrete inconsistency seen live:
account coveragereported this order as$124.50(2 × $45.00) whilequote recenterplanned againstx3. Two commands disagreeing about the same live order is exactly what destroys trust in a tool that spends money.The fix
fetch_statenow readsall=trueand filters by property client-side — the same pathaccount coverageandrewards eligibilityalready use, which is why those two were right.Notes
Found while deploying real capital after a bid partially filled. Worth filing upstream separately; the CLI shouldn't wait on that.
Unit tests construct
Statedirectly so they're unaffected — all 92 pass,fmtandclippy -D warningsclean. Live re-verification is pending an unattended keychain prompt on this machine; the raw-API table above is what establishes the behaviour.