Need to fetch Delta difference (interval can be 10s or 30s) for Delta Neutral Strategy

I want to fetch the Delta Difference between two positions at intervals of 10s or 30s.

I wrote this piece of code making use of api call,

underlying_symbol = 'NSE_INDEX|Nifty 50'
expiry_date = '2024-06-27'

# option_chain_data = get_option_chain(instrument_key, expiry_date)

def get_realtime_delta(instrument_key, strike_price, order_type):
    option_chain_data = get_option_chain(underlying_symbol, expiry_date)

    for option in option_chain_data:
        if option['strike_price'] == strike_price:
            if order_type == 'CE':
                return option['call_options']['option_greeks']['delta']
            elif order_type == 'PE':
                return option['put_options']['option_greeks']['delta']
    return None

import time
# Function to run the code
def calculate_delta_diff():
    deltas = []

    for i in order_df['strike_price']:
        instrument_key = order_df.loc[order_df['strike_price'] == i, 'instrument_key'].values[0]
        strike_price = i
        order_type = order_df.loc[order_df['strike_price'] == i, 'order_type'].values[0]

        real_time_delta = get_realtime_delta(instrument_key, strike_price, order_type)

    # Calculate the difference between the two obtained real-time deltas
    if len(deltas) == 2:
        delta_diff = abs(abs(deltas[0]) - abs(deltas[1]))
        #Threshold activate code
        print(f"Difference between the obtained real-time deltas: {delta_diff}")
        print("Error: DataFrame must contain exactly two orders to calculate the difference.")

# Main loop to run the function every 5 seconds
while True:

Or should I use websocket for this? And also after making positions, in sensibull page we can see the delta difference how do I access that page?

if you are not using web socket you might get 429 error.Upstox api support only 1000 requests per 30m…And to access sensibull page i think you should have UpLink for Business