fetch_sec_def_opt_params – ShinyBroker

# fetch_sec_def_opt_params

`fetch_sec_def_opt_params(underlyingConId, underlyingSymbol, underlyingSecType, host='127.0.0.1', port=7497, client_id=9999, futFopExchange='', timeout=3)`

Fetch the option parameters for a security.

Creates a temporary IBKR client socket at the specified `host`, `port`, and `client_id`, then makes a query for the security-defined option parameters for the security defined by `underlyingConId`, `underlyingSymbol`, `underlyingSecType`, and `futFopExchange`.

`fetch_sec_def_opt_params` will collect all `SECURITY_DEFINITION_OPTION_PARAMETER` messages it receives and return them in a dataframe when it receives a `SECURITY_DEFINITION_OPTION_PARAMETER_END` message.

If `timeout` number of seconds elapse before receiving `SECURITY_DEFINITION_OPTION_PARAMETER_END`, then `fetch_sec_def_opt_params` returns `None`.

Upon completion, `fetch_sec_def_opt_params` closes the socket it opened.

## Parameters

Name | Type | Description | Default
--- | --- | --- | ---
`underlyingConId` | int | `conId` of the underlying security | required
`underlyingSymbol` | str | Symbol of the underlying security for which you want option parameters. | required
`underlyingSecType` | str | Type of the underlying security; e.g., “`STK`” | required
`host` |  | Address of a running IBKR client (such as TWS or IBG) that has been configured to accept API connections | `'127.0.0.1'`
`port` |  | Port of a running IBKR client | `7497`
`client_id` |  | Client ID you want to use for the request. If you are connecting to a system that is used by multiple users, then you may wish to set aside an ID for this purpose; if you’re the only one using the account then you probably don’t have to worry about it – just use the default. | `9999`
`futFopExchange` |  | Only set this parameter if the underlying is a futures contract; in other words, don’t change it from the default `""` if your underlying is a stock. If your underlying is a futures contract, then use `futFopExchange` to specify the exchange for which you want option parameters. You may still pass in `""` if you want the results to include all of the exchanges available at IBKR that trade options on your specified underlying. | `''`
`timeout` |  | Time in seconds to wait for a response. | `3`

## Examples

    import shinybroker as sb

    sec_def_opt_params = sb.fetch_sec_def_opt_params(
        underlyingConId=265598,
        underlyingSymbol="AAPL",
        underlyingSecType="STK"
    )

    print(sec_def_opt_params)