github.com/polygon-io/client-go@v1.16.4/rest/models/contracts.go (about) 1 package models 2 3 // GetOptionsContract is the set of parameters for the GetOptionsContract method. 4 type GetOptionsContractParams struct { 5 // Return the contract that contains this options ticker. 6 Ticker string `validate:"required" path:"ticker"` 7 8 // Specify a point in time for the contract as of this date. 9 AsOf *Date `query:"as_of"` 10 } 11 12 func (p GetOptionsContractParams) WithAsOf(q Date) *GetOptionsContractParams { 13 p.AsOf = &q 14 return &p 15 } 16 17 // GetOptionsContractResponse is the response returned by the GetOptionsContract method. 18 type GetOptionsContractResponse struct { 19 BaseResponse 20 Results OptionsContract `json:"results,omitempty"` 21 } 22 23 // ListOptionsContracts is the set of parameters for the ListOptionsContracts method. 24 type ListOptionsContractsParams struct { 25 // Return contracts relating to this underlying stock ticker. 26 UnderlyingTickerEQ *string `query:"underlying_ticker"` 27 UnderlyingTickerLT *string `query:"underlying_ticker.lt"` 28 UnderlyingTickerLTE *string `query:"underlying_ticker.lte"` 29 UnderlyingTickerGT *string `query:"underlying_ticker.gt"` 30 UnderlyingTickerGTE *string `query:"underlying_ticker.gte"` 31 32 // Specify the type of contract. 33 ContractType *string `query:"contract_type"` 34 35 // Specify the expiration date. 36 ExpirationDateEQ *Date `query:"expiration_date"` 37 ExpirationDateLT *Date `query:"expiration_date.lt"` 38 ExpirationDateLTE *Date `query:"expiration_date.lte"` 39 ExpirationDateGT *Date `query:"expiration_date.gt"` 40 ExpirationDateGTE *Date `query:"expiration_date.gte"` 41 42 // Specify a point in time for contracts as of this date with format YYYY-MM-DD. 43 AsOf *Date `query:"as_of"` 44 45 // Specify the strike price. 46 StrikePriceEQ *float64 `query:"strike_price"` 47 StrikePriceLT *float64 `query:"strike_price.lt"` 48 StrikePriceLTE *float64 `query:"strike_price.lte"` 49 StrikePriceGT *float64 `query:"strike_price.gt"` 50 StrikePriceGTE *float64 `query:"strike_price.gte"` 51 52 // Specify whether to query for expired contracts. 53 Expired *bool `query:"expired"` 54 55 // Sort field used for ordering. 56 Sort *Sort `query:"sort"` 57 58 // Order results based on the sort field. 59 Order *Order `query:"order"` 60 61 // Limit the number of results returned, default is 10 and max is 1000. 62 Limit *int `query:"limit"` 63 } 64 65 func (p ListOptionsContractsParams) WithUnderlyingTicker(c Comparator, q string) *ListOptionsContractsParams { 66 switch c { 67 case EQ: 68 p.UnderlyingTickerEQ = &q 69 case LT: 70 p.UnderlyingTickerLT = &q 71 case LTE: 72 p.UnderlyingTickerLTE = &q 73 case GT: 74 p.UnderlyingTickerGT = &q 75 case GTE: 76 p.UnderlyingTickerGTE = &q 77 } 78 return &p 79 } 80 81 func (p ListOptionsContractsParams) WithContractType(q string) *ListOptionsContractsParams { 82 p.ContractType = &q 83 return &p 84 } 85 86 func (p ListOptionsContractsParams) WithExpirationDate(c Comparator, q Date) *ListOptionsContractsParams { 87 switch c { 88 case EQ: 89 p.ExpirationDateEQ = &q 90 case LT: 91 p.ExpirationDateLT = &q 92 case LTE: 93 p.ExpirationDateLTE = &q 94 case GT: 95 p.ExpirationDateGT = &q 96 case GTE: 97 p.ExpirationDateGTE = &q 98 } 99 return &p 100 } 101 102 func (p ListOptionsContractsParams) WithAsOf(q Date) *ListOptionsContractsParams { 103 p.AsOf = &q 104 return &p 105 } 106 107 func (p ListOptionsContractsParams) WithStrikePrice(c Comparator, q float64) *ListOptionsContractsParams { 108 switch c { 109 case EQ: 110 p.StrikePriceEQ = &q 111 case LT: 112 p.StrikePriceLT = &q 113 case LTE: 114 p.StrikePriceLTE = &q 115 case GT: 116 p.StrikePriceGT = &q 117 case GTE: 118 p.StrikePriceGTE = &q 119 } 120 return &p 121 } 122 123 func (p ListOptionsContractsParams) WithExpired(q bool) *ListOptionsContractsParams { 124 p.Expired = &q 125 return &p 126 } 127 128 func (p ListOptionsContractsParams) WithSort(q Sort) *ListOptionsContractsParams { 129 p.Sort = &q 130 return &p 131 } 132 133 func (p ListOptionsContractsParams) WithOrder(q Order) *ListOptionsContractsParams { 134 p.Order = &q 135 return &p 136 } 137 138 func (p ListOptionsContractsParams) WithLimit(q int) *ListOptionsContractsParams { 139 p.Limit = &q 140 return &p 141 } 142 143 type ListOptionsContractsResponse struct { 144 BaseResponse 145 Results []OptionsContract `json:"results,omitempty"` 146 } 147 148 // OptionsContract contains detailed information on a specified options contract. 149 type OptionsContract struct { 150 AdditionalUnderlyings []Underlying `json:"additional_underlyings,omitempty"` 151 CFI string `json:"cfi,omitempty"` 152 ContractType string `json:"contract_type,omitempty"` 153 Correction int32 `json:"correction,omitempty"` 154 ExerciseStyle string `json:"exercise_style,omitempty"` 155 ExpirationDate Date `json:"expiration_date,omitempty"` 156 PrimaryExchange string `json:"primary_exchange,omitempty"` 157 SharesPerContract float64 `json:"shares_per_contract,omitempty"` 158 StrikePrice float64 `json:"strike_price,omitempty"` 159 Ticker string `json:"ticker,omitempty"` 160 UnderlyingTicker string `json:"underlying_ticker,omitempty"` 161 } 162 163 // An underlying or deliverable associated with an option contract. 164 type Underlying struct { 165 Amount float64 `json:"amount,omitempty"` 166 Type string `json:"type,omitempty"` 167 Underlying string `json:"underlying,omitempty"` 168 }