IbkrApi.ClientPortal.Contract (ibkr_api v1.0.0)
View SourceContract-related functionality for the IBKR Client Portal API.
This module provides functions to retrieve contract information, trading schedules, security definitions, and currency exchange rates.
Summary
Functions
Get detailed contract information using the secdef/info endpoint.
Convenience function to get strikes for a symbol by first searching for the contract.
Get option strikes for a given contract.
Search for contracts based on symbol and other criteria.
Functions
@spec contract_details(String.t()) :: IbkrApi.ErrorMessage.t_res()
@spec get_available_currency_pairs(String.t()) :: IbkrApi.ErrorMessage.t_res()
@spec get_contract_ids(String.t()) :: IbkrApi.ErrorMessage.t_res()
Get detailed contract information using the secdef/info endpoint.
Returns a list of contract information objects matching the criteria.
Parameters
conid
- Contract identifier (required)opts
- Optional parameters::sec_type
- Security type:month
- Expiration month for derivatives:exchange
- Specific exchange:strike
- Strike price for options:right
- "C" for Call, "P" for Put options:issuer_id
- Issuer ID for bonds:filters
- Comma-separated list of additional filters for bonds
Examples
iex> IbkrApi.ClientPortal.Contract.get_contract_info("8314")
{:ok, [%SecdefInfo{conid: 8314, symbol: "IBM", sec_type: "STK", ...}]}
iex> IbkrApi.ClientPortal.Contract.get_contract_info("265598", sec_type: "OPT", strike: 250)
{:ok, [%SecdefInfo{conid: 795753109, symbol: "NVDA", right: "C", ...}, ...]}
@spec get_stock_security_definition(String.t()) :: IbkrApi.ErrorMessage.t_res()
Convenience function to get strikes for a symbol by first searching for the contract.
This function searches for the symbol, finds the first matching contract with options, then retrieves the strikes for the current month.
Parameters
symbol
: The ticker symbol to search foropts
: Optional parameters::month
: Date struct for expiration month (defaults to current month):sec_type
: Security type for search (defaults to "STK")
Examples
iex> get_strikes("AAPL")
{:ok, %StrikesResponse{call: [150, 155, 160], put: [150, 155, 160]}}
Get option strikes for a given contract.
Parameters
contract_id
: Contract identifier of the underlying or derivativesec_type
: Security type (e.g., "OPT" for options)month
: Elixir Date struct representing the expiration monthopts
: Optional parameters including exchange (defaults to "SMART")
Examples
iex> date = ~D[2024-01-15]
iex> get_strikes("265598", "OPT", date)
{:ok, %StrikesResponse{call: [70, 75, 80], put: [70, 75, 80]}}
Search for contracts based on symbol and other criteria.
Parameters
symbol
: The ticker symbol, bond issuer type, or company nameopts
: Optional parameters::sec_type
: Security type ("STK", "IND", "BOND") - defaults to "STK":name
: Boolean indicating if symbol is part of company name:more
: Boolean for additional results:fund
: Boolean for fund search:fund_family_conid_ex
: String for fund family:pattern
: Boolean for pattern search:referrer
: String referrer
Examples
iex> search_contracts("AAPL")
{:ok, [%SearchContract{symbol: "AAPL", conid: "265598", ...}]}
@spec secdef_by_conid([integer()]) :: IbkrApi.ErrorMessage.t_res()
@spec security_futures_by_symbol(String.t()) :: IbkrApi.ErrorMessage.t_res()
@spec security_stocks_by_symbol(String.t()) :: IbkrApi.ErrorMessage.t_res()