A CLI-based portfolio management and trading simulator built using C++. It allows users to manage their portfolio, intraday positions, watchlist, and funds while fetching live market data through APIs. This project works with the KiteConnect API to fetch current market prices and supports various order types like CNC (Cash and Carry), MIS (Margin Intraday Square-off) & NRML (Normal Order).
-
User Management:
- Login, registration, and password recovery system with hashed passwords and security questions.
- Supports multiple users.
-
Market Data:
- Fetch real-time market data (OHLC) using the KiteConnect API.
-
Place Orders:
- Users can place CNC, NRML, and MIS orders.
- Updates the current balance, portfolio/positions, and trade history based on the trade executed.
- Fetches the lot sizes for each instrument to ensure only valid quantities can be bought.
-
Portfolio Management:
- View and manage long-term holdings.
- Calculate unrealized profit/loss based on live market data.
-
Intraday Positions:
- View and manage short-term trades (MIS).
- Display real-time updates for intraday positions.
-
Watchlist:
- Add and remove stocks from a custom watchlist.
-
Funds Management:
- View current balance, add funds, and withdraw funds.
-
Trade History:
- View all trades executed by a user.
- Standard C++ Libraries:
iostream,fstream,vector,string,iomanip,thread,chrono,sstream,algorithm,map,functional,cmath,cstdlib,ctime. - POSIX Functions: Used for non-blocking input and terminal manipulation.
- Python 3.x: Required for API scripts.
- KiteConnect: Python SDK for fetching live market data.
- Twisted: For WebSocket connections.
- GCC/G++: C++ compiler with C++23 support.
- Make: Build automation tool.
- Anaconda (Python Distribution): For running Python scripts.
├── Core/
│ ├── APIs/
│ │ ├── api_KiteConnectWS_LTP_Once.py
| | ├── api_KiteConnectWS_OHLC_Once.py
| | ├── apicall_KiteConnect_LTP.cpp
│ │ ├── apicall_KiteConnect_LTP.h
| | ├── apicall_KiteConnect_OHLC.cpp
| | ├── apicall_KiteConnect_OHLC.h
| | ├── fetchInstruments.txt
| | ├── filterInstruments.cpp
| | ├── instrumentSearch.py
| | ├── KiteConnect_filteredInstruments.csv
| | ├── KiteConnect_instruments.csv
│ ├── Funds/
│ │ ├── funds.cpp
│ │ ├── funds.h
│ ├── Menu/
│ │ ├── mainmenu.cpp
│ │ ├── mainmenu.h
│ ├── Orders/
│ │ ├── buy-sell.cpp
│ │ ├── buy-sell.h
| | ├── getLotSize.cpp
| | ├── getLotSize.h
│ ├── Portfolio/
│ │ ├── portfolio.cpp
│ │ ├── portfolio.h
│ ├── Positions/
│ │ ├── intraday.cpp
│ │ ├── intraday.h
| ├── TradeHistory/
| | ├── tradehistory.cpp
| | ├── tradehistory.h
│ ├── UserLogin/
│ │ ├── login.cpp
│ │ ├── login.h
| ├── Watchlist
| | ├── watchlist.cpp
| | ├── watchlist.h
│ ├── holding.h
| ├── intradayPosition.h
| ├── setNonBlockingMode.cpp
│ ├── setNonBlockingMode.h
├── Keys/
| ├── KiteConnect.key
| ├── KiteConnect_AccessToken.key
├── main.cpp
├── Makefile
├── README.md
-
Clone the Repository:
git clone https://github.com/username/kite-simulator.git cd kite-simulator -
Install Dependencies:
- Install required Python packages:
pip install kiteconnect twisted
- Install required Python packages:
-
Configure API Keys:
- Place your KiteConnect API key and Access Token in the
Keysfolder.
- Place your KiteConnect API key and Access Token in the
-
Build the Project:
- Use the Makefile to compile the project:
make
- Use the Makefile to compile the project:
-
Run the Project:
- Run the compiled executable:
./kite-simulator
- Run the compiled executable:
- Login/Register: Start by logging in or registering as a new user.
- Main Menu Options:
- View Market Data
- Place Orders (MIS/NRML/CNC).
- View Portfolio.
- View Intraday Positions.
- Manage Funds (Add/Withdraw/View).
- Manage Watchlist.
- View Trade History
- Exit: Press
Qin any submenu to return to the main menu.
- Undefined Symbols/Error: Ensure all header files are correctly included and linked.
- Permission Errors: Ensure you have read/write permissions for the data files in
Core/. - Python Errors: Ensure Python scripts have the correct shebang and paths.
- Adit Jain
- Dhwani Balchandani
This project is licensed under the MIT License.