# 📊 Zerodha Live Market Data to Excel

Real-time streaming of **Stocks, Futures & Options** data from Zerodha directly into Microsoft Excel.


## 🎯 Features

✅ **Real-time Data**: Live market data every 1 seconds
✅ **Multi-Asset**: Stocks, Futures, Options support  
✅ **Data Columns**: LTP, OHLC, Volume, Market Depth, OI
✅ **Excel Integration**: Direct streaming into Excel spreadsheet
✅ **F&O Support**: Complete derivatives trading data



## 🎯 Supported Instruments

**Equities**: RELIANCE, TCS, INFY, etc.
**Futures**: NIFTY25JUNFUT, BANKNIFTY25JUNFUT, etc.
**Options**: NIFTY25JUN24800CE, BANKNIFTY25JUN56000PE, etc.

## ⚙️ Initial Setup

### 1. **Zerodha TOTP Setup**
🎬 **Watch this video for complete setup:** https://youtu.be/jLjbrDXgD54

This video shows you exactly how to:
- Enable TOTP in your Zerodha account
- Get the secret key needed for the application

### 2. **Credentials Setup (Auto-Generated)**
🎉 **No manual file creation needed!** 

The application will automatically collect and save your credentials on first run:

1. **Run the application**: `Windows.exe or MacOS`
2. **Follow the interactive prompts** to enter:
   - Zerodha User ID (e.g., AB1234)
   - Zerodha Password
   - TOTP Secret (from QR code)
3. **Credentials are saved automatically** in `credentials.json`
4. **Future runs use saved credentials** - no re-entry needed!

**🔒 Security:** Credentials file is automatically secured with proper permissions.

### **Step 5: Add Symbols**
In Excel Column A, add any of these:

**Stocks:** `RELIANCE`, `TCS`, `INFY`
**Futures:** `NIFTY25JUNFUT`, `BANKNIFTY25JUNFUT`  
**Options:** `NIFTY25JUN24800CE`, `BANKNIFTY25JUN56000PE`

### **Done! 🎉**
Watch real-time market data update every 1 seconds!




## 🔧 Troubleshooting

### **Issue: Login Failed**
**Solution:**
- Check `credentials.json` format
- Verify TOTP secret is correct


### **Issue: Symbol Not Found**
**Solution:**
- Use exact symbol names: `NIFTY25JUNFUT` not `NIFTY JUN FUT`
- Check expiry dates for F&O contracts
- Verify symbol exists on exchange




## 💡 Pro Tips

### **1. Symbol Format Guidelines**
- **Futures:** `SYMBOL25JUNFUT` (e.g., NIFTY25JUNFUT)
- **Options:** `SYMBOL25JUN24800CE` (CE=Call, PE=Put)
- **Stocks:** Standard NSE symbols (RELIANCE, TCS)

### **2. Performance Optimization**
- **Limit symbols:** Use 10-20 symbols for best performance
- **Close unused Excel files**
- **Stable internet** for consistent updates

### **3. Data Analysis**
- **Sort by volume** to find active contracts
- **Watch OI changes** for F&O momentum
- **Use color coding** for quick price trend identification

---

## 🛑 Important Notes

### **⚠️ Security**
- **Never share** your `credentials.json` file
- **Log out** from Zerodha after use
- **Keep software updated**

### **⚠️ Market Hours**
- Data only available during **market hours** (9:15 AM - 3:30 PM IST)
- **Pre-market** and **after-hours** may have limited data

### **⚠️ Data Usage**
- Real-time data uses **internet bandwidth**
- **WebSocket connection** required throughout session
---

**🎉 Enjoy professional-grade market data streaming!**
