Trading & Securities — Real-World Use Case
Live Trading Analysis & Market Important Levels
I built this to show what actually goes on behind the scenes when you hear “automated trading analysis.” A Python script talks to a broker's API, pulls live intraday data and historical charts for Nifty stocks, crunches the numbers to figure out the trend, and spits out actionable levels — entry, stop-loss, targets. Whether you're looking at intraday scalps, swing trades, or positional setups, the system covers it. Pick a symbol below and see it in action.
Live Market Analysis
Live market analysis is where scattered price data becomes a picture you can trade from. This page pulls together streaming prices, technical indicators, and market notes across major instruments — so instead of jumping between tabs before a trade window closes, you have what you need in one place.
The heatmap shows what's moving and what isn't. Individual charts let you switch timeframes and layer indicator overlays to check entry and exit zones. Anything requiring more context — historical setups, trade ideas, longer-form analysis — is a click away. If you're new here, start with the "How to use this page" panel. It's a short pre-trade checklist, and it's worth reading before you act on anything.
One thing to be clear about: the signals here are a starting point, not a strategy. Use them to confirm what your broader analysis already suggests. Size your position, set your stop-loss, and check signals on a higher timeframe before entering. A live monitor surfacing momentum is useful. A live monitor replacing risk management is not.
For developers consuming the data feeds: rendering is optimized for speed; static content above the charts is structured for search indexing.
Market Analysis Dashboard
Why I Built This — And What It Actually Does
If you've ever wondered how professional trading desks and fintech startups automate their market research, this is it. Not a theoretical diagram — a real, working system. I wrote a Python script that connects to a broker's REST API, downloads live intraday data and historical price charts for over 100 NSE-listed stocks, and then runs a full trading analysis pipeline on each one.
The analysis isn't just one thing. It covers intraday levels for day traders who need to know where the stock might bounce or break down in the next hour. It covers swing trading analysisfor traders holding positions for a few days to a couple of weeks — identifying swing highs, swing lows, and the price zones where momentum is likely to shift. And it covers positional trading analysis for folks who take broader bets on the trend over weeks to months.
At its core, the system does what any good chart analysistool does — it reads the price action, figures out whether the market structure is bullish, bearish, or chopping sideways, identifies key support and resistance levels, and looks for high- probability setups where the risk-reward makes sense. The difference is: it does all of this automatically, for every stock in the Nifty universe, every single time you hit “Run Analysis.”
What the Trading Analysis Covers
When you select a symbol and run the analysis, here's what happens under the hood:
- •Trend & Market Structure— The system looks at the last 20+ price bars to determine if the stock is making higher highs and higher lows (bullish), lower highs and lower lows (bearish), or just ranging. This is the foundation of every trade decision.
- •Intraday Levels & VWAP— For day traders, VWAP (Volume Weighted Average Price) tells you if the stock is trading at a premium or discount to the day's average. The system calculates it from live data and flags which side of VWAP the price sits on — a critical decision point for intraday trading analysis.
- •Swing Highs & Swing Lows— These are the recent peaks and valleys where price reversed. They act as natural support and resistance, and they're exactly the levels swing traders watch for breakouts or bounces. Every swing trading level the system finds is displayed in the results.
- •Price Imbalances (Fair Value Gaps)— When price moves too fast in one direction, it leaves gaps behind. These gaps tend to get filled, creating trade opportunities. The system detects bullish and bearish imbalances automatically.
- •Volume Analysis— A breakout without volume is just noise. The system compares the current bar's volume against the recent average to confirm whether a move has real conviction behind it or if it's a fakeout.
- •Setup Generation with Risk Management— Only when the trend, VWAP position, and volume all align does the system generate a trade setup. Every setup comes with a specific entry price, stop-loss (placed outside the liquidity zone), and two targets (1:1 and 1:2 risk-reward). It never risks more than 1% of capital per trade. No exceptions.
Whether you're running quick intraday levels for the morning session, scanning for swing trading setups to hold over the week, or building a positional trading watchlist, the system adapts based on the timeframes and data it processes.
Python Code Walkthrough
4 steps · Upstox V3 API · Multi-timeframe pipeline
A few key snippets from the Python pipeline — the full logic, proprietary rules, and credentials are kept private, but these patterns are the real building blocks of any production trading system.
1. Loading the Instrument Universe
Every trading system starts with knowing what you can trade. Upstox publishes a master instrument JSON with every listed security. We load and filter to our NSE universe.
import json, os
# Upstox publishes the full NSE instrument master
with open('NSE.json', 'r', encoding='utf-8') as f:
instruments = json.load(f)
# Build symbol → instrument_key lookup (equity + indices)
universe = {
item['trading_symbol']: item['instrument_key']
for item in instruments
if item.get('segment') in ('NSE_EQ', 'NSE_INDEX')
}
print(f"Universe: {len(universe)} instruments loaded")
# Universe: 130 instruments loaded2. Multi-Timeframe Data Fetch (Upstox V3 API)
We fetch three timeframes in parallel — Daily (bias), 4H (structure), 1H (entry). V3 uses /v3/historical-candle/<key>/<unit>/<interval>/<to>/<from>.
import requests
from datetime import datetime
from concurrent.futures import ThreadPoolExecutor
API_BASE = "https://api.upstox.com/v3/historical-candle"
headers = {
'Accept': 'application/json',
'Authorization': f'Bearer {os.environ["UPSTOX_TOKEN"]}'
}
def fetch_candles(key, unit, interval, from_date, to_date):
"""V3: /v3/historical-candle/{key}/{unit}/{interval}/{to}/{from}"""
url = f"{API_BASE}/{key}/{unit}/{interval}/{to_date}/{from_date}"
r = requests.get(url, headers=headers)
r.raise_for_status()
return r.json().get('data', {}).get('candles', [])
def fetch_mtf(instrument_key, to_date):
"""Fetch Daily + 4H + 1H in parallel."""
with ThreadPoolExecutor(max_workers=3) as ex:
f_daily = ex.submit(fetch_candles, instrument_key, 'days', 1, '2020-01-01', to_date)
f_h4 = ex.submit(fetch_candles, instrument_key, 'hours', 4, '2023-01-01', to_date)
f_h1 = ex.submit(fetch_candles, instrument_key, 'hours', 1, '2024-01-01', to_date)
return f_daily.result(), f_h4.result(), f_h1.result()3. Parsing & Normalising Candle Data
V3 returns [timestamp, open, high, low, close, volume, oi] arrays. We normalise to a consistent Candle dataclass and sort oldest-first.
from dataclasses import dataclass
from typing import List
@dataclass
class Candle:
ts: str
open: float; high: float; low: float; close: float; volume: int
def parse_candles(raw: list) -> List[Candle]:
"""Normalise V3 candle arrays → Candle objects, oldest-first."""
candles = []
for bar in raw:
if not isinstance(bar, list) or len(bar) < 6:
continue
candles.append(Candle(
ts=str(bar[0]), open=float(bar[1]), high=float(bar[2]),
low=float(bar[3]), close=float(bar[4]), volume=int(bar[5])
))
# V3 returns newest-first — reverse for chronological order
return list(reversed(candles))4. Running the Full Multi-TF Pipeline
The main loop processes every symbol, fetches all three timeframes, saves to disk for the downstream analysis engine. 130+ symbols complete in under 90 seconds.
from datetime import date
to_date = date.today().strftime('%Y-%m-%d')
os.makedirs('output', exist_ok=True)
errors = []
for symbol, key in universe.items():
try:
raw_d, raw_h4, raw_h1 = fetch_mtf(key, to_date)
result = {
"symbol": symbol,
"daily": [[c.ts, c.open, c.high, c.low, c.close, c.volume]
for c in parse_candles(raw_d)],
"h4": [[c.ts, c.open, c.high, c.low, c.close, c.volume]
for c in parse_candles(raw_h4)],
"h1": [[c.ts, c.open, c.high, c.low, c.close, c.volume]
for c in parse_candles(raw_h1)],
}
with open(f"output/{symbol}.json", 'w') as f:
json.dump(result, f, separators=(',', ':'))
print(f"✓ {symbol:12s} D:{len(result['daily'])} 4H:{len(result['h4'])} 1H:{len(result['h1'])}")
except Exception as e:
errors.append(symbol)
print(f"✗ {symbol}: {e}")
print(f"\nDone. {len(universe)-len(errors)}/{len(universe)} OK | {len(errors)} failed: {errors}")Security:API tokens live in server-side environment variables only — never in source code or the frontend. The web dashboard talks to a Cloudflare Worker proxy that injects credentials server-side before forwarding to Upstox.
How the System Fits Together
The trading analysis pipeline is split into four layers. Each one does one job well.
Python Data Pipeline
The workhorse. A Python script loads the instrument list, authenticates with the broker, and fetches intraday + historical data for 100+ stocks in under a minute.
Python · requests · json · os
Secure API Proxy
An edge function sits between the browser and the broker. It holds the API credentials server-side, so nothing sensitive ever touches the frontend.
Cloudflare Workers · TypeScript
Interactive Dashboard
The UI you see on this page. Pick a symbol, hit analyse, and the results render instantly. No page reloads, no server round-trips for the chart analysis.
Next.js · React · Tailwind CSS
Analysis Engine
Runs entirely in your browser. Trend detection, VWAP, swing levels, imbalance detection, and setup generation — all computed client-side for speed.
TypeScript · Client-side compute