Skip to navigation

Stock Symbol Search

View as MarkdownOpen in Claude

Introduction

The function EClient.reqMatchingSymbols is available to search for stock contracts. The input can be either the first few letters of the ticker symbol, or for longer strings, a character sequence matching a word in the security name. For instance to search for the stock symbol ‘IBKR’, the input ‘I’ or ‘IB’ can be used, as well as the word ‘Interactive’. Up to 16 matching results are returned.

There must be an interval of at least 1 second between successive calls to reqMatchingSymbols.

Matching stock contracts are returned to EWrapper.symbolSamples with information about types of derivative contracts which exist (warrants, options, dutch warrants, futures).


EClient.reqMatchingSymbols(reqId, pattern)

Requests matching stock symbols.

reqId
int

Request identifier used to track data.

pattern
string

Either start of ticker symbol or (for larger strings) company name.


self.reqMatchingSymbols(reqId, "IBM")

Receive Searched Stock Contract

EWrapper.symbolSamples(reqID, contractDescription)

Returns array of sample contract descriptions.

reqID
int

Request identifier used to track data.

contractDescription
ContractDescription[]

Provide an array of contract objects matching the requested description.


def symbolSamples(self, reqId: int, contractDescriptions: ListOfContractDescription):
print("Symbol Samples. Request Id: ", reqId)
for contractDescription in contractDescriptions:
derivSecTypes = ""
for derivSecType in contractDescription.derivativeSecTypes:
derivSecTypes += " "
derivSecTypes += derivSecType
print("Contract: conId:%s, symbol:%s, secType:%s primExchange:%s, "
"currency:%s, derivativeSecTypes:%s, description:%s, issuerId:%s" % (
contractDescription.contract.conId,
contractDescription.contract.symbol,
contractDescription.contract.secType,
contractDescription.contract.primaryExchange,
contractDescription.contract.currency, derivSecTypes,
contractDescription.contract.description,
contractDescription.contract.issuerId))