Any request does not return any responses when connected to the fix api test server from the Fix API | Binance Open Platform documentation. The connection to the server is successful, but there is silence for any requests according to the documentation. I can’t even authenticate. I read the documentation carefully. I Created an API key Ed25519 on Spot Test Network and form an authentication request with all the tags from the example. Help me, please.
It sounds like you’re facing issues with connecting and making requests to Binance’s FIX API on their test server.
Check the below and then try the code provided, modify for your use:
Ensure that your API key is active and has permissions for the FIX API. Check the SenderCompID and TargetCompID in your messages.
Verify that your FIX messages are correctly formatted. This includes the start of message (8=FIX.4.4), body length (9=), message type (35=), and the checksum at the end (10=). Incorrect formatting can lead to messages being ignored.
Consider using a FIX protocol library if you aren’t already. Libraries like QuickFIX or similar can help manage the session and ensure that messages are correctly formatted and sent.
Implement detailed logging on your side to capture all messages sent and any responses or errors received. This can help identify if the issue is with the sending or receiving of messages.
I am sharing a basic example on how to setup a FIX using the QuickFIX library:
import quickfix as fix
class BinanceFIXApplication(fix.Application):
def onCreate(self, sessionID):
return
def onLogon(self, sessionID):
print("Successfully logged in to FIX session.")
def onLogout(self, sessionID):
print("Logged out from FIX session.")
def toAdmin(self, message, sessionID):
msgType = fix.MsgType()
message.getHeader().getField(msgType)
if msgType.getValue() == "A": # Logon message
message.setField(fix.Password("YourAPIKey"))
def fromAdmin(self, response, sessionID):
print("Received admin message:", response)
def fromApp(self, response, sessionID):
print("Received application message:", response)
def run_fix_client():
settings = fix.SessionSettings(“path_to_settings_file.cfg”)
application = BinanceFIXApplication()
storeFactory = fix.FileStoreFactory(settings)
logFactory = fix.FileLogFactory(settings)
initiator = fix.SocketInitiator(application, storeFactory, settings, logFactory)
initiator.start()
# Your trading logic here
initiator.stop()
if name == “main”:
run_fix_client()
I am assuming you have a configuration file set up for QuickFIX. Modify it according to your setup.
Based on the informtion provided, I can only help you in identifing the root cause of the issues with the Binance FIX API at this point.
I hope this is helpful. Best of luck!
I have checked everything many times. My request contains everything that is indicated in the documentation. For example, it is my created message:
API key was created on https://testnet.binance.vision/
Are you sure the data is sent to the server and not buffered somewhere?
Sure. I even tried sending requests through the “Mini-Fix” utility. Successfully connected to the server. And for any request, there is also silence.
This might be possible if you’re trying to send plain FIX, without TLS. Then it will appear like the server does not respond with anything, since it’s waiting for TLS handshake to start.
FIX API requires TLS connection.
If your client does not support TLS natively, you can use a proxy like stunnel
.
For example, use the following stunnel config:
[client]
client = yes
accept = 9000
connect = fix-oe.testnet.binance.vision:9000
verifyChain = yes
checkHost = fix-oe.testnet.binance.vision
# You can look up the OpenSSL home directory with
# openssl version -d
# and there should be a file "cert.pem" with OpenSSL's CA certificate bundle.
CAfile = <path/to/CA/bundle/cert.pem>
then connect to localhost:9000
instead of fix-oe.testnet.binance.vision:9000
.
Thank you very much for your help, everything worked.