Extract applyImportedTrades into 18b-chain-apply.js#67
Merged
Conversation
Moves dedup-by-txHash, open/close split, close-trade matching, and
OPEN→EXPIRED outcome correction out of syncRysk/syncHypersurface into
two pure, dual-exported functions in a new module:
applyCloseTrade(tradesArray, closeTrade) → boolean
applyImportedTrades(tradesArray, openTrades, closeTrades, synced)
→ { added, closedCount, corrected }
Outcome correction now runs across the full trades array on every sync,
covering both RYSK and HSFC trades (previously each sync only corrected
its own platform). syncRysk and syncHypersurface become thin wrappers:
fetch → parse → applyImportedTrades → save/render if changed.
Adds test/unit/chain-apply.test.js (10 pure-Node tests, no jsdom).
Closes #59
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
syncRysk/syncHypersurfaceinto two pure, dual-exported functions in a newsrc/js/18b-chain-apply.jsmoduleapplyCloseTrade(tradesArray, closeTrade)— parameterised ontradesArrayinstead of closing over the global, returns booleanapplyImportedTrades(tradesArray, openTrades, closeTrades, synced)→{ added, closedCount, corrected }— handles dedup, pushes open trades (strippingisClose), applies close trades, runs OPEN→EXPIRED correction across the full arraysyncRyskandsyncHypersurfacebecome thin wrappers: fetch → parse →applyImportedTrades→ save/render if anything changedTest plan
test/unit/chain-apply.test.jsadded — 10 pure-Node tests (no jsdom) covering all acceptance criteria:isCloseabsent from pushed tradesnpm test)python3 build.py --checkpasses (26 JS modules, syntax OK)Closes #59
🤖 Generated with Claude Code