Skip to content

Instantly share code, notes, and snippets.

@satishbabariya
Created November 30, 2021 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishbabariya/67483674178fe546836c858049395772 to your computer and use it in GitHub Desktop.
Save satishbabariya/67483674178fe546836c858049395772 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
"github.com/piquette/finance-go/quote"
)
func main() {
ticker := time.NewTicker(1 * time.Second)
done := make(chan bool)
for {
select {
case <-done:
return
case t := <-ticker.C:
go nalco(t)
}
}
}
func nalco(t time.Time) {
q, err := quote.Get("NATIONALUM.NS")
if err != nil {
// Uh-oh.
panic(err)
}
// Success!
regularMarketPrice := q.RegularMarketPrice
date := time.Unix(int64(q.RegularMarketTime), 0)
fmt.Println(fmt.Sprintf("%d:%d:%d", date.Hour(), date.Minute(), date.Second()), regularMarketPrice)
}
@satishbabariya
Copy link
Author

➜  nalco go run main.go
11:59:33 88.9
11:59:33 88.9
11:59:33 88.9
11:59:37 88.9
11:59:37 88.9
11:59:37 88.9
11:59:37 88.9
11:59:37 88.9
11:59:42 88.9
11:59:42 88.9
11:59:42 88.9
11:59:42 88.9
11:59:46 88.9
11:59:46 88.9
11:59:46 88.9
11:59:46 88.9
11:59:49 88.95
11:59:49 88.95

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment