Navigation

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

    Not able to get gainersLosers, PutCallRatio & OIBuildup

    Python SDK
    2
    2
    2
    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.
    • S
      sanjay09 last edited by

      Hi Team,
      Based on info available here i tried to integrate following API but i'm not getting any result.
      https://smartapi.angelone.in/docs/TopGainers

      APIS:
      https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/putCallRatio
      https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/gainersLosers
      https://apiconnect.angelone.in/rest/secure/angelbroking/marketData/v1/OIBuildup

      Example:

      --------------------------------------------------------------

      # TOP GAINERS / LOSERS
      # --------------------------------------------------------------
      def get_top_gainers_losers(self):
      
          api = self.get_api()
      
          try:
      
              payload = {
                  "exchange": "NSE"
              }
      
              resp = api._postRequest(
                  "marketData/v1/gainersLosers",
                  payload
              )
      
              if not resp:
                  return {"gainers": [], "losers": []}
      
              if not resp.get("status"):
                  logger.warning(f"Gainers/Losers fetch failed: {resp}")
                  return {"gainers": [], "losers": []}
      
              data = resp.get("data", {})
      
              return {
                  "gainers": data.get("gainers", []),
                  "losers": data.get("losers", [])
              }
      
          except Exception as e:
              logger.error(f"Gainers/Losers API error: {e}")
              return {"gainers": [], "losers": []}
      

      While testing :
      c = SmartAPIClient()
      c.login()
      movers = c.get_top_gainers_losers()

      print("Top Gainers:")
      for g in movers["gainers"][:5]:
          print(g)
      
      print("\nTop Losers:")
      for l in movers["losers"][:5]:
          print(l)
      

      Getting this output.
      [2026-03-16 10:13:33,230] [INFO] main: Logging into SmartAPI...
      [I 260316 10:13:33 smartConnect:124] in pool
      [2026-03-16 10:13:33,683] [INFO] main: ✔ SmartAPI Login Successful
      [2026-03-16 10:13:33,684] [ERROR] main: Gainers/Losers API error: 'marketData/v1/gainersLosers'
      Top Gainers:

      Top Losers:

      Process finished with exit code 0

      Facing same issue with other API's as well.

      Note: I'm testing this from my local machine, where other apis are working fine but not able to get these info always both in offline market and live market

      Any help with working ways how to get the result will be helpful specially Put Call Ratio is needed.

      A 1 Reply Last reply Reply Quote 0
      • A
        algo_trading_50 @sanjay09 last edited by

        @sanjay09 Sample code here.

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