A real-time stock market visualization tool built using the Fyers WebSocket API and Python.
This application:
- Fetches historical OHLCV (Open, High, Low, Close, Volume) market data
- Streams real-time live market ticks
- Dynamically updates candlestick charts in real-time
The project demonstrates:
- Real-time market data streaming
- Candlestick generation from live ticks
- Volume reconstruction using cumulative exchange volume
- Financial data visualization using Python
A candlestick chart is one of the most commonly used chart types in financial markets.
Each candle represents price activity over a fixed interval of time (1 minute in this project).
A single candle contains:
| Component | Meaning |
|---|---|
| Open | Price at the beginning of the interval |
| High | Highest traded price during the interval |
| Low | Lowest traded price during the interval |
| Close | Price at the end of the interval |
| Volume | Number of shares/contracts traded |
Candlestick charts help traders visualize:
- Market trends
- Momentum
- Volatility
- Reversal patterns
- Buying/Selling pressure
- Real-time WebSocket-based market updates
- Historical + live data synchronization
- Dynamic candlestick creation
- Real-time volume bars
- Automatic candle updates every second
- Timezone-aware timestamps (IST)
- Memory-efficient rolling candle window
- Live matplotlib animation
| Technology | Purpose |
|---|---|
| Python | Core programming language |
| Pandas | Data manipulation |
| Matplotlib | Plotting engine |
| mplfinance | Financial charting |
| Fyers API v3 | Market data access |
| WebSocket | Real-time streaming |
| pytz | Timezone handling |
project/
│
├── autoLogin.py
├── configuration.py
├── credentials.py
├── historicalData.py
├── main.py
├── newCandlestick.py
├── plot.py
├── requirements.txt
├── LICENSE
└── README.md
Install dependencies using:
pip install -r requirements.txtExample requirements.txt:
pandas
matplotlib
mplfinance
pytz
fyers-apiv3
To run this project you need:
- A Fyers trading account
- API credentials
- Access token
Generate the access token using:
python autoLogin.pyNote: Due to SEBI guidelines, a new access token must be generated daily.
Run:
python main.pyThe application will:
- Fetch historical market data
- Connect to the live WebSocket stream
- Open a real-time updating candlestick chart
The WebSocket feed provides:
- Total traded volume for the entire trading session
However, candlestick charts require:
- Volume traded during each candle interval
This project reconstructs candle volume using:
Incremental Volume = Current Total Volume - Previous Total Volume
This is similar to how professional market data systems process exchange feeds.
Current configuration:
- 1-minute candles
Can be extended to:
- 5-minute candles
- 15-minute candles
- Hourly candles
- Daily candles
Note: Refer to Fyers API documentation for supported resolutions.
- Real-time market monitoring
- Algorithmic trading dashboards
- Market microstructure analysis
- Quantitative finance projects
- Trading strategy visualization
- Educational demonstrations
- Internet connection is required
- Market must be open for live updates
- Access tokens expire periodically
- Designed primarily for educational and visualization purposes
Potential upgrades:
- Technical indicators (EMA, VWAP, RSI)
- Multi-timeframe charts
- Persistent database storage
- Multi-symbol support
- GUI improvements
- Thread-safe architecture
- Strategy backtesting integration
- Order book visualization
Vaibhav Saxena
This project is intended for educational and personal use.