Skip to main content

Lookup

Lookup the official option symbol based on a user's text input.

Making Requests

Utilize [OptionsLookupRequest] for querying the endpoint through one of the three available methods:

MethodExecutionReturn TypeDescription
GetDirectstringImmediately fetches and string, allowing direct access to the option symbol.
PackedIntermediate*OptionLookupResponseDelivers a *OptionLookupResponse object containing the data, which requires unpacking to access the string data.
RawLow-level*resty.ResponseOffers the unprocessed *resty.Response for those seeking full control and access to the raw JSON or *http.Response.

OptionLookupRequest

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

OptionsLookupRequest represents a request to the /v1/options/lookup/ endpoint for retrieving an OCC-formatted option symbol based on user input. It encapsulates parameters for user input 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 := OptionLookup().UserInput("AAPL 7/28/2023 200 Call").Get()
if err != nil {
fmt.Print(err)
return
}

fmt.Println(resp)

Output

AAPL230728C00200000

OptionLookup

func OptionLookup() *OptionLookupRequest

OptionLookup creates a new OptionsLookupRequest and uses the default client.

Returns

  • *OptionsLookupRequest

    A pointer to the newly created OptionsLookupRequest with default parameters and associated client.

OptionLookupRequest Setter Methods

UserInput

func (o *OptionLookupRequest) UserInput(userInput string) *OptionLookupRequest

UserInput sets the user input parameter for the OptionsLookupRequest. This method is used to specify the user input for which the options data is requested.

Parameters

  • string

    A string representing the text to lookup with the OptionsLookupRequest endpoint.

Returns

  • *OptionsLookupRequest

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

OptionLookupRequest Execution Methods

Get

func (o *OptionLookupRequest) Get() (string, error)

Get sends the OptionLookupRequest, unpacks the OptionsLookupResponse, and returns the unpacked data as a string. It returns an error if the request or unpacking fails.

Returns

  • string

    A string containing the unpacked options data from the response.

  • error

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

Packed

func (o *OptionLookupRequest) Packed() (*models.OptionLookupResponse, error)

Packed sends the OptionLookupRequest and returns the OptionsLookupResponse.

Returns

  • *models.OptionsLookupResponse

    A pointer to the OptionsLookupResponse obtained from the request.

  • error

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

Raw

func (olr *OptionLookupRequest) Raw() (*resty.Response, error)

Raw executes the OptionLookupRequest and returns the raw *resty.Response. The *resty.Response allows access to the raw JSON or *http.Response for further processing.

Returns

  • *resty.Response

    The raw HTTP response from the executed OptionLookupRequest.

  • error

    An error object if the request fails due to being nil, or other execution errors.

OptionLookupResponse

type OptionLookupResponse struct {
OptionSymbol string `json:"optionSymbol"` // OptionSymbol is the symbol of the option.
}

OptionLookupResponse encapsulates the response data for an option lookup request, primarily containing the option's symbol.

Generated By

Methods

  • IsValid() bool

    Checks if the OptionLookupResponse is valid by verifying the OptionSymbol is not empty.

  • String() string

    Provides a string representation of the OptionLookupResponse, including the OptionSymbol.

  • Unpack() (string, error)

    Validates the OptionLookupResponse and returns the OptionSymbol if valid; otherwise, returns an error.

Notes

  • This struct is primarily used for handling the response of an options lookup request in financial market data applications.

IsValid

func (olr *OptionLookupResponse) IsValid() bool

IsValid determines the validity of the OptionLookupResponse. It is primarily used to ensure that the response received from an option lookup request contains a non-empty OptionSymbol, indicating a successful lookup and a valid option.

Returns

  • bool

    Indicates the validity of the OptionLookupResponse. Returns true if the OptionSymbol is not empty, otherwise false.

String

func (olr *OptionLookupResponse) String() string

Notes

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

Unpack

func (olr *OptionLookupResponse) Unpack() (string, error)

Unpack checks the validity of the OptionLookupResponse and returns the OptionSymbol if the response is deemed valid. This method is primarily used when one needs to extract the OptionSymbol from a valid OptionLookupResponse, ensuring that the response is not empty or malformed before proceeding with further processing.

Returns

  • string

    The OptionSymbol contained within a valid OptionLookupResponse.

  • error

    An error indicating that the OptionLookupResponse is invalid, typically due to an empty OptionSymbol.

Notes

  • This method is crucial for error handling and data validation in financial market data applications, ensuring that only valid responses are processed.