Skip to main content

Quotes

Retrieve an option quote for a given option symbol.

Making Requests

Utilize OptionQuoteRequest for querying the endpoint through one of the three available methods:

MethodExecutionReturn TypeDescription
GetDirect[]OptionQuoteImmediately fetches a slice of []OptionQuote, allowing direct access to the quote data.
PackedIntermediate*OptionQuotesResponseDelivers a *OptionQuotesResponse object containing the data, which requires unpacking to access the OptionQuote data.
RawLow-level*resty.ResponseOffers the unprocessed *resty.Response for those seeking full control and access to the raw JSON or *http.Response.

OptionQuoteRequest

type OptionQuoteRequest struct {
// contains filtered or unexported fields
}

OptionQuotesRequest represents a request to the /v1/options/quotes/ endpoint for retrieving options quotes. It encapsulates parameters for symbol, expiration, and strike to be used in the request.

Generated By

Setter Methods

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.

resp, err := OptionQuote().OptionSymbol("AAPL250117C00150000").Date("2024-02-05").Get()
if err != nil {
fmt.Print(err)
return
}

for _, quote := range resp {
fmt.Println(quote)
}

Output

OptionQuote{OptionSymbol: "AAPL250117C00150000", Underlying: "AAPL", Expiration: 2025-01-17 16:00:00 -05:00, Side: "call", Strike: 150, FirstTraded: 2022-09-12 09:30:00 -04:00, DTE: 347, Ask: 47.7, AskSize: 17, Bid: 47.2, BidSize: 36, Mid: 47.45, Last: 48.65, Volume: 202, OpenInterest: 10768, UnderlyingPrice: 187.68, InTheMoney: true, Updated: "2024-02-05 16:00:00 -05:00", IV: nil, Delta: nil, Gamma: nil, Theta: nil, Vega: nil, Rho: nil, IntrinsicValue: 37.68, ExtrinsicValue: 9.77}

OptionQuote

func OptionQuote() *OptionQuoteRequest

OptionQuotes creates a new OptionQuotesRequest and uses the default client.

Returns

  • *OptionQuotesRequest

    A pointer to the newly created OptionQuotesRequest with default parameters.

OptionQuoteRequest Setter Methods

Date

func (oqr *OptionQuoteRequest) Date(q interface{}) *OptionQuoteRequest

Date sets the date parameter for the OptionQuotesRequest. This method is used to specify the date for which the option quote is requested. It allows for flexibility in the type of date input (e.g., string, time.Time) through the use of an interface{} parameter.

Parameters

  • interface{}

    The date to be set. The actual type accepted can vary (e.g., string, time.Time, int for Unix timestamp).

Returns

  • *OptionQuotesRequest

    This method returns a pointer to the OptionQuotesRequest instance it was called on, allowing for method chaining. If the receiver (*OptionQuotesRequest) is nil, it returns nil to prevent a panic.

From

func (oqr *OptionQuoteRequest) From(q interface{}) *OptionQuoteRequest

From sets the from parameter for the OptionQuotesRequest. This method is used to specify the start date of a date range for which the option quote is requested. Similar to the Date method, it accepts a flexible date input through an interface{} parameter.

Parameters

  • interface{}

    The start date of the range to be set. The actual type accepted can vary.

Returns

  • *OptionQuotesRequest

    This method returns a pointer to the OptionQuotesRequest instance it was called on, allowing for method chaining. If the receiver (*OptionQuotesRequest) is nil, it returns nil to prevent a panic.

OptionSymbol

func (oqr *OptionQuoteRequest) OptionSymbol(q string) *OptionQuoteRequest

OptionSymbol sets the symbol parameter for the OptionQuotesRequest. This method is used to specify the symbol of the option for which the quote is requested.

Parameters

  • string

    A string representing the option symbol to be set.

Returns

  • *OptionQuotesRequest

    This method returns a pointer to the OptionQuotesRequest instance it was called on, allowing for method chaining.

To

