Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    History API is stop returning data for any MCX future stock

    Test
    0
    2
    15
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      N51542847 last edited by

      Hi @admin123 @admin @administrators ,

      History API is stop returning data for MCX future stock's data.
      Can you please resolve this issue or suggest if any changes has made recently to make it work.

      Thanks in advance!

      Sample code -

      def fetchDataOneline(in_exchange,in_symboltoken):
      obj = SmartConnect(api_key=apikey)
      data = obj.generateSession(username, pud, pyotp.TOTP(token).now())
      refrashToken = data['data']['refreshToken']
      res = obj.getProfile(refrashToken)
      print(res['data']['exchanges'])
      try:
      historicParam = {
      "exchange": in_exchange,
      "symboltoken": in_symboltoken,
      "interval": "FIVE_MINUTE",
      "fromdate": "2023-06-10 15:55",
      "todate":"2023-06-22 15:55"
      }
      historic_data = obj.getCandleData(historicParam)

          # Extract the candle data from the 'data' key
          candle_data = historic_data['data']
      
          # Create a DataFrame from the candle data
          df = pd.DataFrame(candle_data, columns=['timestamp', 'open', 'high', 'low', 'close', 'volume'])
          print(df)
      
      except Exception as e:
          print("Historic Api failed: {}".format(e.message))
      # logout
      try:
          time.sleep(1)
          logout = obj.terminateSession('N51542847')
          print("Logout Successfully")
      except Exception as e:
          print("Logout failed: {}".format(e.message))
      
      return df
      

      in_exchange= "MCX"
      in_symboltoken = "244731"

      Output:
      bdad71f4-a2c0-4f45-9d4e-3abe630ad27e-image.png

      M 1 Reply Last reply Reply Quote 0
      • M
        Moderator_2 @N51542847 last edited by

        Hi @N51542847

        Apologies for delayed response.
        We have verified for few of MCX future stock (Instance: ALUMINI24FEBFUT), we are able to fetch the data from the historical API. Kindly reverify and make sure the token passed is not expired and let us know if the issue still occurs.

        Thanks & Regards,
        SmartAPI team

        1 Reply Last reply Reply Quote 0
        • First post
          Last post