Connectivity

The BTCS FIX gateway allows clients to receive market data and manage orders using FIX 4.4 messages.

Endpoints

EnvironmentType of FlowCompIDHostname / IPPort, TLS 1.3Port, Unencrypted
SandboxOrdersBTCSOMTxxxx98229823
SandboxMarket DataBTCSMDTxxxx98249825
ProductionOrdersBTCSOMPxxxx98229823
ProductionMarket DataBTCSMDPxxxx98249825

Note: actual hostname/ip for each endpoint is shared with the client upon successful onboarding.

Configuration

QuickFix

A sample QuickFix client configuration is provided below. The example is for Orders on Test, unencrypted.

Copy
Copied
[DEFAULT]
ConnectionType=initiator
ReconnectInterval=2
FileStorePath=store
FileLogPath=log
StartTime=00:00:00
EndTime=00:00:00
UseLocalTime=N
UseDataDictionary=Y
DataDictionary=./BTCS.FIX44.xml
LogoutTimeout=5
ResetOnLogon=Y
SocketConnectHost=<hostname / ip of BTCS server>
SocketConnectPort=9823
SocketNodelay=Y
SSLEnable=N

[SESSION]
BeginString=FIX.4.4
TargetCompID=BTCSOMT
SenderCompID=<username>
HeartBtInt=30

The client is assigned an application name (username) and an API key (password). The username is also used as the client's SenderCompID. The username and password must be supplied with the first Logon message.

BTCS can provide clients with a reference QuickFix dictionary file.

Stunnel

Clients can achieve TLSv1.3 encryption using stunnel with this configuration.

Copy
Copied
[Orders]
client = yes
accept = 8822
connect = <hostname / ip of BTCS server>:9822
cert = client-keycert.pem
sslVersionMin = TLSv1.3
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
verifyPeer = yes
CAfile = server-cert.pem

[MarketData]
client = yes
accept = 8824
connect = <hostname / ip of BTCS server>:9824
cert = client-keycert.pem
sslVersionMin = TLSv1.3
socket = l:TCP_NODELAY=1
socket = r:TCP_NODELAY=1
verifyPeer = yes
CAfile = server-cert.pem

There is a set of instructions on how to generate the client key and certificate using openssl. The QuickFix client configuration must then have these two values changed, for Orders encrypted, assuming stunnel is running on client's localhost:

Copy
Copied
SocketConnectHost=127.0.0.1
SocketConnectPort=9822

Initial State / Application Recovery

At startup or in the event of a communication failure, the client can recover state on the application level by retrieving a list of account balances and all orders. Currently account balances must be retrieved via a separate REST gateway. Orders can be retrieved using the OrderMassStatusRequest message.Do not rely on FIX message resend functionality to build state. As such the ResetSeqNumFlag field in the Logon request must be set to Yes.