I'd like execute an order for a stock given only the stock symbol. Is there a way to look up the exchange? I can search for the symbol in TWS ie 1259 and it comes up with the correct symbol etc, however when I attempt to execute the order w/ IBPY it does not find the stock unless I specify the exchange. ie
def createContract(sym):
print "Creating Contract"
contract = Contract()
contract.m_symbol = sym
contract.m_localSymbol = sym
contract.m_secType = 'STK'
contract.m_exchange = 'SMART'
contract.m_primaryExch = 'SMART'
contract.m_strike = 0.00
contract.m_currency = 'USD'
return contract
createContract(1259)
Error:
Placing order with id 240
Creating Contract
<error id=240, errorCode=200, errorMsg=No security definition has been found for
the request>
Cancelling order
All done
Exception in thread EReader (most likely raised during interpreter shutdown):
C:\Users\Administrator>
-----------------
def createContract(sym):
print "Creating Contract"
contract = Contract()
contract.m_symbol = sym
contract.m_localSymbol = sym
contract.m_secType = 'STK'
contract.m_exchange = 'SEHK'
contract.m_primaryExch = 'SEHK'
contract.m_strike = 0.00
contract.m_currency = 'USD'
return contract
createContract(1259)
Goes through no problem.... any suggestions on being able to submit an order w/out knowing the exchange beforehand?
Thanks you!
Matt