IntradayEdge
AI in Trading

Building a Personal AI Stock Screener in Python (India Edition)

A practical blueprint for building your own AI-augmented stock screener for NSE — data sources, indicator stack, LLM verdict layer, and what to be careful about.

IntradayEdge Editorial · 2026-05-25 · 9 min read

If you can use a screener like Chartink or Trendlyne, you can build a basic version of one yourself in Python — and add an AI verdict layer on top. The skill ceiling is lower than people think.

This is the design that works for Indian equities.

Why build your own

Off-the-shelf screeners constrain you to their indicators and their universes. A personal screener gives you:

  • Full control over what to filter (your indicators, your weights).
  • An AI narrative layer on top, tuned to your style.
  • Free or near-free running cost.
  • A backtest you actually trust because you wrote the rules.

It also forces you to clarify your strategy. Half the value is in the rule-writing, not the running.

Stack overview

Layer Tool
Universe NSE Nifty 500 (or sub-set)
Data yfinance, nsepython, or paid (e.g., Kite Connect)
Indicators pandas-ta or TA-Lib
Scoring Plain Python (rule-based composite)
LLM verdict OpenAI / Gemini / a local Llama model
Output CSV, Markdown email, or a small web UI (Streamlit / Flask)

Total moving parts: small. Total Python LOC for a working v1: under 300.

The data problem (read first)

Indian equity data sources have known issues:

  • yfinance works but is undocumented and breaks occasionally; symbols are RELIANCE.NS.
  • nsepython wraps NSE endpoints — fragile when NSE rotates them.
  • Kite Connect (Zerodha) — paid, official, the right answer if this becomes a real workflow.
  • Upstox API / Angel One SmartAPI — alternatives with broker-backed support.

For prototyping, yfinance is fine. For production daily runs, move to a broker API.

Indicator block (minimum viable)

A minimal indicator block per stock:

Pseudo-code shape:

for each ticker in universe:
    df = fetch_ohlcv(ticker, lookback=200)
    df = compute_indicators(df)
    score = composite_score(df.iloc[-1])
    if score > threshold:
        candidates.append({ticker, score, snapshot})

That’s the deterministic part. It’s reproducible, debuggable, and free.

The composite score

Simplest: each indicator gives +1 / 0 / −1 vote. Sum them.

Indicator +1 if −1 if
RSI(14) > 55 rising falling
MACD histogram positive rising negative falling
SuperTrend green recent flip recent flip red
Above 20-EMA yes no
Volume > 1.2× 20-day avg yes < 0.8×

Score 0–5. Filter at score ≥ 3.

This is the same shape as traditional rule-based screeners — and it gives you the explainability they have.

The LLM verdict layer

After the deterministic shortlist, pass each candidate to an LLM with a constrained prompt:

You are an equity-research assistant. Given the indicator snapshot
below for {ticker}, classify the setup as BUY / HOLD / SELL with a
one-line verdict and a two-sentence reasoning. Use ONLY the data
provided. Do not invent news or fundamentals.

INDICATORS:
- RSI(14): 62, rising
- MACD: +0.34, histogram positive
- SuperTrend(10,3): green
- Above 20-EMA: yes
- Volume: 1.4x 20-day average

Three rules for the prompt:

  1. Constrain context. Don’t let the LLM use prior knowledge — too much hallucination risk.
  2. Force structure. Ask for fixed JSON output ({"verdict": "BUY", "reason": "..."}) so you can parse it.
  3. Cap tokens. Short outputs cost less and hallucinate less.

For the broader pattern, read ChatGPT for stock analysis in India.

Costs

For Nifty 500 daily with a frontier-model LLM verdict per stock:

  • ~500 calls × ~400 tokens each = 200K tokens/day.
  • At current frontier-model pricing, that’s ₹50 – ₹150/day depending on model and rate.
  • Use a smaller model (gpt-4o-mini, Gemini Flash, Llama 3.1 8B local) and the cost falls to single-digit rupees per day.

For prototyping, run on Nifty 100 and use a free-tier API.

A pragmatic project layout

ai-screener/
  data/
    fetch.py         # universe + OHLCV
  indicators/
    compute.py       # RSI, MACD, SuperTrend, VWAP
  score/
    composite.py     # rule-based scoring
  ai/
    verdict.py       # LLM call + JSON parsing
  output/
    write_md.py      # daily Markdown shortlist
  run_daily.py       # entry point

Tiny. Maintainable. Yours.

Pitfalls

  1. Don’t auto-trade. Build the screener; keep the trade decision. AI hallucinations + auto-execution = blown account.
  2. Watch lookahead. When backtesting, only use data that would have been available at signal time. Easy to mess up with adjusted prices.
  3. Validate by paper trading. 30 trades minimum before any real money.
  4. Track expectancy, not win rate. See AI signal accuracy.
  5. Don’t over-engineer the AI layer. A great deterministic screen + a thin LLM layer beats a fancy ML model 95% of the time.

What IntradayEdge does similarly

The IntradayEdge dashboard is essentially this architecture, productized: deterministic indicators → composite score → LLM verdict per shortlisted stock → human review. It is research output, not advice; see the disclaimer.

If you want to understand how an AI screener works, build a v1 yourself. If you want to use one daily without maintenance, use a built one.

FAQs

Do I need a GPU? No. Indicator computation is CPU/pandas. LLM calls go to a hosted API. Local LLMs are optional.

What’s the easiest free data source? yfinance for prototyping. Move to a broker API for production.

Should I use an ML model for ranking instead of rules? You can. Start with a rule-based score. Once you have 12+ months of out-of-sample results, then train a gradient-boosted model on the same features. Don’t start with ML.

For the bigger context, read AI stock analysis in India.

Continue reading

All posts →
Disclaimer: IntradayEdge is an educational and research workflow. It is not a SEBI-registered investment advisor and does not offer buy/sell recommendations. Read the full disclaimer.