Navigation

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

    Historical prices not working

    Python SDK
    2
    6
    59
    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
      Sukhwant280 last edited by

      @admin hi,

      tried the code from below link not working for me:
      https://smartapi.angelbroking.com/docs/Historical

      please can you share a working example of code, will help a lot

      thanks
      Sukhwant

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

        HI @Sukhwant280 find the sample code below:
        historicParam={
        "exchange": "NSE",
        "symboltoken": "14977",
        "interval": "FIFTEEN_MINUTE",
        "fromdate": '2021-07-01 09:41',
        "todate": '2021-07-29 10:41'
        }
        df = obj.getCandleData(historicParam)
        print (df)

        S 1 Reply Last reply Reply Quote 0
        • S
          Sukhwant280 @admin last edited by

          @admin thanks a lot for the below code, but its not complete. so i tried at my end using your code and in rest api. and i am getting error. below is my code, Please let me know where i am going wrong.

          error message: TypeError: can't concat str to bytes

          FYI - new to python

          thnaks
          Sukhwant

           import http.client
          
          conn = http.client.HTTPSConnection("apiconnect.angelbroking.com")
          historicParam={
          "exchange": "NSE",
          "symboltoken": "14977",
          "interval": "FIFTEEN_MINUTE",
          "fromdate": '2021-07-01 09:41',
          "todate": '2021-07-29 10:41'
          }
          
          headers = {
            'X-PrivateKey': 'API_KEY',
            'Accept': 'application/json',
            'X-SourceID': 'WEB',
            'X-ClientLocalIP': 'CLIENT_LOCAL_IP',
            'X-ClientPublicIP': 'CLIENT_PUBLIC_IP',
            'X-MACAddress': 'MAC_ADDRESS',
            'X-UserType': 'USER',
            'Authorization': 'Bearer AUTHORIZATION_TOKEN',
            'Accept': 'application/json',
            'X-SourceID': 'WEB',
            'Content-Type': 'application/json'
          }
          conn.request("POST", "/rest/secure/angelbroking/historical/v1/getCandleData", historicParam, headers)
          res = conn.getresponse()
          data = res.read()
          print(data.decode("utf-8"))
          
          S 1 Reply Last reply Reply Quote 0
          • S
            Sukhwant280 @Sukhwant280 last edited by

            @admin - any update mate

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

              HI @Sukhwant280 we will update you soon.

              S 1 Reply Last reply Reply Quote 0
              • S
                Sukhwant280 @admin last edited by

                @admin

                i got the solution from this link of yours:
                https://smartapi.angelbroking.com/topic/1194/basic-smartapi-integration-using-python

                thanks a lot. consider this thread as closed from my side.

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