I want to request contract details and it worked the first time I run the code, but when I press run again, it won't return anything. It will work if I quit TWS and pycharm and try again I am new to python and don't understand how it works overall, pls help.
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.common import *
from ibapi.contract import *
from ContractSamples import ContractSamples
class TestApp(EClient, EWrapper):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId:TickerId, errorCode:int, errorString:str):
print("Error: ", reqId, "", errorCode, "", errorString)
def contractDetails(self, reqId:int, contractDetails:ContractDetails):
print("contractDetail: ", reqId, " ", contractDetails)
def main():
app = TestApp()
app.connect("127.0.0.1", 7496, 0)
contract = Contract()
contract.symbol = "AAPL"
contract.secType = "STK"
contract.exchange = "SMART"
contract.currency = "USD"
contract.primaryExchange = "NASDAQ"
app.reqContractDetails(10, contract)
app.run()
if __name__ == "__main__":
main()
No error msg, just no result: "Process finished with exit code 0".