github.com/polygon-io/client-go@v1.16.4/rest/models/contracts_test.go (about) 1 package models_test 2 3 import ( 4 "testing" 5 "time" 6 7 "github.com/polygon-io/client-go/rest/models" 8 ) 9 10 func TestGetOptionsContractParams(t *testing.T) { 11 ticker := "A" 12 date := models.Date(time.Date(2023, 3, 23, 0, 0, 0, 0, time.Local)) 13 expect := models.GetOptionsContractParams{ 14 Ticker: ticker, 15 AsOf: &date, 16 } 17 actual := models.GetOptionsContractParams{ 18 Ticker: ticker, 19 }.WithAsOf(date) 20 checkParams(t, expect, *actual) 21 } 22 23 func TestListOptionsContractsParams(t *testing.T) { 24 date := models.Date(time.Date(2023, 3, 23, 0, 0, 0, 0, time.Local)) 25 contractType := "call" 26 expired := true 27 strike := 100.0 28 sort := models.TickerSymbol 29 order := models.Asc 30 limit := 100 31 ticker := "A" 32 expect := models.ListOptionsContractsParams{ 33 ContractType: &contractType, 34 UnderlyingTickerEQ: &ticker, 35 UnderlyingTickerLT: &ticker, 36 UnderlyingTickerLTE: &ticker, 37 UnderlyingTickerGT: &ticker, 38 UnderlyingTickerGTE: &ticker, 39 ExpirationDateEQ: &date, 40 ExpirationDateLT: &date, 41 ExpirationDateLTE: &date, 42 ExpirationDateGT: &date, 43 ExpirationDateGTE: &date, 44 StrikePriceEQ: &strike, 45 StrikePriceLT: &strike, 46 StrikePriceLTE: &strike, 47 StrikePriceGT: &strike, 48 StrikePriceGTE: &strike, 49 AsOf: &date, 50 Expired: &expired, 51 Sort: &sort, 52 Order: &order, 53 Limit: &limit, 54 } 55 actual := models.ListOptionsContractsParams{}. 56 WithContractType(contractType). 57 WithUnderlyingTicker(models.EQ, ticker). 58 WithUnderlyingTicker(models.LT, ticker). 59 WithUnderlyingTicker(models.LTE, ticker). 60 WithUnderlyingTicker(models.GT, ticker). 61 WithUnderlyingTicker(models.GTE, ticker). 62 WithExpirationDate(models.EQ, date). 63 WithExpirationDate(models.LT, date). 64 WithExpirationDate(models.LTE, date). 65 WithExpirationDate(models.GT, date). 66 WithExpirationDate(models.GTE, date). 67 WithStrikePrice(models.EQ, strike). 68 WithStrikePrice(models.LT, strike). 69 WithStrikePrice(models.LTE, strike). 70 WithStrikePrice(models.GT, strike). 71 WithStrikePrice(models.GTE, strike). 72 WithAsOf(date). 73 WithExpired(expired). 74 WithSort(sort). 75 WithOrder(order). 76 WithLimit(limit) 77 78 checkParams(t, expect, *actual) 79 }