This project provides plugins for Zorro to connect to brokers and simulators via the FIX (version 4.4) API. Currently supported are:
- FXCM FIX Plugin: connecting to FXCM via FXCM FIX API and pulling historical market data with FXCM ForexConnect SDK
- FIX Simulator Plugin: connecting to a market data simulator and matching engine via FIX
The project depends on the QuickFix open source library. Performance-wise it is not as fast as commercial FIX implementations but provides a straightforward API and application framework to develop FIX based server and client applications. Some of the core building blocks and fix_simulation_server are inspired from their examples.
Contributions, bug reports and constructive feedback are very welcome.
- v2.2.0 Adding FXCM FIX conformance tests and fixing various small issues, separating FXCM FIX client into separate library, updated README.md
- v2.1.0 FXCM ForexConnect is accessed through a proxy server, smaller bug fixes, order status messages, 64 bit version
- v2.0.0 First FXCM FIX plugin, separated and updated Simulation FIX plugin
- v1.0.1 Improving order cancellation and many smaller bug fixing
- v1.0.0 First official release
The project uses most modern C++ 20 and depends on the following third party components:
- QuickFix with prebuilt static libraries included for x86 and x64
- FXCM ForexConnect SDK which requires separate installation
The environment variable ZorroInstallDir
has to point to the Zorro installation.
echo %ZorroInstallDir%
C:\zorro\Zorro_2620
The FXCM FIX plugin and the FXCM market data server needs a few enviornment environment variables.
FIX_USER_NAME
: user name for FIX accountFIX_PASSWORD
: password for FIX accountFIX_TARGET_SUBID
: FIX target sub id provided by FXCMFIX_ACCOUNT_ID
; FIX account idFXCM_USER_NAME
: user name (may be same asFIX_USER_NAME
)FXCM_PASSWORD
:password (may be same asFIX_PASSWORD
)FXCM_MAKRET_DATA_SERVER_LOG_PATH
: log path tick data and incremental bar updates can be configured by specifying the environment variable
The installation of FXCM ForexConnect SDK sets the following environment variables:
echo %FOREXCONNECT_PATH_X64%
C:\Program Files\Candleworks\ForexConnectAPIx64
respectively
echo %FOREXCONNECT_PATH_X86%
C:\Program Files (x86)\Candleworks\ForexConnectAPI
Assure that they point to the installed version of the ForexConnect SDK.
In order to use the C++ test script from Zorro, add the path to the Visual Studio build directory to the Zorro.ini
file:
VCPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build"
The directory zorro_scripts
containes various Zorro trading scripts for testing:
Test_FIX.c
quoting with limit ordersTest_Requote_FIX.c
quoting with limit orders and canceling and requote if market movesTest_Requote_TMF_FIX.c
requoting and use a Zorro trade management functionTest_FIX+.cpp
DLL version of quoting with limit orders which can be run with Zorro64.exeTest_FIX_Mkt.c
buy and sell with market ordersTest_Trade_GUI.c
executing orders with a Zorro Panel - requires Zorro S license
The FXCM FIX client plugin implements the FXCM FIX 4.4. protocol, inlcuding their specific extensions as documented in the FXCM FIX specification. The FXCM ForexConnect SDK is used to fetch historical market data from FXCM.
Zorro already comes with a plugin for FXCM which uses the
FXCM ForexConnect SDK under the hood. The advantage of the FIX protocol
is that it offers much better rate limits as can be seen from the
FXCM API comparison.
The following additional features are on the road map:
- Other order types beside market and limit orders, e.g. adding IOC, FOK limit orders, stop loss and take profit.
- Integrate Ability to pull FXCM historical tick data in
BrokerHistory2
The FXCM FIX client plugin implements all of Zorro's broker plugin functions.
- Historical market data through FXCM ForexConnect SDK
- Subscribe to real time market data either as snapshot and updates or snapshot and incremental update; note that FXCM only provides top of book and generally no volume
- NewOrderSingle supporting market and limit orders
- Order cancellation and order modification
- Trading session status (message TradingSessionStatus)
- Position reports (message PositionReport)
- Collateral inquiry (message CollateralReport)
- Execution reports (message ExecReport)
More details can be found in FXCM FIX client and its implementation.
The FXCM FIX plugin can be configured with
- TOML file zorro_fxcm_fix_plugin_config.toml
- FIX session config template file zorro_fxcm_fix_client_template.cfg
- Macro FIX_MSG_TRACE_LOG in fix_client.cpp to enable or disable FIX message trace log, useful in conformance tests to collect messages
Note that the post build step takes the FIX session config template file replaces the credentials from the environment variables
and copies the so configured file to the plugin directory under ZorroInstallDir
.
From version 2.1.0 the FXCM ForexConnect API is not directly integrated anymore with the Zorro FIX plugin but is running as a
standalone proxy server fxcm_market_data_server
, exposing various rest endpoints. It can be directly started from Visual Studio
and extends the system path with the respective path to the FXCM ForexConnect dlls:
Project Properties fxcm_market_data_server -> Configuration Properties -> Debugging -> Environment
Path=$(Path);$(FOREXCONNECT_PATH_X64)\bin
for platform x64, respectively for x86 or Win32
Path=$(Path);$(FOREXCONNECT_PATH_X86)\bin
Start fxcm_market_data_server
with the proper path setting
C:\repos\zorro-fix\x64\Debug>fxcm_market_data_server.exe
[2024-06-19 20:23:51.874] [combined] [debug] Logging started, logger_name=combined, level=1, cwd=C:\repos\zorro-fix\x64\Debug
[2024-06-19 20:23:51.899] [combined] [info] session status connecting
[2024-06-19 20:24:00.263] [combined] [info] session status connected
[2024-06-19 20:24:00.264] [combined] [info] connected - server ready to accept service requests
[2024-06-19 20:24:00.266] [combined] [info] server stated on 0.0.0.0:8080
The following REST endpoints are available:
/status
http://localhost:8083/status/instr
http://localhost:8083/instr?symbol=EUR/USD/subscribe
http://localhost:8083/subscribe?symbol=EUR/USD/bars
http://localhost:8083/bars?symbol=EUR/USD&from=2024-06-18%2000:00:00&timeframe=m1/ticks
http://localhost:8083/ticks?symbol=EUR/USD&from=2024-06-27%2000:00:00/ticks_to_csv
http://localhost:8083/ticks_to_csv?symbol=EUR/USD&from=2024-06-27%2000:00:00&to==2024-06-27%2006:00:00
The /subscribe
endpoint can be used to subscribe to tick based realtime updates for a symbol. Under the hood it uses the LiveBarStreamer
,
which is updated with every incoming tick and generates a bar once the bar period is completed.
The proxy server logs to the screen as well as to the log file fxcm_proxy_server.log
.
The FXCM FIX client plugin is built against ForexConnect SDK 1.6.5, which can be downloaded from these links:
Note that the link libraries and headers are in the GitHub repository to facilitate the build process and can be found in the FXCM third party directory. For another version of ForexConnect SDK the libraries and include files have to be changed accordingly.
The FXCM FIX client plugin requires the FXCM ForexConnect SDK in the search path. Add the FXCM ForexConnect SDK
C:\Program Files (x86)\Candleworks\ForexConnectAPI\bin
directory to the system path.
The project requires the following environment variables to be defined:
ZorroInstallDir
: directory where Zorro is installedFIX_ACCOUNT_ID
: account id provided by FXCMFIX_USER_NAME
: user name provided by FXCMFIX_PASSWORD
: password provided by FXCMFIX_TARGET_SUBID
: target subid provided by FXCM
These environment variables are used in various automation scripts in the scripts folders as well as in Visual Studio post build events.
Eventually it is necessary to update the FIX session config template. Note that this file is configured appropriately from the values of the environment variables and copied to the Zorro installation directory as part of the post build process.
- FIX specification
- FXCM data dictionary
- FIX conformance test
- FXCM FIX API examples
- FXCM ForexConnect API
- FXCM ForexConnect SDK
- ForexConnect online documentation
- ForexConnect online documentation
- FXCM market data
The goal of the FIX Simulator plugin is to provide a market data simulator and connect to it via FIX. Currently it covers the following FIX functionalities:
- Subscribe to (simulated) market data
- MarketDataRequest (out)
- MarketDataSnapshotFullRefresh (in)
- MarketDataIncrementalRefresh (in)
- Order execution
- NewOrderSingle (out)
- OrderCancelRequest (out)
- OrderCancelReplaceRequest (out)
- ExecReport (in)
The Simulation FIX client plugin and the FIX simulation server are work in progress. For instance it does not support
accounts which is required to implement BrokerAccount
. The market simulators only handle top of book. Eventually we
want a fully simulated book, e.g. based in the Fodra-Pham
model or any other suitable order book simulation model.
The fix_sumulation_server
implements FIX 4.4 protocol for order execution against a model driven market.
It also provides a REST server to get historical market data, simulated from the model.
Before starting Zorro
the simulation server must be started:
fix_simulation_server.exe session.cfg market_config.toml
The FIX session configuration session.cfg
must be the first argument. The second argument is the
market configuration market_config.toml
. These files are copied to the build directories
with a post build event.
In order to parse a FIX message string there are several online parsers such as
QuickFix can be built from source directly with Visual Studio 2022.
The debug and release QuickFix libraries should be copied into third-parties\quickfix\x86-Debug
respectively
third-parties\quickfix\x86-Release
.
Check also the project configurations where the QuickFix libraries are expecrted to be found.
First make sure that the environment variable ZorroInstallDir
is set and points to the Zorro
install location.
To make the development process more efficiently, the post build steps are added to the projects. Check the project properties for details.
There is a build issue with spdlog on Windows reported on GitHub. It is addressed by adding
#define _SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS
to the pch.h
files where needed.