Repository navigation
v1.7.1: P&L, import and review fixes from a full audit - #50
Merged
Merged
Conversation
Import - A fill that flips the position (long 100, sell 200) is split at zero: the long closes with its P&L and the short opens. The split is redone when an earlier fill arrives in a later import, survives an unchanged execution edit, and a re-import still recognises the original statement line. - Fractional shares that add up to a closed position are a closed trade (tolerance everywhere, execution edits keep fractional size). - Duplicate detection knows the option contract (expiry, strike, type, second strike), in the database fingerprints and in Thinkorswim's cash-balance / trade-history matching. - Later fills on an open single-leg option are regrouped into round trips; a fill joins an open vertical only when it is the same vertical. - Notes and tags follow their fills when a regroup renumbers trades; when two reviewed trades merge, both reviews are kept. Numbers - Manual option and futures trades use the contract multiplier (backend, Add Trade preview, Trade Details ROI and dollar risk). A manual exit at $0 is a closing fill. - Profit factor uses net P&L on both sides; open positions no longer count in win rate, expectancy or trade count (KPIs and the year view). Other - Diary uploads: validated date, server-made unique file names, nothing outside the uploads folder. - Day Review reloads lifetime numbers per account; late responses no longer overwrite Day Review, Reports or a regenerated review. Every fix has a regression test that fails on v1.7.0 (backend/tests/test_audit_fixes.py, frontend integration and TradeDetail tests). ChatGPT-reviewed (3 passes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e rebuild fails - When a regroup scores which new trade inherits an old trade's notes, the two halves of a split reversal count as different fills, so notes on the short no longer move to the preceding long. - If a rebuilt trade cannot be stored, the whole import is rolled back instead of leaving the trades it replaced deleted. ChatGPT-reviewed (4th pass, on the private port). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
A full audit of v1.7.0 found 12 bugs, 6 of which could show wrong P&L or other numbers. Every fix below has a regression test that fails on v1.7.0 and passes here. Four ChatGPT review passes on the fixes found 10 more edge cases, all fixed and tested.
Fixes
Import and grouping
Numbers
Other
Effect on the bundled samples
Tested
test_audit_fixes.py).ChatGPT-reviewed (4 passes).
🤖 Generated with Claude Code