Expirations
Get a list of current or historical option expiration dates for an underlying symbol.
Making Requests
Utilize OptionsExpirationsRequest for querying the endpoint through one of the three available methods:
| Method | Execution | Return Type | Description |
|---|---|---|---|
| Get | Direct | []time.Time | Immediately fetches and returns a slice of []time.Time, allowing direct access to each expiration date. |
| Packed | Intermediate | *OptionsExpirationsResponse | Delivers a *OptionsExpirationsResponse object containing the data, which requires unpacking to access the []time.Time slice. |
| Raw | Low-level | *resty.Response | Offers the unprocessed *resty.Response for those seeking full control and access to the raw JSON or *http.Response. |
OptionsExpirationsRequest
type OptionsExpirationsRequest struct {
// contains filtered or unexported fields
}
OptionsExpirationsRequest represents a request for retrieving options expirations data from the /v1/options/expirations/ endpoint. It encapsulates parameters for the underlying symbol and strike price to be used in the request. This struct provides methods such as UnderlyingSymbol() and Strike() to set these parameters respectively.
Generated By
-
OptionsExpirations() *OptionsExpirationsRequestOptionsExpirations creates a new *OptionsExpirationsRequest and returns a pointer to the request allowing for method chaining.
Setter Methods
-
Strike(float64) *OptionsExpirationsRequestSets the strike price parameter for the options expirations request.
-
UnderlyingSymbol(string) *OptionsExpirationsRequestSets the underlying symbol parameter for the options expirations request.
Execution Methods
These methods are used to send the request in different formats or retrieve the data. They handle the actual communication with the API endpoint.
-
Get() ([]time.Time, error)Sends the request, unpacks the response, and returns []time.Time allowing direct-access to the data.
-
Packed() (*OptionsExpirationsResponse, error)Returns a struct that contains equal-length slices of primitives. This packed response mirrors Market Data's JSON response.
-
Raw() (*resty.Response, error)Sends the request as is and returns the raw HTTP response.
OptionsExpirations
func OptionsExpirations() *OptionsExpirationsRequest
OptionsExpirations creates a new OptionsExpirationsRequest with the default client.
Returns
-
*OptionsExpirationsRequestA pointer to the newly created OptionsExpirationsRequest with default parameters.
OptionsExpirationsRequest Setter Methods
Date
func (oer *OptionsExpirationsRequest) Date(q interface{}) *OptionsExpirationsRequest
Date sets the date parameter for the OptionsExpirationsRequest. This method is used to specify the date for which the options expirations are requested. It modifies the dateParams field of the OptionsExpirationsRequest instance to store the date value.
Parameters
-
interface{}An interface{} that represents the starting date. It can be a string, a time.Time object, a Unix timestamp or any other type that the underlying dates package can process.
Returns
-
*OptionsExpirationsRequestThis method returns a pointer to the OptionsExpirationsRequest instance it was called on. This allows for method chaining. If the receiver (*OptionsExpirationsRequest) is nil, it returns nil to prevent a panic.
Strike
func (o *OptionsExpirationsRequest) Strike(strike float64) *OptionsExpirationsRequest
Strike sets the strike price parameter for the OptionsExpirationsRequest. This method is used to specify a particular strike price for filtering the options expirations.
Parameters
-
float64A float64 representing the strike price to be set.
Returns
-
*OptionsExpirationsRequestThis method returns a pointer to the OptionsExpirationsRequest instance it was called on, allowing for method chaining.
UnderlyingSymbol
func (o *OptionsExpirationsRequest) UnderlyingSymbol(symbol string) *OptionsExpirationsRequest
UnderlyingSymbol sets the underlying symbol parameter for the OptionsExpirationsRequest. This method is used to specify the symbol of the underlying asset for which the options expirations are requested.
Parameters
-
stringA string representing the underlying symbol to be set.
Returns
-
*OptionsExpirationsRequestThis method returns a pointer to the OptionsExpirationsRequest instance it was called on, allowing for method chaining.
OptionsExpirationsRequest Execution Methods
Get
func (o *OptionsExpirationsRequest) Get() ([]time.Time, error)
Get sends the OptionsExpirationsRequest, unpacks the OptionsExpirationsResponse, and returns a slice of time.Time. It returns an error if the request or unpacking fails. This method uses the default client for the request.
Returns
-
[]time.TimeA slice of time.Time containing the unpacked options expirations data from the response.
-
errorAn error object that indicates a failure in sending the request or unpacking the response.
Packed
func (o *OptionsExpirationsRequest) Packed() (*models.OptionsExpirationsResponse, error)
Packed sends the OptionsExpirationsRequest and returns the OptionsExpirationsResponse. This method uses the default client for the request.
Returns
-
*models.OptionsExpirationsResponseA pointer to the OptionsExpirationsResponse obtained from the request.
-
errorAn error object that indicates a failure in sending the request.