This repository contains a Python script for integrating with the Upstox API to fetch holdings, place orders, and subscribe to a WebSocket feed for real-time updates. The fetched data is stored in a MySQL database.
Before running the script, make sure you have:
-
Python installed on your system.
-
Required Python packages installed. You can install them using pip:
pip install pymysql requests websocket-client
-
An Upstox API key and access token. You can obtain these from the Upstox developer portal.
-
MySQL installed on your system or access to a MySQL database.
-
Update the MySQL connection configuration in the script (
mysql_config
) with your MySQL server details. -
Replace
'your_upstox_api_key'
and'actual_access_token_value_here'
with your Upstox API key and access token respectively.
-
Clone the repository to your local machine:
git clone https://github.com/your_username/Upstox-API.git
-
Navigate to the repository directory:
cd upstox-api-integration
-
Run the script:
python upstox_integration.py
-
The script will fetch holdings, save them to the MySQL database, and subscribe to the WebSocket feed for real-time updates.
-
Ensure your Upstox API key and access token are kept secure. It's recommended to use environment variables or a configuration file to store sensitive information.
-
Add error handling and logging to enhance the robustness of the script.
-
Test the script thoroughly before using it in a production environment.
This project is licensed under the MIT License.