Navigation

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

    Announcing Top Gainers/ Losers, PCR and OI BuildUp APIs for SmartAPI Users

    General Discussion
    0
    16
    363
    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.
    • M
      Moderator_1 last edited by

      Dear SmartAPI users,

      We are glad to announce Top Gainers/ losers, PCR (Put Call Ratio) and OI Build Up API in the derivatives segment for our users.

      1. Top Gainers/ Losers
        Top Gainers/Losers API gives you the Top gainers and Losers in the derivatives segment for the day. You can choose from which types of data you want. The data is available for three time periods, i.e. near(Current Month), next(Next Month), Far (The month after next month).

      API end point for the same is:

      https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/gainersLosers
      

      Headers are same as for all other requests.
      Method - POST
      The Request packet is as follows:

      {"datatype":"PercOIGainers", // Type of Data you want(PercOILosers/PercOIGainers/PercPriceGainers/PercPriceLosers)
      "expirytype":"NEAR" // Expiry Type (NEAR/NEXT/FAR)}
      

      The response received for the request is as follows:

      {
          "status": true,
          "message": "SUCCESS",
          "errorcode": "",
          "data": [
              {
                  "tradingSymbol": "HDFCBANK25JAN24FUT",
                  "percentChange": 20.02,
                  "symbolToken": 55394,
                  "opnInterest": 118861600,
                  "netChangeOpnInterest": 1.98253E7
              },
              {
                  "tradingSymbol": "IEX25JAN24FUT",
                  "percentChange": 15.57,
                  "symbolToken": 55409,
                  "opnInterest": 77827500,
                  "netChangeOpnInterest": 1.0485E7
              },
              {
                  "tradingSymbol": "KOTAKBANK25JAN24FUT",
                  "percentChange": 11.07,
                  "symbolToken": 55428,
                  "opnInterest": 30164800,
                  "netChangeOpnInterest": 3007600.0
              },
              {
                  "tradingSymbol": "ICICIGI25JAN24FUT",
                  "percentChange": 7.91,
                  "symbolToken": 55402,
                  "opnInterest": 3954500,
                  "netChangeOpnInterest": 290000.0
              },
              {
                  "tradingSymbol": "DRREDDY25JAN24FUT",
                  "percentChange": 7.17,
                  "symbolToken": 55376,
                  "opnInterest": 2211625,
                  "netChangeOpnInterest": 148000.0
              },
              {
                  "tradingSymbol": "TATASTEEL25JAN24FUT",
                  "percentChange": 6.73,
                  "symbolToken": 55503,
                  "opnInterest": 234679500,
                  "netChangeOpnInterest": 1.4795E7
              },
              {
                  "tradingSymbol": "OFSS25JAN24FUT",
                  "percentChange": 6.5,
                  "symbolToken": 55462,
                  "opnInterest": 770400,
                  "netChangeOpnInterest": 47000.0
              },
              {
                  "tradingSymbol": "INDUSINDBK25JAN24FUT",
                  "percentChange": 6.23,
                  "symbolToken": 55417,
                  "opnInterest": 16300000,
                  "netChangeOpnInterest": 956500.0
              },
              {
                  "tradingSymbol": "CUB25JAN24FUT",
                  "percentChange": 5.99,
                  "symbolToken": 55367,
                  "opnInterest": 32735000,
                  "netChangeOpnInterest": 1850000.0
              },
              {
                  "tradingSymbol": "GUJGASLTD25JAN24FUT",
                  "percentChange": 5.98,
                  "symbolToken": 55389,
                  "opnInterest": 6023750,
                  "netChangeOpnInterest": 340000.0
              }
          ]
      }
      

      This lists down all the OI Gainers for the day. Please note that this data is cumulative of OI of all strike prices for the Option Contracts, hence maps all the data to the futures token of the same expiry date. Futures Token here just denotes expiry date and the underlying stock. OI Gainers/ Losers or Price Gainers/ Losers data is for options contracts only.

      Key Possible Values
      DataType PercPriceGainers
      PercPriceLosers
      PercOILosers
      PercOIGainers
      ExpiryType NEAR
      FAR
      NEXT
      1. PCR Volume API

      PCR Volume API gives the ratio of Put - Call Ratio for Options Contracts in the market using which you can gauge the market sentiments and make you trading decisions.

      The API endpoint is:

      https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/putCallRatio
      

      Method - GET

      Headers remain same as in all other requests.

      Request Body:

      //No request Body
      

      Response from the API:

      {
          "status": true,
          "message": "SUCCESS",
          "errorcode": "",
          "data": [
              {
                  "pcr": 1.04,
                  "tradingSymbol": "NIFTY25JAN24FUT"
              },
              {
                  "pcr": 0.58,
                  "tradingSymbol": "HEROMOTOCO25JAN24FUT"
              },
              {
                  "pcr": 0.65,
                  "tradingSymbol": "ADANIPORTS25JAN24FUT"
              },
              ]
          }
      

      Please note that PCR here represents the cumulative PCR of Options Contracts for all strike prices, hence the Trading Symbol has been mapped to the corresponding futures instrument for each underlying stock. It represents PCR for Options only.

      1. OI BuildUp

      Using this API, you can check for Long Buildup, Short Buildup, Short Covering and Long Unwinding. Pass the requisite keys in the API and you'd get the appropriate list for your usage.

      The API end point is:

      https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/OIBuildup
      

      Method - POST
      Headers will be same as all the other APIs

      The request Body will be as follows:

      {"expirytype":"NEAR",
      "datatype":"Long Built Up"}
      

      Similar to Top Gainers/ Losers API, we can pass multiple values in the data_type and expiry_type keys.

      The values are as follows:

      Key Possible Values
      DataType Long Built Up
      Short Built Up
      Short Covering
      Long Unwinding
      ExpiryType NEAR
      FAR
      NEXT

      Please note that there is a single space between the different words in datatype, i.e. Long<single space>Built<single-space>Up

      The response will be as follows:

      {
          "status": true,
          "message": "SUCCESS",
          "errorcode": "",
          "data": [
              {
                  "symbolToken": "55424",
                  "ltp": "723.8",
                  "netChange": "-28.25",
                  "percentChange": "-3.76",
                  "opnInterest": "24982.5",
                  "netChangeOpnInterest": "-76.25",
                  "tradingSymbol": "JINDALSTEL25JAN24FUT"
              },
              {
                  "symbolToken": "55452",
                  "ltp": "134.25",
                  "netChange": "-5.05",
                  "percentChange": "-3.63",
                  "opnInterest": "67965.0",
                  "netChangeOpnInterest": "-3120.0",
                  "tradingSymbol": "NATIONALUM25JAN24FUT"
              }
            ]
           }
      

      You will get all the responses on passing the correct values for data type and expiry time.

      We hope this helps you make better trading decisions and helps you with your trading tasks.

      Thank you.

      Regards
      SmartAPI Team

      P 1 Reply Last reply Reply Quote 0
      • P
        Purushottam @Moderator_1 last edited by

        @Moderator_1 for this api i am getting error of Invalid api Key, though i am having valid API key. Even i tried all four type of API i.e. trading, market, publish, historical

        M 1 Reply Last reply Reply Quote 1
        • M
          Moderator_1 @Purushottam last edited by

          Hello @Purushottam,

          Is it still not working for you?
          Since you're getting Invalid API key error, can you please confirm that you're able to consume other APIs?

          It is working at our end.

          Thank you.

          Regards
          SmartAPI Team

          K 1 Reply Last reply Reply Quote 0
          • S
            SIMAMONDAL last edited by

            When i write the above code for fetching details of Gainers/ Losers, and call for obj.gainersLosers(params) it shows Attribute Error: 'SmartConnect' object has no attribute 'gainersLosers'
            Please help me why the code generate error message and how to solve it .
            Thanks in advance.

            Screenshot 2024-05-13 074420.png Screenshot 2024-05-13 074235.png ![Screenshot 2024-05-13 074420.png]

            M 1 Reply Last reply Reply Quote 0
            • M
              Moderator_3 @SIMAMONDAL last edited by

              Hello @SIMAMONDAL
              Have you updated the sdk to the latest version and please check after the update .
              Regards,
              SmartAPI Team

              S 1 Reply Last reply Reply Quote 0
              • S
                SIMAMONDAL @Moderator_3 last edited by

                @Moderator_3 Please explain how to update the sdk to the latest version

                Please explain. Thanks for the previous reply.

                M 1 Reply Last reply Reply Quote 0
                • M
                  Moderator_3 @SIMAMONDAL last edited by

                  Hello @SIMAMONDAL
                  Please go through the below link to get the idea
                  https://github.com/angel-one/smartapi-python
                  Regards,
                  SmartAPI Team

                  1 Reply Last reply Reply Quote 0
                  • A
                    ameliassk last edited by

                    Is it still not working for you?
                    Since you're getting Invalid API key error, can you please confirm that you're able to consume other APIs? Click here

                    1 Reply Last reply Reply Quote 0
                    • O
                      omcv last edited by

                      I got a question after going through the documentation of smart-api websocket2.0.

                      Question: Can we get top gainers/losers through the websocket ?
                      Is this currently supported ?

                      Can some one kindly address my question. Thanks!

                      A 1 Reply Last reply Reply Quote 0
                      • A
                        admin @omcv last edited by

                        @omcv It is not supported via websocket.

                        1 Reply Last reply Reply Quote 0
                        • K
                          kalanithi @Moderator_1 last edited by

                          @Moderator_1 Hi Team, I am also getting the same error.

                          Response: {'success': False, 'message': 'Invalid API Key', 'errorCode': 'AG8004', 'data': ''}.
                          Below is the code I tried. Could you please help

                          import requests

                          Define the API endpoint

                          url = "https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/gainersLosers"

                          Define the headers (replace with actual values as required)

                          headers = {
                          "Authorization": "Bearer eyJhbGciOiJIUzxxxxxxx", #token
                          "Content-Type": "application/json",
                          "Accept": "application/json"
                          }

                          Define the request packet

                          payload = {
                          "datatype": "PercPriceGainers", # datatype
                          "expirytype": "NEAR" # expiry type
                          }

                          Send the POST request

                          response = requests.post(url, headers=headers, json=payload)

                          Check the response

                          if response.status_code == 200:
                          print("Request Successful")
                          print("Response:", response.json())
                          else:
                          print(f"Request Failed with status code {response.status_code}")
                          print("Response:", response.text)

                          1 Reply Last reply Reply Quote 0
                          • C
                            C54532785 last edited by

                            PercPriceGainers , PercOIGainers , Long Built Up are showing negative stocks. The data is not valid data

                            1 Reply Last reply Reply Quote 0
                            • C
                              C54532785 last edited by

                              Top gainers and loosers are displaying wrong values. Long build up is returning wrong value.

                              1 Reply Last reply Reply Quote 0
                              • W
                                whemant last edited by

                                hello @Moderator_1

                                I am getting an error AB1004 when the datatype = PercPriceGainers. Other datatypes PercOIGainers, PercOILosers, PercPriceLosers all working fine

                                login_obj = user_details['obj']

                                params = {
                                "datatype": "PercPriceGainers",
                                "expirytype": "NEAR"
                                }

                                print(login_obj.gainersLosers(params))

                                {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}

                                This was working fine till yesterday.

                                W 1 Reply Last reply Reply Quote 0
                                • W
                                  whemant @whemant last edited by

                                  Am I the only one encountering this error? Why am I experiencing this issue only with 'PercPriceGainers' and not with 'PercPriceLosers'?

                                  This has been happening since yesterday; it was working perfectly fine before that.

                                  @Moderator_1 @Moderator_2 @Moderator_3, @Moderator_4 , could you please respond to this?

                                  [E 250128 10:19:46 smartConnect:242] Error occurred while making a POST request to https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/gainersLosers. Error: Something Went Wrong, Please Try After Sometime. URL: https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/gainersLosers, Headers: {'Content-type': 'application/json', 'X-ClientLocalIP': '127.0.0.1', 'X-ClientPublicIP': '106.193.147.98', 'X-MACAddress': '87:9e:2a:03:ef:88', 'Accept': 'application/json', 'X-PrivateKey': 'hidden', 'X-UserType': 'USER', 'X-SourceID': 'WEB'}, Request: {'datatype': 'PercPriceGainers', 'expirytype': 'NEAR'}, Response: {'message': 'Something Went Wrong, Please Try After Sometime', 'errorcode': 'AB1004', 'status': False, 'data': None}

                                  1 Reply Last reply Reply Quote 0
                                  • V
                                    v66167 last edited by

                                    @Moderator_1 said in Announcing Top Gainers/ Losers, PCR and OI BuildUp APIs for SmartAPI Users:

                                    https://apiconnect.angelbroking.com/rest/secure/angelbroking/marketData/v1/OIBuildup

                                    is this working for anybody?

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