Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Problem Statement: 6) AI for the Indian Investor

Chart Pattern Intelligence — Real-time technical pattern detection (breakouts, reversals, support/resistance, divergences) across the full National Stock Exchange (NSE) universe — with plain-English explanation and historical back-tested success rates for that pattern on that specific stock

NSE Chart Pattern Intelligence (CPI)

Full-universe NSE EQ scanning · intraday structure · same-code backtests · Gemini-powered explanations

A production-style MVP: rotate through the NSE equity registry, detect chart patterns on fresh 5m/15m bars, aggregate a screener and sector heatmap, and serve a Next.js desk UI with charts, timelines, and optional Google Gemini JSON narratives—while daily history backtests use the same deterministic pattern engine for consistency.


Highlights

Area What you get
Universe NSE EQUITY_L.csv (EQ) → SQLite registry; optional sector_map.json + name heuristics
Live detection pattern_logic on intraday OHLCV (Yahoo Finance, TTL cache)
Backtests Same detect_all_at_index slid over daily bars; configurable horizon & success threshold
Scanner Background batches → scan_results
AI Structured Gemini output when GEMINI_API_KEY is set; template fallback otherwise
UI Multi-page app: Overview, Opportunities, Sector heat, Stock terminal (?symbol= deep links)

Tech stack

Backend: FastAPI · SQLAlchemy · SQLite · Pandas / NumPy · yfinance · httpx · python-dotenv

Frontend: Next.js 15 · React 19 · Tailwind CSS · Recharts · Lucide


Repository layout

ET_GenAI/
├── backend/
│   ├── app/
│   │   ├── main.py          # API + lifespan (scanner)
│   │   ├── core/            # config, settings
│   │   ├── db/              # SQLAlchemy models
│   │   ├── services/        # universe, ingest, scanner, patterns, AI, backtest
│   │   └── ...
│   ├── data/
│   │   └── sector_map.json  # optional symbol → sector / cap overrides
│   ├── requirements.txt
│   └── .env                 # create locally (not committed)
├── frontend/
│   ├── app/(app)/           # routed pages: /, /opportunities, /heatmap, /terminal
│   ├── components/
│   └── ...
└── README.md

Quick start

Prerequisites

  • Python 3.11+ (recommended)
  • Node.js 20+ and npm
  • Outbound HTTPS (NSE CSV, Yahoo, Gemini if used)

1. Backend

cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

Create backend/.env (see Environment below). Then:

uvicorn app.main:app --reload --port 8000

First-time registry: call sync so the DB has EQ symbols (UI: Sync universe, or HTTP below):

POST http://localhost:8000/api/universe/sync

The scanner starts with the app and processes symbols in batches (SCANNER_BATCH_SIZE, SCANNER_INTERVAL_SEC in config).

2. Frontend

cd frontend
npm install
npm run dev

Open http://localhost:3000.

If the API is not on port 8000, set:

# frontend/.env.local
NEXT_PUBLIC_API_BASE_URL=http://localhost:8000

Environment

Variable Where Purpose
GEMINI_API_KEY backend/.env Enables Gemini JSON explanations (AI Studio key)
GEMINI_MODEL backend/.env Optional override (default gemini-2.0-flash)
GEMINI_API_BASE backend/.env Optional API base URL
DATABASE_URL backend/.env Optional; default SQLite backend/data/cpi.db
NEXT_PUBLIC_API_BASE_URL frontend/.env.local Backend origin for browser fetches

Verify Gemini: GET http://localhost:8000/api/ai/ping → ok: true when the key and model work.


API (selected)

Method Path Notes
GET /health Liveness + scanner flag
POST /api/universe/sync Refresh NSE listing into DB
GET /api/universe/stats Active EQ count
GET /api/universe/symbols?q=&limit= Symbol search (registry)
GET /api/screener/opportunities Filtered list (paginated cap)
GET /api/screener/opportunities-full Full evaluation rows + filter notes
GET /api/screener/heatmap Per-sector bull/bear counts
GET /api/stocks/insight?symbol= Chart, signals, backtests, AI, timeline
GET /api/ai/ping Gemini connectivity check

Frontend routes

Path Purpose
/ Dashboard overview
/opportunities Full screener table → links to terminal
/heatmap Sector signal heat
/terminal Watchlist, chart, insight; use ?symbol=TCS

Design notes

  • Intraday data drives live signals; daily bars drive historical backtest stats so multi-year samples stay meaningful.
  • Detection logic is shared (pattern_logic); only the OHLCV timeframe differs.
  • This software is for research and education, not personalized investment advice.

Publishing to GitHub

Use a repository rooted in this folder (not your user home directory).

A. New repo on GitHub

  1. On GitHub: New repository → name it (e.g. nse-chart-pattern-intelligence), leave empty (no README/license if you will push existing files).

B. Initialize Git locally (from this project root)

cd path\to\ET_GenAI
git init
git add .
git commit -m "Initial commit: NSE Chart Pattern Intelligence MVP"
git branch -M main
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git
git push -u origin main

Use SSH if you prefer: git@github.com:YOUR_USERNAME/YOUR_REPO.git

C. If Git was initialized in the wrong folder before

If git status shows your entire home directory, either run the commands above from ET_GenAI only after git init there, or clone a fresh repo and copy the project in.


License

Add a LICENSE file when you decide how you want to share the code (e.g. MIT).

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages