Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. Prasanna.k
    P
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Prasanna.k

    @Prasanna.k

    1
    Reputation
    3
    Posts
    1
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    Prasanna.k Follow

    Best posts made by Prasanna.k

    • RE: Getting Invalid API Key for Top Gainers API

      yes sir same problem occurs v{'success': False, 'message': 'Invalid Token', 'errorCode': 'AG8001', 'data': ''} please resolve this so we can fetch it using Functions Like SmartAPI.xyz

      posted in Bugs
      P
      Prasanna.k

    Latest posts made by Prasanna.k

    • RE: Getting Invalid API Key for Top Gainers API

      yes sir same problem occurs v{'success': False, 'message': 'Invalid Token', 'errorCode': 'AG8001', 'data': ''} please resolve this so we can fetch it using Functions Like SmartAPI.xyz

      posted in Bugs
      P
      Prasanna.k
    • RE: getLtpData Rate limit changed?

      @admin123 @admin still getting this error on connection time out
      num_threads = 2
      delay_between_requests = 0.1 which sends 4 requests but still gets connection time out of my strategy which completes its ops in 90 sec at present it takes more than 280 sec (5 min approx). please resolve this.

      posted in Python SDK
      P
      Prasanna.k
    • how can i fetch strike price of futures stock

      url = "https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json"

      Read the JSON file and store it as a DataFrame

      df = pd.read_json(url)
      df1 = df[df['exch_seg'] == 'NFO']# retrieve only nfo segment

      print (df1)

      df1.to_csv('NFO.csv', index=True)

      df2 = df1[(df1['instrumenttype'] == 'FUTSTK') & (df1['expiry'] == '27JUL2023')]#retrive only option stock

      df2.to_csv('NFOOPTSTK.csv', index=False)

      print (df2)

      df2.loc['expiry'] = pd.to_datetime(df2['expiry'] ) #to sort according to expiry

      expdt = df2.sort_values('expiry') #to sort according to expiry

      print (expdt)

      expdt.to_csv('sortedexp.csv', index=False)

      Filter the DataFrame based on the condition

      assingn_value = df2[(df2['instrumenttype'] == 'FUTSTK')]

      tokens = assingn_value['token'].tolist()
      symbols = assingn_value['symbol'].tolist()
      names = assingn_value['name'].tolist()
      instrument_types = assingn_value['instrumenttype'].tolist()
      exch_types = assingn_value['exch_seg'].tolist()
      lot_size = assingn_value['lotsize'].tolist()

      print(names, lot_size, symbols)

      combined_data = list(zip(tokens, symbols, names, instrument_types, exch_types, lot_size))

      print("Combined Data:", combined_data) # Check if combined_data has any data

      for row in combined_data:

      print(*row)

      for one stock or symbol

      try:

      ltp = smartApi.ltpData('NFO', symbols[1], tokens[1])

      print(ltp)

      except Exception as e:

      print("Error fetching LTP data:", e)

      for multiple stock using DF

      ltp_data_list = []

      try:
      for i in range(len(symbols)):
      # Assuming the JSON data is returned by smartApi.ltpData function
      ltp_data = smartApi.ltpData('NFO', symbols[i], tokens[i])

          # Extract relevant data from the JSON
          exchange = ltp_data['data']['exchange']
          tradingsymbol = ltp_data['data']['tradingsymbol']
          symboltoken = ltp_data['data']['symboltoken']
          open_price = ltp_data['data']['open']
          high_price = ltp_data['data']['high']
          low_price = ltp_data['data']['low']
          close_price = ltp_data['data']['close']
          ltp = ltp_data['data']['ltp']
          lotsize = lot_size[i]
      
          # Append data to the list
          ltp_data_list.append({
              'Exchange': exchange,
              'symbol': tradingsymbol,
              'Exchange' : exchange,
              'token': symboltoken,
              'Open': open_price,
              'High': high_price,
              'Low': low_price,
              'Close': close_price,
              'LTP': ltp,
              'lotsize' :lot_size[i]
          })
      
          # Optional: print each symbol and LTP
          # print("Symbol: {} | LTP: {}".format(symbols[i], ltp))
      

      except Exception as e:
      print("Error fetching LTP data:", e)

      Create a DataFrame

      ltp_df = pd.DataFrame(ltp_data_list)

      print(ltp_df)

      ltp_df.to_csv ('ltp.csv', index= False )

      filtered_stocks = ltp_df[I will write condition ] I want to fetch strike price of stock how can i

      posted in Python SDK
      P
      Prasanna.k