func (oqr *OptionQuoteRequest) To(q interface{}) *OptionQuoteRequest

To sets the to parameter for the OptionQuotesRequest. This method is used to specify the end date of a date range for which the option quote is requested. It accepts a flexible date input through an interface{} parameter, similar to the From method.

Parameters

  • interface{}

    The end date of the range to be set. The actual type accepted can vary, depending on implementation.

Returns

  • *OptionQuotesRequest

    This method returns a pointer to the OptionQuotesRequest instance it was called on, allowing for method chaining. If the receiver (*OptionQuotesRequest) is nil, it returns nil to prevent a panic.

OptionQuoteRequest Execution Methods

Get

func (oqr *OptionQuoteRequest) Get() ([]models.OptionQuote, error)

Get sends the OptionQuoteRequest, unpacks the OptionQuotesResponse, and returns a slice of OptionQuote. It returns an error if the request or unpacking fails. This method uses the default client for the request.

Returns

  • []models.OptionQuote

    A slice of OptionQuote containing the unpacked options quotes data from the response.

  • error

    An error object that indicates a failure in sending the request or unpacking the response.

Packed

func (oqr *OptionQuoteRequest) Packed() (*models.OptionQuotesResponse, error)

Packed sends the OptionQuoteRequest and returns the OptionQuotesResponse. This method uses the default client for the request.

Returns

  • *models.OptionQuotesResponse

    A pointer to the OptionQuotesResponse obtained from the request.

  • error

    An error object that indicates a failure in sending the request.

Raw

func (oqr *OptionQuoteRequest) Raw() (*resty.Response, error)

Raw executes the OptionQuoteRequest and returns the raw *resty.Response. This method uses the default client for the request. The *resty.Response can be used to access the raw JSON or *http.Response directly.

Returns

  • *resty.Response

    The raw HTTP response from the executed request.

  • error

    An error object if the OptionQuoteRequest is nil or if an error occurs during the request execution.

OptionQuotesResponse

type OptionQuotesResponse struct {
OptionSymbol []string `json:"optionSymbol"` // OptionSymbol holds the symbols of the options.
Underlying []string `json:"underlying"` // Underlying contains the symbols of the underlying assets.
Expiration []int64 `json:"expiration"` // Expiration stores UNIX timestamps for when the options expire.
Side []string `json:"side"` // Side indicates whether the option is a call or a put.
Strike []float64 `json:"strike"` // Strike represents the strike prices of the options.
FirstTraded []int64 `json:"firstTraded"` // FirstTraded stores UNIX timestamps for when the options were first traded.
DTE []int `json:"dte"` // DTE (Days to Expiration) indicates the number of days until the options expire.
Ask []float64 `json:"ask"` // Ask contains the ask prices of the options.
AskSize []int64 `json:"askSize"` // AskSize holds the sizes of the ask orders.
Bid []float64 `json:"bid"` // Bid contains the bid prices of the options.
BidSize []int64 `json:"bidSize"` // BidSize holds the sizes of the bid orders.
Mid []float64 `json:"mid"` // Mid represents the mid prices calculated between the bid and ask prices.
Last []float64 `json:"last"` // Last contains the last traded prices of the options.
Volume []int64 `json:"volume"` // Volume indicates the trading volumes of the options.
OpenInterest []int64 `json:"openInterest"` // OpenInterest represents the total number of outstanding contracts.
UnderlyingPrice []float64 `json:"underlyingPrice"` // UnderlyingPrice contains the prices of the underlying assets.
InTheMoney []bool `json:"inTheMoney"` // InTheMoney indicates whether the options are in the money.
Updated []int64 `json:"updated"` // Updated stores UNIX timestamps for when the option data was last updated.
IV []*float64 `json:"iv,omitempty"` // IV (Implied Volatility) represents the implied volatilities of the options.
Delta []*float64 `json:"delta,omitempty"` // Delta measures the rate of change of the option's price with respect to the underlying asset's price.
Gamma []*float64 `json:"gamm,omitempty"` // Gamma measures the rate of change in delta over the underlying asset's price movement.
Theta []*float64 `json:"theta,omitempty"` // Theta represents the rate of decline in the option's value with time.
Vega []*float64 `json:"vega,omitempty"` // Vega measures sensitivity to volatility.
Rho []*float64 `json:"rho,omitempty"` // Rho measures sensitivity to the interest rate.
IntrinsicValue []float64 `json:"intrinsicValue"` // IntrinsicValue represents the value of the option if it were exercised now.
ExtrinsicValue []float64 `json:"extrinsicValue"` // ExtrinsicValue represents the value of the option above its intrinsic value.
}

