¿ªÔÆÌåÓýMark ? As it happens, today I worked out a Python script for sending commands to IBC (see below): this was as part of an ongoing discussion relating to an issue in the IBC repository on Github. ? I¡¯m not a Python user, so it took me a while to get it to work: it¡¯s based on something I found in the Python Wiki (see ), which is a little out-of-date. ? This works fine as a free-standing script so it can be run from the? command line in either Windows or Linux, but it would be easy to incorporate it into a Python program. ? I¡¯ll probably add something like this to the IBC download, as it¡¯s better and more versatile than the current Stop.bat/Restart.bat files (apart from the need to install Python, but that is straightforward). ? Here¡¯s the script: ? #!/usr/bin/env py ? import socket import time ? ? TCP_IP = '10.252.0.7'??? # IP address or name of computer running TWS TCP_PORT = 7463????????? # CommandServerPort setting in config.ini: BUFFER_SIZE = 1024 ? MESSAGE = b"RESTART\n"? # Command to send to IBC ? s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) ? print("sending: ", MESSAGE) s.send(MESSAGE) ? data = s.recv(BUFFER_SIZE) print("received data:", data) ? time.sleep(1) ? print("closing socket") s.close() ? print("exiting script") ? ? ? From: [email protected] <[email protected]> On Behalf Of Mark Murari
Sent: 17 March 2023 19:11 To: [email protected] Subject: Re: [ibc] IBC Version 3.16.0 ? Working quite slowly through my upgrade todo list, I am luckily at the point where I am trying to enable the recent restart function in Linux (via python). This python code should work but and pointers as to where I can locate the correct command server address and port would be appreciated, or do I need to explicitly configure these myself? ? |