开云体育

ctrl + shift + ? for shortcuts
© 2025 开云体育

secID empty


 

I am trying to retrieve all executions with according ISIN by using secID but the response to secID seems to be empty. Can anyone tell me what I am doing wrong?

...
class TradingApp(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)

def position(self, account: str, contract: Contract, position: Decimal, avgCost: float):
print("Position.", "Account:", account, "Symbol:",contract.symbol,"secId:", contract.secId, "Position:", position, "Avg cost:", avgCost)

def positionEnd(self):
print("PositionEnd")

...
?
Response:
Position. Account: **** Symbol: AAPL secId: ?Position: **** Avg cost: **


 

1) At least for stocks, you have to be subscribed to ISINs in IBKR market data centre to receive them.
2) Then, to get the ISIN you need to look up ContractDetails for the issue in question and retrieve ContractDetails.secIdList["ISIN"].
--
Best,
DS


 

@ds-avatar is correct, but let me add a little context.

The and fields in the class can be used when API clients need to specify an instrument (say instead of symbol or ConId). The API documentation specifically says "when querying contract's details or placing orders". Those fields will be empty/null when TWS API returns a Contract object to you. In fact, Contract objects in messages from TWS/IBGW to API clients do not even include those fields.

ISINs are only returned to TWS API clients in the field of objects when you call ?You could use the Contract object from position callback and call to get the ISIN.

It is a best practice to make calls once per session for the instruments you work with, since the objects contain timely and relevant information for your trading process (multipliers, market rules, most up-to-date trading hours, ...). Since IBKR's ConId and ISIN are permanent identifiers, you could cache them and eliminate entirely the need for additional for ISIN lookup.

闯ü谤驳别苍

?

?
On Fri, Aug 9, 2024 at 11:00 AM, ds-avatar wrote:

1) At least for stocks, you have to be subscribed to ISINs in IBKR market data centre to receive them.
2) Then, to get the ISIN you need to look up ContractDetails for the issue in question and retrieve ContractDetails.secIdList["ISIN"].
--
Best,
DS