OptionQuotesResponse represents the JSON structure of the response received for option quotes. It includes slices for various option attributes such as symbols, underlying assets, expiration times, and pricing information.

IsValid

func (oqr *OptionQuotesResponse) IsValid() bool

IsValid determines the validity of an OptionQuotesResponse by invoking the Validate method. This method is primarily used to ensure that the OptionQuotesResponse adheres to expected formats and contains all necessary data before proceeding with further processing or operations.

Returns

  • bool

    Indicates whether the OptionQuotesResponse is valid.

Notes

  • This method relies on the Validate method to check for inconsistencies or missing data in the OptionQuotesResponse.

String

func (oqr *OptionQuotesResponse) String() string

String generates a formatted string representation of all OptionQuotes contained within the OptionQuotesResponse. This method is primarily used for producing a human-readable summary of the OptionQuotes, which can be useful for logging, debugging, or displaying the data in a more accessible format.

Parameters

  • oqr *OptionQuotesResponse

    A pointer to the OptionQuotesResponse instance.

Returns

  • string

    A string that represents all OptionQuotes in a human-readable format.

Notes

  • This method simplifies the visualization of complex OptionQuotes data by converting it into a string format.

Unpack

func (oqr *OptionQuotesResponse) Unpack() ([]OptionQuote, error)

Unpack converts the OptionQuotesResponse into a slice of OptionQuote structs, allowing for the individual option quotes contained within the response to be accessed and manipulated more easily. This method is primarily used when there's a need to work with the data of each option quote separately after fetching a bulk response.

Parameters

  • *OptionQuotesResponse oqr

    A pointer to the OptionQuotesResponse instance to be unpacked.

Returns

  • []OptionQuote

    A slice of OptionQuote structs that represent the unpacked data.

  • *error

    An error if the time zone loading fails or if the validation fails.

Notes

  • This method first validates the OptionQuotesResponse to ensure consistency before attempting to unpack it.

Validate

func (oqr *OptionQuotesResponse) Validate() error

Returns

  • error

    An error if there is an inconsistency in the lengths of slices or if there are no option symbols. Returns nil if all checks pass.

Notes

  • This method is particularly important for preventing runtime errors that could occur when processing inconsistent data.

OptionQuote

type OptionQuote struct {
OptionSymbol string // OptionSymbol is the symbol of the option.
Underlying string // Underlying is the symbol of the underlying asset.
Expiration time.Time // Expiration is the time when the option expires.
Side string // Side indicates whether the option is a call or a put.
Strike float64 // Strike is the strike price of the option.
FirstTraded time.Time // FirstTraded is the time when the option was first traded.
DTE int // DTE (Days to Expiration) is the number of days until the option expires.
Ask float64 // Ask is the ask price of the option.
AskSize int64 // AskSize is the size of the ask order.
Bid float64 // Bid is the bid price of the option.
BidSize int64 // BidSize is the size of the bid order.
Mid float64 // Mid is the mid price calculated between the bid and ask prices.
Last float64 // Last is the last traded price of the option.
Volume int64 // Volume is the trading volume of the option.
OpenInterest int64 // OpenInterest is the total number of outstanding contracts.
UnderlyingPrice float64 // UnderlyingPrice is the price of the underlying asset.
InTheMoney bool // InTheMoney indicates whether the option is in the money.
Updated time.Time // Updated is the time when the option data was last updated.
IV *float64 // IV (Implied Volatility) is the implied volatility of the option.
Delta *float64 // Delta measures the rate of change of the option's price with respect to the underlying asset's price.
Gamma *float64 // Gamma measures the rate of change in delta over the underlying asset's price movement.
Theta *float64 // Theta represents the rate of decline in the option's value with time.
Vega *float64 // Vega measures sensitivity to volatility.
Rho *float64 // Rho measures sensitivity to the interest rate.
IntrinsicValue float64 // IntrinsicValue is the value of the option if it were exercised now.
ExtrinsicValue float64 // ExtrinsicValue is the value of the option above its intrinsic value.
}

