i want to capure 7 mins trading activity of bank nifty and store the values in ecel sheet, can some one tell me where to start
Hello,
To get started, follow these steps:
-
Create an Application
Visit Upstox Apps and create your application. -
Obtain the Session Token
Generate the session token and integrate the API into your application. -
Fetch Intraday Data
Use the Intraday Candle Data API to retrieve 1-minute Bank Nifty trading activity for today. -
Capture 7-Minute Activity
If you need 7-minute trading activity, extract the last 7 OHLC (Open, High, Low, Close) values from the data. -
Export Data to Excel
Process the data and export it to an Excel sheet as needed.
You can implement this using any framework of your choice, such as Python.
Thanks!
import time
import upstox_python_sdk
Replace with your Upstox API credentials
API_KEY = “"
API_SECRET = "”
ACCESS_TOKEN = “YzMDkzLCJpc3MiOiJ1ZGFwaS1nYXRld2F5LXNlcnZpY2UiLCJleHAiOjE3NDM2MzEyMDB9.5D51EN3MFrDTfUj0WYy6uiWD2JCpnwCmUeBy94yS1zs”
Initialize the Upstox client
client = upstox_python_sdk.Upstox(API_KEY, API_SECRET)
client.set_access_token(ACCESS_TOKEN)
Function to fetch live market data
def get_live_data(symbol, exchange=“NSE_EQ”):
try:
data = client.get_live_feed(symbol, exchange, ‘full’)
return data
except Exception as e:
print(“Error fetching data:”, e)
return None
Example: Fetching real-time data for RELIANCE stock
symbol = “RELIANCE”
exchange = “NSE_EQ”
while True:
live_data = get_live_data(symbol, exchange)
if live_data:
print(f"Time: {time.strftime(‘%H:%M:%S’)} | Price: {live_data[‘last_price’]}")
time.sleep(2) # Fetch data every 2 seconds
I tried with these code but it was showing error with moule
I believe you are trying the script from chat gpt… I’m travelling on the same boat.
yes ram, why should we collaborate and work
Hello,
Please refer to API docs: GitHub - upstox/upstox-python: Official Python SDK for accessing Upstox API instead of using ChatGPT.
Thanks & Regards
Sure, we can work together.
How can we connect, I’m ready to connect at insta profile name: Standupnaveen