Navigation

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

    Error while getting LTP data

    Go SDK
    2
    4
    54
    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.
    • R
      rakshify last edited by rakshify

      @admin
      Getting an error while getting LTP data
      I am using the following code snippet

      //import used
      SmartApi "github.com/angelbroking-github/smartapigo"
      
      ltp, err := GetABClient().GetLTP(SmartApi.LTPParams{
      		Exchange:      instr.ExchSeg,
      		TradingSymbol: instr.Symbol,
      		SymbolToken:   instr.Token,
      	})
      

      Getting following error:

      base.HTTP: 2021/09/15 16:04:26 http.go:154: Error parsing JSON response: json: cannot unmarshal number into Go struct field LTPResponse.data.open of type string | {"status":true,"message":"SUCCESS","errorcode":"","data":{"exchange":"NSE","tradingsymbol":"ULTRACEMCO-EQ","symboltoken":"11532","open":7889.0,"high":7929.0,"low":7790.0,"close":7856.45,"ltp":7820.85}}
      time="2021-09-15T16:04:26+05:30" level=info msg="json: cannot unmarshal number into Go struct field LTPResponse.data.open of type string"
      

      It seems that SmartApi.LTPResponse struct has OHLC fields defined as string and response from api server is in float.

      Please help to fix me this.

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

        HI @devendrav We have reported this we will test and update you.

        R A 2 Replies Last reply Reply Quote 0
        • R
          rakshify @admin last edited by rakshify

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • A
            admin @admin last edited by

            HI @devendrav this issue has been resolved.

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