A Production-Ready Portfolio Dashboard for Kotak Neo API
Project description
Kotak Neo Portfolio Dashboard ๐
A professional, production-ready Python dashboard for tracking your Kotak Securities portfolio in real-time. Built with Streamlit, this application connects to the Kotak Neo API to provide live P&L tracking, sector analytics, and visual portfolio insights.
๐ Features
๐ Live Portfolio Hydration
- Automatically fetches live market quotes (LTP)
- Updates your portfolio value in real-time
๐ง Intelligent Caching
- Smart fallback logic
- Calculates Day's Change using OHLC data if the live feed is incomplete
๐ Visual Analytics
- Day's P&L Tracking: See exactly how much your portfolio moved today
- Sector Allocation: Interactive Donut charts showing exposure by sector
- Allocation Bar Chart: Visual breakdown of investment distribution
๐ Secure Authentication
- Uses TOTP (Time-based OTP) for seamless 2FA login
- Credentials stored securely in a local
.envfile (never hardcoded)
๐งฑ Robust Architecture
- Modular backend design
- Separation of:
- Authentication
- Data Fetching
- Analytics
๐ Project Structure
kotak-dashboard/
โโโ .devcontainer/ # VS Code Dev Container configuration
โโโ .github/workflows/ # CI/CD Pipelines
โโโ kotak_dashboard/ # Main Application Package
โ โโโ __init__.py
โ โโโ app.py # Streamlit UI Layer
โ โโโ backend.py # Core Logic (Auth, API, Math)
โ โโโ cli.py # Command-line entry point
โโโ tests/ # Test Suite
โ โโโ conftest.py
โ โโโ test_backend_analytics.py
โ โโโ test_backend_data.py
โโโ .env.example # Template for API credentials
โโโ Dockerfile # Production-ready Docker image
โโโ pyproject.toml # Modern Python dependency management
โโโ README.md # Documentation
๐ ๏ธ Prerequisites
Python Environment
- Python 3.11+ (Strict requirement for neo_api_client compatibility)
Kotak Neo API Credentials
You will need the following from the Kotak Neo API Portal:
- Consumer Key
- Mobile Number
- UCC (User Client Code)
- TOTP Secret Key (The alphanumeric key used to generate 2FA codes)
- MPIN
โ๏ธ Installation & Setup
Option 1: Standard Local Install (Recommended)
-
Clone the repository
git clone https://github.com/yourusername/kotak-dashboard.git cd kotak-dashboard
-
Create a Virtual Environment (Python 3.11)
# macOS/Linux python3.11 -m venv .venv source .venv/bin/activate # Windows py -3.11 -m venv .venv .venv\Scripts\activate
-
Install Dependencies We use pip to install the package in editable mode.
pip install --upgrade pip pip install -e .
Option 2: Using Docker ๐ณ
Run the dashboard in an isolated container without installing Python locally.
-
Build the image
docker build -t kotak-dashboard .
-
Run the container
docker run -p 8501:8501 -v $(pwd)/.env:/app/.env kotak-dashboard
Option 3: VS Code Dev Container
- Open the project folder in VS Code.
- Install the Dev Containers extension.
- Press F1 and select "Dev Containers: Reopen in Container".
- VS Code will build a fully configured environment for you.
๐งช Running Tests
This project uses pytest for unit testing. The test suite covers:
- Authentication flows
- Data hydration logic
- Analytics calculations
Install Test Dependencies
pip install -e .[test]
๐ CI/CD Pipeline
The project includes a GitHub Actions workflow (.github/workflows/ci_cd.yml) that automatically:
- Sets up Python 3.11
- Runs the full test suite with
pytest - Builds the Python package (Source Distribution & Wheel)
- Uploads the build artifacts to GitHub
๐ Configuration
First Run Setup
When you run the app for the first time, a sidebar will appear asking for your credentials.
- Enter your Consumer Key, Mobile, UCC, TOTP Secret, and MPIN.
- Click "Save & Login".
- This will automatically create a
.envfile in your project root.
Manual Setup (Optional)
Copy the example file and fill it in manually:
cp .env.example .env
Edit .env:
KOTAK_CONSUMER_KEY=your_key_here
KOTAK_MOBILE=9876543210
KOTAK_UCC=YA004
KOTAK_TOTP_SECRET=YOURSECRETKEY123
KOTAK_MPIN=123456
๐โโ๏ธ Usage
Once installed, you can start the dashboard using the command line:
kotak-dashboard
Or directly via Streamlit:
streamlit run kotak_dashboard/app.py
Open your browser to http://localhost:8501 to view your portfolio.
โ ๏ธ Disclaimer
This application is an unofficial tool built for educational and personal tracking purposes. It interacts with the Kotak Neo API but is not affiliated with Kotak Securities.
- Trading Risk: Stock market investments are subject to market risks. This tool does not provide financial advice.
- Security: Your credentials are stored locally on your machine in the
.envfile. Do not share this file or commit it to public repositories.
Built with โค๏ธ using Python & Streamlit.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kotak_dashboard-1.0.0.tar.gz.
File metadata
- Download URL: kotak_dashboard-1.0.0.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcfba1765ba2ed0bcf1aab6918c8458becfd95737dbf778494e82303d76d41bd
|
|
| MD5 |
f299515b5b9226a237ac0911be927de8
|
|
| BLAKE2b-256 |
0d3eca54bdaf57f24bfa84697d79806ac12131bbaca922b4146bebe1d22ec123
|
File details
Details for the file kotak_dashboard-1.0.0-py3-none-any.whl.
File metadata
- Download URL: kotak_dashboard-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23cbfd515073aff19996d53036cbe43ae615a268afa40f4cb11a10e809e1bcad
|
|
| MD5 |
a0ac9a27d7d2b19c3c02a5b7ce2968ab
|
|
| BLAKE2b-256 |
154115268d05622d46c5c49a3ed3394bb0d40db2b97b53bf820a2c0f2821a36e
|