fix(web): derive expiry-day markers from trades.expiry, not hardcoded Tue/Thu#7
Merged
SwathiMystery merged 1 commit intomainfrom Apr 21, 2026
Merged
Conversation
… Tue/Thu The previous check marked every Tuesday (BSE) and Thursday (NSE) regardless of whether anything actually expired on that day for this user — noisy, and wrong the moment SEBI shifts weekly expiry days again (it already has, more than once). The DB knows the real answer: every execution row carries the derivative expiry from the broker. - New query: expiry_days_in_range(user, start, end_excl) → frozenset[date] - Calendar view passes a per-month expiry set to the template - Day view computes is_expiry as membership in a single-day range - helpers.is_expiry_day kept as a thin compatibility shim that returns False unless an explicit set is passed (no more global Tue/Thu opinion) - Legend copy: 'weekly expiry (Tue/Thu)' → 'expiry of a contract you traded'
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.
What
Calendar expiry marker was hardcoded to Tue/Thu. Now reads the actual
trades.expiryvalues from the user's own DB.Why
drvExpiryDate, normalised intotrades.expiry.Changes
khata/web/queries.py::expiry_days_in_range(user, start, end_excl) → frozenset[date]— distinct expiry dates from the user's trades inside a half-open window.khata/web/main.py— calendar view passes per-month set; day view membership-tests its single date.khata/web/helpers.py::is_expiry_day— kept as a thin compatibility shim; returns False unless an explicit set is passed.khata/web/templates/calendar.html— usesd in expiry_daysdirectly; legend updated to "expiry of a contract you traded".Verification
Against a live account:
SELECT DISTINCT expiry FROM tradesChecklist
uv run ruff check khata testscleanuv run ruff format khata testsapplied