fetch_contract_details
fetch_contract_details(contract, host='127.0.0.1', port=7497, client_id=9999)Fetch contract details
Fetches the contract details returned by IBKR for a specified contract. Useful for checking & validating a contract definition. Prints out an error message and returns None if no contract is found. Results are returned in a dataframe with more than one matching contract if multiple matches are found.
Parameters
| Name | Type | Description | Default | 
|---|---|---|---|
| contract | Contract | The Contract object for which you want data | 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 | 
Examples
import shinybroker as sb
# Contract Details for a Stock
apple_deets = sb.fetch_contract_details(
    contract=sb.Contract({
        'symbol': "AAPL",
        'secType': "STK",
        'exchange': "SMART",
        'currency': "USD"
    })
)
print(apple_deets)
#print the hours that AAPL is liquid this week:
print(apple_deets['liquidHours'][0])
# Contract Details for a Google Call
gc_deets = sb.fetch_contract_details(
    contract=sb.Contract({
        'symbol': 'GOOG',
        'secType': 'OPT',
        'exchange': 'SMART',
        'currency': 'USD',
        'lastTradeDateOrContractMonth': '20261218',
        'strike': 160,
        'right': 'C',
        'multiplier': '100'
    })
)
print(gc_deets)
# It's possible to match more than one contract with a call for contract
#   details as in this example which fetches Contract Details for all strikes
#   for Google Calls expiring on '20261218'.
# Note that here, the strike isn't specified, so the contract definition will
#  match more than one contract.
gc_deets_multi = sb.fetch_contract_details(
    contract=sb.Contract({
        'symbol': 'GOOG',
        'secType': 'OPT',
        'exchange': 'SMART',
        'currency': 'USD',
        'lastTradeDateOrContractMonth': '20261218',
        'right': 'C',
        'multiplier': '100'
    })
)
print(gc_deets_multi)
# Try an example with a bad security definition.
# SPX isn't a stock, it's an Index "IND". The call below will return None and
#  print out an informative warning message.
bad_def_details = sb.fetch_contract_details(
    contract=sb.Contract({
        'symbol': "SPX",
        'secType': "STK",
        'exchange': "ARCA",
        'currency': "USD"
    })
)
print(bad_def_details)