Python 3 FIX No Response

Created at 02 Oct 2016, 22:38
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DA

darhk

Joined 26.04.2016

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.


@darhk
Replies

darhk
02 Oct 2016, 22:45

I forgot to mention I am testing using a cTrader demo account.


@darhk

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

tetra
03 Oct 2016, 20:07

Why don't you check the c# example?


@tetra

darhk
03 Oct 2016, 20:14

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.


@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

mindbreaker
04 Oct 2016, 21:19

RE: RE:

or better go to jforex API and java.


@mindbreaker

beneditobvn
26 Mar 2018, 21:41

Hey darhk, have you finished a Python script that works with this FIX API?


@beneditobvn