if i opt under ‘upstox plus’ is it MANDATORY to subscribe ONLY under ‘Full D30 (Plus)’ or I can even subscribe ‘Option Greeks’ or ‘Full’?
under ‘upstox plus’ if I subscribe ONLY under ‘Option Greeks’ mode with ‘5 connections per user’ how many scrips per connection i can subscrbe for? [2000 + 2000 + 2000 + 2000 + 2000 = 10000]?
under ‘upstox plus’ if I subscribe ONLY under ‘Full’ mode with ‘5 connections per user’ how many scrips per connection i can subscrbe for? [2000 + 2000 + 2000 + 2000 + 2000 = 10000]? or [1500 + 1500 + 1500 + 1500 + 1500 = 7500]?
under ‘upstox plus’ if I subscribe ONLY under ‘Full D30 (Plus)’ mode with ‘5 connections per user’ how many scrips per connection i can subscrbe for? [2000 + 2000 + 2000 + 2000 + 2000 = 10000]? or [1500 + 1500 + 1500 + 1500 + 1500 = 7500]?
async def fetch_market_data():
“”“Fetch market data using WebSocket and print it.”“”
# Create default SSL context
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
# Configure OAuth2 access token for authorization
configuration = upstox_client.Configuration()
api_version = '2.0'
configuration.access_token = 'ACCESS_TOKEN'
# Get market data feed authorization
response = get_market_data_feed_authorize(
api_version, configuration)
# Connect to the WebSocket with SSL context
async with websockets.connect(response.data.authorized_redirect_uri, ssl=ssl_context) as websocket:
print('Connection established')
await asyncio.sleep(1) # Wait for 1 second
# Data to be sent over the WebSocket
data = {
"guid": "someguid",
"method": "sub",
"data": {
"mode": "full",
"instrumentKeys": ["NSE_INDEX|Nifty Bank", "NSE_INDEX|Nifty 50"]
}
}
# Convert data to binary and send over WebSocket
binary_data = json.dumps(data).encode('utf-8')
await websocket.send(binary_data)
# Continuously receive and decode data from WebSocket
while True:
message = await websocket.recv()
decoded_data = decode_protobuf(message)
# Convert the decoded data to a dictionary
data_dict = MessageToDict(decoded_data)
# Print the dictionary representation
print(json.dumps(data_dict))
Execute the function to fetch market data
asyncio.run(fetch_market_data())
I will be running above .py file in multiple of connections.