### CMakeLists.txt Configuration for Roq C++ Example 7 Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-7/CMakeLists.txt This snippet shows the CMake configuration for building the example 7 application. It includes setting the target name, adding subdirectories, defining source files, creating an executable, managing dependencies, linking libraries, setting compile definitions, and installing the target. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-7) add_subdirectory(flags) set(SOURCES application.cpp config.cpp strategy.cpp settings.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### CMake Executable and Library Configuration Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/metrics/CMakeLists.txt This CMakeLists.txt snippet defines the build process for a C++ executable. It sets the target name, includes subdirectories for flags, specifies source files, adds dependencies, links against various roq and third-party libraries, and configures compile definitions. Finally, it installs the target executable. ```cmake set(TARGET_NAME ${PROJECT_NAME}-metrics) add_subdirectory(flags) set(SOURCES application.cpp config.cpp settings.cpp strategy.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-utils::roq-utils roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### Install Roq Coinbase Pro Gateway Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/README.md Installs the 'roq-coinbase-pro' package from the roq-trading conda channel, providing the Coinbase Pro gateway. ```bash conda install -y --channel https://roq-trading.com/conda/unstable \ roq-coinbase-pro ``` -------------------------------- ### CMake Build Configuration for Roq C++ Example 9 Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-9/CMakeLists.txt This CMake script configures the build for a specific example within the Roq C++ samples project. It defines the target name, lists source files, adds dependencies, links necessary libraries, sets compile definitions, and specifies installation rules. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-9) add_subdirectory(flags) set(SOURCES application.cpp config.cpp settings.cpp strategy.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### Run Example 5 with a Single Gateway Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-5/README.md This command executes Example 5, specifying the trader's login name and the path to the market gateway's UNIX domain socket. It's used to initiate the multi-threaded communication demonstration. ```bash ./roq-samples-example-5 \ --name "trader" \ ~/deribit.sock ``` -------------------------------- ### Configure ROQ C++ Sample 3 Build with CMake Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-3/CMakeLists.txt This snippet demonstrates how to configure a C++ project using CMake. It defines the target executable, lists all source files, adds dependencies, links necessary libraries (including ROQ client, algo, logging, flags, and API, as well as fmt), and sets compile-time definitions for package name and version. Finally, it installs the built target. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-3) add_subdirectory(flags) set(SOURCES application.cpp config.cpp ema.cpp instrument.cpp model.cpp settings.cpp strategy.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-algo::roq-algo roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### Run Live Trading for Example 3 (Bash) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-3/README.md This command executes the Roq C++ samples example 3 for live trading. It specifies the trader name and the path to the Deribit socket. The `--enable_trading` flag can be added to actually place orders on the market. ```bash ./roq-samples-example-3 \ --name "trader" \ ~/deribit.sock ``` -------------------------------- ### Build C++ Executable with CMake Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-2/CMakeLists.txt This snippet defines a CMake executable target, specifying source files, dependencies, and linked libraries. It also sets compile definitions and configures installation. Dependencies include roq-client, roq-logging, roq-flags, roq-api, and fmt. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-2) add_subdirectory(flags) set(SOURCES application.cpp config.cpp instrument.cpp settings.cpp strategy.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### Run Live Trading with Event Logs (Bash) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-6/README.md Switches the Roq sample example 3 to live trading mode. It requires a trader name and paths to the Deribit and Bitmex socket files. ```bash ./roq-samples-example-3 \ --name "trader" \ ~/deribit.sock \ ~/bitmex.sock ``` -------------------------------- ### Install Roq Deribit Gateway Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/README.md Installs the 'roq-deribit' package from the roq-trading conda channel, which provides the Deribit gateway. ```bash conda install -y --channel https://roq-trading.com/conda/unstable \ roq-deribit ``` -------------------------------- ### Install roq-tools Package via Conda Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md Demonstrates the installation of the roq-tools package using Conda. This package may provide additional utilities or functionalities required by some examples or advanced usage scenarios. ```bash conda install -y --channel https://roq-trading.com/conda/stable \ roq-tools ``` -------------------------------- ### Log output from roq-samples-example-2 execution Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-2/README.md This log output details the startup sequence of the roq-samples-example-2 application. It includes information about service starting, session establishment, connection status to different exchanges (Deribit, Coinbase Pro), and instrument data reception. ```text I0413 16:04:55.321692 19803971 service.cpp:50] ===== START ===== I0413 16:04:55.322590 19803971 service.cpp:34] The metrics service will *not* be started I0413 16:04:55.332823 19803971 controller.cpp:74] session_id="a619015b-e720-48a7-9580-e25b49c80a15" I0413 16:04:55.332840 19803971 controller.cpp:78] Dispatching... I0413 16:04:55.332892 19803971 controller.cpp:82] Starting event loop thread... I0413 16:04:55.333617 19804165 controller.cpp:113] Event loop thread is now running I0413 16:04:56.333282 19804165 session_manager.cpp:50] Connecting "unix:///Users/thraneh/dev/roq-dev/roq-deribit/src/roq/deribit/deribit-test.sock" I0413 16:04:56.333534 19804165 session_manager.cpp:50] Connecting "unix:///Users/thraneh/dev/roq-dev/roq-coinbase-pro/src/roq/coinbase_pro/coinbase-pro-sandbox.sock" I0413 16:04:56.334276 19804165 session.cpp:32] Adding name="coinbase-pro" (user_id=1) I0413 16:04:56.334512 19804165 session.cpp:32] Adding name="deribit" (user_id=1) I0413 16:04:56.334487 19803971 pollster.cpp:305] Adding name="coinbase-pro" (user_id=1) I0413 16:04:56.336018 19803971 instrument.cpp:27] [coinbase-pro:BTC-USD] connected=true I0413 16:04:56.336049 19803971 pollster.cpp:305] Adding name="deribit" (user_id=1) I0413 16:04:56.336079 19803971 instrument.cpp:27] [deribit:BTC-PERPETUAL] connected=true I0413 16:04:56.336669 19803971 instrument.cpp:45] [deribit:BTC-PERPETUAL] download=true I0413 16:04:56.336873 19803971 instrument.cpp:73] [deribit:BTC-PERPETUAL] market_data=true I0413 16:04:56.340776 19803971 instrument.cpp:90] [deribit:BTC-PERPETUAL] tick_size=0.5 I0413 16:04:56.340813 19803971 instrument.cpp:93] [deribit:BTC-PERPETUAL] min_trade_vol=1 I0413 16:04:56.340823 19803971 instrument.cpp:96] [deribit:BTC-PERPETUAL] multiplier=10 I0413 16:04:56.340839 19803971 instrument.cpp:45] [coinbase-pro:BTC-USD] download=true I0413 16:04:56.340882 19803971 instrument.cpp:73] [coinbase-pro:BTC-USD] market_data=true I0413 16:04:56.341208 19803971 instrument.cpp:90] [coinbase-pro:BTC-USD] tick_size=0.010000000000000002 I0413 16:04:56.341281 19803971 instrument.cpp:93] [coinbase-pro:BTC-USD] min_trade_vol=0.0010000000000000002 I0413 16:04:56.341305 19803971 instrument.cpp:107] [coinbase-pro:BTC-USD] trading_status=OPEN I0413 16:04:56.342191 19803971 instrument.cpp:117] MarketByPriceUpdate={stream_id=4, exchange="coinbase-pro", symbol="BTC-USD", ... I0413 16:04:56.364501 19803971 instrument.cpp:53] [coinbase-pro:BTC-USD] download=false I0413 16:04:56.364548 19803971 instrument.cpp:107] [deribit:BTC-PERPETUAL] trading_status=OPEN I0413 16:04:56.365014 19803971 instrument.cpp:117] MarketByPriceUpdate={stream_id=4, exchange="deribit", symbol="BTC-PERPETUAL", ... I0413 16:04:56.386994 19803971 instrument.cpp:53] [deribit:BTC-PERPETUAL] download=false I0413 16:04:56.387006 19803971 instrument.cpp:193] [deribit:BTC-PERPETUAL] ready=true ``` -------------------------------- ### CMakeLists.txt Configuration for Flags Example Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-7/flags/CMakeLists.txt This snippet outlines the CMake build configuration for the Roq C++ example 7. It includes setting target names, including RoqAutogen, defining autogen schemas, generating C++ headers and sources, managing gitignore, creating a library, and linking necessary dependencies like absl::flags. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-7-flags) include(RoqAutogen) set(AUTOGEN_SCHEMAS flags.json) roq_autogen_hpp( OUTPUT AUTOGEN_HEADERS SOURCES ${AUTOGEN_SCHEMAS} TEMPLATE_DIR ${TEMPLATE_DIR} TEMPLATE_TYPE "flags") add_custom_target(${TARGET_NAME}-autogen-headers ALL DEPENDS ${AUTOGEN_HEADERS}) roq_autogen_cpp( OUTPUT AUTOGEN_SOURCES SOURCES ${AUTOGEN_SCHEMAS} TEMPLATE_DIR ${TEMPLATE_DIR} TEMPLATE_TYPE "flags") roq_gitignore(OUTPUT .gitignore SOURCES ${TARGET_NAME} ${AUTOGEN_HEADERS} ${AUTOGEN_SOURCES}) add_library(${TARGET_NAME} OBJECT ${AUTOGEN_SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-autogen-headers) target_link_libraries(${TARGET_NAME} absl::flags) ``` -------------------------------- ### Run roq-samples-example-1 with multiple socket connections Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-1/README.md This command executes the sample application, specifying a name for the trader and providing paths to the Unix domain sockets for Deribit and Coinbase Pro. It illustrates how to initiate connections to different trading platforms. ```bash ./roq-samples-example-1 \ --name "trader" \ ~/deribit.sock \ ~/coinbase-pro.sock ``` -------------------------------- ### Execute Single Gateway Example Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-1/README.md This bash command executes the roq-samples-example-1 program, acting as a single gateway. It specifies a trader name and the path to a Unix domain socket for communication. ```bash ./roq-samples-example-1 \ --name "trader" \ ~/deribit.sock ``` -------------------------------- ### Install Roq Data Package Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/README.md Installs the 'roq-data' package from the roq-trading conda channel. This package is required for simulation data. ```bash conda install -y --channel https://roq-trading.com/conda/unstable \ roq-data ``` -------------------------------- ### Log Output of Single Gateway Connection Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-1/README.md This is the log output from running the single gateway example. It details the startup process, connection to the Deribit socket, session management, and the status of market data streams. ```text I0413 16:01:02.530790 19792386 service.cpp:50] ===== START ===== I0413 16:01:02.531982 19792386 service.cpp:34] The metrics service will *not* be started I0413 16:01:02.552006 19792386 controller.cpp:74] session_id="6ca9cc67-61d0-4671-ab7e-db7284acb55e" I0413 16:01:02.552400 19792386 controller.cpp:78] Dispatching... I0413 16:01:02.553257 19792386 controller.cpp:82] Starting event loop thread... I0413 16:01:02.554198 19792429 controller.cpp:113] Event loop thread is now running I0413 16:01:03.553985 19792429 session_manager.cpp:50] Connecting "unix:///Users/thraneh/dev/roq-dev/roq-deribit/src/roq/deribit/deribit-test.sock" I0413 16:01:03.554458 19792429 session.cpp:32] Adding name="deribit" (user_id=1) I0413 16:01:03.554544 19792386 pollster.cpp:305] Adding name="deribit" (user_id=1) I0413 16:01:03.554608 19792386 strategy.cpp:17] [0:deribit] connected={} I0413 16:01:03.554865 19792386 strategy.cpp:49] [0:deribit] Settings={mbp_max_depth=0, mbp_allow_price_inversion=false, mbp_allow_fractional_tick_size=true} I0413 16:01:03.554876 19792386 strategy.cpp:33] [0:deribit] DownloadBegin={account=""} I0413 16:01:03.554892 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=1, account="A1", supports=0x3f0000, status=READY, type=FIX, priority=PRIMARY} I0413 16:01:03.554900 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=2, account="A1", supports=0x10400000, status=READY, type=WEB_SOCKET, priority=PRIMARY} I0413 16:01:03.554906 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=3, account="", supports=0x6, status=READY, type=WEB_SOCKET, priority=PRIMARY} I0413 16:01:03.554912 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=4, account="", supports=0x69, status=READY, type=FIX, priority=PRIMARY} I0413 16:01:03.554919 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=5, account="", supports=0x4, status=READY, type=WEB_SOCKET, priority=PRIMARY} I0413 16:01:03.554991 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=6, account="", supports=0x68, status=READY, type=FIX, priority=PRIMARY} I0413 16:01:03.554998 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=7, account="", supports=0x68, status=READY, type=FIX, priority=PRIMARY} I0413 16:01:03.555005 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=8, account="", supports=0x68, status=READY, type=FIX, priority=PRIMARY} I0413 16:01:03.555013 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=9, account="", supports=0x4, status=READY, type=WEB_SOCKET, priority=PRIMARY} I0413 16:01:03.555020 19792386 strategy.cpp:57] [0:deribit] StreamStatus={stream_id=10, account="", supports=0x4, status=READY, type=WEB_SOCKET, priority=PRIMARY} I0413 16:01:03.555087 19792386 strategy.cpp:83] [0:deribit] ReferenceData={stream_id=4, exchange="deribit", symbol="BTC-24SEP21", description="future", security_type=FUTURES, currency="USD", settlement_currency="USD", commission_currency="BTC", tick_size=0.5, multiplier=10, min_trade_vol=1, option_type=UNDEFINED, strike_currency="", strike_price=nan, underlying="", time_zone="", issue_date=18621[86400]s, settlement_date=0[86400]s, expiry_datetime=1632470400s, expiry_datetime_utc=1632470400s} I0413 16:01:03.555371 19792386 strategy.cpp:83] [0:deribit] ReferenceData={stream_id=4, exchange="deribit", symbol="BTC-31DEC21", description="future", security_type=FUTURES, currency="USD", settlement_currency="USD", commission_currency="BTC", tick_size=0.5, multiplier=10, min_trade_vol=1, option_type=UNDEFINED, strike_currency="", strike_price=nan, underlying="", time_zone="", issue_date=18669[86400]s, settlement_date=0[86400]s, expiry_datetime=1640937600s, expiry_datetime_utc=1640937600s} I0413 16:01:03.555486 19792386 strategy.cpp:83] [0:deribit] ReferenceData={stream_id=4, exchange="deribit", symbol="BTC-23APR21", description="future", security_type=FUTURES, currency="USD", settlement_currency="USD", commission_currency="BTC", tick_size=0.5, multiplier=10, min_trade_vol=1, option_type=UNDEFINED, strike_currency="", strike_price=nan, underlying="", time_zone="", issue_date=18719[86400]s, settlement_date=0[86400]s, expiry_datetime=1619164800s, expiry_datetime_utc=1619164800s} I0413 16:01:03.557827 19792386 strategy.cpp:83] [0:deribit] ReferenceData={stream_id=4, exchange="deribit", symbol="BTC-25JUN21", description="future", security_type=FUTURES, currency="USD", settlement_currency="USD", commission_currency="BTC", tick_size=0.5, multiplier=10, min_trade_vol=1, option_type=UNDEFINED, strike_currency="", strike_price=nan, underlying="", time_zone="", issue_date=18620[86400]s, settlement_date=0[86400]s, expiry_datetime=1624608000s, expiry_datetime_utc=1624608000s} I0413 16:01:03.558991 19792386 strategy.cpp:91] [0:deribit] MarketStatus={stream_id=5, exchange="deribit", symbol="BTC-25JUN21", trading_status=OPEN} ``` -------------------------------- ### Execute roq-samples-example-1 with verbose logging Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-1/README.md This command executes the roq-samples-example-1 with verbose logging enabled, specifying a trader name and a socket path for communication. It's crucial for debugging and understanding the flow of operations. ```bash ROQ_v=1 ./roq-samples-example-1 \ --name "trader" \ ~/deribit.sock ``` -------------------------------- ### CMakeLists.txt Configuration for C++ REST Application Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/rest/CMakeLists.txt This snippet configures a C++ executable using CMake. It sets the target name, adds subdirectories for flags, lists source files, defines the executable, sets up dependencies, links necessary libraries (including roq client, web, IO, logging, flags, API, fmt, and unordered_dense), specifies compile definitions, and installs the target. ```cmake set(TARGET_NAME ${PROJECT_NAME}-rest) add_subdirectory(flags) set(SOURCES application.cpp config.cpp controller.cpp session.cpp settings.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-web::roq-web roq-io::roq-io roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api unordered_dense::unordered_dense fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### Example of roq-dump Output: Detailed Event Entry (Gateway Settings) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md This console output shows a detailed entry for 'gateway_settings' from an event log processed by roq-dump. It includes message information and specific gateway settings. ```console controller.cpp:102] event={message_info={source=0, source_name="cme", source_session_id="00000000-0000-0000-0000-000000000000", source_seqno=1, receive_time_utc=1ns, receive_time=1ns, source_send_time=1ns, source_receive_time=1ns, origin_create_time=1ns, origin_create_time_utc=1ns, is_last=true, opaque=0}, gateway_settings={mbp_max_depth=3, mbp_allow_price_inversion=false}} ``` -------------------------------- ### Run Simulation with Event Logs (Bash) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-6/README.md Executes the Roq sample example 6 in simulation mode. It requires specifying a trader name and paths to the Deribit and Bitmex data files. ```bash ./roq-samples-example-6 \ --name "trader" \ --simulation=true \ $CONDA_PREFIX/share/roq/data/deribit.roq \ $CONDA_PREFIX/share/roq/data/bitmex.roq ``` -------------------------------- ### Example 5: Output Log Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-5/README.md This log output details the execution flow of Example 5, including thread startup, message dispatching, and the passing of 'CustomMessage' from a producer thread to the main controller. It also shows the graceful termination of the event loop and producer threads. ```text I0415 05:41:44.053465 258955 service.cpp:50] ===== START ===== I0415 05:41:44.055003 258955 service.cpp:34] The metrics service will *not* be started I0415 05:41:44.061089 258955 controller.cpp:74] session_id="69c87294-fc6f-4c5e-b284-bf429e1d066d" I0415 05:41:44.061113 258955 controller.cpp:78] Dispatching... I0415 05:41:44.061141 258955 controller.cpp:82] Starting event loop thread... I0415 05:41:44.061580 258957 producer.cpp:32] producer was started I0415 05:41:44.061568 258956 controller.cpp:113] Event loop thread is now running I0415 05:41:44.061781 258955 pollster.cpp:334] Register consumer I0415 05:41:44.061808 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.161879 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.261975 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.362072 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.462175 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.562272 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.662368 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.762466 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.862563 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} I0415 05:41:44.962661 258955 strategy.cpp:38] [0:internal-6751528361785890386] CustomMessage={length=12} ^CW0415 05:41:45.011017 258956 controller.cpp:123] Signal 2 (Interrupt) I0415 05:41:45.011028 258956 controller.cpp:119] Event loop thread has terminated I0415 05:41:45.062882 258957 producer.cpp:42] producer was terminated I0415 05:41:45.062943 258955 controller.cpp:88] Waiting for event loop thread to terminate... I0415 05:41:45.062958 258955 controller.cpp:91] Done! I0415 05:41:45.063070 258955 service.cpp:54] ===== STOP ===== ``` -------------------------------- ### Run ROQ Simulation Example Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md This bash command executes the ROQ C++ simulation example. It takes parameters like the exchange, symbol, and a simulation file path. This is used to test ROQ's functionality in a simulated trading environment. ```bash ROQ_v=1 ../example-3/roq-samples-example-3 \ --name trader \ --exchange CME \ --symbol GEZ1 \ --simulation \ cme/test.roq ``` -------------------------------- ### Filesystem Module Inclusion Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/CMakeLists.txt Includes the GNUInstallDirs CMake module, which provides standard directory variables for installation. This is useful for consistent installation paths. ```cmake # filesystem include(GNUInstallDirs) ``` -------------------------------- ### Install roq-api Package via Conda Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md Shows how to install the roq-api package using Conda from a specified channel. This is an alternative to cloning the repository and is useful for managing dependencies and ABI compatibility. ```bash conda install -y --channel https://roq-trading.com/conda/stable \ roq-api ``` -------------------------------- ### Example of roq-dump Output: Detailed Event Entry (Market Status) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md This console output provides an example of a 'market_status' event as seen in roq-dump. It includes message metadata and the trading status of a market. ```console controller.cpp:218] event={message_info={source=0, source_name="cme", source_session_id="00000000-0000-0000-0000-000000000000", source_seqno=3, receive_time_utc=3ns, receive_time=3ns, source_send_time=3ns, source_receive_time=3ns, origin_create_time=3ns, origin_create_time_utc=3ns, is_last=true, opaque=0}, market_status={exchange="CME", symbol="GEZ1", trading_status=OPEN}} ``` -------------------------------- ### Broadcast Everything via roq-samples-io-context (Bash) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/io-context/README.md This command broadcasts all market data using the roq-samples-io-context tool. It configures the trader name, WebSocket port, UDP port, and the Unix domain socket path for communication. ```bash ./roq-samples-io-context \ --name trader \ --ws_port 2345 \ --udp_port 1234 \ ~/run/deribit.sock ``` -------------------------------- ### Example of roq-dump Output: Detailed Event Entry (Market By Price) Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md This console output demonstrates a 'market_by_price_update' event analyzed by roq-dump. It shows message details along with bid and ask price/quantity information. ```console controller.cpp:269] event={message_info={source=0, source_name="cme", source_session_id="00000000-0000-0000-0000-000000000000", source_seqno=4, receive_time_utc=4ns, receive_time=4ns, source_send_time=4ns, source_receive_time=4ns, origin_create_time=4ns, origin_create_time_utc=4ns, is_last=true, opaque=0}, market_by_price_update={exchange="CME", symbol="GEZ1", bids=[{price=99.785, quantity=3}, {price=99.78, quantity=2}, {price=99.775, quantity=1}], asks=[{price=99.8, quantity=3}, {price=99.805, quantity=2}, {price=99.81, quantity=1}], snapshot=true, exchange_time_utc=0ns}} ``` -------------------------------- ### CMakeLists.txt Configuration for RoqAutogen Flags Example Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-3/flags/CMakeLists.txt This snippet demonstrates the CMake configuration for generating C++ headers and sources using RoqAutogen based on a 'flags.json' schema. It sets up build targets, dependencies, and links necessary libraries. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-3-flags) include(RoqAutogen) set(AUTOGEN_SCHEMAS flags.json) roq_autogen_hpp( OUTPUT AUTOGEN_HEADERS SOURCES ${AUTOGEN_SCHEMAS} TEMPLATE_DIR ${TEMPLATE_DIR} TEMPLATE_TYPE "flags") add_custom_target(${TARGET_NAME}-autogen-headers ALL DEPENDS ${AUTOGEN_HEADERS}) roq_autogen_cpp( OUTPUT AUTOGEN_SOURCES SOURCES ${AUTOGEN_SCHEMAS} TEMPLATE_DIR ${TEMPLATE_DIR} TEMPLATE_TYPE "flags") roq_gitignore(OUTPUT .gitignore SOURCES ${TARGET_NAME} ${AUTOGEN_HEADERS} ${AUTOGEN_SOURCES}) add_library(${TARGET_NAME} OBJECT ${AUTOGEN_SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-autogen-headers) target_link_libraries(${TARGET_NAME} absl::flags) ``` -------------------------------- ### CMakeLists.txt Configuration for Example 1 Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/example-1/CMakeLists.txt This snippet defines a CMake executable target, specifies its source files, adds dependencies including autogenerated headers, and links various libraries required for the RoQ client and logging functionalities. It also sets compile definitions for package name and build version. ```cmake set(TARGET_NAME ${PROJECT_NAME}-example-1) add_subdirectory(flags) set(SOURCES application.cpp config.cpp settings.cpp strategy.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${TARGET_NAME}-flags-autogen-headers) target_link_libraries( ${TARGET_NAME} PRIVATE ${TARGET_NAME}-flags roq-client::roq-client roq-client::roq-client-flags roq-logging::roq-logging roq-logging::roq-logging-flags roq-flags::roq-flags roq-api::roq-api fmt::fmt) target_compile_definitions(${TARGET_NAME} PRIVATE ROQ_PACKAGE_NAME="${TARGET_NAME}" ROQ_BUILD_VERSION="${CMAKE_PROJECT_VERSION}") install(TARGETS ${TARGET_NAME}) ``` -------------------------------- ### CMake Minimum Version and Project Setup Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/CMakeLists.txt Sets the minimum required CMake version and defines the project name and version. This is a standard practice for CMake projects to ensure compatibility. ```cmake cmake_minimum_required(VERSION 4.0) # project project(roq-cpp-samples VERSION "0.0.1") ``` -------------------------------- ### Example of roq-dump Output: Event Log Summary Source: https://github.com/roq-trading/roq-cpp-samples/blob/master/src/roq/samples/import/README.md This is an example of the console output when generating a summary of an event log using roq-dump. It breaks down event types by count, size, and average size. ```console +--------------------------+------------------+------------------+------------+ | type | count | bytes | avg. size | +--------------------------+------------------+------------------+------------+ | subscribe | 0 | 0 | nan | | download_begin | 0 | 0 | nan | | download_end | 0 | 0 | nan | | gateway_settings | 1 | 0 | 0.0 | | external_latency | 0 | 0 | nan | | market_data_status | 0 | 0 | nan | | order_manager_status | 0 | 0 | nan | | reference_data | 1 | 128 | 128.0 | | market_status | 1 | 304 | 304.0 | | top_of_book | 0 | 0 | nan | | market_by_price_update | 2 | 520 | 260.0 | | market_by_order_update | 0 | 0 | nan | | trade_summary | 0 | 0 | nan | | statistics_update | 0 | 0 | nan | | create_order | 0 | 0 | nan | | modify_order | 0 | 0 | nan | | cancel_order | 0 | 0 | nan | | order_ack | 0 | 0 | nan | | order_update | 0 | 0 | nan | | trade_update | 0 | 0 | nan | | position_update | 0 | 0 | nan | | funds_update | 0 | 0 | nan | | custom_message | 0 | 0 | nan | +--------------------------+------------------+------------------+------------+ | total | 5 | 952 | 190.4 | +--------------------------+------------------+------------------+------------+ controller.cpp:741] period 1ns to 5ns controller.cpp:742] duration 0d 0h 0m 0s ```