Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs
    1. Home
    2. laskshmi
    3. Posts
    L
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by laskshmi

    • Error in Websocket connection.

      Trying to connect to websocket and getting the below error on Nov 21 2023. It was working fine till 12:40 and getting the same "No Such Host" error there after.

      2023-11-21 12:40:24.996 [reactor-http-nio-3] WARN  r.netty.http.client.HttpClientConnect       - [3c5c6782-54, L:/192.168.29.145:21902 - R:apiconnect.angelbroking.com/103.82.177.189:443] The connection observed an error
      java.io.IOException: An existing connection was forcibly closed by the remote host
      	at java.base/sun.nio.ch.SocketDispatcher.read0(Native Method)
      
      2023-11-21 12:40:47.313 [WebSocketConnectReadThread-50] ERROR c.a.api.utils.WebSocketClientUtils - Websocket Exception: 
      java.net.UnknownHostException: No such host is known (smartapisocket.angelone.in)
      	at java.base/java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
      	at java.base/java.net.InetAddress$PlatformNameService.lookupAllHostAddr(InetAddress.java:929)
      
      posted in Bugs
      L
      laskshmi
    • Historical Candle Data not working as expected

      GetCandleData API
      Hi,
      I developed a logic during march of this year that would periodically hit the https://apiconnect.angelbroking.com/rest/secure/angelbroking/historical/v1/getCandleData API and it was working fine. I didn't work the project after that. When I tried to run the same now after several months with the below request.

      {
          "exchange": "NFO",
          "symboltoken": "57919",
          "interval": "ONE_MINUTE",
          "fromdate": "2023-11-16 09:15",
          "todate": "2023-11-16 09:15"
      }
      

      I get error response like below.

      {
          "message": "Internal Error",
          "errorcode": "AB2001",
          "status": false,
          "data": null
      }
      

      But when I try

      {
          "exchange": "NFO",
          "symboltoken": "57919",
          "interval": "ONE_MINUTE",
          "fromdate": "2023-11-16 09:15",
          "todate": "2023-11-16 09:16"
      }
      

      I get proper response

      {
          "status": true,
          "message": "SUCCESS",
          "errorcode": "",
          "data": [
              [
                  "2023-11-16T09:15:00+05:30",
                  44390.85,
                  44390.85,
                  44276.6,
                  44300.0,
                  2626
              ],
              [
                  "2023-11-16T09:16:00+05:30",
                  44300.0,
                  44301.7,
                  44275.0,
                  44283.3,
                  1679
              ]
          ]
      }
      

      my question is why does 09:15 to 09:15 doesn't work, but 09:15 to 09:16 works and even 09:16 to 09:16 works, why does the first one doesn't work. This is breaking my logic.

      posted in General Discussion
      L
      laskshmi
    • RE: Historic API not working

      Same issue here too.

      Access denied because of exceeding access rate
      

      9894182e-1e9b-47ef-9405-b8e4a2759ddf-image.png

      @admin @administrators Please take a look

      posted in Bugs
      L
      laskshmi
    • Historical API Not working FEB 14 2023

      Hi @admin @administrators

      Historical API is not returning any data for today (FEB 14 2023). But values are returned for previous day as expected

      93677407-8f3e-4887-800b-725d7e75f008-image.png

      If i change the date to Feb 13, then its working.

      793bb649-db9f-4076-899d-4daf3d66a6d3-image.png

      Please check this. Thank you !!!

      posted in Bugs
      L
      laskshmi
    • RE: Unable to Connect Via postman

      @sagard

      You are not supposed to use this URL in postman. https://smartapi.angelbroking.com/publisher-login?api_key=xxx. You can use this url directly from browser and the token will be sent in the redirect URL which u mentioned while creating an APP in smart API.

      To get the jwtToken from postman use the below details
      https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword
      Method: POST
      No Authorization

      Headers:
      Content-Length:<postman generated values>
      Content-Type:<postman generated values>
      Accept:application/json
      X-ClientLocalIP:<ur client ip>
      X-ClientPublicIP:<ur public ip>
      X-MACAddress:<ur mac address>
      X-PrivateKey:<Your API KEY>
      X-UserType:USER
      X-SourceID:WEB
      

      Update your details ()in the header.

      BODY:

      {
          "clientcode": "{{clientID}}",
          "password": "{{clientPIN}}",
          "totp": "483811"
      }
      

      Hope this helps!!

      posted in Bugs
      L
      laskshmi
    • RE: Delay In Historical Data API

      @falconTrader
      Thanks for replying.

      Unfortunately, the websocket streaming method doesn't provide the option to request data based on specific time frames, such as ONE_MINUTE or FIVE_MINUTE. To obtain OHLC data like what's available from the Historical API, manual collection and calculation of data from websocket streaming would be required. This can be a time-consuming process and may result in some delay, even if processing time is only in the range of milliseconds to seconds, It will have a huge impact during high volatility market days.

      Also, I use Java and my bad i couldnt help you with ur python issue. 😢

      posted in NodeJS SDK
      L
      laskshmi
    • Delay In Historical Data API

      Hi @admin

      I am currently trying to work on a logic that requires getting the candleData of ONE_MINUTE time-frame of Futures (NFO) in real time(i.e to get the 09:15, 09:16, 09:17 candleStick data as soon as the minute is completed). The response should have OHLC Volume data. I have two question

      1. I would like to know what are all the options available to get the the required data every one minute.
      2. I already tried hitting the Historical Data API with currentDays from and to Time Stamp. For example, Lets assume that today is Feb 3, 2023 and I tried to hit the historical data api at 09:16 with the below request which will produce the response that will have one array element which holds 09:15 candledata.

      REQUEST FOR HISTORICAL API

      {
          "exchange": "NFO",
          "symboltoken": "48756",
          "interval": "ONE_MINUTE",
          "fromdate": "2023-02-03 09:15",
          "todate": "2023-02-03 09:15"
      }
      

      Here, my second question is, when i hit the historical API every one minute ie 09:15:00. 09:16:00 and 09:17:00 .... so on, I am not getting the latest candle data in the response, it takes atleast ~5 seconds after a minute is completed to get the latest candledata in historical api. i.e I get the desired result at 09:15:05, 09:16:04 and 09:17:05 etc.... So , is there any way to reduce this 5sec gap in fetching the desired result or is there any other API that i can use instead of historical data API to get the candlestick data of one minute timeframe without any delay.

      posted in NodeJS SDK
      L
      laskshmi
    • RE: Historical Data API not sending data for requested number of days

      @laskshmi said in Historical Data API not sending data for requested number of days:

      @admin
      Any update on this??

      @admin any update, iTs been 10 days

      posted in NodeJS SDK
      L
      laskshmi
    • BankNifty index Historical Data not available

      Hi @admin,

      Currently i am unable to get any response from server for Historical data API when using the below request to fetch Banknifty or Nifty index data.

      {
          "exchange": "NSE",
          "symboltoken": "26009",
          "interval": "ONE_MINUTE",
          "fromdate": "2023-01-03 09:15",
          "todate": "2023-01-03 09:30"
      }
      

      RESOPNSE:

      {
          "status": true,
          "message": "SUCCESS",
          "errorcode": "",
          "data": null
      }
      

      I did see many post having the same question, but too old back in 2021. So Just wanted to confirm if we have the historical data for Indices.

      Thank you 😊😊

      posted in General Discussion
      L
      laskshmi
    • RE: Historical Data API not sending data for requested number of days

      @admin
      Any update on this??

      posted in NodeJS SDK
      L
      laskshmi
    • RE: Unable to Connect Via postman

      @asiam9

      I finally connected to AB API using POSTMAN. Looks like I was just missing out an request header (feeling so stupid right now 😋). Below are the heder that u need to add in ur

      Postman Request Headers:
      44fc6765-0e3b-40a5-a183-40b1e620835e-image.png

      Just make sure u have all the selected headers (mandatory), remaining all are optional. THen hit send and u will receive 200 with the response .

      Hope this message helps u. 🙂

      posted in Bugs
      L
      laskshmi
    • Historical Data API not sending data for requested number of days

      @admin
      In the API documentation, it says that Historical data of 30 days can be request in a single hit with ONE_MINUTE interval.
      af80d265-a8dd-4dfb-a4fb-98966e9476d0-image.png

      But in actual case, I am receiving a maximum of 500 candle stick data irrespective of the interval. i.e If i request data of Jan 2 9:15 to to Jan 17 09:15 with ONE_MINUTE, I dont receive the data for requested days, instead receiving exactly 500 arrays which is approximately from Jan 13(Driday) to Jan 17 (Tuesday). So instead of 30 days i receive 3 days candle stick data.

      Request:
      8d1b5d05-d622-4866-a346-9b584dc7bd3f-image.png

      Start of Response:
      d56378b3-3f34-4d76-9df2-5777833c1f44-image.png

      End of Response:
      82fcf952-ddea-4744-a77b-2afb65226c12-image.png

      Can you let me know why I am not able to get the data for requested days ?

      posted in NodeJS SDK
      L
      laskshmi
    • RE: Websocket Call in Java

      @admin
      Thanks for replying 😀, I was finally able to parse the data properly and see the LTP data

      ByteBuffer packet = ByteBuffer.wrap(message.array()).order(ByteOrder.LITTLE_ENDIAN);
                      ZonedDateTime exchangeTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(packet.getLong(35)), TZ_IST);
                      System.out.print("\nToken Details : "+getTokenID(packet));
                      System.out.print("\nSequence Number: "+packet.getLong(27));
                      System.out.print("\nExchange TIme: "+exchangeTime);
                      System.out.print("\nLTP: "+packet.getLong(43));
      

      Output of the above code:
      7ec943f1-5776-44e2-8c26-92e56b5269a4-image.png

      Thanks a lot @admin,@Ashok and @tsingh

      posted in NodeJS SDK
      L
      laskshmi
    • RE: Websocket Call in Java

      @Ashok
      i dont think its base64 encoding. in the documentation its mentioned that it is Little ENDIAN, but when i try to get the byte coding from the byteBuffer in Java it says BIG ENDIAN

      This is how the conversion goes(see screenshot below), i have tried all the available charset conversions but nothing is working.
      47fb646e-0201-4074-8f3d-ca82947a5014-image.png

      and if i do message.flip().array(), where message is the byte buffer i receive from angel one, below is my result
      [1, 1, 50, 56, 56, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -38, 37, 0, 0, 0, 0, 0, -24, 111, 51, 92, -123, 1, 0, 0, -71, -34, 3, 0, 0, 0, 0, 0]

      @admin Need ur help here, can someone show me how to parse the response from websocket server to a readable from in Java?? I am struck here for more than 2 weeks

      posted in NodeJS SDK
      L
      laskshmi
    • RE: Websocket Call in Java

      @admin
      I have tried and able to successfully get the response back from webscoket server in both postman and in Java. but i am not able to read it.
      REQUEST:

      {
          "correlationID": "abcde12345",
          "action": 1,
          "params": {
              "mode": 1,
              "tokenList": [
                  {
                      "exchangeType": 1,
                      "tokens": [
                          "2885"
                      ]
                  }
              ]
          }
      }
      

      RESPONSE:
      8e2e1338-641e-4e60-a6c3-8f31edb01cc6-image.png

      Tried the same request in Java also, getting a ByteBuffer response object, but when i tried to decode it using different charset but still its in unreadble form.

      message = java.nio.HeapByteBuffer[pos=0 lim=51 cap=51]
      UTF_8 = 2885                     rK+      ?W?  ]?     
      UTF_16 = ???          r?   ???]? ?
      UTF_16LE = ???          ??  ?????  ?
      UTF_16BE = ???          r?   ???]? ?
      US_ASCII = 2885                     rK+      ?W?  ]?     
      ISO_8859_1 = 2885                     rK+      �W?  ]�
      

      Response Screenshot from Intellij:
      f5f0d57a-c544-4e21-bbe4-4946b0851569-image.png

      Please let me know how i can convert the response to a readable format. Thanks

      posted in NodeJS SDK
      L
      laskshmi
    • Websocket Call in Java

      @admin
      Can someone please share a sample code on how to connect to websocket Angelone apis. I have tried connecting, sending a ping message and received a pong message. But when i tried with the below requests, i am not getting any reply from server. I would like to see a sample code so that i refer and create my own code.

      {
        "correlationID": "abcde12345",
        "action": 1,
        "params": {
          "mode": 1,
          "tokenList": [
            {
              "exchangeType": 1,
              "tokens": [
                "14366"
              ]
            }
          ]
        }
      }
      

      14366 is the token for IDEA-EQ stock. No response in both postman and through java.

      Any help is much appreciated.

      posted in NodeJS SDK
      L
      laskshmi
    • RE: How long can a jwtToken be used for?

      @admin
      Got it. Thanks for the reply. 👍

      posted in General Discussion
      L
      laskshmi
    • RE: Clarification Needed

      @admin
      Thanks for your reply. Please let me know once this is updated. 😊

      posted in General Discussion
      L
      laskshmi
    • Clarification Needed

      @admin
      I can see that a single error code is having multiple error mesages.
      For Example:
      For errorcode: AB1007, i have seen below three message().

      1. INVALID PARAMETERS --> (when I tried to place order with incorrect parameters)
      2. YOUR USER ID OR PASSWORD IS INVALID --> (when i tried to login with incorrect credentials)
      3. AMX Error -->(this is the message given in Documentation)

      Since i am getting different type of message for single code from the SmartAPI, My logic for error handling is kinda messed up right now.

      Now for second question:
      I can see that the response structure itself is getting changed for particular type of request. As per documentation, it should be like below for both success and failure scenarios.
      *Success:
      {
      "status" : true,
      "message" : "SUCCESS",
      "errorcode" : "",
      "data" : {}
      }

      Failure
      {
      "status" : false,
      "message" : "Invalid totp",
      "errorcode" : "AB1050",
      "data" : null
      }

      But whenever I hit a request with incorrect jwttoken then i get the below response:
      {
      "success" : false,
      "message" : "Invalid Token",
      "errorCode" : "AG8001",
      "data" : ""
      }
      So far i have seen this response in getProfile call and placeOrder call (when request is called with invalid authorization token). Instead of status key as false , I get a field names success with value false and the errorCode should be errorcode(with lower case 'c').

      How could i write the logic for processing the response , if it varies like this. please look into this and correct this at the earliest. I have notified to @Apoorva-Jayaswal (apoorva.jayswal@angelbroking.com) through email 2 weeks back.

      posted in General Discussion
      L
      laskshmi
    • RE: How long can a jwtToken be used for?

      Update:
      Correct me if i am wrong. @admin
      My observation is that a token I generated around 8 AM is still valid till 9.30 PM. I guess we can just generate one token per day. 🙂

      posted in General Discussion
      L
      laskshmi