INNER CODE UNIT · Python
check_daily_reset
buzzsubash/algo_trading_strategies_india · broker-utilities/mtm_square_off_zerodha/zerodha_ltp_subscriber.py:191
def check_daily_reset(self):
"""Reset daily tracking at start of new trading day"""
today = time.strftime('%Y-%m-%d')
if today != self.current_date:
self.logger.info(f"🌅 New trading day detected: {today}")
self.logger.info(f"📊 Yesterday tracked {len(self.daily_instruments)} instruments")
# Clear yesterday's instruments and subscriptions
self.daily_instruments.clear()
self.current_date = today
# Unsubscribe from all (fresh start for new day)
if self.subscribed_tokens:
try:
self.ticker.unsubscribe(list(self.subscribed_tokens))
self.subscribed_tokens.clear()
self.logger.info("🔄 Cleared all subscriptions for new trading day")
except Exception as e: