## Connectivity The BTCS FIX gateway allows clients to receive market data and manage orders using FIX 4.4 messages. ### Endpoints | Environment | Type of Flow | CompID | Hostname / IP | Port, TLS 1.3 | Port, Unencrypted | | --- | --- | --- | --- | --- | --- | | Sandbox | Orders | BTCSOMT | xxxx | 9822 | 9823 | | Sandbox | Market Data | BTCSMDT | xxxx | 9824 | 9825 | | Production | Orders | BTCSOMP | xxxx | 9822 | 9823 | | Production | Market Data | BTCSMDP | xxxx | 9824 | 9825 | **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. ```cli [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= SocketConnectPort=9823 SocketNodelay=Y SSLEnable=N [SESSION] BeginString=FIX.4.4 TargetCompID=BTCSOMT SenderCompID=\ 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. ```cli [Orders] client = yes accept = 8822 connect = :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 = :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](/api/pages/fix/stunnel) 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: ```cli 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`.