Rate limit exceeded when calling option chain quotes API

11:35am 03-Jul-2023

Hi! While using the option chain quotes API, I am getting 'API call  per limit exceeded' when I using the following code:

import time

import datetime as dt

import numpy as np

import pandas as pd

import sys

import requests

import json

from breeze_connect import BreezeConnect

import datetime as dt

 

 

iciciToken = 14256454

expiry = dt.datetime(2023,7,6)

 

from breeze_connect import BreezeConnect

isec = BreezeConnect(api_key='XXX')

connection = isec.generate_session(api_secret='XXX', session_token=str(iciciToken))

print ('ISEC connection : ', connection)

 

def getOptionChainData(isec,expiry):

    a = 0

    while a < 3:

        try:

            data = isec.get_option_chain_quotes(stock_code="NIFTY",

                                exchange_code="NFO",

                                product_type="options",

                                expiry_date=expiry.isoformat()[:10] + 'T09:00:00.000Z',

                                right="call",

                                strike_price="")

 

            dfCall = pd.DataFrame(data['Success'])

            spot = float(dfCall.iloc[0]['spot_price'])

            

            data2 = isec.get_option_chain_quotes(stock_code="NIFTY",

                                exchange_code="NFO",

                                product_type="options",

                                expiry_date=expiry.isoformat()[:10] + 'T09:00:00.000Z',

                                right="put",

                                strike_price="")

 

            dfPut = pd.DataFrame(data2['Success'])

            spot = float(dfPut.iloc[0]['spot_price'])

            break

        except:

            print ('Cannot get option chain data, retrying ...', dt.datetime.now())

            a+=1

            if a==3 :

                print ('Coulnot get data after 3 attempts, SKIPPING FOR THIS TIME!!')

                return None, None, None

    return dfCall, dfPut, spot

 

 

 

dfCall, dfPut, spot = getOptionChainData(isec,expiry)

print (dfCall)

print (dfPut)

print (spot)

 

! I am pretty sure I am not calling 100 APIs per minute, which is the rate limit of Breeze. Why is this error coming repeatedly?

 

Please Login or Signup
-