### Install roq-client using Conda Source: https://github.com/roq-trading/roq-api/blob/master/README.md This command installs the 'roq-client' package using the conda package manager. It specifies the channel 'https://roq-trading.com/conda/stable' for downloading the package and uses '--channel' to add the channel. '-y' automatically confirms any prompts. ```bash conda install -y --channel https://roq-trading.com/conda/stable \ roq-client ``` -------------------------------- ### CMake: Install API Headers Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Installs the autogenerated headers and the configured API header file to the specified destination directory. ```cmake install(FILES ${AUTOGEN_HEADERS} ${API_HPP} DESTINATION ${TARGET_DIR}) ``` -------------------------------- ### Installation Rules for Headers and Documentation Source: https://github.com/roq-trading/roq-api/blob/master/CMakeLists.txt Configures the installation of public header files and the CHANGELOG.md. It specifies the destination directories and uses pattern matching to include only relevant header files, excluding intermediate build files. ```cmake # install (public headers) install( DIRECTORY ${CMAKE_SOURCE_DIR}/include/roq/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/roq FILES_MATCHING PATTERN "*.h*" PATTERN "CMakeFiles" EXCLUDE) # doxygen option(BUILD_DOCS "Enable doxygen" OFF) if(BUILD_DOCS) find_package(Doxygen) add_subdirectory(${CMAKE_SOURCE_DIR}/doxygen) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-doxygen) add_dependencies(${PROJECT_NAME}-doxygen ${PROJECT_NAME}-include-cpp) endif() # install (cmake) install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}-config) install(FILES ${CMAKE_SOURCE_DIR}/CHANGELOG.md DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME}) ``` -------------------------------- ### Basic CMake Setup and Project Definition Source: https://github.com/roq-trading/roq-api/blob/master/CMakeLists.txt Initializes CMake version, sets module paths, and defines the project name and version using Git tags. It enables the C++ language and includes necessary CMake modules for configuration and versioning. ```cmake cmake_minimum_required(VERSION 4.0) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) # config include(RoqConfig) # version (using git tag) include(GetGitRepoVersion) message("Using GIT_REPO_VERSION=${GIT_REPO_VERSION}") # project project(roq-api VERSION ${GIT_REPO_VERSION}) ``` -------------------------------- ### CMake: Specify Installation Directory for Schema Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Defines the installation directory for the schema-related files, ensuring they are placed correctly within the system's include paths. ```cmake set(TARGET_DIR ${CMAKE_INSTALL_INCLUDEDIR}/roq) ``` -------------------------------- ### Query Gateway Metrics via Curl Source: https://github.com/roq-trading/roq-api/wiki/Monitoring This example demonstrates how to query gateway metrics directly using the curl command. It assumes metrics are exposed via HTTP on the default port. ```shell curl http://localhost:12345/metrics ``` -------------------------------- ### Exporting CMake Configuration Source: https://github.com/roq-trading/roq-api/blob/master/CMakeLists.txt Defines and installs CMake configuration files for the project, enabling other projects to find and link against roq-api. This includes creating a config file with a specific namespace. ```cmake set(CMAKE_LIB_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) export( TARGETS ${PROJECT_NAME} NAMESPACE ${PROJECT_NAME}:: FILE ${CMAKE_LIB_DIR}/${PROJECT_NAME}-config.cmake) install( EXPORT ${PROJECT_NAME}-config NAMESPACE ${PROJECT_NAME}:: DESTINATION ${CMAKE_LIB_DIR}) ``` -------------------------------- ### Initialize Git Submodules Source: https://github.com/roq-trading/roq-api/blob/master/README.md This command initializes and updates all Git submodules recursively, ensuring that all necessary external dependencies are downloaded and integrated into the project. ```bash git submodule update --init --recursive ``` -------------------------------- ### Build Project with CMake and Make Source: https://github.com/roq-trading/roq-api/blob/master/README.md This command sequence builds the project using CMake for configuration and Make for compilation. It first runs CMake to generate build files based on the current directory ('.') and then uses 'make -j4' to compile the project in parallel using 4 threads for faster build times. It may be necessary to delete CMakeCache.txt if CMake caches an incorrect configuration. ```bash cmake . && make -j4 ``` -------------------------------- ### CMake Build Configuration for roq-api Executable Source: https://github.com/roq-trading/roq-api/blob/master/test/CMakeLists.txt Configures the build process for the roq-api test executable. It defines the target name, source files, executable creation, dependencies, and library linking. It also includes conditional linker flags for release builds and sets up the test command. ```cmake set(TARGET_NAME ${PROJECT_NAME}-test) set(SOURCES alignment.cpp compat.cpp exceptions.cpp format.cpp mask.cpp side.cpp span.cpp string.cpp support_type.cpp main.cpp) add_executable(${TARGET_NAME} ${SOURCES}) add_dependencies(${TARGET_NAME} ${PROJECT_NAME}-include-cpp) target_link_libraries(${TARGET_NAME} PRIVATE fmt::fmt magic_enum::magic_enum nameof::nameof Catch2::Catch2) if(ROQ_BUILD_TYPE STREQUAL "Release") set_target_properties(${TARGET_NAME} PROPERTIES LINK_FLAGS_RELEASE -s) endif() add_test(NAME ${TARGET_NAME} COMMAND ${TARGET_NAME}) ``` -------------------------------- ### Create Conda Development Environment Source: https://github.com/roq-trading/roq-api/blob/master/README.md This command creates a new conda development environment. It takes two arguments: the environment name (e.g., 'unstable') and a build type (e.g., 'debug'). This is used to set up the necessary packages and configurations for development. ```bash scripts/create_conda_env unstable debug ``` -------------------------------- ### Configure Doxygen Build (CMake) Source: https://github.com/roq-trading/roq-api/blob/master/doxygen/CMakeLists.txt This CMake script configures the build process for Doxygen documentation. It defines targets, processes the Doxyfile template, and executes Doxygen to generate HTML and XML outputs. ```cmake set(TARGET_NAME ${PROJECT_NAME}-doxygen) set(TARGET_DIR ${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME}) # doxyfile set(DOXYFILE ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${DOXYFILE} @ONLY) # target set(INDEX_HTML ${CMAKE_CURRENT_BINARY_DIR}/html/index.html) add_custom_command( OUTPUT ${INDEX_HTML} COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} VERBATIM DEPENDS ${DOXYGEN_EXECUTABLE} ${DOXYFILE}) add_custom_target(${TARGET_NAME} ALL DEPENDS ${INDEX_HTML}) # install install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/xml/ DESTINATION ${TARGET_DIR}/xml FILES_MATCHING PATTERN "*.xml") install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/ DESTINATION ${TARGET_DIR}/html FILES_MATCHING PATTERN "*.html") ``` -------------------------------- ### Sub-project and Library Definition Source: https://github.com/roq-trading/roq-api/blob/master/CMakeLists.txt Adds sub-projects for schema and include directories, enabling the build of associated targets. It also defines an INTERFACE library for the main project and sets up dependencies. ```cmake # includes include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_INCLUDEDIR}) # sub-projects add_subdirectory(${CMAKE_SOURCE_DIR}/schema/roq) add_subdirectory(${CMAKE_SOURCE_DIR}/include/roq) if(BUILD_TESTING) add_subdirectory(${CMAKE_SOURCE_DIR}/test) endif() # project add_library(${PROJECT_NAME} INTERFACE) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}-include-cpp) ``` -------------------------------- ### Dependency Discovery and Inclusion Source: https://github.com/roq-trading/roq-api/blob/master/CMakeLists.txt Locates and includes required external libraries such as fmt, magic_enum, nameof, and Catch2 for testing. It also finds custom build tools like roq-autogen and clang-format. ```cmake # filesystem include(GNUInstallDirs) # dependencies find_package(fmt REQUIRED) find_package(magic_enum REQUIRED) find_package(nameof REQUIRED) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) endif() if(BUILD_TESTING) find_package(Catch2 REQUIRED) endif() # autogen find_program(ROQ_AUTOGEN roq-autogen REQUIRED) set(TEMPLATE_DIR ${CMAKE_SOURCE_DIR}/scripts/templates) set(SCHEMA_LINK_DIR ${CMAKE_SOURCE_DIR}/schema) # clang-format find_program(CLANG_FORMAT clang-format REQUIRED) ``` -------------------------------- ### CMake: Configure API Header File Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Configures the main API header file (api.hpp) using a template and specifies the output path. ```cmake set(API_HPP ${CMAKE_BINARY_DIR}/${TARGET_DIR}/api.hpp) configure_file("api.hpp.in" ${API_HPP} @ONLY) ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/roq-trading/roq-api/blob/master/README.md This command activates a previously created conda development environment. After activation, the environment's packages and executables become available in the current shell session. ```bash source opt/conda/bin/activate dev ``` -------------------------------- ### Set Target Name and Schema Files in CMake Source: https://github.com/roq-trading/roq-api/blob/master/schema/roq/CMakeLists.txt This snippet demonstrates how to set a target name using a variable and define a list of schema files using the set command in CMake. It's a common pattern for managing build targets and source files. ```cmake set(TARGET_NAME ${PROJECT_NAME}-schema-roq) # XXX FIXME share with other subdirectories set(SCHEMA_ROQ action.json add_routes.json batch_begin.json batch_end.json buffer_capacity.json cancel_all_orders_ack.json cancel_all_orders.json cancel_order.json cancel_quotes_ack.json category.json connected.json connection_status.json control.json control_ack.json create_order.json custom_matrix.json custom_matrix_update.json custom_metrics.json custom_metrics_update.json data_source.json disconnected.json download_begin.json download_end.json encoding.json error.json execution_instruction.json external_latency.json fill.json filter.json funds_update.json gateway_settings.json gateway_status.json interval.json layer.json leg.json legs_update.json liquidity.json margin_mode.json market_by_order_update.json market_by_price_update.json market_status.json mass_quote_ack.json mbo_update.json mbp_update.json measurement.json message_info.json modify_order.json option_type.json order_ack.json order_cancel_policy.json order_management.json order_status.json order_type.json order_update.json origin.json parameter.json parameters_update.json portfolio.json portfolio_update.json position_effect.json position.json position_update.json precision.json priority.json protocol.json quality_of_service.json quantity_type.json rate_limit.json rate_limits_update.json rate_limit_trigger.json rate_limit_type.json ready.json reference_data.json remove_routes.json request_id_type.json request_status.json request_type.json risk_limit.json risk_limits.json risk_limits_update.json route_ack.json route.json route_request_status.json routing.json security_type.json service_update.json side.json start.json state.json statistics.json statistics_type.json statistics_update.json stop.json stream_status.json support_type.json tick_size_step.json time_in_force.json timer.json time_series_update.json top_of_book.json trade.json trade_summary.json trade_update.json trading_status.json transport.json update_action.json update_reason.json update_type.json variant_type.json) ``` -------------------------------- ### CMake: Define Target and Include RoqAutogen Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Sets the target name for the API build and includes the RoqAutogen module. This is a foundational step in the CMake build process for the Roq API. ```cmake set(TARGET_NAME ${PROJECT_NAME}-include-cpp) include(RoqAutogen) ``` -------------------------------- ### CMake: List Schema Files for Autogen Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Lists all the JSON schema files that will be used for autogenerating API headers. This array is later passed to the autogen function. ```cmake set(SCHEMA_ROQ action.json add_market.json add_routes.json bar.json batch_begin.json batch_end.json buffer_capacity.json cancel_all_orders_ack.json cancel_all_orders.json cancel_order.json cancel_quotes_ack.json cancel_quotes.json category.json connected.json connection_status.json control_ack.json control.json create_order.json custom_matrix.json custom_matrix_update.json custom_metrics.json custom_metrics_update.json data_source.json disconnected.json download_begin.json download_end.json encoding.json error.json execution_instruction.json external_latency.json fill.json filter.json funds_update.json gateway_settings.json gateway_status.json interval.json layer.json leg.json legs_update.json liquidity.json margin_mode.json market_by_order_update.json market_by_price_update.json market_status.json mass_quote_ack.json mass_quote.json mbo_update.json mbp_update.json measurement.json message_info.json modify_order.json option_type.json order_ack.json order_cancel_policy.json order_management.json order_status.json order_type.json order_update.json origin.json parameter.json parameters_update.json portfolio.json portfolio_update.json position_effect.json position.json position_update.json precision.json priority.json protocol.json quality_of_service.json quantity_type.json quote.json rate_limit.json rate_limits_update.json rate_limit_trigger.json rate_limit_type.json ready.json reference_data.json remove_routes.json request_id_type.json request_status.json request_type.json risk_limit.json risk_limits.json risk_limits_update.json route_ack.json route.json route_request_status.json routing.json security_type.json service_update.json side.json start.json state.json statistics.json statistics_type.json statistics_update.json stop.json strategy_update.json stream_status.json support_type.json tick_size_step.json time_in_force.json timer.json time_series_update.json top_of_book.json trade.json trade_summary.json trade_update.json trading_status.json transport.json update_action.json update_reason.json update_type.json variant_type.json) set(SOURCES ${SCHEMA_ROQ}) ``` -------------------------------- ### CMake: Autogenerate API Headers Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Uses the roq_autogen_hpp function to generate API headers from the provided schema files. It specifies output, sources, namespace, and template directories. ```cmake roq_autogen_hpp( OUTPUT AUTOGEN_HEADERS SOURCES ${SOURCES} NAMESPACE "roq" SCHEMA_LINK_DIR ${SCHEMA_LINK_DIR} TEMPLATE_DIR ${TEMPLATE_DIR} TEMPLATE_TYPE "api") ``` -------------------------------- ### CMake: Create Custom Target for Autogenerated Files Source: https://github.com/roq-trading/roq-api/blob/master/include/roq/CMakeLists.txt Creates a custom CMake target that depends on the autogenerated headers and Gitignore, ensuring they are built when requested. ```cmake add_custom_target(${TARGET_NAME} ALL DEPENDS ${AUTOGEN_HEADERS} ${GITIGNORE}) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.