Skip to content

fix: resolve stale watchlist and premature monitoring issues - #13

Merged
kunalrbhatia merged 1 commit into
masterfrom
fix/stale-watchlist-early-monitoring
May 13, 2026
Merged

fix: resolve stale watchlist and premature monitoring issues#13
kunalrbhatia merged 1 commit into
masterfrom
fix/stale-watchlist-early-monitoring

Conversation

@kunalrbhatia

Copy link
Copy Markdown
Owner

Overview

This PR addresses the 'Buy scrip not found' errors and unexpected 10:00 AM breach detections observed in the logs.

Problem

  1. Stale Watchlist: The \ radeStore\ was not cleared daily, and the PM2 process persists state across days. This caused the previous day's watchlist to be monitored on subsequent days.
  2. Early Monitoring: The cron schedule for \Price Monitor\ and \Trade Monitor\ was too broad (*/5 10-15 * * 1-5), causing it to start at 10:00 AM, before the \Morning Scanner\ (scheduled for 10:30 AM) could provide a fresh watchlist.
  3. Invalid Data: The monitoring logic did not validate if LTP was valid (e.g., > 0), leading to 'Breach detected at 0' logs when the API returned empty or invalid data.

Solution

  1. Daily Initialization: Added a \dailyInit\ task at 9:00 AM IST to refresh the Angel One session, download the scrip master, and clear the \ radeStore.
  2. Refined Cron Schedules: Corrected monitoring crons to run between 10:35 AM and 3:25 PM, ensuring they only operate after the scan is complete.
  3. LTP Validation: Added checks in \Price Monitor\ and \Morning Scanner\ to skip stocks with LTP <= 0.
  4. State Management: Added \clearWatchList\ to \TradeStore\ to ensure a clean slate every morning.

Verification

  • Added unit tests for \clearWatchList\ and LTP validation.
  • All 18 test suites passed (137 tests total).
  • 100% coverage in \jobs/\ and \store/\ modules.
  • Performed final sanity checks: \lint, \ ormat, \ ypecheck, \�uild, and \ est.

@kunalrbhatia
kunalrbhatia merged commit 8c475b2 into master May 13, 2026
2 checks passed
@kunalrbhatia
kunalrbhatia deleted the fix/stale-watchlist-early-monitoring branch May 13, 2026 07:48
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.

1 participant