Python 3 FIX No Response
Python 3 FIX No Response
02 Oct 2016, 22:38
I wrote just a short script in Python3.5 to test out the FIX capabilities, it is just a socket connect and logon message. The problem is I am not receiving any response from the FIX server. You can see where I am trying to receive and print a response on lines 8-9.
import socket s = socket.socket() try: s.connect(('212.83.157.16', 5201)) logon = b"8=FIX.4.4|9=113|35=A|49=ctrader.3139500|56=CSERVER|50=Quote|34=1|52=20161002-18:08:03.155|98=0|108=30|141=Y|553=3139500|554=pass|10=129|" s.send(logon) msg = s.recv(2048) print(msg.decode('ascii')) except: print("Connection failed.") finally: s.close() print("Script terminated.")
Is it because I am testing during market close? Or have I made a mistake in the FIX logon message? Thanks for any help.
Replies
darhk
03 Oct 2016, 06:06
import socket s = socket.socket() logon = "8=FIX.4.4|9=113|35=A|49=ctrader.3139500|56=CSERVER|50=Quote|34=1|52=20161003-03:02:03.155|98=0|108=30|141=Y|553=3139500|554=pass|10=129|".replace('|', chr(0x01)) try: s.connect(('212.83.157.16', 5201)) s.send(logon.encode(encoding='ascii')) msg = s.recv(1024) print("Message:", msg) except: print("Connection failed.") finally: s.close() print("Script terminated.")
I changed some things up and I am finally getting a response from the server, but the response is just empty bytes (b'').
@darhk
mindbreaker
04 Oct 2016, 20:47
RE:
darhk said:
Which sample are you referring to?
Ideally, I would like to avoid using a FIX engine (too much bloat) and C# as I am just want to collect market data on my Linux based server.
Hi
You can install .net core and try c# code on linux Server
https://www.microsoft.com/net/download
and try write in C# and run from command line
@mindbreaker
beneditobvn
26 Mar 2018, 21:41
Hey darhk, have you finished a Python script that works with this FIX API?
@beneditobvn
darhk
02 Oct 2016, 22:45
I forgot to mention I am testing using a cTrader demo account.
@darhk