finance-go icon indicating copy to clipboard operation
finance-go copied to clipboard

Actually return an error for unknown symbol

Open pallotron opened this issue 2 years ago • 3 comments

quote.Get of an inexistent symbol should return a non nil error. This does not happen.... To repro ask for a quote from a un-existant symbol:

package main

import (
  "fmt"

  "github.com/piquette/finance-go/quote"
)

func main() {
  q, err := quote.Get("FOOAASDADSAS") // <---- panic here because both `q` and `err` are `nil` 
  if err != nil {
    panic(err)
  }
  fmt.Printf("RegulardMarketPrice: %# +v", q.RegularMarketPrice)
}

This will panic:

$ go run .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0x620b2e]

goroutine 1 [running]:
main.main()
        /home/pallotron/projects/example/ticker-quote.go:14 +0x2e
exit status 2
[Exit code 1 @ 10:12:01]

get.Quote should return an error in this case.

pallotron avatar Jan 23 '22 11:01 pallotron

Hello? Can you review this please? :)

pallotron avatar Feb 03 '22 22:02 pallotron

@ackleymi, @jacks821 @pkaeding can you guys please stamp this?

pallotron avatar Feb 10 '22 14:02 pallotron

@ackleymi Could you merge this? This is the only error I encounter with this library so far and I think many people would be happy if they don't get a panic and a error instead.

CMiksche avatar Jun 04 '22 11:06 CMiksche

this project is very active :D

pallotron avatar Sep 29 '22 09:09 pallotron

this project is very active :D

Seems abandoned.

ktpx avatar Oct 05 '22 13:10 ktpx

Is there any forks maintained?

sunglim avatar Apr 20 '23 15:04 sunglim

@pallotron Please feel free to bring this change to my fork, https://github.com/sunglim/yh-finance-go

sunglim avatar Apr 20 '23 16:04 sunglim