github.com/polygon-io/client-go@v1.16.4/rest/example/options/trades/main.go (about) 1 // Options - Trades 2 // https://polygon.io/docs/options/get_v3_trades__optionsticker 3 // https://github.com/polygon-io/client-go/blob/master/rest/trades.go 4 package main 5 6 import ( 7 "context" 8 "log" 9 "os" 10 11 polygon "github.com/polygon-io/client-go/rest" 12 "github.com/polygon-io/client-go/rest/models" 13 ) 14 15 func main() { 16 17 // init client 18 c := polygon.New(os.Getenv("POLYGON_API_KEY")) 19 20 // set params 21 params := models.ListTradesParams{ 22 Ticker: "O:TSLA210903C00700000", 23 }.WithLimit(50000).WithOrder(models.Asc) 24 25 // make request 26 iter := c.ListTrades(context.Background(), params) 27 28 // do something with the result 29 for iter.Next() { 30 log.Print(iter.Item()) 31 } 32 if iter.Err() != nil { 33 log.Fatal(iter.Err()) 34 } 35 36 }