I'm trying to open order ninja trader platform with automated trading interface For that, I have enabled the ati service from options setting in Ninja Trader and trying to send a command to the suggested port through python like below:
import socket
def send_ati_command(command):
try:
# Connect to NinjaTrader ATI port
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect(('localhost', 36973))
s.sendall(command.encode())
data = s.recv(1024)
print('Received', repr(data.decode()))
except Exception as e:
print("An error occurred:", e)
# Example command
command = "PLACE;Account=Sim101;Instrument=NQ 03-24;Action=BUY;Qty=1;OrderType=MARKET;TIF=DAY"
send_ati_command(command)
getting response from the server as:
Received '2\x00'
Can someone please identify what I am doing wrong here, Also, there is no log being created while sending the command.