OptionQuote represents a single option quote with detailed information such as the symbol, underlying asset, expiration time, and pricing information.

DisplayDelta

func (oq OptionQuote) DisplayDelta() string

DisplayDelta formats the Delta value of an OptionQuote into a string. Delta measures the rate of change of the option's price with respect to the underlying asset's price. This method is useful for displaying Delta in a human-readable format, especially in user interfaces or logs.

Returns

  • string

    The formatted Delta value as a string. If Delta is nil, returns "nil".

DisplayGamma

func (oq OptionQuote) DisplayGamma() string

DisplayGamma formats the Gamma value of an OptionQuote into a string. Gamma measures the rate of change in Delta over the underlying asset's price movement. This method is useful for displaying Gamma in a human-readable format, particularly in user interfaces or logs.

Returns

  • string

    The formatted Gamma value as a string. If Gamma is nil, returns "nil".

DisplayIV

func (oq OptionQuote) DisplayIV() string

Formats the implied volatility (IV) of an option into a string. This method is primarily used for displaying the IV in a human-readable format, which is useful for logging, debugging, or displaying the IV value in user interfaces.

Returns

  • string

    The formatted IV value as a string. If the IV is nil, returns "nil".

Notes

  • The IV is formatted to a floating-point number as a string. If the IV is not set (nil), the method returns the string "nil".

DisplayMid

func (oq OptionQuote) DisplayMid() string

Formats the mid price of an option into a string. This method is primarily used for displaying the mid price in a human-readable format, which is useful for logging, debugging, or displaying the mid price value in user interfaces.

Returns

  • string

    The formatted mid price value as a string.

Notes

  • The mid price is calculated as the average of the bid and ask prices. This method formats the mid price to a floating-point number as a string.

DisplayRho

func (oq OptionQuote) DisplayRho() string

DisplayRho formats the Rho value of an OptionQuote into a string. Rho measures sensitivity to the interest rate. This method is useful for displaying Rho in a human-readable format, especially in user interfaces or logs.

Returns

  • string

    The formatted Rho value as a string. If Rho is nil, returns "nil".

DisplayTheta

func (oq OptionQuote) DisplayTheta() string

DisplayTheta formats the Theta value of an OptionQuote into a string. Theta represents the rate of decline in the option's value with time. This method is useful for displaying Theta in a human-readable format, especially in user interfaces or logs.

Returns

  • string

    The formatted Theta value as a string. If Theta is nil, returns "nil".

DisplayVega

func (oq OptionQuote) DisplayVega() string

DisplayVega formats the Vega value of an OptionQuote into a string. Vega measures sensitivity to volatility. This method is useful for displaying Vega in a human-readable format, particularly in user interfaces or logs.

Returns

  • string

    The formatted Vega value as a string. If Vega is nil, returns "nil".

String

func (oq OptionQuote) String() string

String provides a human-readable representation of an OptionQuote, encapsulating its key details in a formatted string. This method is primarily used for logging, debugging, or displaying the OptionQuote in a format that is easy to read and understand. It includes information such as the option symbol, underlying asset, expiration date, and more, formatted into a single string.

Returns

  • string

    A formatted string that encapsulates the OptionQuote details, making it easier to read and understand.

Notes

  • This method is particularly useful for debugging purposes or when there's a need to log the OptionQuote details in a human-readable format.