INNER CODE UNIT · Python

delta

aaryansinha16/AI-trader · backend/app.py:590

        delta = (ticks[i] - ticks[i - 1]).total_seconds()
        if delta >= min_gap_secs:
            gaps.append((ticks[i - 1], ticks[i]))

    # Trailing gap: last tick → now
    if (now_ist - ticks[-1]).total_seconds() >= min_gap_secs:
        gaps.append((ticks[-1], now_ist))

    return gaps


def _backfill_ticks_if_stale():
    """
    During market hours, scan today's NIFTY-I tick coverage for gaps and
    fill each one via TrueData REST `getticks`. Idempotent: deletes the
    affected window first to dedupe with anything the websocket has
    streamed in parallel.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…