Skip to content

0aagam/stock-strategy-analyzer

Repository files navigation

Stock Strategy Analyzer

A web app to search NSE/BSE stocks, view candlestick charts, and apply trading strategies (Moving Average, RSI) with Buy/Sell signal overlays.


Tech Stack

Layer Tech
Frontend Next.js + Tailwind CSS + TradingView Lightweight Charts
Backend FastAPI + yfinance + pandas
Hosting Vercel (both frontend & backend)

Local Development

1. Backend

cd files
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m uvicorn api.index:app --reload --host 127.0.0.1 --port 8000

Backend runs at: http://127.0.0.1:8000
Test it: http://127.0.0.1:8000/market-overview

2. Frontend

cd files
npm install
npm run dev

Frontend runs at: http://localhost:3000

The frontend uses the backend via the /api prefix in production, and you can still use the local backend at http://127.0.0.1:8000 during development.


Deployment to Vercel (both free)

Step 1 — Deploy the Backend

  1. Push the backend/ folder to a GitHub repo (can be the same repo)
  2. Go to https://vercel.com → New Project → import that repo
  3. Set Root Directory to backend
  4. Deploy. Note the URL — e.g. https://stock-analyzer-backend.vercel.app

Step 2 — Deploy the Frontend

  1. Go to Vercel → New Project → import the same (or different) repo
  2. Set Root Directory to frontend
  3. Add environment variable:
    • Key: NEXT_PUBLIC_API_URL
    • Value: your backend Vercel URL from Step 1
  4. Deploy.

API Reference

GET /market-overview

Returns NIFTY 50, SENSEX values + top 5 gainers/losers from a hardcoded watchlist.

GET /stock?symbol=RELIANCE&interval=5m

Returns OHLC candle data.
Intervals: 1m | 5m | 15m | 30m | 1h

GET /analyze?symbol=RELIANCE&interval=5m&strategy=ma

Returns candles + Buy/Sell signals + summary.
Strategies: ma (Moving Average) | rsi (RSI)


Notes

  • Data is delayed ~15 minutes (yfinance limitation)
  • 1m data only goes back 7 days; 5m/15m up to 60 days
  • MA strategy needs at least 50 candles — use 15m, 30m, or 1h timeframes for best results
  • The .NS suffix is auto-added if you type just RELIANCE instead of RELIANCE.NS

Releases

No releases published

Packages

 
 
 

Contributors