ib_async.contract
Generated from the installed ib_async 2.1.0 package. Signatures and defaults are version-specific.
Financial instrument types used by Interactive Brokers.
Bag
Bag(**kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Bond
Bond(**kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
CFD
CFD(symbol: str = '', exchange: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
ComboLeg
ComboLeg(conId: int = 0, ratio: int = 0, action: str = '', exchange: str = '', openClose: int = 0, shortSaleSlot: int = 0, designatedLocation: str = '', exemptCode: int = -1) -> None
ComboLeg(conId: int = 0, ratio: int = 0, action: str = '', exchange: str = '', openClose: int = 0, shortSaleSlot: int = 0, designatedLocation: str = '', exemptCode: int = -1)
Fields
| Name | Type | Default |
|---|---|---|
conId | int | 0 |
ratio | int | 0 |
action | str | `` |
exchange | str | `` |
openClose | int | 0 |
shortSaleSlot | int | 0 |
designatedLocation | str | `` |
exemptCode | int | -1 |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Commodity
Commodity(symbol: str = '', exchange: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
ContFuture
ContFuture(symbol: str = '', exchange: str = '', localSymbol: str = '', multiplier: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Contract
Contract(secType: str = '', conId: int = 0, symbol: str = '', lastTradeDateOrContractMonth: str = '', strike: float = 0.0, right: str = '', multiplier: str = '', exchange: str = '', primaryExchange: str = '', currency: str = '', localSymbol: str = '', tradingClass: str = '', includeExpired: bool = False, secIdType: str = '', secId: str = '', description: str = '', issuerId: str = '', comboLegsDescrip: str = '', comboLegs: list['ComboLeg'] = <factory>, deltaNeutralContract: Optional[ForwardRef('DeltaNeutralContract')] = None) -> None
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
create
create(**kwargs) -> 'Contract'
Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given.
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
isHashable
isHashable(self) -> bool
See if this contract can be hashed by conId.
Note: Bag contracts always get conId=28812380, so they're not hashable by conId, but we generate a synthetic hash for them based on leg details instead.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
recreate
recreate(c) -> 'Contract'
Comply an existing generic Contract into its most specific type.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
ContractDescription
ContractDescription(contract: ib_async.contract.Contract | None = None, derivativeSecTypes: list[str] = <factory>) -> None
ContractDescription(contract: ib_async.contract.Contract | None = None, derivativeSecTypes: list[str] = <factory>)
Fields
| Name | Type | Default |
|---|---|---|
contract | ib_async.contract.Contract | None | None |
derivativeSecTypes | list | factory: list |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
ContractDetails
ContractDetails(contract: ib_async.contract.Contract | None = None, marketName: str = '', minTick: float = 0.0, orderTypes: str = '', validExchanges: str = '', priceMagnifier: int = 0, underConId: int = 0, longName: str = '', contractMonth: str = '', industry: str = '', category: str = '', subcategory: str = '', timeZoneId: str = '', tradingHours: str = '', liquidHours: str = '', evRule: str = '', evMultiplier: int = 0, mdSizeMultiplier: int = 1, aggGroup: int = 0, underSymbol: str = '', underSecType: str = '', marketRuleIds: str = '', secIdList: list[ib_async.contract.TagValue] = <factory>, realExpirationDate: str = '', lastTradeTime: str = '', stockType: str = '', minSize: float = 0.0, sizeIncrement: float = 0.0, suggestedSizeIncrement: float = 0.0, cusip: str = '', ratings: str = '', descAppend: str = '', bondType: str = '', couponType: str = '', callable: bool = False, putable: bool = False, coupon: float = 0, convertible: bool = False, maturity: str = '', issueDate: str = '', nextOptionDate: str = '', nextOptionType: str = '', nextOptionPartial: bool = False, notes: str = '') -> None
ContractDetails(contract: ib_async.contract.Contract | None = None, marketName: str = '', minTick: float = 0.0, orderTypes: str = '', validExchanges: str = '', priceMagnifier: int = 0, underConId: int = 0, longName: str = '', contractMonth: str = '', industry: str = '', category: str = '', subcategory: str = '', timeZoneId: str = '', tradingHours: str = '', liquidHours: str = '', evRule: str = '', evMultiplier: int = 0, mdSizeMultiplier: int = 1, aggGroup: int = 0, underSymbol: str = '', underSecType: str = '', marketRuleIds: str = '', secIdList: list[ib_async.contract.TagValue] = <factory>, realExpirationDate: str = '', lastTradeTime: str = '', stockType: str = '', minSize: float = 0.0, sizeIncrement: float = 0.0, suggestedSizeIncrement: float = 0.0, cusip: str = '', ratings: str = '', descAppend: str = '', bondType: str = '', couponType: str = '', callable: bool = False, putable: bool = False, coupon: float = 0, convertible: bool = False, maturity: str = '', issueDate: str = '', nextOptionDate: str = '', nextOptionType: str = '', nextOptionPartial: bool = False, notes: str = '')
Fields
| Name | Type | Default |
|---|---|---|
contract | ib_async.contract.Contract | None | None |
marketName | str | `` |
minTick | float | 0.0 |
orderTypes | str | `` |
validExchanges | str | `` |
priceMagnifier | int | 0 |
underConId | int | 0 |
longName | str | `` |
contractMonth | str | `` |
industry | str | `` |
category | str | `` |
subcategory | str | `` |
timeZoneId | str | `` |
tradingHours | str | `` |
liquidHours | str | `` |
evRule | str | `` |
evMultiplier | int | 0 |
mdSizeMultiplier | int | 1 |
aggGroup | int | 0 |
underSymbol | str | `` |
underSecType | str | `` |
marketRuleIds | str | `` |
secIdList | list | factory: list |
realExpirationDate | str | `` |
lastTradeTime | str | `` |
stockType | str | `` |
minSize | float | 0.0 |
sizeIncrement | float | 0.0 |
suggestedSizeIncrement | float | 0.0 |
cusip | str | `` |
ratings | str | `` |
descAppend | str | `` |
bondType | str | `` |
couponType | str | `` |
callable | bool | False |
putable | bool | False |
coupon | float | 0 |
convertible | bool | False |
maturity | str | `` |
issueDate | str | `` |
nextOptionDate | str | `` |
nextOptionType | str | `` |
nextOptionPartial | bool | False |
notes | str | `` |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
liquidSessions
liquidSessions(self) -> list[ib_async.contract.TradingSession]
No library docstring is provided; consult the signature, type fields, and operational guides.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tradingSessions
tradingSessions(self) -> list[ib_async.contract.TradingSession]
No library docstring is provided; consult the signature, type fields, and operational guides.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Crypto
Crypto(symbol: str = '', exchange: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
DeltaNeutralContract
DeltaNeutralContract(conId: int = 0, delta: float = 0.0, price: float = 0.0) -> None
DeltaNeutralContract(conId: int = 0, delta: float = 0.0, price: float = 0.0)
Fields
| Name | Type | Default |
|---|---|---|
conId | int | 0 |
delta | float | 0.0 |
price | float | 0.0 |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Forex
Forex(pair: str = '', exchange: str = 'IDEALPRO', symbol: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
pair
pair(self) -> str
Short name of pair.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Future
Future(symbol: str = '', lastTradeDateOrContractMonth: str = '', exchange: str = '', localSymbol: str = '', multiplier: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
FuturesOption
FuturesOption(symbol: str = '', lastTradeDateOrContractMonth: str = '', strike: float = 0.0, right: str = '', exchange: str = '', multiplier: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Index
Index(symbol: str = '', exchange: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
MutualFund
MutualFund(**kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Option
Option(symbol: str = '', lastTradeDateOrContractMonth: str = '', strike: float = 0.0, right: str = '', exchange: str = '', multiplier: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
ScanData
ScanData(rank: int, contractDetails: ib_async.contract.ContractDetails, distance: str, benchmark: str, projection: str, legsStr: str) -> None
ScanData(rank: int, contractDetails: ib_async.contract.ContractDetails, distance: str, benchmark: str, projection: str, legsStr: str)
Fields
| Name | Type | Default |
|---|---|---|
rank | int | required |
contractDetails | ContractDetails | required |
distance | str | required |
benchmark | str | required |
projection | str | required |
legsStr | str | required |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
Stock
Stock(symbol: str = '', exchange: str = '', currency: str = '', **kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
TagValue
TagValue(tag: str, value: str)
TagValue(tag, value)
TradingSession
TradingSession(start: datetime.datetime, end: datetime.datetime)
TradingSession(start, end)
Warrant
Warrant(**kwargs)
Contract(**kwargs) can create any contract using keyword
arguments. To simplify working with contracts, there are also more
specialized contracts that take optional positional arguments.
Some examples::
Contract(conId=270639) Stock('AMD', 'SMART', 'USD') Stock('INTC', 'SMART', 'USD', primaryExchange='NASDAQ') Forex('EURUSD') CFD('IBUS30') Future('ES', '20180921', 'GLOBEX') Option('SPY', '20170721', 240, 'C', 'SMART') Bond(secIdType='ISIN', secId='US03076KAA60') Crypto('BTC', 'PAXOS', 'USD')
Args: conId (int): The unique IB contract identifier. symbol (str): The contract (or its underlying) symbol. secType (str): The security type:
-
'STK' = Stock (or ETF)
-
'OPT' = Option
-
'FUT' = Future
-
'IND' = Index
-
'FOP' = Futures option
-
'CASH' = Forex pair
-
'CFD' = CFD
-
'BAG' = Combo
-
'WAR' = Warrant
-
'BOND' = Bond
-
'CMDTY' = Commodity
-
'NEWS' = News
-
'FUND' = Mutual fund
-
'CRYPTO' = Crypto currency
-
'EVENT' = Bet on an event lastTradeDateOrContractMonth (str): The contract's last trading day or contract month (for Options and Futures). Strings with format YYYYMM will be interpreted as the Contract Month whereas YYYYMMDD will be interpreted as Last Trading Day. strike (float): The option's strike price. right (str): Put or Call. Valid values are 'P', 'PUT', 'C', 'CALL', or '' for non-options. multiplier (str): The instrument's multiplier (i.e. options, futures). exchange (str): The destination exchange. currency (str): The underlying's currency. localSymbol (str): The contract's symbol within its primary exchange. For options, this will be the OCC symbol. primaryExchange (str): The contract's primary exchange. For smart routed contracts, used to define contract in case of ambiguity. Should be defined as native exchange of contract, e.g. ISLAND for MSFT. For exchanges which contain a period in name, will only be part of exchange name prior to period, i.e. ENEXT for ENEXT.BE. tradingClass (str): The trading class name for this contract. Available in TWS contract description window as well. For example, GBL Dec '13 future's trading class is "FGBL". includeExpired (bool): If set to true, contract details requests and historical data queries can be performed pertaining to expired futures contracts. Expired options or other instrument types are not available. secIdType (str): Security identifier type. Examples for Apple:
- secIdType='ISIN', secId='US0378331005'
- secIdType='CUSIP', secId='037833100' secId (str): Security identifier. comboLegsDescription (str): Description of the combo legs. comboLegs (List[ComboLeg]): The legs of a combined contract definition. deltaNeutralContract (DeltaNeutralContract): Delta and underlying price for Delta-Neutral combo orders.
Fields
| Name | Type | Default |
|---|---|---|
secType | str | `` |
conId | int | 0 |
symbol | str | `` |
lastTradeDateOrContractMonth | str | `` |
strike | float | 0.0 |
right | str | `` |
multiplier | str | `` |
exchange | str | `` |
primaryExchange | str | `` |
currency | str | `` |
localSymbol | str | `` |
tradingClass | str | `` |
includeExpired | bool | False |
secIdType | str | `` |
secId | str | `` |
description | str | `` |
issuerId | str | `` |
comboLegsDescrip | str | `` |
comboLegs | list | factory: list |
deltaNeutralContract | Optional | None |
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.