Sample application demonstrating how to connect and interact with BTC Markets' FIX engine using a Python application.
The following dependencies are required:
openssl
development headerspoetry
(recommended for package management)x86 processor
(ARM is currently not supported)
For Ubuntu users:
sudo apt get install python3-poetry libssl-dev
For other operating systems, please refer to their respective documentation for installing these dependencies.
poetry install
poetry shell
A template configuration file should be located at resources/template.cfg
- Set connection host:
SocketConnectHost=fix.btcmarkets.net
- Set SenderCompID:
SenderCompID=Public API key generated at BTC Markets website
- Set PrivateKey:
PrivateKey=Secret API key generated at BTC Markets website
Basic usage:
cd examples/threaded_workflow
Modify the config.cfg file to include the target API endpoints and credentials.
Execute:
python run.py
The run.py
file contains an illustration implementation following the flow:
- Application
Logon
to FIX server ->--------- Logon -FIX.4.4:PUBLIC_API_KEY->BTCM ---------
. Sleep 2 seconds - On successful logon, a
limit order
is created ->--------- Received execution report for limit order, Id: ID-[timestamp], Status: 0
. Sleep 2 seconds - On successful order creation, initiates
order status
request ->--------- Received execution report for order status: 0
. Sleep 2 seconds - On successful order status, initiates
order cancel
request ->--------- Received execution report for cancel order, Id: ID-[timestamp], Status: 4
. Sleep 2 seconds - Application waits for Heartbeat (configured in property file) ->
--------- Heartbeat --------- SenderCompID: [public_api_key], SendTime: [timestamp]
- After heartbeat received -> Processes incoming heartbeat message
- On the heartbeat, sends order with invalid parameters to simulate order reject ->
Received order reject. Order: SeqNumber: [7]. Reason: [Value is incorrect (out of range) for this tag, field=103]
- On the next heartbeat, sends cancel order with non-existing ID ->
--------- Received order reject. Order: SeqNumber: [10]. Reason: [Required tag missing, field=37] ---------
- On the upcoming heartbeat, shuts down initiator. Before logout is initiated ->
--------- Received message: [Logout] ---------
The application implements a FixClientSampleApplication
class that handles:
- FIX message processing
- Order creation and cancellation
- Order status requests
- Heartbeat monitoring
- Error handling
The sample demonstrates proper connection handling, order lifecycle management, and error scenarios when interacting with the BTC Markets FIX engine.