github.com/polygon-io/client-go@v1.16.4/rest/example/stocks/quotes/main.go (about) 1 // Stocks - Quotes (NBBO) 2 // https://polygon.io/docs/stocks/get_v3_quotes__stockticker 3 // https://github.com/polygon-io/client-go/blob/master/rest/quotes.go 4 package main 5 6 import ( 7 "context" 8 "log" 9 "os" 10 "time" 11 12 polygon "github.com/polygon-io/client-go/rest" 13 "github.com/polygon-io/client-go/rest/models" 14 ) 15 16 func main() { 17 18 // init client 19 c := polygon.New(os.Getenv("POLYGON_API_KEY")) 20 21 // set params 22 params := models.ListQuotesParams{ 23 Ticker: "AAPL", 24 }.WithTimestamp(models.EQ, models.Nanos(time.Date(2021, 7, 22, 0, 0, 0, 0, time.UTC))). 25 WithSort(models.Timestamp). 26 WithOrder(models.Asc). 27 WithLimit(50000) 28 29 // make request 30 iter := c.ListQuotes(context.Background(), params) 31 32 // do something with the result 33 for iter.Next() { 34 log.Print(iter.Item()) 35 } 36 if iter.Err() != nil { 37 log.Fatal(iter.Err()) 38 } 39 40 }