Compare commits

..
Author SHA1 Message Date
John Colvin 2e42edc399 build: Port build_sparkd.py over from development branch 2024-08-30 15:29:59 +00:00
John Colvin a8b560475a fix build (sparkd): Fix typo BUILD_ADMIN_WEB_APP -> BUILD_WEB 2024-08-30 15:29:36 +00:00
John Colvin bee0f950ba fix build (sparkd): Use vcpkg toolchain 2024-08-30 15:28:59 +00:00
John Colvin 6f1dc66172 fix build: Fix sparkd rpath and include dirs
* Qualify sparkd include dirs w/ BUILD_INTERFACE
  - INTERFACE_INCLUDE_DIRECTORIES cannot be prefixed in the source dir
    (cmake doesn't allow it)
2024-08-30 15:26:42 +00:00
John Colvin 647737cd14 fix add emumba lic and install script 2024-08-30 15:21:32 +00:00
John Colvin d41ba5643d fix build: Include <cstdint> in a few places 2024-08-30 14:44:49 +00:00
John Colvin 22cbdcebae fix address trivial werrors 2024-08-30 14:43:33 +00:00
John Colvin 634e24bd37 fix build: Remove erroneous file(GLOB_RECURSE) call 2024-08-30 14:42:44 +00:00
John Colvin 6697185376 build (sparkd): Update fmt to 10.2.1 2024-08-30 14:42:17 +00:00
John Colvin d21dc56c6b fix build: Update fmt integration w/ spartan logger
The previous impl broke when we updated fmt to 10.2.1
2024-08-30 14:41:41 +00:00
John Colvin fe5ff75855 fix build: Add a few includes, suppress some werrors
Not sure how this slipped through the cracks, but I'm guessing the build
broke when we upgraded the cpp compilers (to clang 17 and gcc 13).

* Include <cstdint> in a few places
* Suppress -Wstringop-overflow in sparkd-gcc-release build
* Change const char * param to explicit std::string for proper type
  deduction in call to 'std::make_tuple'. For some reason, the gcc build
  was failing with an array-bounds werror (changing the arg fixed it).
2024-08-29 17:32:59 +00:00
John Colvin ad0a1991b2 fix build: Make 'pragma once' the first line in Dispatcher.h
Otherwise we get redefinition errors include caused by duplicate include.
2024-08-29 17:29:16 +00:00
John Colvin 375d349113 cleanup: Remove leftover CMakeDeps
From web build
2024-08-29 17:20:16 +00:00
John Colvin 707914af16 fix build: Address trivial werrors after upgrading to C++ 20
All werrors were about implicit 'this' captures in lambdas
2024-08-29 16:24:05 +00:00
John Colvin dd2da2a1f9 build: Benign changes to remove errors in clang 15 2024-08-29 16:19:56 +00:00
John Colvin 8bab682b5e Add emumba lic and install script for devcontainer 2024-08-29 11:43:58 -04:00
John Colvin 3966a7886e Change externals url from ssh to https style
So we don't need ssh keys to clone it (the builtin credential manager
makes https authentication safe/easy)
2024-08-29 11:12:53 -04:00
John Colvin 033bef4ab6 Add gitattributes to ensure proper line endings for various file types 2024-08-29 10:35:31 -04:00
John Colvin 18a5fd4b1d fix build (client): Change 'WIN32' macros to '_WIN32'
Not sure exactly how this broke, but the WIN32 macro is no longer defined.
2024-08-29 10:25:34 -04:00
John Colvin 6dce2fcde1 refactor: Remove redundant optional.h
It was from a time when Windows std didn't provide the 'optional' header
2024-08-29 10:24:22 -04:00
John Colvin 933faf93c1 Update externals
We removed some deps that are now managed by vcpkg
2024-08-29 10:16:55 -04:00
John Colvin 8b73367805 Set up devcontainer for sparkd
With config from development branch
2024-08-29 10:15:53 -04:00
John Colvin 6d69adb891 Port build configuration over from development branch
It's cleaner here, and makes transitioning between branches easier.
The new build_spark.py uses cmake --preset and dotnet build.
2024-08-29 10:15:53 -04:00
John Colvin aee8ee4033 build: Update nuget packages in Spark.csproj 2024-08-28 23:46:03 -04:00
John Colvin dcc84567c6 fix build (spark client): Remove deps on preview features
Namely, the 'Sum' extension function for an IEnumerable of tuples.
2024-08-28 23:45:33 -04:00
John Colvin 8c2e80097e build (windows): Update to c++ 20 2024-08-28 23:45:02 -04:00
John Colvin 066c950e67 fix build (windows): Update libfmt to 10.2.1 2024-08-28 23:44:25 -04:00
John Colvin 238494989d fix build: Remove unnecessary cpp files from win build 2024-08-28 23:44:19 -04:00
John Colvin 400318af23 build: Add vcpkg submodule 2024-08-28 23:44:07 -04:00
John Colvin aec2b875cb cleanup: Remove unused docker submodules 2024-08-28 23:43:39 -04:00
John Colvin d810b1eee6 Copy 'write_tag_block.sh' over from development
This script is used when we create the devcontainer
2024-01-12 11:55:13 -05:00
John Colvin 027942d206 devcontainer: Name mount dir w/ 'devcontainerId'
To ensure it is unique on the main host (i.e., outside the container). Get rid
of devcontainer_initialize.sh, all it did was run "mkdir". Something this
trivial can be inlined in the devcontainer.json (less indirection this way).
2024-01-12 11:51:00 -05:00
John Colvin 81d07028f3 Gitignore the '.devcontainer' dir (not the json file)
We actually do track a 'devcontainer.json' file (to keep as a template). We
just don't keep it in the '.devcontainer' dir, for the same reason we don't
track the '.vscode' dir: so devs can tailor it to their specific needs.
2024-01-12 11:50:58 -05:00
John Colvin 435a5af0a7 docker: Install kitware-archive-keyring to keep key in sync (for cmake) 2024-01-12 11:50:13 -05:00
196 changed files with 2215 additions and 3168 deletions

No files matched your search

+129
View File
@@ -0,0 +1,129 @@
FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
# Note installations that take a while (more than 10s)
RUN apt-get update
RUN apt-get install -y ca-certificates
RUN apt-get install -y ccache
RUN apt-get install -y curl
RUN apt-get install -y fish
RUN apt-get install -y gdb
# git-all: ~250s
RUN apt-get install -y git-all
RUN apt-get install -y gnupg
# liblttng-ust-dev: ~30s
RUN apt-get install -y liblttng-ust-dev
RUN apt-get install -y libssh2-1-dev
RUN apt-get install -y locales
RUN apt-get install -y ninja-build
# openssh-server: ~40s
RUN apt-get install -y openssh-server
RUN apt-get install -y pkg-config
RUN apt-get install -y software-properties-common
RUN apt-get install -y sudo
RUN apt-get install -y tzdata
RUN apt-get install -y vim
RUN apt-get install -y zip
# Python: ~30s
RUN apt-get install -y \
python3-pip \
python3-venv \
&& python3 -m pip install --upgrade pip
# GCC
ARG gcc_major=13
RUN \
add-apt-repository ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y g++-$gcc_major
# Clang
ARG clang_major=17
RUN \
curl -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key 2> /dev/null \
| gpg --dearmor - \
| tee /usr/share/keyrings/llvm-snapshot.gpg > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-$clang_major main" \
| tee -a "/etc/apt/sources.list.d/llvm.list" \
&& apt-get update \
&& apt-get install -y \
clang-$clang_major \
clang-format-$clang_major \
clangd-$clang_major
# CMake
RUN \
curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2> /dev/null \
| gpg --dearmor - \
| tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" \
| tee /etc/apt/sources.list.d/kitware.list > /dev/null \
&& apt-get update \
&& apt-get install -y cmake
# Dotnet
RUN apt-get update && apt-get install -y dotnet7
# Node
ARG node_major=18
RUN mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$node_major.x nodistro main" \
| tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs
# Emumba (deps)
RUN apt-get update && apt-get -y install rapidjson-dev
# Emumba
COPY emumba /emumba
RUN dpkg -i /emumba/emumba-deribit-connector-3.3.1-Linux.LICENSE_DISABLED.deb \
&& rm -r /emumba
# Pcap
RUN apt-get update && apt-get install -y libpcap0.8-dev
RUN apt-get update && apt-get install -y \
docker.io \
docker-compose \
docker-compose-v2
# Set up default executables (update-alternatives)
RUN \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-$clang_major 100; \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-$clang_major 100; \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-$clang_major 100; \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-$clang_major 100; \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-$gcc_major 100; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-$gcc_major 100
# Add compiler symlinks for ccache
RUN \
ln -s /usr/bin/ccache /usr/local/bin/clang; \
ln -s /usr/bin/ccache /usr/local/bin/clang++; \
ln -s /usr/bin/ccache /usr/local/bin/clang-$clang_major; \
ln -s /usr/bin/ccache /usr/local/bin/clang++-$clang_major; \
ln -s /usr/bin/ccache /usr/local/bin/gcc; \
ln -s /usr/bin/ccache /usr/local/bin/g++
RUN locale-gen en_US.UTF-8
ARG docker_user="bts"
ARG docker_uid="1000"
ARG docker_pass="bts"
RUN \
groupadd -g "$docker_uid" "$docker_user" \
&& useradd \
-m \
-u "$docker_uid" \
-g "$docker_uid" \
-G sudo \
--password "$(openssl passwd -1 "$docker_pass")" \
"$docker_user"
RUN usermod -aG docker "$docker_user"
+43
View File
@@ -0,0 +1,43 @@
{
"dockerFile": "Dockerfile",
// Creates local dir to mount to HOME in docker
"initializeCommand": "mkdir -p ${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId}",
"hostRequirements": {
"memory": "4gb",
"storage": "6gb"
},
"postCreateCommand": "/home/bts/spark/docker/sparkd/dev/devcontainer_post_create.sh",
"containerUser": "bts",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/bts/spark,type=bind",
"workspaceFolder": "/home/bts/spark",
"updateRemoteUserUID": true,
"shutdownAction": "none",
// Note: If running multiple containers on the same host, each must use a
// unique set of ports. Usually we just add 1000 to each port as needed. For
// example, if 8000-8003 is taken, go with 9000-9003, then 10000-10003, etc.
"runArgs": [
"--shm-size",
"2gb",
"--network",
"host"
],
"mounts": [
"source=${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId},target=/home/bts,type=bind",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
],
"customizations": {
"vscode": {
"settings": {
"clangd.arguments": [
"--compile-commands-dir=${workspaceFolder}/build/clang/debug"
]
},
"extensions": [
"eamodio.gitlens",
"llvm-vs-code-extensions.vscode-clangd",
"ms-vscode.cmake-tools",
"ms-vscode.cpptools"
]
}
}
}
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
this_dir="$(realpath "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")"
sudo dpkg -i "$this_dir/emumba-deribit-connector-3.3.1-Linux.LICENSE_DISABLED.deb"
+4
View File
@@ -0,0 +1,4 @@
*.cmd text=auto eol=crlf
*.cs text=auto eol=crlf
*.sh text=auto eol=lf
*.py text=auto eol=lf
+2 -3
View File
@@ -42,7 +42,7 @@ trace_data/
/.ignore
*.rej
.clangd/
*CMakeDeps.cmake
*CMakeDeps*.cmake
/sniper.ipynb
/src/.clang-format
/src/server/sparkd/cmds/spartan/analysis/.ipynb_checkpoints
@@ -51,5 +51,4 @@ trace_data/
/.venv*/*
.cache/
src/web/api/tsconfig.*.g.json
**/CMakeDeps.cmake
**/CMakeDeps_win.cmake
**/.devcontainer
+1 -7
View File
@@ -1,12 +1,6 @@
[submodule "externals"]
path = externals
url = git@bitbucket.org:bluetradesys/externals.git
[submodule "docker/linux"]
path = docker/linux
url = git@bitbucket.org:bluetradesys/linux_docker.git
[submodule "docker/windows"]
path = docker/windows
url = git@bitbucket.org:bluetradesys/windows_docker.git
url = https://bitbucket.org/bluetradesys/externals.git
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
+23 -40
View File
@@ -1,7 +1,5 @@
cmake_minimum_required(VERSION 3.12)
project(spark)
include("${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_CXX_STANDARD 20)
if(WIN32)
@@ -16,16 +14,24 @@ set(
CACHE
STRING
"External dependencies root folder (should contain folders: lib, bin, include")
set(SPARK_PYTHON "${EXTERNALS_ROOT}/python")
set(SPARK_BIN "${EXTERNALS_ROOT}/bin")
set(SPARK_INCLUDE "${EXTERNALS_ROOT}/include")
set(SPARK_LIB "${EXTERNALS_ROOT}/lib/${CMAKE_BUILD_TYPE}")
set(EXTERNALS_BIN "${EXTERNALS_ROOT}/bin")
set(EXTERNALS_INCLUDE "${EXTERNALS_ROOT}/include")
set(EXTERNALS_LIB "${EXTERNALS_ROOT}/lib/$<CONFIG>")
set(BUILD_DOCS OFF CACHE BOOL "Build documentation")
set(BUILD_SDK OFF CACHE BOOL "Build the sdk")
set(BUILD_WEB ON CACHE BOOL "Build the web server")
set(EXPORT_MD_CONSUMER OFF CACHE BOOL "Export (extern) C functions for MD consumer interop")
if (WIN32)
set(BUILD_SPARKD OFF CACHE BOOL "Build sparkd")
set(BUILD_WEB OFF CACHE BOOL "Build the web server")
else()
set(BUILD_SPARKD ON CACHE BOOL "Build sparkd")
set(BUILD_WEB ON CACHE BOOL "Build the web server")
endif()
include_directories(BEFORE SYSTEM ${SPARK_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
link_directories(${SPARK_LIB})
include_directories(BEFORE SYSTEM ${EXTERNALS_INCLUDE} ${EXTERNALS_ROOT}/include/zlib)
link_directories(${EXTERNALS_LIB})
add_compile_definitions(EXPORT_MD_CONSUMER="${EXPORT_MD_CONSUMER}")
if(WIN32)
# flags
set(
@@ -38,7 +44,7 @@ if(WIN32)
/D_WINSOCK_DEPRECATED_NO_WARNINGS \
/D__TBB_NO_IMPLICIT_LINKAGE \
/DBOOST_ALL_NO_LIB \
/std:c++20 \
/std:c++17 \
/D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_DEBUG} /MT")
@@ -53,10 +59,6 @@ if(WIN32)
# subdirs
add_subdirectory(src/lib)
else()
# make sparkd look for libspark.so in its directory
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH ".")
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install/${CMAKE_BUILD_TYPE}/sparkd")
add_compile_definitions(SPARK_ENABLE_CCAPI)
add_compile_definitions(CCAPI_ENABLE_SERVICE_MARKET_DATA)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_FTX)
@@ -80,37 +82,18 @@ else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wno-undef")
# subdirs
add_subdirectory(src/server/sparkd)
if (BUILD_SPARKD)
add_subdirectory(src/server/sparkd)
add_subdirectory(src/data_files)
endif()
add_subdirectory(src/lib)
if (BUILD_WEB)
add_subdirectory(src/web)
endif()
add_subdirectory(doc/user)
if(BUILD_DOCS)
add_subdirectory(doc/user)
endif()
if(BUILD_SDK)
add_subdirectory(src/sdk)
endif()
add_subdirectory(src/data_files)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/server
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/server
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/server/sparkd/sparkd ${CMAKE_BINARY_DIR}/server
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/web ${CMAKE_BINARY_DIR}/server
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/data_files ${CMAKE_BINARY_DIR}/server
COMMAND ln ARGS -sf ${CMAKE_BINARY_DIR}/src/lib/libspark.so ${CMAKE_BINARY_DIR}/server
COMMAND
ln ARGS -sf
${EXTERNALS_ROOT}/lib/Release/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0
${CMAKE_BINARY_DIR}/server
COMMAND ln ARGS -sf ${EXTERNALS_ROOT}/lib/Release/libACE-5.7.5.so ${CMAKE_BINARY_DIR}/server
COMMAND mkdir ARGS -p ${CMAKE_BINARY_DIR}/server/plugins
COMMENT "Creating server runtime layout"
DEPENDS sparkd data_files_dir)
add_custom_target(server_layout ALL DEPENDS ${CMAKE_BINARY_DIR}/server)
install(DIRECTORY "${CMAKE_BINARY_DIR}/server/plugins" DESTINATION bin)
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libACE-5.7.5.so" DESTINATION bin)
install(FILES "${CMAKE_SOURCE_DIR}/externals/linux/lib/${CMAKE_BUILD_TYPE}/libOnixS.IceImpactMulticastPriceFeedHandlerCpp.so.3.16.0.0" DESTINATION bin)
install(FILES "${CMAKE_SOURCE_DIR}/externals/src/emumba/sparkd.lic" DESTINATION bin)
endif()
+216
View File
@@ -0,0 +1,216 @@
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "spark",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build/${presetName}",
"environment": {
"SPARK_CMAKE_CXX_FLAGS": "/MP /WX /wd4250 /wd4251 /wd4244 /wd4267 /wd4355 /wd4275 /wd4345 /bigobj /EHsc /DCURL_STATICLIB /D_WINSOCK_DEPRECATED_NO_WARNINGS /D__TBB_NO_IMPLICIT_LINKAGE /DBOOST_ALL_NO_LIB /std:c++20 /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600"
},
"cacheVariables": {
"CMAKE_CXX_FLAGS": "$env{SPARK_CMAKE_CXX_FLAGS}",
"CMAKE_CXX_FLAGS_DEBUG": "$env{SPARK_CMAKE_CXX_FLAGS} /MTd",
"CMAKE_CXX_FLAGS_RELEASE": "$env{SPARK_CMAKE_CXX_FLAGS} /MT",
"CMAKE_CXX_STANDARD": "20",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}",
"CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUG",
"CMAKE_SHARED_LINKER_FLAGS_RELEASE": "/OPT:REF /OPT:ICF /LTCG",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"EXTERNALS_ROOT": "${sourceDir}/externals/windows",
"CONFIG_DEFAULTS_PATH": "config/defaults/*.conf",
"DOTNET_BINARY_DIR": "${sourceDir}/build/$<CONFIG>/bin/net7.0;${sourceDir}/build/$<CONFIG>/bin/net7.0-windows",
"EXPORT_MD_CONSUMER": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "sparkd",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"platform": "",
"CMAKE_CXX_STANDARD": "20",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/install/${presetName}",
"CMAKE_EXE_LINKER_FLAGS": "-Wno-undef",
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"CONFIG_DEFAULTS_PATH": "config/defaults/*.conf",
"EXTERNALS_ROOT": "${sourceDir}/externals/linux",
"BUILD_SDK": {
"type": "BOOL",
"value": "OFF"
},
"BUILD_WEB": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "sparkd-debug",
"inherits": "sparkd",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": {
"type": "BOOL",
"value": "ON"
},
"CCAPI_LOG_LEVEL": "Info"
}
},
{
"name": "sparkd-release",
"inherits": "sparkd",
"hidden": true,
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CCAPI_LOG_LEVEL": "Warn"
}
},
{
"name": "sparkd-debug-clang",
"inherits": "sparkd-debug",
"displayName": "Sparkd (Debug | Clang)",
"description": "Debug build compiled w/ clang",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++20 -fdiagnostics-color -DDEBUG"
}
},
{
"name": "sparkd-debug-gcc",
"inherits": "sparkd-debug",
"displayName": "Sparkd (Debug | Gcc)",
"description": "Debug build compiled w/ gcc",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_CXX_FLAGS_DEBUG": "-g -fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++20 -fdiagnostics-color -Wno-stringop-overread -DDEBUG"
}
},
{
"name": "sparkd-release-clang",
"inherits": "sparkd-release",
"displayName": "Sparkd (Release | Clang)",
"description": "Release build compiled w/ clang",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers --std=c++20 -fdiagnostics-color -fno-omit-frame-pointer -DNDEBUG -O3"
}
},
{
"name": "sparkd-release-gcc",
"inherits": "sparkd-release",
"displayName": "Sparkd (Release | Gcc)",
"description": "Release build compiled w/ gcc",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_CXX_FLAGS_RELEASE": "-fPIC -Wall -pedantic -Wextra -Werror -Wno-missing-braces -Wno-ignored-qualifiers -Wno-stringop-overflow --std=c++20 -fdiagnostics-color -Wno-stringop-overread -Wno-maybe-uninitialized -fno-omit-frame-pointer -DNDEBUG -O3"
}
}
],
"buildPresets": [
{
"name": "spark",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"hidden": true
},
{
"name": "spark-debug",
"displayName": "Spark (Debug)",
"inherits": "spark",
"configurePreset": "spark",
"configuration": "Debug"
},
{
"name": "spark-release",
"displayName": "Spark (Release)",
"inherits": "spark",
"configurePreset": "spark",
"configuration": "Release"
},
{
"name": "sparkd",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"hidden": true
},
{
"name": "sparkd-debug-clang",
"configurePreset": "sparkd-debug-clang",
"displayName": "Sparkd (Debug | Clang)",
"inherits": "sparkd"
},
{
"name": "sparkd-debug-clang-j6",
"configurePreset": "sparkd-debug-clang",
"displayName": "Sparkd (Debug | Clang | jobs=6)",
"inherits": "sparkd",
"jobs": 6
},
{
"name": "sparkd-debug-gcc",
"configurePreset": "sparkd-debug-gcc",
"displayName": "Sparkd (Debug | Gcc)",
"inherits": "sparkd"
},
{
"name": "sparkd-release-clang",
"configurePreset": "sparkd-release-clang",
"displayName": "Sparkd (Release | Clang)",
"inherits": "sparkd"
},
{
"name": "sparkd-release-gcc",
"configurePreset": "sparkd-release-gcc",
"displayName": "Sparkd (Release | Gcc)",
"inherits": "sparkd"
}
]
}
+39
View File
@@ -0,0 +1,39 @@
include(${CMAKE_SOURCE_DIR}/cmake/PackBasic.cmake)
include(GNUInstallDirs)
function(install_basic)
set(_options)
set(_one_value_args)
set(_multi_value_args HEADERS)
cmake_parse_arguments(_ARGS "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN})
if (_ARGS_HEADERS)
set(${PROJECT_NAME}_HEADERS ${_ARGS_HEADERS})
else()
file(
GLOB_RECURSE ${PROJECT_NAME}_HEADERS
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.h
)
endif()
target_sources(${PROJECT_NAME}
PUBLIC
FILE_SET HEADERS FILES ${${PROJECT_NAME}_HEADERS})
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
EXPORT ${PROJECT_NAME}Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
pack_basic()
endfunction()
+36
View File
@@ -0,0 +1,36 @@
include(CMakePackageConfigHelpers)
function(pack_basic)
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
if(NOT GIT_FOUND OR PROJECT_VERSION STREQUAL "")
set(PROJECT_VERSION "0.0.0")
endif()
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
endfunction()
+12
View File
@@ -0,0 +1,12 @@
function(print_list var)
set(CMAKE_MESSAGE_INDENT "")
set(_var_str "")
foreach(item IN LISTS ${var})
set(_var_str "${_var_str}\n ${item}")
endforeach()
if ("${ARGN}" STREQUAL "VERBOSE")
message(VERBOSE "***${var}:${_var_str}")
else()
message("***${var}:${_var_str}")
endif()
endfunction()
+2 -2
View File
@@ -1,5 +1,5 @@
set(Protobuf_PROTOC_EXECUTABLE "${SPARK_BIN}/protoc")
set(PROTOBUF_INCLUDE_DIRS "${SPARK_INCLUDE}")
set(Protobuf_PROTOC_EXECUTABLE "${EXTERNALS_BIN}/protoc")
set(PROTOBUF_INCLUDE_DIRS "${EXTERNALS_INCLUDE}")
set(PROTOBUF_STATIC_LIB "libprotobuf")
function(Protobuf_Generate_Cpp SRCS HDRS)
File renamed without changes.
+1
View File
@@ -0,0 +1 @@
set(sources /home/taha/spark/doc/user/build.sh;content/_index.md;content/bts_spark/Glossary/_index.md;content/bts_spark/Help/_index.md;content/bts_spark/Help/about_spark.png;content/bts_spark/Help/image39.png;content/bts_spark/Help/image58.png;content/bts_spark/Launcher/_index.md;content/bts_spark/Launcher/image38.png;content/bts_spark/Launcher/image68.png;content/bts_spark/Logging-In-to-the-System/_index.md;content/bts_spark/Logging-In-to-the-System/image3.png;content/bts_spark/Logging-In-to-the-System/image64.png;content/bts_spark/Market/_index.md;content/bts_spark/Market/change_securities.png;content/bts_spark/Market/image11.png;content/bts_spark/Market/image14.png;content/bts_spark/Market/image20.png;content/bts_spark/Market/image21.png;content/bts_spark/Market/image23.png;content/bts_spark/Market/image24.png;content/bts_spark/Market/image34.png;content/bts_spark/Market/image49.png;content/bts_spark/Market/image53.png;content/bts_spark/Market/image66.png;content/bts_spark/Market/image69.png;content/bts_spark/Market/market_view.png;content/bts_spark/Market/settings_icon.png;content/bts_spark/Market/time_and_sales.png;content/bts_spark/My-Windows/_index.md;content/bts_spark/My-Windows/image15.png;content/bts_spark/My-Windows/image16.png;content/bts_spark/My-Windows/image37.png;content/bts_spark/Settings/_index.md;content/bts_spark/Settings/image51.png;content/bts_spark/Settings/image9.png;content/bts_spark/Spreader/_index.md;content/bts_spark/Spreader/image10.png;content/bts_spark/Spreader/image13.png;content/bts_spark/Spreader/image18.png;content/bts_spark/Spreader/image19.png;content/bts_spark/Spreader/image28.png;content/bts_spark/Spreader/image29.png;content/bts_spark/Spreader/image31.png;content/bts_spark/Spreader/image35.png;content/bts_spark/Spreader/image40.png;content/bts_spark/Spreader/image43.png;content/bts_spark/Spreader/image54.png;content/bts_spark/Spreader/image55.png;content/bts_spark/Spreader/image56.png;content/bts_spark/Spreader/image6.png;content/bts_spark/Spreader/image7.png;content/bts_spark/Spreader/image70.png;content/bts_spark/Spreader/image72.png;content/bts_spark/Spreader/image8.png;content/bts_spark/Trading/OrderTypes/index.md;content/bts_spark/Trading/_index.md;content/bts_spark/Trading/algo_studio.png;content/bts_spark/Trading/collapse_all_icon.png;content/bts_spark/Trading/cover_algo_control.png;content/bts_spark/Trading/expand_all_icon.png;content/bts_spark/Trading/image1.png;content/bts_spark/Trading/image17.png;content/bts_spark/Trading/image2.png;content/bts_spark/Trading/image25.png;content/bts_spark/Trading/image27.png;content/bts_spark/Trading/image33.png;content/bts_spark/Trading/image42.png;content/bts_spark/Trading/image44.png;content/bts_spark/Trading/image47.png;content/bts_spark/Trading/image48.png;content/bts_spark/Trading/image5.png;content/bts_spark/Trading/image50.png;content/bts_spark/Trading/image52.png;content/bts_spark/Trading/image57.png;content/bts_spark/Trading/image59.png;content/bts_spark/Trading/image60.png;content/bts_spark/Trading/image61.png;content/bts_spark/Trading/image62.png;content/bts_spark/Trading/image73.png;content/bts_spark/Trading/image74.png;content/bts_spark/Trading/join_algo_control.png;content/bts_spark/Trading/ladder.png;content/bts_spark/Trading/ladder_badges.png;content/bts_spark/Trading/ladder_main_part.png;content/bts_spark/Trading/lean_algo_control.png;content/bts_spark/Trading/mini_orderbook.png;content/bts_spark/Trading/oco_algo_control.png;content/bts_spark/Trading/offset_algo_control.png;content/bts_spark/Trading/pnl_calculation.png;content/bts_spark/Trading/pnl_window.png;content/bts_spark/Trading/recreate_icon.png;content/bts_spark/Trading/settings_icon.png;content/bts_spark/Trading/spark_menu_order_book.png;content/bts_spark/Trading/top_algo_control.png;content/bts_spark/Trading/trigger_algo_control.png;content/bts_spark/_index.md;content/release_notes/_index.md;content/system_requirements/_index.md;static/book.js;static/favicon.ico;static/image.js;templates/index.html;templates/page.html;templates/section.html;templates/shortcodes/back_button.html)
Submodule docker/linux deleted from 6537812262.
+8 -2
View File
@@ -48,9 +48,15 @@ RUN apt-get update && apt-get install -y \
# cmake
RUN \
curl -fsSL https://apt.kitware.com/keys/kitware-archive-latest.asc 2> /dev/null \
| gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg > /dev/null \
&& apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" \
| gpg --dearmor - \
| tee /usr/share/keyrings/kitware-archive-keyring.gpg > /dev/null \
&& echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" \
| tee /etc/apt/sources.list.d/kitware.list > /dev/null \
&& apt-get update \
&& rm /usr/share/keyrings/kitware-archive-keyring.gpg \
&& apt-get install -y kitware-archive-keyring \
&& echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs)-rc main" \
| tee -a /etc/apt/sources.list.d/kitware.list >/dev/null \
&& apt-get install -y cmake
# node
+3 -2
View File
@@ -1,6 +1,7 @@
{
"image": "bluetradingsystems/sparkd-dev:latest",
"initializeCommand": "${localWorkspaceFolder}/docker/sparkd/dev/devcontainer_initialize.sh",
// Creates local dir to mount to HOME in docker
"initializeCommand": "mkdir -p ${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId}",
"hostRequirements": {
"memory": "4gb",
"storage": "6gb"
@@ -27,6 +28,6 @@
"8003:8003"
],
"mounts": [
"source=${localEnv:HOME}/.sparkd-dev/mounts/sparkd-dev,target=/home/bts,type=bind"
"source=${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId},target=/home/bts,type=bind"
]
}
@@ -1,3 +0,0 @@
#!/usr/bin/env bash
mkdir -p "$HOME/.sparkd-dev/mounts/sparkd-dev"
Submodule docker/windows deleted from de7d40c09d.
-5
View File
@@ -4,8 +4,6 @@ VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_api", "src\client\spark_api\spark_api.csproj", "{DC9A8975-8211-4FC9-A9BA-C8B9D26AD481}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspark", "build\src\lib\libspark.vcxproj", "{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Spark", "src\client\spark\Spark.csproj", "{9A4D4D07-1AB6-4B2B-B111-A4F34D6C267E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "sparkcmd", "src\client\sparkcmd\sparkcmd.csproj", "{387566C6-C6F6-412C-A30C-9855BBCB4816}"
@@ -13,9 +11,6 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_core", "src\client\spark_core\spark_core.csproj", "{6E449EB6-20AC-4FA6-B8D9-10F4BB7E1FEE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_sdk", "src\client\spark_sdk\spark_sdk.csproj", "{6963C314-83C4-4667-B0D0-C2F7AE208C29}"
ProjectSection(ProjectDependencies) = postProject
{FDC3A021-386E-3A2C-A7EB-CBE94A95BE25} = {FDC3A021-386E-3A2C-A7EB-CBE94A95BE25}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "spark_test", "src\client\spark_test\spark_test.csproj", "{ECD78CC5-138F-4809-A764-2358C2AC2E82}"
EndProject
@@ -218,10 +218,14 @@ namespace mbts.spark {
background = buy_sell_background_fill_color;
hoverbackground = _mk_hover_bg_brush(dark, _darkbg, 0);
(_num_root_orders, _filled, _quantity) = _root_nodes
.Select(n => (1u, n.filled_quantity(), n.quantity()))
.Sum();
_num_root_orders = 0;
_filled = 0;
_quantity = 0;
foreach (var n in _root_nodes) {
_num_root_orders++;
_filled += n.filled_quantity();
_quantity += n.quantity();
}
if (_num_root_orders == 1) {
var order = _root_nodes.First();
border = _owner.model.order_gateway.factory.get_metadata(order).Color.rgb_brush();
@@ -190,13 +190,24 @@ namespace mbts.analytics {
}
}
void _compute_swipe_sum() =>
(swipe_sum_puts, swipe_sum_calls, swipe_sum_net) = _visible_selected_cells
.SelectMany(tup =>
tup.exps.Select(exp => {
var (p, c, n) = tup.row.get_cell_values(exp);
return (p.if_nan(0), c.if_nan(0), n.if_nan(0));
}))
.Sum();
void _compute_swipe_sum() {
swipe_sum_puts = 0;
swipe_sum_calls = 0;
swipe_sum_net = 0;
foreach (var (row, exps) in _visible_selected_cells) {
foreach (var exp in exps) {
var (p, c, n) = row.get_cell_values(exp);
if (!p.is_nan()) {
swipe_sum_puts += p;
}
if (!c.is_nan()) {
swipe_sum_calls += c;
}
if (!n.is_nan()) {
swipe_sum_net += n;
}
}
}
}
}
}
+32 -20
View File
@@ -1,4 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
@@ -21,33 +22,39 @@
<RootNamespace>bts</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
<Version>$(major).$(minor).$(patch)</Version>
<Version Condition="'$(version)'=='..'">1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Google.Protobuf" Version="3.24.3" />
<PackageReference Include="IronPython" Version="3.4.1" />
<PackageReference Include="MathNet.Numerics" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="OxyPlot.Core" Version="2.1.2" />
<PackageReference Include="OxyPlot.Wpf" Version="2.1.2" />
<PackageReference Include="protobuf-net" Version="3.2.26" />
<PackageReference Include="System.Composition" Version="7.0.0-preview.2.22152.2" />
<PackageReference Include="System.Composition.AttributedModel" Version="7.0.0-preview.2.22152.2" />
<PackageReference Include="System.Composition.Hosting" Version="7.0.0-preview.2.22152.2" />
<PackageReference Include="System.Composition.TypedParts" Version="7.0.0-preview.2.22152.2" />
<PackageReference Include="System.Reactive.Core" Version="5.0.0" />
<PackageReference Include="System.Reactive.Interfaces" Version="5.0.0" />
<PackageReference Include="System.Reactive.Linq" Version="5.0.0" />
<PackageReference Include="System.Reactive.PlatformServices" Version="5.0.0" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<ProjectReference Include="../spark_api/spark_api.csproj" />
<ProjectReference Include="../spark_core/spark_core.csproj" />
<PackageReference Include="Google.Protobuf" Version="3.21.4" />
<PackageReference Include="IronPython" Version="2.7.12" />
<PackageReference Include="NAudio" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
<PackageReference Include="protobuf-net" Version="3.1.17" />
<PackageReference Include="OxyPlot.Core" Version="2.1.2" />
<PackageReference Include="OxyPlot.Wpf" Version="2.1.2" />
<PackageReference Include="System.Reactive" Version="6.0.0" />
<PackageReference Include="System.Reactive.Core" Version="6.0.0" />
<PackageReference Include="System.Reactive.Interfaces" Version="6.0.0" />
<PackageReference Include="System.Reactive.Linq" Version="6.0.0" />
<PackageReference Include="System.Reactive.PlatformServices" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\spark_api\spark_api.csproj" />
<ProjectReference Include="..\spark_core\spark_core.csproj" />
</ItemGroup>
<ItemGroup>
@@ -55,15 +62,20 @@
<Resource Include="**/*.png" />
<ConfigDefaults Include="../../lib/config/defaults/*.conf" />
</ItemGroup>
<ItemGroup>
<Resource Remove="logo.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="logo.ico" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Sounds/game_sound_correct.wav" />
<EmbeddedResource Include="Sounds/whistle.wav" />
</ItemGroup>
<Target Name="diagnostic" AfterTargets="PreBuildEvent" />
</Project>
@@ -1190,6 +1190,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2) Sum<T1, T2>(this IEnumerable<(T1, T2)> source)
where T1 : INumber<T1>
where T2 : INumber<T2> =>
@@ -1202,6 +1203,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2) Sum<T1, T2>(this IEnumerable<(T1, T2)> source, T1 seed1, T2 seed2)
where T1 : IAdditionOperators<T1, T1, T1>
where T2 : IAdditionOperators<T2, T2, T2> =>
@@ -1215,6 +1217,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2, T3) Sum<T1, T2, T3>(this IEnumerable<(T1, T2, T3)> source)
where T1 : INumber<T1>
where T2 : INumber<T2>
@@ -1228,6 +1231,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2, T3) Sum<T1, T2, T3>(
this IEnumerable<(T1, T2, T3)> source, T1 seed1, T2 seed2, T3 seed3)
where T1 : IAdditionOperators<T1, T1, T1>
@@ -1244,6 +1248,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2, T3, T4) Sum<T1, T2, T3, T4>(this IEnumerable<(T1, T2, T3, T4)> source)
where T1 : INumber<T1>
where T2 : INumber<T2>
@@ -1258,6 +1263,7 @@ namespace System.Collections.Generic {
/// A tuple whose items each represent the sum of their repsective items in
/// <paramref name="source"/>
/// </returns>
[RequiresPreviewFeatures]
public static (T1, T2, T3, T4) Sum<T1, T2, T3, T4>(
this IEnumerable<(T1, T2, T3, T4)> source, T1 seed1, T2 seed2, T3 seed3, T4 seed4)
where T1 : IAdditionOperators<T1, T1, T1>
+1
View File
@@ -0,0 +1 @@
set(sources files/audit_ilink3.py;files/audit_upload.sh;files/audit_uploader.py;files/cert_secure_logon.txt;files/example.conf;files/futures.coconut.xz;files/onixs_ice/ConnectivityConfiguration.APITest.xml;files/onixs_ice/ConnectivityConfiguration.PerfTest.xml;files/onixs_ice/ConnectivityConfiguration.Production.xml;files/perf_trace/compiled.css;files/perf_trace/index.html;files/perf_trace/jquery-3.3.1.min.js;files/perf_trace/main.js;files/perf_trace/perf_log.sql;files/perf_trace/perf_trace_analysis.sql;files/perf_trace/plotly-latest.min.js;files/small_es.pcap.xz;files/spartan/create_polygon_books.sql;files/spartan/log.sql;files/spartan/md.sql;files/spartan/sim_db.sql)
+62 -147
View File
@@ -1,169 +1,84 @@
cmake_minimum_required(VERSION 3.5)
project(libspark)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
include(GNUInstallDirs)
include(${CMAKE_SOURCE_DIR}/cmake/safe_dep_glob.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/Protobuf.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GenerateDefaultConfig.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/PrintList.cmake)
# DEPENDENCIES
file(
GLOB_RECURSE Config_Protos
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
config/protos/*.proto
api/domain/SecurityMetadataCollection.proto)
file(
GLOB_RECURSE Service_Protos
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/services/*.proto)
file(
GLOB_RECURSE NonConfig_Protos
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.proto)
list(REMOVE_ITEM NonConfig_Protos ${Service_Protos} ${Config_Protos})
file(
GLOB_RECURSE Conf_Defaults
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
config/defaults/*.conf)
if (DEFINED DOTNET_BINARY_DIR OR DEFINED DOTNET_WINDOWS_BINARY_DIR)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/AddCopyBinariesTarget.cmake)
endif()
if(WIN32)
file(
GLOB_RECURSE SparkLib_Sources
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/*.cpp
config/*.cpp
core/*.cpp
domain_model/*.cpp
expression/*.cpp
logging/*.cpp
io/*.cpp
md/*.cpp
os/*.cpp
quickbus/*.cpp
sparkproto/*.cpp
testing/*.cpp
utils/*.cpp)
if(BUILD_SPARKD)
message(FATAL_ERROR "Cannot build sparkd on Windows (Please set BUILD_SPARKD to False)")
endif()
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetWindowsClientSources.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetWindowsClientLinkLibraries.cmake)
elseif(${BUILD_SPARKD})
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxServerSources.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxServerLinkLibraries.cmake)
else()
file(
GLOB_RECURSE SparkLib_Sources
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.cpp)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxClientSources.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetLinuxClientLinkLibraries.cmake)
endif()
update_deps_file("${SparkLib_Sources};${Config_Protos};${Service_Protos};${NonConfig_Protos};${Conf_Defaults}")
# END DEPENDENCIES
# Cpp sources
set(${PROJECT_NAME}_Sources)
get_cpp_sources(${PROJECT_NAME}_Sources)
print_list(${PROJECT_NAME}_Sources VERBOSE)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${NonConfig_Protos} ${Config_Protos})
service_compiler_generate_cpp(SERVICE_COMPILER_SRCS SERVICE_COMPILER_HDRS ${Service_Protos})
# Proto sources
get_proto_sources(_cfg_protos _non_cfg_protos _service_protos _cfg_defaults)
print_list(_cfg_protos VERBOSE)
print_list(_non_cfg_protos VERBOSE)
print_list(_service_protos VERBOSE)
print_list(_cfg_defaults VERBOSE)
# generate list of config protos
set(config_proto_file ${CMAKE_CURRENT_BINARY_DIR}/config_proto_files.h)
update_deps_file("${${PROJECT_NAME}_Sources};${_cfg_protos};${_service_protos};${_non_cfg_protos};${_cfg_defaults}")
# generate a string with the current config files
set(config_proto_str "const char * config_proto_files[] = { // generated file\n")
foreach(protopath ${Config_Protos})
get_filename_component(protoname ${protopath} NAME)
string(APPEND config_proto_str "\"${protoname}\",\n")
endforeach(protopath)
string(APPEND config_proto_str "} ;\n")
# Generate proto cpp
message(STATUS "Generating proto cpp")
protobuf_generate_cpp(_proto_srcs _proto_hdrs ${_non_cfg_protos} ${_cfg_protos})
service_compiler_generate_cpp(SERVICE_COMPILER_SRCS SERVICE_COMPILER_HDRS ${_service_protos})
message(STATUS "Generating default config")
generate_default_config(_cfg_protos _cfg_defaults)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_Sources} ${_proto_srcs} ${SERVICE_COMPILER_SRCS})
# compare with file and if there is any difference update the file
set(old_config_proto_str "")
if(EXISTS "${config_proto_file}")
file(READ "${config_proto_file}" old_config_proto_str)
endif()
if(NOT old_config_proto_str STREQUAL config_proto_str)
file(WRITE "${config_proto_file}" "${config_proto_str}")
endif()
# generate static defaults
set(config_defaults_file ${CMAKE_CURRENT_BINARY_DIR}/config_defaults.h)
# Defaults cannot be a single string because the compiler complains about a string longer than 65k
set(config_defaults_str "const char * config_static_defaults[] = { ")
foreach(cfg_file_path ${Conf_Defaults})
file(READ ${cfg_file_path} cfg_file_content)
string(REPLACE "\"" "\\\"" cfg_file_content_escaped ${cfg_file_content})
string(REPLACE "\n" ";" cfg_lines ${cfg_file_content_escaped})
foreach(line ${cfg_lines})
string(APPEND config_defaults_str "\n \"${line}\",")
endforeach(line)
endforeach(cfg_file_path)
string(APPEND config_defaults_str "};")
set(old_defaults_str "")
if(EXISTS ${config_defaults_file})
file(READ ${config_defaults_file} old_defaults_str)
endif()
if(NOT config_defaults_str STREQUAL old_defaults_str)
file(WRITE "${config_defaults_file}" "${config_defaults_str}")
endif()
# lib
if(WIN32)
add_library(libspark SHARED ${SparkLib_Sources} ${PROTO_SRCS} ${SERVICE_COMPILER_SRCS})
else()
add_library(libspark SHARED ${SparkLib_Sources} ${PROTO_SRCS} ${SERVICE_COMPILER_SRCS})
endif()
# include paths
target_include_directories(
libspark PUBLIC
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src)
${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
if(WIN32)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(
libspark
libcurl
fmt::fmt-header-only
libtbb
libboost_system
libboost_thread
libboost_filesystem
libboost_regex
libboost_chrono
libboost_date_time
libboost_atomic
libprotobuf
libprotoc
libssl
libcrypto
crypt32)
else()
target_link_libraries(
libspark
protobuf
double-conversion
boost_system
boost_thread
boost_filesystem
boost_regex
boost_chrono
boost_date_time
boost_atomic
SQLiteCpp
sqlite3
curl
uuid
ssl
crypto
fmt
tbb
cryptopp
pugixml
lttng-ust
Pcap++
Packet++
Common++
ssh2
-lrt
-ldl
-lpcap
-static-libgcc
-static-libstdc++
-pthread)
get_link_libraries(_link_libs)
print_list(_link_libs VERBOSE)
target_link_libraries(${PROJECT_NAME} ${_link_libs})
install(TARGETS libspark DESTINATION bin)
# Copy binaries to Dotnet build dirs (for csprojs that depend on libspark)
if (DEFINED DOTNET_BINARY_DIR)
add_copy_binaries_target(
copy_to_dotnet_binary_dir
"${DOTNET_BINARY_DIR}"
"Copy ${PROJECT_NAME} bins to Dotnet build dir")
endif()
if(WIN32)
include(${CMAKE_SOURCE_DIR}/tools/vs_filters.cmake)
include(${CMAKE_SOURCE_DIR}/cmake/vs_filters.cmake)
endif()
foreach(_hdr ${_proto_hdrs})
file(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_BINARY_DIR}/protobufs ${_hdr})
install(FILES ${_hdr} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${_relative_path})
endforeach()
include(${CMAKE_SOURCE_DIR}/cmake/InstallBasic.cmake)
file(
GLOB_RECURSE _hdrs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.h
)
install_basic(HEADERS ${_hdrs})
+5
View File
@@ -0,0 +1,5 @@
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
check_required_components(@PROJECT_NAME@)
-13
View File
@@ -1,13 +0,0 @@
#pragma once
#include <functional>
namespace bts::algorithm {
template <typename _Tp, typename _TAddend, _Tp _Addend>
struct PlusX {
/// Returns the sum
_Tp operator()(const _Tp &__x) const { return __x + _Addend; }
};
} // namespace bts::algorithm
-49
View File
@@ -1,49 +0,0 @@
#pragma once
#include <string>
namespace bts::algorithm {
class StringCaseConverter {
public:
static void to_upper(const std::string &str, std::string &dest) noexcept;
static std::string to_upper(const std::string &str) noexcept;
static void to_lower(const std::string &str, std::string &dest) noexcept;
static std::string to_lower(const std::string &str) noexcept;
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
inline std::string StringCaseConverter::to_upper(const std::string &str) noexcept {
std::string rv{str};
for (auto &c : rv) {
c = std::toupper(c);
}
return rv;
}
inline void StringCaseConverter::to_upper(const std::string &str, std::string &dest) noexcept {
dest = str;
for (auto &c : dest) {
c = std::toupper(c);
}
}
inline std::string StringCaseConverter::to_lower(const std::string &str) noexcept {
std::string rv{str};
for (auto &c : rv) {
c = std::tolower(c);
}
return rv;
}
inline void StringCaseConverter::to_lower(const std::string &str, std::string &dest) noexcept {
dest = str;
for (auto &c : dest) {
c = std::tolower(c);
}
}
} // namespace bts::algorithm
-28
View File
@@ -1,28 +0,0 @@
#pragma once
#define CATCH_AND_LOG(subsys, level, label) \
catch (const std::exception &ex) { \
LOG(subsys, level, label ": {}", std::string{ex.what()}); \
} \
catch (...) { \
LOG(subsys, level, label ": Unknown exception"); \
}
#define CATCH_AND_HANDLE(err_var_name, impl) \
catch (const std::exception &err_var_name##_ex) { \
const auto &err_var_name = err_var_name##_ex.what(); \
impl; \
} \
catch (...) { \
const std::string err_var_name{"Unknown exception"}; \
impl; \
}
// Normalizes 'std::exception' and '...' handlers into single callback
#define CATCH_AND_HANDLE_MSG(impl) \
catch (const std::exception &ex) { \
impl(std::string{ex.what()}); \
} \
catch (...) { \
impl(std::string{"Unknown exception"}); \
}
+3 -3
View File
@@ -13,7 +13,7 @@
#include "lib/config/protos/quickbus_cfg.pb.h"
#include "lib/config/protos/system.pb.h"
#ifdef WIN32
#ifdef _WIN32
#include <excpt.h>
#endif
@@ -59,7 +59,7 @@ CAPI Quickbus *api_create_quickbus(const char *qbconfig, long length) {
}
CAPI void api_destroy_quickbus(Quickbus *qbus) {
#ifndef WIN32
#ifndef _WIN32
if (qbus != nullptr) {
delete qbus;
}
@@ -186,7 +186,7 @@ CAPI void api_client_send(
void *extra) {
LOG(Api, Diag, "send rpc {}", ((int64_t)buffer));
std::string strbuf(buffer, buffer_length);
qbus::RPCRequest request(move(strbuf));
qbus::RPCRequest request(std::move(strbuf));
api_client_send_internal(
pclient, std::move(request), cb, rpc_connect_timeout_ms(), extra);
}
+1 -1
View File
@@ -60,7 +60,7 @@ CAPI void api_server_call_callback(
reinterpret_cast<qbus::ReplyHandler **>(ppvhandler);
std::string reply_buffer((const char *)buffer, (size_t)length);
qbus::RPCReplyPtr replyptr =
std::make_shared<qbus::RPCReply>(move(reply_buffer));
std::make_shared<qbus::RPCReply>(std::move(reply_buffer));
(**pphandler)(replyptr);
delete (*pphandler);
*pphandler = nullptr;
+3 -3
View File
@@ -72,7 +72,7 @@ class ClientChannel {
response_buffer + header_size,
response_size - header_size);
if (response->ParseFromZeroCopyStream(&data_stream)) {
on_response(Result<Response>(move(response)));
on_response(Result<Response>(std::move(response)));
return;
}
} else {
@@ -88,12 +88,12 @@ class ClientChannel {
rxcpp::observable<RawUpdate<std::shared_ptr<T>>>
subscribe(int method_id, const char *method, const std::string &qualifier) {
return rxcpp::observable<>::create<RawUpdate<std::shared_ptr<T>>>(
[=](rxcpp::subscriber<RawUpdate<std::shared_ptr<T>>> observer) {
[=, this](rxcpp::subscriber<RawUpdate<std::shared_ptr<T>>> observer) {
StreamAccessRequest request;
request.set_qualifier(qualifier);
send<StreamAccessRequest, StreamAccessResponse>(
method_id, request,
[=](const Result<StreamAccessResponse> &response) {
[=, this](const Result<StreamAccessResponse> &response) {
// There is a race on server startup. If the server is not
// yet we can't return a dead stream if (!response) {
// observer.on_error(
+1 -1
View File
@@ -28,7 +28,7 @@ void QuickbusClientChannel::send_core(
(*on_response)(buffer, length);
delete on_response;
};
OnReply *heap_on_response = new OnReply(move(on_response));
OnReply *heap_on_response = new OnReply(std::move(on_response));
api_client_send(
_pclient, request_envalope.c_str(), request_envalope.size(), trampoline,
heap_on_response);
@@ -11,8 +11,8 @@ using namespace rxcpp::operators;
{{#each service}}
// Constructor
{{name}}::{{name}}(std::unique_ptr<bts::api::ClientChannel> pchannel) : _pchannel(move(pchannel)) {}
{{name}}::{{name}}({{name}}&& other) : _pchannel(move(other._pchannel)) { }
{{name}}::{{name}}(std::unique_ptr<bts::api::ClientChannel> pchannel) : _pchannel(std::move(pchannel)) {}
{{name}}::{{name}}({{name}}&& other) : _pchannel(std::move(other._pchannel)) { }
{{#each method}}
{{#if server_streaming}}
@@ -92,7 +92,7 @@ void Authenticated{{name}}Base::dispatch(const bts::api::RequestHeader& header,
return iter->second;
};
{{/unless}}
return [=](
return [=, this](
const std::vector<{{output_type_cpp}}>* added,
const std::vector<{{output_type_cpp}}>* changed,
std::set<{{key_type.cpptype}}>* removed) mutable {
-31
View File
@@ -1,31 +0,0 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api::orderman {
PB_ENUM_FROM_JSON(OrderStatus)
PB_ENUM_TO_JSON(OrderStatus)
PB_ENUM_FROM_JSON(TriggerPriceType)
PB_ENUM_TO_JSON(TriggerPriceType)
} // namespace bts::api::orderman
FMT_IMPL(
bts::api::orderman::OrderStatus,
s,
"{}",
bts::api::orderman::OrderStatus_Name(s));
FMT_IMPL(
bts::api::orderman::TriggerPriceType,
t,
"{}",
bts::api::orderman::TriggerPriceType_Name(t));
+1 -1
View File
@@ -43,7 +43,7 @@ void HelloServiceServer::yell_hello(
HelloResponse response;
ShoutRequest sr;
sr.set_msg("hello " + request.name());
_shouter.upper(sr, [=](Result<ShoutResponse> response) {
_shouter.upper(sr, [=, this](Result<ShoutResponse> response) {
if (response.success()) {
HelloResponse hr;
hr.set_message(response.value()->msg());
+15
View File
@@ -0,0 +1,15 @@
function(add_copy_binaries_target tgt_name dest_dir)
set(_dest_files)
foreach (_dest_dir ${dest_dir})
set(_dest_file ${_dest_dir}/${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
list(APPEND _dest_files ${_dest_file})
add_custom_command(
OUTPUT ${_dest_file}
COMMAND ${CMAKE_COMMAND}
ARGS -E copy
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/${PROJECT_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
${_dest_file}
DEPENDS ${PROJECT_NAME})
endforeach()
add_custom_target(${tgt_name} ALL DEPENDS ${_dest_files} COMMENT ${ARGN})
endfunction()
+53
View File
@@ -0,0 +1,53 @@
function(generate_default_config cfg_protos cfg_defaults)
# generate list of config protos
set(_cfg_proto_file ${CMAKE_CURRENT_BINARY_DIR}/config_proto_files.h)
# generate a string with the current config files
set(_cfg_proto_str "const char * config_proto_files[] = { // generated file\n")
foreach(_proto_path ${${cfg_protos}})
get_filename_component(_proto_name ${_proto_path} NAME)
string(APPEND _cfg_proto_str "\"${_proto_name}\",\n")
endforeach(_proto_path)
string(APPEND _cfg_proto_str "} ;\n")
# compare with file and if there is any difference update the file
set(_old_cfg_proto_str "")
if(EXISTS "${_cfg_proto_file}")
file(READ "${_cfg_proto_file}" _old_cfg_proto_str)
endif()
if(NOT _old_cfg_proto_str STREQUAL _cfg_proto_str)
file(WRITE "${_cfg_proto_file}" "${_cfg_proto_str}")
endif()
# generate static defaults
set(_cfg_defaults_file ${CMAKE_CURRENT_BINARY_DIR}/config_defaults.h)
# Defaults cannot be a single string because the compiler complains about a
# string longer than 65k
set(_cfg_defaults_str "const char * config_static_defaults[] = { ")
foreach(_cfg_file_path ${${cfg_defaults}})
file(READ ${_cfg_file_path} _cfg_file_content)
string(REPLACE "\"" "\\\"" _cfg_file_content_escaped ${_cfg_file_content})
string(REPLACE "\n" ";" _cfg_lines ${_cfg_file_content_escaped})
foreach(_line ${_cfg_lines})
string(APPEND _cfg_defaults_str "\n \"${_line}\",")
endforeach(_line)
endforeach(_cfg_file_path)
string(APPEND _cfg_defaults_str "};")
set(_old_cfg_defaults_str "")
if(EXISTS ${_cfg_defaults_file})
file(READ ${_cfg_defaults_file} _old_cfg_defaults_str)
endif()
if(NOT _cfg_defaults_str STREQUAL _old_cfg_defaults_str)
file(WRITE "${_cfg_defaults_file}" "${_cfg_defaults_str}")
endif()
endfunction()
@@ -0,0 +1,23 @@
function(get_link_libraries dest)
set(${dest}
curl
tbb
boost_system
boost_thread
boost_filesystem
boost_regex
boost_chrono
boost_date_time
boost_atomic
protobuf
protoc
ssl
crypto
debug fmtd
optimized fmt
cryptopp
SQLiteCpp
sqlite3
uuid
PARENT_SCOPE)
endfunction()
+172
View File
@@ -0,0 +1,172 @@
function(get_proto_sources cfg_srcs non_cfg_srcs service_srcs cfg_defaults)
file(
GLOB_RECURSE _cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
config/protos/*.proto
api/domain/SecurityMetadataCollection.proto)
file(
GLOB_RECURSE _service_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/services/*.proto)
file(
GLOB_RECURSE _non_cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.proto)
list(REMOVE_ITEM _non_cfg_srcs ${_service_srcs} ${_cfg_srcs})
file(
GLOB_RECURSE _cfg_defaults
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CONFIG_DEFAULTS_PATH})
set(_cfg_defaults)
foreach(cfg_path ${CONFIG_DEFAULTS_PATH})
file(
GLOB_RECURSE cfg_files
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${cfg_path})
list(APPEND _cfg_defaults ${cfg_files})
endforeach()
set(${cfg_srcs} ${_cfg_srcs} PARENT_SCOPE)
set(${non_cfg_srcs} ${_non_cfg_srcs} PARENT_SCOPE)
set(${service_srcs} ${_service_srcs} PARENT_SCOPE)
set(${cfg_defaults} ${_cfg_defaults} PARENT_SCOPE)
endfunction()
function(get_cpp_sources dest)
set(${dest}
api/core/ApiClientInterop.cpp
api/core/ApiServerInterop.cpp
api/md/MarketDataConfigUtils.cpp
api/public/ApiServer.cpp
api/public/ClientChannel.cpp
api/public/QuickbusClientChannel.cpp
api/public/ServerChannel.cpp
api/public/ServiceContext.cpp
api/test/ApiTests.cpp
api/test/HelloServiceServer.cpp
config/ConfigDownloader.cpp
config/ConfigErrorCollector.cpp
config/ConfigPropertyEvaluator.cpp
config/ConfigQuerier.cpp
config/ConfigValueQueue.cpp
config/ConfigurationException.cpp
config/ConfigurationState.cpp
config/PreprocessInputStream.cpp
config/config.cpp
config/tests/HTTPServer.cpp
config/tests/config_ref_tests.cpp
config/tests/config_tests.cpp
config/text_format/text_format.cpp
core/TimeSpan.cpp
core/TimeStamp.cpp
domain/DomainSecurityUtils.cpp
domain/SecurityCriteria.cpp
domain/SecurityCriteriaClause.cpp
domain_model/Security.cpp
domain_model/SecurityTests.cpp
domain_model/sod.cpp
domain_model/tests/domain_tests.cpp
expression/BooleanGrammar.cpp
expression/ExpressionEvaluator.cpp
expression/ParserExceptions.cpp
expression/Value.cpp
expression/tests/expression_parser_tests.cpp
io/http/CurlHandle.cpp
io/http/HTTPClient.cpp
io/http/HTTPHeaders.cpp
io/http/HTTPRequest.cpp
io/http/HTTPResponse.cpp
logging/LoggerHub.cpp
logging/Sink.cpp
logging/logging.cpp
logging/tests/logging_tests.cpp
md/Diag/MDPeriodicDumper.cpp
md/Diag/ShmDumper.cpp
md/MBOProcessor.cpp
md/MBOServiceServer.cpp
md/MDClient.cpp
md/MDConsumer.cpp
md/MDConsumerHandle.cpp
md/MDConsumerInterop.cpp
md/MDProducer.cpp
md/MDProducerHandle.cpp
md/MemorySegmentUtils.cpp
md/PriceSize.cpp
md/Product.cpp
md/SecurityCache.cpp
md/SecurityDB.cpp
md/SecurityIDRecorder.cpp
md/SecurityMapper.cpp
md/SecurityMarketState.cpp
md/SecurityOracle.cpp
md/SecurityStore.cpp
md/SettlementRecorder.cpp
md/Shm/FixedSecurity.cpp
md/SyntheticSecurityService.cpp
md/cme/MDP3Utils.cpp
md/common.cpp
md/ice/ICEUtils.cpp
md/relay/QueryServer.cpp
md/relay/RelayClient.cpp
md/relay/RelayRecorder.cpp
md/service/MarketDataServiceServer.cpp
md/test/Co2ManagedTestHelper.cpp
md/test/Co2TestInstrument.cpp
md/test/mbo_tests.cpp
md/test/md2_tests.cpp
md/test/md_test_utils.cpp
md/test/synthetic_book_merge_tests.cpp
os/os.cpp
os/tests/os_tests.cpp
quickbus/core/LocalNode.cpp
quickbus/core/Quickbus.cpp
quickbus/core/SubscriptionID.cpp
quickbus/core/TableID.cpp
quickbus/message_model/Update.cpp
quickbus/message_model/merge_updates.cpp
quickbus/network/QBConnection.cpp
quickbus/network/QBConnectionManager.cpp
quickbus/network/endpoint_description.cpp
quickbus/pubsub/TablePublisher.cpp
quickbus/pubsub/TableSubscriber.cpp
quickbus/pubsub/tests/qb_pubsub_tests.cpp
quickbus/routing/INode.cpp
quickbus/routing/NodeID.cpp
quickbus/routing/Router.cpp
quickbus/rpc/RPCClient.cpp
quickbus/rpc/RPCServer.cpp
quickbus/rpc/RPCSessionID.cpp
quickbus/rpc/rpc_utils.cpp
quickbus/rpc/tests/qb_rpc_tests.cpp
quickbus/tests/quickbus_tests.cpp
testing/catch_test_runner.cpp
utils/AuthSessionManager.cpp
utils/AuthToken.cpp
utils/Dispatcher.cpp
utils/FileUtils.cpp
utils/GrowableSPSCQueue.cpp
utils/HTTPStream.cpp
utils/MathUtils.cpp
utils/PBUtils.cpp
utils/Puid.cpp
utils/SecureLogon.cpp
utils/SharedMemory.cpp
utils/Sqlite_utils.cpp
utils/Uuid.cpp
utils/datetime.cpp
utils/download.cpp
utils/file_utils.cpp
utils/init_spark_lib.cpp
utils/is_unittest_environment.cpp
utils/sftp.cpp
utils/stats.cpp
utils/tests/AuthTokenTests.cpp
utils/tests/IDGeneratorTests.cpp
utils/tests/MathUtilsTests.cpp
utils/tests/SingleWriterConcurrentVectorTests.cpp
utils/thread_manager.cpp
PARENT_SCOPE)
endfunction()
@@ -0,0 +1,35 @@
function(get_link_libraries dest)
find_package(fmt CONFIG REQUIRED)
set(${dest}
protobuf
double-conversion
boost_system
boost_thread
boost_filesystem
boost_regex
boost_chrono
boost_date_time
boost_atomic
SQLiteCpp
sqlite3
curl
uuid
ssl
crypto
fmt::fmt-header-only
tbb
cryptopp
pugixml
lttng-ust
Pcap++
Packet++
Common++
ssh2
-lrt
-ldl
-lpcap
-static-libgcc
-static-libstdc++
-pthread
PARENT_SCOPE)
endfunction()
+39
View File
@@ -0,0 +1,39 @@
function(get_proto_sources cfg_srcs non_cfg_srcs service_srcs cfg_defaults)
file(
GLOB_RECURSE _cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
config/protos/*.proto
api/domain/SecurityMetadataCollection.proto
api/md/MarketDataConfig.proto)
file(
GLOB_RECURSE _service_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/services/*.proto)
file(
GLOB_RECURSE _non_cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.proto)
list(REMOVE_ITEM _non_cfg_srcs ${_service_srcs} ${_cfg_srcs})
set(_cfg_defaults)
foreach(cfg_path ${CONFIG_DEFAULTS_PATH})
file(
GLOB_RECURSE cfg_files
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${cfg_path})
list(APPEND _cfg_defaults ${cfg_files})
endforeach()
set(${cfg_srcs} ${_cfg_srcs} PARENT_SCOPE)
set(${non_cfg_srcs} ${_non_cfg_srcs} PARENT_SCOPE)
set(${service_srcs} ${_service_srcs} PARENT_SCOPE)
set(${cfg_defaults} ${_cfg_defaults} PARENT_SCOPE)
endfunction()
function(get_cpp_sources dest)
file(
GLOB_RECURSE _dest
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.cpp)
set(${dest} ${_dest} PARENT_SCOPE)
endfunction()
@@ -0,0 +1,20 @@
function(get_link_libraries dest)
find_package(fmt CONFIG REQUIRED)
set(${dest}
crypt32
fmt::fmt-header-only
libcrypto
libcurl
libboost_system
libboost_thread
libboost_filesystem
libboost_regex
libboost_chrono
libboost_date_time
libboost_atomic
libprotobuf
libprotoc
libssl
libtbb
PARENT_SCOPE)
endfunction()
+162
View File
@@ -0,0 +1,162 @@
function(get_proto_sources cfg_srcs non_cfg_srcs service_srcs cfg_defaults)
file(
GLOB_RECURSE _cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
config/protos/*.proto
api/domain/SecurityMetadataCollection.proto)
file(
GLOB_RECURSE _service_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
api/services/*.proto)
file(
GLOB_RECURSE _non_cfg_srcs
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
*.proto)
list(REMOVE_ITEM _non_cfg_srcs ${_service_srcs} ${_cfg_srcs})
file(
GLOB_RECURSE _cfg_defaults
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CONFIG_DEFAULTS_PATH})
set(_cfg_defaults)
foreach(cfg_path ${CONFIG_DEFAULTS_PATH})
file(
GLOB_RECURSE cfg_files
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${cfg_path})
list(APPEND _cfg_defaults ${cfg_files})
endforeach()
set(${cfg_srcs} ${_cfg_srcs} PARENT_SCOPE)
set(${non_cfg_srcs} ${_non_cfg_srcs} PARENT_SCOPE)
set(${service_srcs} ${_service_srcs} PARENT_SCOPE)
set(${cfg_defaults} ${_cfg_defaults} PARENT_SCOPE)
endfunction()
function(get_cpp_sources dest)
set(${dest}
api/core/ApiClientInterop.cpp
api/core/ApiServerInterop.cpp
api/public/ApiServer.cpp
api/public/ClientChannel.cpp
api/public/QuickbusClientChannel.cpp
api/public/ServerChannel.cpp
api/public/ServiceContext.cpp
api/test/ApiTests.cpp
api/test/HelloServiceServer.cpp
config/ConfigCheck.cpp
config/ConfigDownloader.cpp
config/ConfigErrorCollector.cpp
config/ConfigPropertyEvaluator.cpp
config/ConfigValueQueue.cpp
config/ConfigurationException.cpp
config/ConfigurationState.cpp
config/PreprocessInputStream.cpp
config/ConfigLog.cpp
config/config.cpp
config/tests/HTTPServer.cpp
config/tests/config_ref_tests.cpp
config/tests/config_tests.cpp
config/text_format/text_format.cpp
domain_model/Security.cpp
domain_model/SecurityTests.cpp
domain_model/sod.cpp
domain_model/tests/domain_tests.cpp
expression/BooleanGrammar.cpp
expression/ExpressionEvaluator.cpp
expression/ParserExceptions.cpp
expression/Value.cpp
expression/tests/expression_parser_tests.cpp
logging/LoggerHub.cpp
logging/Sink.cpp
logging/logging.cpp
logging/tests/logging_tests.cpp
md/Diag/MDPeriodicDumper.cpp
md/Diag/ShmDumper.cpp
md/MBOProcessor.cpp
md/MBOServiceServer.cpp
md/MDClient.cpp
md/MDConsumer.cpp
md/MDConsumerHandle.cpp
md/MDConsumerInterop.cpp
md/MDProducer.cpp
md/MDProducerHandle.cpp
md/MarketDataError.cpp
md/MarketDataGateway.cpp
md/MarketDataRegistrationFactory.cpp
md/MemorySegmentUtils.cpp
md/PlatformLoader.cpp
md/PriceSize.cpp
md/Product.cpp
md/SecurityCache.cpp
md/SecurityDB.cpp
md/SecurityMapper.cpp
md/SecurityMarketState.cpp
md/SecurityOracle.cpp
md/SecurityStore.cpp
md/Shm/FixedSecurity.cpp
md/SyntheticSecurityService.cpp
md/cme/MDP3Utils.cpp
md/common.cpp
md/ice/ICEUtils.cpp
md/relay/QueryServer.cpp
md/relay/RelayClient.cpp
md/relay/RelayRecorder.cpp
md/service/MarketDataServiceServer.cpp
md/test/Co2ManagedTestHelper.cpp
md/test/Co2TestInstrument.cpp
md/test/mbo_tests.cpp
md/test/md2_tests.cpp
md/test/md_test_utils.cpp
md/test/synthetic_book_merge_tests.cpp
os/os.cpp
os/tests/os_tests.cpp
quickbus/core/LocalNode.cpp
quickbus/core/Quickbus.cpp
quickbus/core/SubscriptionID.cpp
quickbus/core/TableID.cpp
quickbus/message_model/Update.cpp
quickbus/message_model/merge_updates.cpp
quickbus/network/QBConnection.cpp
quickbus/network/QBConnectionManager.cpp
quickbus/network/endpoint_description.cpp
quickbus/pubsub/TablePublisher.cpp
quickbus/pubsub/TableSubscriber.cpp
quickbus/pubsub/tests/qb_pubsub_tests.cpp
quickbus/routing/INode.cpp
quickbus/routing/NodeID.cpp
quickbus/routing/Router.cpp
quickbus/rpc/RPCClient.cpp
quickbus/rpc/RPCServer.cpp
quickbus/rpc/RPCSessionID.cpp
quickbus/rpc/rpc_utils.cpp
quickbus/rpc/tests/qb_rpc_tests.cpp
quickbus/tests/quickbus_tests.cpp
testing/catch_test_runner.cpp
utils/AuthSessionManager.cpp
utils/AuthToken.cpp
utils/Dispatcher.cpp
utils/FileUtils.cpp
utils/GrowableSPSCQueue.cpp
utils/HTTPStream.cpp
utils/MathUtils.cpp
utils/PBUtils.cpp
utils/Puid.cpp
utils/SecureLogon.cpp
utils/SharedMemory.cpp
utils/Uuid.cpp
utils/datetime.cpp
utils/download.cpp
utils/file_utils.cpp
utils/init_spark_lib.cpp
utils/is_unittest_environment.cpp
utils/sftp.cpp
utils/stats.cpp
utils/tests/AuthTokenTests.cpp
utils/tests/MathUtilsTests.cpp
utils/tests/SingleWriterConcurrentVectorTests.cpp
utils/thread_manager.cpp
PARENT_SCOPE)
endfunction()
+2 -2
View File
@@ -141,7 +141,7 @@ void ConfigValueQueue::assign(
if (field->is_repeated()) {
for (vector<Value>::iterator i = v.begin(); i != v.end(); ++i) {
int size = reflection->FieldSize(*message, field);
add(
add<TProto>(
message, reflection, field, (TProto)boost::get<TValue>(*i));
if (index != size) {
for (int i = index; i < size; ++i) {
@@ -182,7 +182,7 @@ void ConfigValueQueue::lexical_assign(
for (vector<Value>::iterator i = v.begin(); i != v.end(); ++i) {
int size = reflection->FieldSize(*message, field);
TProto result = boost::lexical_cast<TProto>(boost::get<TValue>(*i));
add(message, reflection, field, result);
add<TProto>(message, reflection, field, result);
if (index != size) {
for (int i = index; i < size; ++i) {
reflection->SwapElements(message, field, i, size);
+2 -2
View File
@@ -29,7 +29,7 @@
#include "lib/config_defaults.h"
#include "lib/config_proto_files.h"
#ifdef WIN32
#ifdef _WIN32
#include <Winsock2.h>
#include <d2d1.h>
#else
@@ -566,7 +566,7 @@ void ConfigurationState::generate_all_config_proto(
&bts_config_dp, config_message, message_desc, ++field_number);
}
} else {
#ifdef WIN32
#ifdef _WIN32
// on linux the linker might throw away config protos that
// are not used in sparkd. On windows we build a dll so that
// should not happen
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#define BITWISE_OP(enum_type, numeric_type, op) \
enum_type operator op(enum_type lhs, enum_type rhs) noexcept { \
return static_cast<enum_type>(static_cast<numeric_type>(lhs) \
op static_cast<numeric_type>(rhs)); \
}
#define BITWISE_OPS(enum_type, numeric_type) \
BITWISE_OP(enum_type, numeric_type, |) \
BITWISE_OP(enum_type, numeric_type, &) \
BITWISE_OP(enum_type, numeric_type, ^)
#define HAS_FLAG(enum_value, flag) (enum_value & flag) == flag
#define STRIP_FLAG(enum_value, flag) (enum_value | flag) ^ flag
-154
View File
@@ -1,154 +0,0 @@
#pragma once
#define ENUM_BASIC_MEMBERS(type) \
Value value; \
\
type() = default; \
/*NOLINTNEXTLINE*/ \
constexpr type(Value value) noexcept : value(value) {} \
\
type(const type &) noexcept = default; \
type(type &&) noexcept = default; \
type &operator=(const type &) noexcept = default; \
type &operator=(type &&) noexcept = default; \
\
~type() = default; \
\
static constexpr bool parse(const char *name, type *value) noexcept; \
static bool parse(const std::string &name, type *value) noexcept; \
\
[[nodiscard]] constexpr const char *name() const noexcept;
#define ENUM_VALUE_TO_NAME_CASE(type, v) \
case type::v: \
return #v;
#define ENUM_NAME_TO_VALUE_CLAUSE(type, v) \
if (name == #v) { \
*value = type::v; \
return true; \
}
#define ENUM_NAMEC_TO_VALUE_CLAUSE(type, v) \
if (std::string_view(name) == #v) { \
*value = type::v; \
return true; \
}
// clang-format off
#define ENUM_NAME_DEF(type, for_all) \
constexpr const char *type::name() const noexcept { \
switch (value) { \
for_all(ENUM_VALUE_TO_NAME_CASE) \
default: return "ENUM_UNKNOWN"; \
} \
}
// clang-format on
#define ENUM_PARSE_DEF(type, for_all) \
constexpr bool type::parse(const char *name, type *value) noexcept { \
for_all(ENUM_NAMEC_TO_VALUE_CLAUSE) return false; \
} \
inline bool type::parse(const std::string &name, type *value) noexcept { \
for_all(ENUM_NAME_TO_VALUE_CLAUSE) return false; \
}
#define ENUM_EQUALITY_OPS(type) \
constexpr bool operator==(type lhs, type rhs) noexcept { \
return lhs.value == rhs.value; \
} \
constexpr bool operator!=(type lhs, type rhs) noexcept { \
return lhs.value != rhs.value; \
} \
constexpr bool operator==(type lhs, type::Value rhs) noexcept { \
return lhs.value == rhs; \
} \
constexpr bool operator!=(type lhs, type::Value rhs) noexcept { \
return lhs.value != rhs; \
}
#define ENUM_OUTPUT_OPS(type) \
inline std::ostream &operator<<(std::ostream &out, type value) noexcept { \
out << value.name(); \
return out; \
} \
\
inline std::ostream &operator<<( \
std::ostream &out, type::Value value) noexcept { \
out << type{value}.name(); \
return out; \
}
#define ENUM_FROM_JSON(type) \
inline void from_json(const nlohmann::json &j, type &value) { \
std::string value_str; \
j.get_to(value_str); \
type::parse(value_str, &value); \
}
#define ENUM_TO_JSON(type) \
inline void to_json(nlohmann::json &j, const type &value) { \
j = value.name(); \
}
#define ENUM_DECLARE_VALUE(t, x) x,
#define ENUM_CLASS_DEF(type, for_all) \
class type { \
public: \
enum Value { for_all(ENUM_DECLARE_VALUE) }; \
\
ENUM_BASIC_MEMBERS(type) \
}; \
\
ENUM_OUTPUT_OPS(type) \
ENUM_NAME_DEF(type, for_all) \
ENUM_PARSE_DEF(type, for_all) \
ENUM_FROM_JSON(type) \
ENUM_TO_JSON(type) \
ENUM_EQUALITY_OPS(type)
#define ENUM_BITWISE_COMPARISON_OP(enum_type, numeric_type, op) \
constexpr enum_type operator op(enum_type lhs, enum_type rhs) noexcept { \
return static_cast<enum_type>(static_cast<numeric_type>(lhs) \
op static_cast<numeric_type>(rhs)); \
}
#define ENUM_BITWISE_COMPARISON_OPS(enum_type, numeric_type) \
ENUM_BITWISE_COMPARISON_OP(enum_type, numeric_type, |) \
ENUM_BITWISE_COMPARISON_OP(enum_type, numeric_type, &) \
ENUM_BITWISE_COMPARISON_OP(enum_type, numeric_type, ^)
#define ENUM_BITWISE_ASSIGNMENT_OP(enum_type, op) \
inline enum_type &operator op##=(enum_type &lhs, enum_type rhs) noexcept { \
lhs = lhs op rhs; \
return lhs; \
}
#define ENUM_BITWISE_ASSIGNMENT_OPS(enum_type) \
ENUM_BITWISE_ASSIGNMENT_OP(enum_type, |) \
ENUM_BITWISE_ASSIGNMENT_OP(enum_type, &) \
ENUM_BITWISE_ASSIGNMENT_OP(enum_type, ^)
#define ENUM_BITWISE_OPS(enum_type, numeric_type) \
ENUM_BITWISE_COMPARISON_OPS(enum_type, numeric_type) \
ENUM_BITWISE_ASSIGNMENT_OPS(enum_type)
#define ENUM_HAS_FLAG(enum_value, flag) (enum_value & flag) == flag
#define ENUM_STRIP_FLAG(enum_value, flag) (enum_value | flag) ^ flag
#define PB_ENUM_FROM_JSON(enum_type) \
inline void from_json(const nlohmann::json &j, enum_type &value) { \
io::JsonReader jr{&j}; \
std::string name; \
bool success = jr.read(name) && enum_type##_Parse(name, &value); \
if (!success) { \
const auto j_str = j.dump(2); \
LOG(Gen, Diag, "Failed to parse json to " #enum_type ":\n{}", j_str); \
} \
}
#define PB_ENUM_TO_JSON(enum_type) \
inline void to_json(nlohmann::json &j, const enum_type &value) { \
j = enum_type##_Name(value); \
}
-34
View File
@@ -1,34 +0,0 @@
#pragma once
#include <fmt/core.h>
#include <fmt/format.h>
#ifndef _WIN32
#include <range/v3/view.hpp>
#endif
#include <vector>
#define FMT(template_str, ...) fmt::format(template_str, __VA_ARGS__)
#define FMT_JOIN(range, delimiter) \
fmt::to_string(fmt::join(range.begin(), range.end(), delimiter))
namespace bts {
template <class Range>
std::string _fmt_join(Range range, const char *delimiter) {
return fmt::join(range.begin(), range.end(), delimiter);
}
#ifndef _WIN32
template <class Range, class Op>
std::string _fmt_join_fn(Range range, const char *delimiter, Op op) {
return fmt::to_string(
fmt::join(range | ranges::views::transform(op), delimiter));
}
#endif
} // namespace bts
#ifndef _WIN32
#define FMT_JOIN_FN(range, delimiter, fn) \
bts::_fmt_join_fn(range, delimiter, fn)
#endif
-65
View File
@@ -1,65 +0,0 @@
#pragma once
#include <fmt/format.h>
#define FMT_IMPL(Type, var_name, ...) \
template <> \
struct fmt::formatter<Type> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const Type &var_name, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
return fmt::format_to(ctx.out(), __VA_ARGS__); \
} \
}
#define FMT_IMPL_T(Type, var_name, ...) \
struct fmt::formatter<Type> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const Type &var_name, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
return fmt::format_to(ctx.out(), __VA_ARGS__); \
} \
}
#define FMT_IMPL_OSTREAM(T) \
template <> \
struct fmt::formatter<T> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const T &t, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
std::stringstream ss; \
ss << t; \
return fmt::format_to(ctx.out(), "{}", ss.str()); \
} \
}
#define FMT_IMPL_OSTREAM_T(T, ...) \
struct fmt::formatter<T<__VA_ARGS__>> { \
constexpr auto parse(fmt::format_parse_context &ctx) \
-> decltype(ctx.end()) { \
return ctx.end(); \
} \
\
template <typename FormatContext> \
auto format(const T<__VA_ARGS__> &t, FormatContext &ctx) const \
-> decltype(ctx.out()) { \
std::stringstream ss; \
ss << t; \
return fmt::format_to(ctx.out(), "{}", ss.str()); \
} \
}
+2 -2
View File
@@ -132,7 +132,7 @@ std::size_t HashPhaser::auto_phase_range(Iter first, Iter last) {
std::uint16_t el_count =
num_vals > (std::numeric_limits<std::uint16_t>::max)()
? max_els
: (static_cast<std::uint16_t>(num_vals) > max_els ? static_cast<std::uint16_t>(num_vals) : max_els);
: std::max(static_cast<std::uint16_t>(num_vals), max_els);
auto bits_per_hash = (sizeof(std::size_t) * __CHAR_BIT__) / el_count;
std::size_t phase = 1U << (bits_per_hash - 1);
std::size_t composite_hash = 0;
@@ -157,7 +157,7 @@ std::size_t HashPhaser::auto_phase_range(Iter first, Iter last, Hash hash) {
std::uint16_t el_count =
num_vals > (std::numeric_limits<std::uint16_t>::max)()
? max_els
: (static_cast<std::uint16_t>(num_vals) > max_els ? static_cast<std::uint16_t>(num_vals) : max_els);
: std::max(static_cast<std::uint16_t>(num_vals), max_els);
auto bits_per_hash = (sizeof(std::size_t) * __CHAR_BIT__) / el_count;
std::size_t phase = 1U << (bits_per_hash - 1);
std::size_t composite_hash = 0;
-26
View File
@@ -1,26 +0,0 @@
#include "TimeSpan.h"
#include <boost/date_time/posix_time/time_formatters.hpp>
#include <boost/date_time/posix_time/time_parsers.hpp>
namespace bts::core {
TimeSpan TimeSpan::from_iso_string(const std::string &iso_string) {
const auto pdur = boost::posix_time::duration_from_string(iso_string);
return from_posix_duration(pdur);
}
std::string TimeSpan::to_iso_string() const {
const auto pdur = to_posix_duration();
return boost::posix_time::to_iso_string(pdur);
}
std::ostream &operator<<(std::ostream &out, const TimeSpan &ts) noexcept {
out << ts.to_iso_string();
return out;
}
TimeSpan TimeSpan::from_posix_duration(boost::posix_time::time_duration d) {
return TimeSpan{d.total_nanoseconds()};
}
} // namespace bts::core
-125
View File
@@ -1,125 +0,0 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/date_time/posix_time/posix_time_config.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/time.hpp>
#include <chrono>
#include <cstdint>
#include <fmt/format.h>
#include <string>
namespace bts::core {
/**
* @brief Represents a duration of time
*/
class TimeSpan {
public:
constexpr TimeSpan() = default;
explicit constexpr TimeSpan(std::int64_t ticks);
static constexpr TimeSpan zero();
static constexpr TimeSpan from_nanos(std::int64_t value);
static constexpr TimeSpan from_micros(std::int64_t value);
static constexpr TimeSpan from_millis(std::int64_t value);
static constexpr TimeSpan from_seconds(std::int64_t value);
static TimeSpan from_posix_duration(boost::posix_time::time_duration t);
static TimeSpan from_iso_string(const std::string &iso_string);
constexpr std::int64_t nanos() const;
constexpr std::int64_t micros() const;
constexpr std::int64_t millis() const;
constexpr std::int64_t seconds() const;
constexpr double total_millis() const;
constexpr double total_seconds() const;
constexpr boost::posix_time::time_duration to_posix_duration() const;
std::string to_iso_string() const;
private:
// nanos
std::int64_t ticks_{};
};
constexpr bool operator==(TimeSpan lhs, TimeSpan rhs) noexcept;
constexpr bool operator!=(TimeSpan lhs, TimeSpan rhs) noexcept;
constexpr bool operator<(TimeSpan lhs, TimeSpan rhs) noexcept;
constexpr bool operator>(TimeSpan lhs, TimeSpan rhs) noexcept;
std::ostream &operator<<(std::ostream &out, const TimeSpan &ts) noexcept;
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
constexpr TimeSpan::TimeSpan(std::int64_t ticks) : ticks_(ticks) {}
constexpr TimeSpan TimeSpan::zero() { return TimeSpan{0}; }
constexpr TimeSpan TimeSpan::from_nanos(std::int64_t value) {
return TimeSpan{value};
}
constexpr TimeSpan TimeSpan::from_micros(std::int64_t value) {
constexpr const auto nanos_per_micro = 1'000;
return TimeSpan{value * nanos_per_micro};
}
constexpr TimeSpan TimeSpan::from_millis(std::int64_t value) {
constexpr const auto nanos_per_milli = 1'000'000;
return TimeSpan{value * nanos_per_milli};
}
constexpr TimeSpan TimeSpan::from_seconds(std::int64_t value) {
constexpr const auto nanos_per_second = 1'000'000'000;
return TimeSpan{value * nanos_per_second};
}
constexpr std::int64_t TimeSpan::nanos() const { return ticks_; }
constexpr std::int64_t TimeSpan::micros() const { return ticks_ / 1'000; }
constexpr std::int64_t TimeSpan::millis() const { return ticks_ / 1'000'000; }
constexpr std::int64_t TimeSpan::seconds() const {
return ticks_ / 1'000'000'000;
}
constexpr double TimeSpan::total_millis() const {
return static_cast<double>(ticks_) / 1000'000;
}
constexpr double TimeSpan::total_seconds() const {
return static_cast<double>(ticks_) / 1000'000'000;
}
constexpr boost::posix_time::time_duration TimeSpan::to_posix_duration() const {
return boost::date_time::subsecond_duration<
boost::posix_time::time_duration, 1000000000>{nanos()};
}
constexpr bool operator==(TimeSpan lhs, TimeSpan rhs) noexcept {
return lhs.nanos() == rhs.nanos();
}
constexpr bool operator!=(TimeSpan lhs, TimeSpan rhs) noexcept {
return lhs.nanos() != rhs.nanos();
}
constexpr bool operator<(TimeSpan lhs, TimeSpan rhs) noexcept {
return lhs.nanos() < rhs.nanos();
}
constexpr bool operator>(TimeSpan lhs, TimeSpan rhs) noexcept {
return lhs.nanos() > rhs.nanos();
}
} // namespace bts::core
FMT_IMPL(bts::core::TimeSpan, t, "{}", t.to_iso_string());
-58
View File
@@ -1,58 +0,0 @@
#include "TimeStamp.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/time_formatters.hpp>
namespace bts::core {
using std::uint32_t;
static bool is_valid_ymd(uint32_t year, uint32_t month, uint32_t day) {
return year >= 1970 && month >= 1 && month <= 12 && day >= 1 && day <= 31;
}
TimeStamp::TimeStamp(uint32_t year, uint32_t month, uint32_t day) {
bts_assert_msgf(
is_valid_ymd(year, month, day), "Invalid timestamp {}/{}/{} (y/m/d)",
year, month, day);
std::tm date = {};
date.tm_year = year - 1900;
date.tm_mon = month - 1;
date.tm_mday = day;
auto time = std::chrono::system_clock::from_time_t(mktime(&date));
auto duration = time.time_since_epoch();
value_ =
std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();
}
bool TimeStamp::from_ymd(
std::uint32_t year, std::uint32_t month, std::uint32_t day, TimeStamp *result) {
if (!is_valid_ymd(year, month, day)) {
return false;
}
*result = TimeStamp{year, month, day};
return true;
}
TimeStamp TimeStamp::from_iso_string(const std::string &iso_string) {
auto ptime = datetime::parse_iso_date_time_string(iso_string);
return from_ptime(ptime);
}
std::string TimeStamp::to_iso_string() const {
return boost::posix_time::to_iso_string(to_ptime());
}
std::ostream &operator<<(std::ostream &out, const TimeStamp &ts) noexcept {
out << ts.to_iso_string();
return out;
}
TimeStamp TimeStamp::from_ptime(boost::posix_time::ptime t) {
// time_t is Unix time: number of seconds since epoch Jan 1, 1970
auto epoch_pt =
t - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1));
auto epoch_nanos = epoch_pt.total_nanoseconds();
return TimeStamp{static_cast<std::uint64_t>(epoch_nanos)};
}
} // namespace bts::core
+2 -186
View File
@@ -1,211 +1,27 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/core/TimeSpan.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
#include <boost/date_time/posix_time/ptime.hpp>
#include <boost/date_time/time.hpp>
#include <chrono>
#include <cstdint>
#include <fmt/format.h>
#include <limits>
#include <string>
namespace bts::core {
/**
* @brief Represents time as nano-seconds since the unix epoch (Jan 1, 1970)
*/
// I can send this whole class later but its a nice wrapper around the linux
// posix time
struct TimeStamp {
public:
constexpr TimeStamp() = default;
explicit constexpr TimeStamp(std::uint64_t value);
// constructs a TimeStamp from a UTC date
explicit TimeStamp(uint32_t year, uint32_t month, uint32_t day);
static constexpr TimeStamp min();
static constexpr TimeStamp max();
static constexpr TimeStamp from_int64(std::int64_t value);
static constexpr TimeStamp from_nanos(std::int64_t value);
static constexpr TimeStamp from_micros(std::int64_t value);
static constexpr TimeStamp from_millis(std::int64_t value);
static constexpr TimeStamp from_seconds(std::int64_t value);
static TimeStamp from_ptime(boost::posix_time::ptime t);
static TimeStamp from_iso_string(const std::string &iso_string);
static bool from_ymd(
std::uint32_t year,
std::uint32_t month,
std::uint32_t day,
TimeStamp *result);
constexpr std::uint64_t nanos() const;
constexpr std::uint64_t micros() const;
constexpr std::uint64_t millis() const;
constexpr std::uint64_t seconds() const;
constexpr double total_millis() const;
constexpr double total_seconds() const;
constexpr std::int64_t to_int64();
inline void to_date(uint32_t &year, uint32_t &month, uint32_t &day);
constexpr boost::posix_time::ptime to_ptime() const;
std::string to_iso_string() const;
// current epoch ns
static uint64_t now_ns() {
#ifndef _WIN32
return datetime::unix_nano_now();
#else
auto now = std::chrono::system_clock::now();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
now.time_since_epoch())
.count();
return ns;
#endif
}
static TimeStamp now() { return from_nanos(now_ns()); }
private:
// posix time
std::uint64_t value_{};
};
constexpr bool operator==(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr bool operator!=(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr bool operator<(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr bool operator<=(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr bool operator>(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr bool operator>=(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr TimeSpan operator-(TimeStamp lhs, TimeStamp rhs) noexcept;
constexpr TimeStamp operator-(TimeStamp lhs, TimeSpan rhs) noexcept;
constexpr TimeStamp operator+(TimeStamp lhs, TimeSpan rhs) noexcept;
std::ostream &operator<<(std::ostream &out, const TimeStamp &ts) noexcept;
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
constexpr TimeStamp::TimeStamp(std::uint64_t value) : value_(value) {}
constexpr TimeStamp TimeStamp::min() { return TimeStamp{0}; }
constexpr TimeStamp TimeStamp::max() {
return TimeStamp{std::numeric_limits<std::uint64_t>::max()};
}
constexpr TimeStamp TimeStamp::from_int64(std::int64_t value) {
bts_assert(value >= 0);
return TimeStamp{static_cast<std::uint64_t>(value)};
}
constexpr TimeStamp TimeStamp::from_nanos(std::int64_t value) {
bts_assert(value >= 0);
return TimeStamp{static_cast<std::uint64_t>(value)};
}
constexpr TimeStamp TimeStamp::from_micros(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_micro = 1'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_micro)};
}
constexpr TimeStamp TimeStamp::from_millis(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_milli = 1'000'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_milli)};
}
constexpr TimeStamp TimeStamp::from_seconds(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_second = 1'000'000'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_second)};
}
constexpr std::uint64_t TimeStamp::nanos() const { return value_; }
constexpr std::uint64_t TimeStamp::micros() const { return value_ / 1'000; }
constexpr std::uint64_t TimeStamp::millis() const { return value_ / 1'000'000; }
constexpr std::uint64_t TimeStamp::seconds() const {
return value_ / 1'000'000'000;
}
constexpr double TimeStamp::total_millis() const {
return static_cast<double>(value_) / 1000'000;
}
constexpr double TimeStamp::total_seconds() const {
return static_cast<double>(value_) / 1000'000'000;
}
constexpr std::int64_t TimeStamp::to_int64() {
bts_assert(
value_ <=
static_cast<std::uint64_t>(std::numeric_limits<std::int64_t>::max()));
return static_cast<std::int64_t>(value_);
}
void TimeStamp::to_date(uint32_t &year, uint32_t &month, uint32_t &day) {
std::uint64_t epoch_secs = value_ / (1000 * 1000 * 1000);
time_t ts_tt(epoch_secs);
struct tm *ptm = gmtime(&ts_tt);
year = ptm->tm_year + 1900;
month = ptm->tm_mon + 1;
day = ptm->tm_mday;
}
constexpr boost::posix_time::ptime TimeStamp::to_ptime() const {
constexpr const auto nanos_per_sec = 1'000'000'000;
constexpr const auto nanos_per_micro = 1'000;
// time_t is Unix time: number of seconds since epoch Jan 1, 1970
std::time_t ts = value_ / nanos_per_sec;
const auto nanos_rem = value_ % nanos_per_sec;
return boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1)) +
boost::posix_time::seconds(static_cast<long>(ts)) +
boost::posix_time::microseconds(nanos_rem / nanos_per_micro);
}
constexpr bool operator==(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() == rhs.nanos();
}
constexpr bool operator!=(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() != rhs.nanos();
}
constexpr bool operator<(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() < rhs.nanos();
}
constexpr bool operator<=(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() <= rhs.nanos();
}
constexpr bool operator>(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() > rhs.nanos();
}
constexpr bool operator>=(TimeStamp lhs, TimeStamp rhs) noexcept {
return lhs.nanos() >= rhs.nanos();
}
constexpr TimeSpan operator-(TimeStamp lhs, TimeStamp rhs) noexcept {
return TimeSpan::from_nanos(lhs.nanos() - rhs.nanos());
}
constexpr TimeStamp operator-(TimeStamp lhs, TimeSpan rhs) noexcept {
return TimeStamp{lhs.nanos() - rhs.nanos()};
}
constexpr TimeStamp operator+(TimeStamp lhs, TimeSpan rhs) noexcept {
return TimeStamp{lhs.nanos() + rhs.nanos()};
}
} // namespace bts::core
FMT_IMPL(bts::core::TimeStamp, t, "{}", t.to_iso_string());
-6
View File
@@ -1,14 +1,10 @@
#pragma once
#include "Side.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/bts_assert.h"
#include <cmath>
#include <cstdint>
#include <limits>
#include <ostream>
#include <string>
#if bts_assert_msg
#define __ASSERT_MSG(EXP, msg) bts_assert_msg(EXP, msg)
@@ -494,8 +490,6 @@ inline std::ostream &operator<<(std::ostream &out, Price p) noexcept {
} // namespace bts::domain
FMT_IMPL(bts::domain::Price, p, "{}", p.to_double());
namespace std { // NOLINT
constexpr size_t hash<bts::domain::Price>::operator()(
-6
View File
@@ -1,9 +1,5 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/logging/logging.h"
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
namespace bts::domain {
@@ -114,5 +110,3 @@ QTY_UINT32_BIN_REF_OP(%=)
#undef QTY_UINT32_BIN_REF_OP
} // namespace bts::domain
FMT_IMPL(bts::domain::Quantity, q, "{}", *q);
-4
View File
@@ -1,6 +1,4 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
@@ -9,5 +7,3 @@ namespace bts::domain {
using SecurityID = utils::ValueWrapper<struct SecuirtyIDTag, std::uint64_t>;
} // namespace bts::domain
FMT_IMPL(bts::domain::SecurityID, id, "{}", *id);
+4 -7
View File
@@ -1,16 +1,13 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/domain_model/Side.h"
#include "lib/domain_model/Venue.h"
#include "lib/domain_model/common.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <cmath>
#include <memory>
#include "lib/domain_model/Security.pb.h"
#include "lib/domain_model/common.h"
#include "lib/utils/bts_assert.h"
namespace boost {
namespace gregorian {
class date;
+8 -2
View File
@@ -1,5 +1,11 @@
#pragma once
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
namespace bts {
using SecurityKey = utils::ValueWrapper<struct SecurityKeyTag, uint32_t>;
}
using SecurityKey = utils::ValueWrapper<struct SecurityKeyTag, std::uint32_t>;
} // namespace bts
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api {
PB_ENUM_FROM_JSON(Side)
PB_ENUM_TO_JSON(Side)
} // namespace bts::api
FMT_IMPL(bts::api::Side, s, "{}", bts::api::Side_Name(s));
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include <nlohmann/json.hpp>
namespace bts::api {
PB_ENUM_FROM_JSON(Venue)
PB_ENUM_TO_JSON(Venue)
} // namespace bts::api
FMT_IMPL(bts::api::Venue, v, "{}", bts::api::Venue_Name(v));
+1 -5
View File
@@ -1,12 +1,11 @@
#pragma once
#ifndef WIN32
#ifndef _WIN32
#include <bits/stdint-uintn.h>
#endif
#include <cstdint>
#include <string>
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/SecurityKey.h"
#include "lib/utils/ValueWrapper.h"
@@ -103,6 +102,3 @@ using Price = utils::ValueWrapper<struct OrderPriceTag, double>;
using Quantity = CQuantity;
using UserLogin = utils::ValueWrapper<struct UserLoginTag, std::string>;
} // namespace bts
FMT_IMPL(bts::Price, p, "{}", p.value());
FMT_IMPL(bts::Quantity, q, "{}", q.value());
-48
View File
@@ -1,48 +0,0 @@
#pragma once
#include <nlohmann/json.hpp>
#include <sstream>
#include <string>
namespace bts::io {
class JsonDumper {
public:
template <class T>
static std::string dump(const T &value, int indentation = 2);
template <class Iter>
static std::string dump(
Iter first,
Iter last,
int indentation = 2,
const char *separator = ",\n");
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
template <class T>
std::string JsonDumper::dump(const T &value, int indentation) {
nlohmann::json j;
to_json(j, value);
return j.dump(indentation);
}
template <class Iter>
std::string JsonDumper::dump(
Iter first, Iter last, int indentation, const char *separator) {
if (first == last) {
return "";
}
std::stringstream str;
auto it = first;
str << "[" << dump(*it, indentation);
while (++it != last) {
str << separator << dump(*it, indentation);
}
str << "]";
return str.str();
}
} // namespace bts::io
-22
View File
@@ -1,22 +0,0 @@
#pragma once
#define _TO_JSON_FIELD(field) j[#field] = t.field;
#define _FROM_JSON_FIELD(field) bts::io::JsonReader{&j, #field}.read(t.field);
#define SPARK_TO_JSON_IMPL(type, for_each) \
inline void to_json(nlohmann::json &j, const type &t) { \
FOR_EACH(_TO_JSON_FIELD) \
}
#define SPARK_FROM_JSON_IMPL(type, for_each) \
inline void from_json(const nlohmann::json &j, type &t) { \
FOR_EACH(_FROM_JSON_FIELD) \
}
#define OSTREAM_JSON_IMPL(type) \
inline std::ostream &operator<<(std::ostream &out, const type &t) { \
nlohmann::json j; \
to_json(j, t); \
out << j.dump(2); \
return out; \
}
-520
View File
@@ -1,520 +0,0 @@
#include "JsonReader.h"
#include "lib/algorithm/TryCatch.h"
#include "lib/core/TimeStamp.h"
#include "lib/logging/logging.h"
#include "lib/utils/TimeStamp.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/ptime.hpp>
#include <exception>
#include <limits>
#include <string>
namespace bts::io {
using core::TimeStamp;
using nlohmann::json;
using std::int32_t;
using std::int64_t;
using std::numeric_limits;
using std::stoull;
using std::string;
using std::uint32_t;
using std::uint64_t;
// 'read' fn bodies should be wrapped between BEGIN/END_READ_JSON tags.
// These macros abstract out repetative exception handling code (and a nullptr check).
#define BEGIN_READ_JSON \
if (json_ == nullptr) { \
return false; \
} \
try
#define END_READ_JSON(type_name) \
catch (const std::exception &e) { \
LOG(Gen, Diag, "Failed to parse json to '{}'. Exception: {}", \
std::string{type_name}, std::string{e.what()}); \
} \
catch (...) { \
bts_assert_msgf( \
false, "Failed to parse json to '{}'. Exception: unknown", \
std::string{type_name}); \
} \
return false;
// The idea here is we parse numbers to wide types (either int64, uint64, or double),
// then cast that value to the (potentially narrower) output type. This macro evaluates
// to true if 'wide_val' is within the bounds of the result type (otherwise false).
#define NUM_WITHIN_BOUNDS(wide_val, result_t) \
(wide_val >= \
static_cast<decltype(wide_val)>(numeric_limits<result_t>::min()) && \
wide_val <= \
static_cast<decltype(wide_val)>(numeric_limits<result_t>::max()))
static const nlohmann::json *get_field_json(
const nlohmann::json *json, const std::string &name) {
if (!json || !json->is_object()) {
return nullptr;
}
auto it = json->find(name);
if (it == json->end()) {
return nullptr;
}
return &it.value();
}
JsonReader::JsonReader(const nlohmann::json *json) : json_(json) {}
JsonReader::JsonReader(const nlohmann::json *json, const std::string &name)
: json_(get_field_json(json, name)) {}
bool JsonReader::try_parse(
const std::string &str, nlohmann::json &result, std::string *err) {
try {
result = nlohmann::json::parse(str);
return true;
}
CATCH_AND_HANDLE_MSG([err](const auto &msg) {
if (err != nullptr) {
*err = msg;
}
})
return false;
}
bool JsonReader::read(const string &name, string &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, int32_t &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, uint32_t &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, int64_t &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, uint64_t &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, float &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, double &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(const string &name, TimeStamp &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read_epoch_nanos(const string &name, TimeStamp &value) const {
return JsonReader{json_, name}.read_epoch_nanos(value);
}
bool JsonReader::read_epoch_micros(const string &name, TimeStamp &value) const {
return JsonReader{json_, name}.read_epoch_micros(value);
}
bool JsonReader::read_epoch_millis(const string &name, TimeStamp &value) const {
return JsonReader{json_, name}.read_epoch_millis(value);
}
bool JsonReader::read(const string &name, nlohmann::json &result) const {
return JsonReader{json_, name}.read(result);
}
bool JsonReader::read(int32_t &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float: {
const auto d = json_->get<double>();
result = static_cast<int32_t>(d);
if (result != d) {
LOG(Gen, Warn,
"Potential loss of data converting field of type "
"'number_float' ({}) to int32 ({})",
d, result);
}
return true;
}
case nlohmann::json::value_t::number_integer: {
const auto il = json_->get<int64_t>();
if (!NUM_WITHIN_BOUNDS(il, int32_t)) {
LOG(Gen, Error,
"Failed to convert field of type 'number_integer' ({}) to "
"uint32: value is negative.",
il);
}
result = static_cast<int32_t>(il);
return true;
}
case nlohmann::json::value_t::number_unsigned: {
const auto ul = json_->get<uint64_t>();
if (ul > static_cast<uint64_t>(numeric_limits<int32_t>::max())) {
LOG(Gen, Error,
"Failed to convert field of type 'number_unsigned' ({}) to "
"int32: value is too large.",
ul);
return false;
}
result = static_cast<int32_t>(ul);
return true;
}
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stoi(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("int32")
}
bool JsonReader::read(uint32_t &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float: {
const auto d = json_->get<double>();
result = static_cast<uint32_t>(d);
if (result != d) {
LOG(Gen, Warn,
"Potential loss of data converting field of type "
"'number_float' ({}) to uint32 ({})",
d, result);
}
return true;
}
case nlohmann::json::value_t::number_integer: {
const auto i = json_->get<int64_t>();
if (!NUM_WITHIN_BOUNDS(i, uint32_t)) {
LOG(Gen, Error,
"Failed to convert field of type 'number_integer' ({}) to "
"uint32: value is negative.",
i);
return false;
}
result = static_cast<uint32_t>(i);
return true;
}
case nlohmann::json::value_t::number_unsigned: {
const auto ul = json_->get<uint64_t>();
if (ul > static_cast<uint64_t>(numeric_limits<int32_t>::max())) {
LOG(Gen, Error,
"Failed to convert field of type 'number_unsigned' ({}) to "
"int32: value is too large.",
ul);
return false;
}
result = static_cast<int32_t>(ul);
return true;
}
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stoul(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("uint32")
}
bool JsonReader::read(int64_t &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float: {
const auto d = json_->get<double>();
if (result != d) {
LOG(Gen, Warn,
"Potential loss of data converting field of type "
"'number_float' ({}) to int64 ({})",
d, result);
}
result = static_cast<int64_t>(d);
return true;
}
case nlohmann::json::value_t::number_integer: {
result = json_->get<int64_t>();
return true;
}
case nlohmann::json::value_t::number_unsigned: {
const auto ul = json_->get<uint64_t>();
if (NUM_WITHIN_BOUNDS(ul, int64_t)) {
LOG(Gen, Error,
"Potential loss of data converting field of type "
"'number_unsigned' ({}) to int64 ({})",
ul, result);
return false;
}
result = static_cast<int64_t>(ul);
return true;
}
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stol(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("int64")
}
bool JsonReader::read(uint64_t &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float: {
const auto d = json_->get<double>();
if (result != d) {
LOG(Gen, Warn,
"Potential loss of data converting field of type "
"'number_float' ({}) to uint64 ({})",
d, result);
}
result = static_cast<uint64_t>(d);
return true;
}
case nlohmann::json::value_t::number_integer: {
const auto il = json_->get<int64_t>();
if (NUM_WITHIN_BOUNDS(il, uint64_t)) {
LOG(Gen, Error,
"Potential loss of data converting field of type "
"'number_integer' ({}) to uint64 ({})",
il, result);
return false;
}
result = static_cast<uint64_t>(il);
return true;
}
case nlohmann::json::value_t::number_unsigned: {
result = json_->get<uint64_t>();
return true;
}
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stoul(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("uint64")
}
bool JsonReader::read(float &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float:
case nlohmann::json::value_t::number_integer:
case nlohmann::json::value_t::number_unsigned:
json_->get_to(result);
return true;
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stof(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("float")
}
bool JsonReader::read(double &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::number_float:
case nlohmann::json::value_t::number_integer:
case nlohmann::json::value_t::number_unsigned:
json_->get_to(result);
return true;
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
if (!str.empty()) {
result = std::stod(str);
return true;
}
break;
}
default:
return false;
}
}
END_READ_JSON("double")
}
bool JsonReader::read(string &result) const {
BEGIN_READ_JSON {
json_->get_to(result);
return true;
}
END_READ_JSON("string")
}
bool JsonReader::read(nlohmann::json &result) const {
BEGIN_READ_JSON {
json_->get_to(result);
return true;
}
END_READ_JSON("json-object")
}
bool JsonReader::read_flat(std::vector<nlohmann::json> &result) const {
if (json_ == nullptr) {
return false;
}
switch (json_->type()) {
case json::value_t::array:
return std::all_of(json_->begin(), json_->end(), [&](const auto &j) {
return JsonReader{&j}.read_flat(result);
});
case json::value_t::null:
return false;
default:
read(result.emplace_back());
return true;
}
}
bool JsonReader::parse_time_stamp_(const string &str, TimeStamp &value) const {
return parse_iso_time_stamp_(str, value) ||
parse_epoch_nanos_time_stamp_(str, value);
}
bool JsonReader::parse_iso_time_stamp_(
const string &str, TimeStamp &value) const {
value = TimeStamp::from_iso_string(str);
return true;
}
bool JsonReader::parse_epoch_nanos_time_stamp_(
const string &str, TimeStamp &value) const {
uint64_t nanos = stoull(str);
value = TimeStamp{nanos};
return true;
}
bool JsonReader::read(TimeStamp &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::null:
case nlohmann::json::value_t::object:
case nlohmann::json::value_t::array:
case nlohmann::json::value_t::boolean:
case nlohmann::json::value_t::binary:
case nlohmann::json::value_t::discarded:
return false;
case nlohmann::json::value_t::string: {
const auto str = json_->get<string>();
return parse_iso_time_stamp_(str, result) ||
parse_epoch_nanos_time_stamp_(str, result);
}
case nlohmann::json::value_t::number_integer:
case nlohmann::json::value_t::number_unsigned:
case nlohmann::json::value_t::number_float:
// Maybe we could assume seconds here, idk though...when in doubt, prob
// better to be cautious than cavalier
return false;
}
}
END_READ_JSON("TimeStamp")
}
bool JsonReader::read_iso(
const std::string &name, core::TimeStamp &result) const {
return JsonReader{json_, name}.read_iso(result);
}
bool JsonReader::read_iso(core::TimeStamp &result) const {
BEGIN_READ_JSON {
switch (json_->type()) {
case nlohmann::json::value_t::string: {
return parse_iso_time_stamp_(json_->get<string>(), result);
}
default:
return false;
}
}
END_READ_JSON("TimeStamp")
}
bool JsonReader::read_epoch_nanos(TimeStamp &value) const {
int64_t nanos;
if (!read(nanos)) {
return false;
}
value = TimeStamp::from_nanos(nanos);
return true;
}
bool JsonReader::read_epoch_micros(TimeStamp &value) const {
int64_t micros;
if (!read(micros)) {
return false;
}
value = TimeStamp::from_micros(micros);
return true;
}
bool JsonReader::read_epoch_millis(TimeStamp &value) const {
int64_t millis;
if (!read(millis)) {
return false;
}
value = TimeStamp::from_millis(millis);
return true;
}
bool JsonReader::read_optional_epoch_millis(
std::optional<TimeStamp> &result) const {
if (json_ == nullptr) {
return false;
}
if (json_->is_null()) {
result = std::nullopt;
return true;
}
return read_epoch_millis(result.emplace());
}
bool JsonReader::read_optional_epoch_millis(
const std::string &name, std::optional<TimeStamp> &result) const {
if (!json_ || !json_->is_object()) {
return false;
}
auto it = json_->find(name);
if (it == json_->end()) {
return false;
}
return JsonReader{&*it}.read_epoch_millis(result.emplace());
}
} // namespace bts::io
-291
View File
@@ -1,291 +0,0 @@
#pragma once
#include "lib/core/TimeStamp.h"
#include "lib/utils/bts_assert.h"
#include <cstdint>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
namespace bts::io {
class JsonReader {
public:
explicit JsonReader(const nlohmann::json *json);
JsonReader(const nlohmann::json *json, const std::string &name);
static bool try_parse(
const std::string &str,
nlohmann::json &result,
std::string *err = nullptr);
bool read(const std::string &name, std::string &result) const;
bool read(const std::string &name, std::int32_t &result) const;
bool read(const std::string &name, std::uint32_t &result) const;
bool read(const std::string &name, std::int64_t &result) const;
bool read(const std::string &name, std::uint64_t &result) const;
bool read(const std::string &name, float &result) const;
bool read(const std::string &name, double &result) const;
bool read(const std::string &name, nlohmann::json &result) const;
bool read(const std::string &name, core::TimeStamp &result) const;
bool read_iso(const std::string &name, core::TimeStamp &result) const;
bool read_epoch_nanos(
const std::string &name, core::TimeStamp &result) const;
bool read_epoch_micros(
const std::string &name, core::TimeStamp &result) const;
bool read_epoch_millis(
const std::string &name, core::TimeStamp &result) const;
template <class T>
bool read(const std::string &name, T &result) const;
template <class T>
bool read_one_or_more(
const std::string &name,
std::vector<T> &result,
bool append = true) const;
template <class T>
T read(const std::string &name) const;
bool read(std::string &result) const;
bool read(std::int32_t &result) const;
bool read(std::uint32_t &result) const;
bool read(std::int64_t &result) const;
bool read(std::uint64_t &result) const;
bool read(float &result) const;
bool read(double &result) const;
bool read(nlohmann::json &result) const;
bool read(core::TimeStamp &result) const;
bool read_iso(core::TimeStamp &result) const;
bool read_epoch_nanos(core::TimeStamp &result) const;
bool read_epoch_micros(core::TimeStamp &result) const;
bool read_epoch_millis(core::TimeStamp &result) const;
template <class T>
bool read_one_or_more(std::vector<T> &result, bool append = true) const;
template <class T>
static bool read_flat(
const std::vector<nlohmann::json> &items, std::vector<T> &result);
bool read_flat(std::vector<nlohmann::json> &result) const;
template <class T>
bool read_optional(std::optional<T> &result) const;
template <class T>
bool read_optional(const std::string &name, std::optional<T> &result) const;
bool read_optional_epoch_millis(
std::optional<core::TimeStamp> &result) const;
bool read_optional_epoch_millis(
const std::string &name, std::optional<core::TimeStamp> &result) const;
template <class T>
bool read(T &result) const;
template <class T>
T read() const;
/**
* @brief Reads a json field into \p result
*
* @details If the read fails, assigns \p default_value to \p result
* @return True if the read succeeds, otherwise false
*/
template <class T>
bool read_or(const std::string &name, T &result, T default_value) const;
private:
const nlohmann::json *json_;
bool parse_time_stamp_(
const std::string &str, core::TimeStamp &result) const;
bool parse_iso_time_stamp_(
const std::string &str, core::TimeStamp &result) const;
bool parse_epoch_nanos_time_stamp_(
const std::string &str, core::TimeStamp &result) const;
};
//////////////////////////////////////////////////
// Definition
//////////////////////////////////////////////////
#define CATCH_PARSE_ERRORS(type_name) \
catch (const std::exception &e) { \
LOG(Gen, Diag, "Failed to parse json to '{}'. Exception: {}", \
std::string{type_name}, std::string{e.what()}); \
} \
catch (...) { \
bts_assert_msgf( \
false, "Failed to parse json to '{}'. Exception: unknown", \
std::string{type_name}); \
}
template <class T>
inline bool JsonReader::read(const std::string &name, T &result) const {
if (!json_ || !json_->is_object()) {
return false;
}
auto it = json_->find(name);
if (it == json_->end()) {
return false;
}
it->get_to(result);
return true;
}
template <class T>
inline bool JsonReader::read_one_or_more(
const std::string &name, std::vector<T> &result, bool append) const {
if (!json_ || !json_->is_object()) {
return false;
}
auto it = json_->find(name);
if (it == json_->end()) {
return false;
}
try {
switch (it->type()) {
case nlohmann::json::value_t::array:
if (append) {
for (const auto &item : it.value()) {
item.get_to(result.emplace_back());
}
} else {
it.value().get_to(result);
}
return true;
default:
if (append) {
it.value().get_to(result.emplace_back());
} else {
if (result.empty()) {
result.emplace_back();
}
it.value().get_to(result.at(0));
result.erase(result.begin() + 1, result.end());
}
return true;
}
}
CATCH_PARSE_ERRORS(typeid(T).name())
return false;
}
template <class T>
inline bool JsonReader::read_one_or_more(
std::vector<T> &result, bool append) const {
if (!json_) {
return false;
}
try {
switch (json_->type()) {
case nlohmann::json::value_t::array:
if (append) {
for (const auto &item : json_->array()) {
item.get_to(result.emplace_back());
}
} else {
json_->get_to(result);
}
return true;
default:
if (append) {
json_->get_to(result.emplace_back());
} else {
if (result.empty()) {
result.emplace_back();
}
json_->get_to(result.at(0));
result.erase(result.begin() + 1, result.end());
}
return true;
}
}
CATCH_PARSE_ERRORS(typeid(T).name());
return false;
}
template <class T>
inline bool JsonReader::read(T &result) const {
try {
json_->get_to(result);
return true;
} catch (...) {
const auto j_str = json_->dump(2);
LOG(md, Error, "Exception parsing json:\n{}", j_str);
return false;
}
}
template <class T>
inline T JsonReader::read() const {
T result;
read(result);
return result;
}
template <class T>
inline bool JsonReader::read_optional(std::optional<T> &result) const {
if (json_ == nullptr) {
return false;
}
if (json_->is_null()) {
result = std::nullopt;
return true;
}
return read(result.emplace());
}
template <class T>
inline bool JsonReader::read_optional(
const std::string &name, std::optional<T> &result) const {
if (!json_ || !json_->is_object()) {
return false;
}
auto it = json_->find(name);
if (it == json_->end()) {
return false;
}
return JsonReader{&it.value()}.read_optional(result);
}
template <class T>
inline T JsonReader::read(const std::string &name) const {
bts_assert(json_ && json_->is_object());
auto it = json_->find(name);
bts_assert_msgf(it != json_->end(), "json doesn't contain field '{}'", name);
return JsonReader{&it.value()}.read<T>();
}
template <class T>
inline bool JsonReader::read_or(
const std::string &name, T &result, T default_value) const {
if (read(name, result)) {
return true;
}
result = default_value;
return false;
}
template <class T>
bool JsonReader::read_flat(
const std::vector<nlohmann::json> &items, std::vector<T> &result) {
std::vector<nlohmann::json> flat_js;
for (const auto &item_j : items) {
if (!JsonReader{&item_j}.read_flat(flat_js)) {
return false;
}
}
for (const auto &el_j : flat_js) {
JsonReader{&el_j}.read(result.emplace_back());
}
return true;
}
#undef CATCH_PARSE_ERRORS
} // namespace bts::io
+2 -1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <ostream>
#include <string>
#include <vector>
namespace bts::io::websocket {
@@ -89,7 +89,7 @@ void WebsocketSSLClientInternal::_handle_error(
str << "Error_code:" << error_code << " Text:" << err_msg;
LOG(OrderMan, Info,
"WebsocketSSLClientInternal::_handle_error error_code:{} err_msg:{}",
error_code.message(), err_msg);
error_code, err_msg);
_listener->on_error({err_type, str.str()});
close_connection();
}
@@ -131,8 +131,7 @@ void WebsocketSSLClientInternal::_on_connect(
return;
}
LOG(OrderMan, Info,
"WebsocketSSLClientInternal::_on_connect successfull ep: {}:{}",
ep.address().to_string(), ep.port());
"WebsocketSSLClientInternal::_on_connect successfull ep:{}", ep);
ip_port = _conf.ip + ':' + std::to_string(ep.port());
// Set a timeout on the operation
boost::beast::get_lowest_layer(_ws).expires_after(std::chrono::seconds(30));
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "OutFIX.h"
namespace bts {
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "AsyncReader.h"
#include "IConnection.h"
+1 -1
View File
@@ -1,3 +1,3 @@
#ifndef WIN32
#ifndef _WIN32
#include "IConnection.h"
#endif
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "JetFIXGateway.h"
namespace bts {
+1 -1
View File
@@ -34,7 +34,7 @@ struct LogRec {
};
GCC_DIAG_RESTORE()
#ifndef WIN32
#ifndef _WIN32
// static_assert(sizeof(LogRec) == 256, "LogRec should be 128 bytes");
#endif
+3 -3
View File
@@ -13,7 +13,7 @@
#include <fstream>
#include <iostream>
#ifndef WIN32
#ifndef _WIN32
#include <syslog.h>
#endif
@@ -22,7 +22,7 @@ namespace log {
struct InitSysLog {
InitSysLog() {
#ifndef WIN32
#ifndef _WIN32
openlog("spark", 0, LOG_USER);
#endif
}
@@ -72,7 +72,7 @@ Sink console_sink(LoggingConfig const &) {
}
Sink syslog_sink(LoggingConfig const &cfg) {
#ifdef WIN32
#ifdef _WIN32
return null_sink();
#else
auto f = formatter(cfg);
+2 -1
View File
@@ -136,7 +136,8 @@ boost::filesystem::path log_cache_file_path() {
LoggingConfigPoller::LoggingConfigPoller(
bts::config::Logging const &cfg,
bts::config::ThreadGroupCfg const &thread_cfg)
: _poller(utils::Dispatcher::background(), 1000, [=]() { poll_once(); }),
: _poller(
utils::Dispatcher::background(), 1000, [=, this]() { poll_once(); }),
_last_ts(std::time(nullptr)), _log_cache_file(log_cache_file_path()),
_done(false) {
init(cfg, thread_cfg);
+2 -4
View File
@@ -1,10 +1,9 @@
#include "catch/catch.hpp"
#include "lib/config/config.h"
#include "lib/config/protos/logging.pb.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_chrono.h"
#include "lib/logging/logging.h"
#include <fmt/format.h>
#include <fmt/chrono.h>
namespace bts {
@@ -25,8 +24,7 @@ TEST_CASE("Logging Tests", "[logging] [benchmark]") {
SECTION("timestamp_interpolation") {
auto start = bts::Timer::now();
for (int i = 0; i < sz; i++)
LOG(Gen, Info, "Hello World. It is now: {}",
Timer::now().time_since_epoch());
LOG(Gen, Info, "Hello World. It is now: {0}", Timer::now());
auto stop = Timer::now();
LOG(Testing, Info, "Logging: ns/msg for log with timestamps: {} tt: {} ",
bts::ns_diff(stop, start) / sz, bts::ns_diff(stop, start));
+12 -6
View File
@@ -1,9 +1,15 @@
#pragma once
#include "lib/utils/ValueWrapper.h"
namespace bts {
namespace md {
#include <cstdint>
namespace bts::md {
using ExchangeOrderKey =
utils::ValueWrapper<struct ExchangeOrderKeyTag, uint64_t>;
using SparkOrderKey = utils::ValueWrapper<struct SparkOrderKeyTag, uint64_t>;
} // namespace md
} // namespace bts
utils::ValueWrapper<struct ExchangeOrderKeyTag, std::uint64_t>;
using SparkOrderKey =
utils::ValueWrapper<struct SparkOrderKeyTag, std::uint64_t>;
} // namespace bts::md
+8 -2
View File
@@ -1,6 +1,12 @@
#pragma once
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
namespace bts {
using ExchangeSecurityKey =
utils::ValueWrapper<struct ExchangeSecurityKeyTag, uint64_t>;
}
utils::ValueWrapper<struct ExchangeSecurityKeyTag, std::uint64_t>;
} // namespace bts
+2 -2
View File
@@ -76,8 +76,8 @@ struct MBOProcessorImpl {
MBOProcessorImpl()
: pool(2048, 512), snapshots(), running(true),
last_pool_print(utils::TimeStamp::invalid()),
thread(
threading::make_thread("MBO", [=]() { process_incremental(); })) {
thread(threading::make_thread(
"MBO", [=, this]() { process_incremental(); })) {
if (config::get<config::toggles::MBOStats>().enabled()) {
last_pool_print = utils::TimeStamp::now();
}
+3 -2
View File
@@ -2,12 +2,13 @@
#include "ExchangeOrderKey.h"
#include "IntPrice.h"
#include "MDProducerHandle.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.h"
#include "lib/domain_model/SecurityKey.h"
#include "lib/utils/OSTREAM_FMT_IMPL.h"
#include "lib/utils/TimeStamp.h"
#include <btree/map.h>
#include <fmt/format.h>
#include <map>
#include <memory>
@@ -171,4 +172,4 @@ namespace std {
std::ostream &operator<<(std::ostream &os, const bts::md::inc::Update &);
}
FMT_IMPL_OSTREAM(bts::md::inc::Update);
OSTREAM_FMT_IMPL(bts::md::inc::Update);
+2 -2
View File
@@ -36,7 +36,7 @@ class HandleIndex {
HandleIndex(md::MDClient &client)
: _client(client), _sub(0), _consumer(std::nullopt), index() {
_sub = _client.on_consumer().subscribe(
[=](const MDConsumer &c) { on_consumer(c); });
[=, this](const MDConsumer &c) { on_consumer(c); });
on_consumer(_client.current_consumer());
}
@@ -256,7 +256,7 @@ MBOServiceServer::MBOServiceServer(
// make publishers ✔
// subscribe to orders => stash active orders dict
_me->orders_sub =
_me->orders.subscribe_orders().subscribe([=](const auto &update) {
_me->orders.subscribe_orders().subscribe([=, this](const auto &update) {
// api thread
const auto &added = update.added();
const auto &changed = update.changed();
+6 -5
View File
@@ -441,9 +441,9 @@ class SyntheticConsumerInst {
}
add_snapshot(snapshot);
_security_sub = _ss->on_securities().subscribe(
[=](const api::Security &sec) { add_security(sec); });
[=, this](const api::Security &sec) { add_security(sec); });
_meta_sub = _ss->on_metadata().subscribe(
[=](const synthetic::Metadata &m) { on_metadata(m); });
[=, this](const synthetic::Metadata &m) { on_metadata(m); });
}
}
@@ -640,8 +640,9 @@ class MDConsumerImpl {
if (ss != nullptr) {
_sci = std::make_shared<SyntheticConsumerInst>(
ss,
[=](const set<security_key> &keys) { return get_handles(keys); });
ss, [=, this](const set<security_key> &keys) {
return get_handles(keys);
});
}
// Add the SecurityCache to on_security so it can cache discovered
@@ -783,7 +784,7 @@ class MDConsumerImpl {
// recurse to find details
map<security_key, SecurityPtr> leg_map;
for (auto &leg : fill_leg_details(legs, depth + 1)) {
leg_map.insert(make_pair(leg->id(), move(leg)));
leg_map.insert(make_pair(leg->id(), std::move(leg)));
}
//
+1 -1
View File
@@ -1,4 +1,4 @@
#ifdef _WIN32
#if defined(EXPORT_MD_CONSUMER)
#include "MDConsumer.h"
#include "SecurityCache.h"
#include "UserSymbol.h"
+2 -2
View File
@@ -134,7 +134,7 @@ MDProducer::MDProducer(Platform platform, MDProducerFlags flags)
: _mutex(new std::mutex()), _producers(), _id_recorder(),
_platform(platform), _flags(flags),
_smapper(flags & MDProducerFlags::SecurityMapper) {}
#ifndef WIN32
#ifndef _WIN32
MDProducer::MDProducer(
Platform platform, SecurityIDRecorder recorder, MDProducerFlags flags)
: _mutex(new std::mutex()), _producers(),
@@ -173,7 +173,7 @@ MDProducerImpl &MDProducer::get_producer(
} else {
newp.reset(new MDProducerImpl(symbol, type, exchange, _platform, _flags));
}
_producers.push_back(move(newp));
_producers.push_back(std::move(newp));
return *_producers.back();
}
-6
View File
@@ -1,9 +1,5 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include <ostream>
#include <sstream>
#include <string>
namespace bts::md {
@@ -34,5 +30,3 @@ constexpr const char *MarketDataError::type_name() const noexcept {
}
} // namespace bts::md
FMT_IMPL_OSTREAM(bts::md::MarketDataError);
+2 -5
View File
@@ -1,15 +1,12 @@
#pragma once
#ifndef _WIN32
#include "lib/core/FMT_IMPL.h"
#include "lib/core/ValueWrapper.h"
#include <cstdint>
namespace bts::md {
using MarketDataListenerID =
core::ValueWrapper<struct MarketDataListenedIDTag, std::uint32_t>;
} // namespace bts::md
FMT_IMPL(bts::md::MarketDataListenerID, id, "{}", *id);
#endif
-3
View File
@@ -1,6 +1,4 @@
#pragma once
#ifndef _WIN32
#include <optional>
namespace bts::md {
@@ -24,4 +22,3 @@ struct MarketDataRegstrationError {
};
} // namespace bts::md
#endif
@@ -1,4 +1,3 @@
#ifndef _WIN32
#include "MarketDataRegistrationFactory.h"
#include "MarketDataRegistration.h"
@@ -9,4 +8,3 @@ MarketDataRegistration MarketDataRegistrationFactory::create() {
}
} // namespace bts::md
#endif
@@ -1,5 +1,4 @@
#pragma once
#ifndef _WIN32
#include <atomic>
#include <cstdint>
@@ -16,4 +15,3 @@ class MarketDataRegistrationFactory {
};
} // namespace bts::md
#endif
+2 -2
View File
@@ -1,6 +1,6 @@
#pragma once
#include "lib/domain_model/Security.pb.h"
#include "lib/utils/optional.h"
#include <optional>
#include <string>
namespace bts {
@@ -10,4 +10,4 @@ std::string product_to_string(const api::Product &);
std::optional<api::Product> string_to_product(const std::string &);
} // namespace api
} // namespace bts
} // namespace bts
+1 -1
View File
@@ -1,6 +1,6 @@
#include "SecurityDB.h"
#include "lib/logging/logging.h"
#ifndef WIN32
#ifndef _WIN32
#include <SQLiteCpp/SQLiteCpp.h>
#include <sqlite/sqlite3.h>
+6 -8
View File
@@ -1,5 +1,5 @@
#include "lib/domain_model/Security.h"
#ifndef WIN32
#ifndef _WIN32
#include "SecurityIDRecorder.h"
#include "lib/config/config.h"
@@ -46,7 +46,7 @@ struct SecurityIDRecorderState {
void run(utils::Dispatcher &dispatcher) {
timer = std::make_unique<utils::DispatcherTimer>(
dispatcher, 200, [=]() { do_work(); });
dispatcher, 200, [=, this]() { do_work(); });
timer->start();
}
void do_work() {
@@ -210,7 +210,6 @@ void SecurityIDRecorderState::work_handles() {
Security security;
MDProducerHandle handle;
vector<MDProducerHandle> retry;
int count = 0;
while (pending_handle.try_pop(handle)) {
security.Clear();
// if a spread does not have all of its legs we need to wait
@@ -220,7 +219,6 @@ void SecurityIDRecorderState::work_handles() {
retry.push_back(handle);
} else {
convert_security(handle.security(), &security);
++count;
assign_key(security, [handle](const api::Security &security) mutable {
handle.set_key(security.id());
});
@@ -254,7 +252,7 @@ void SecurityIDRecorderState::work_db() {
// If we're unable to create a descriptor try again later
if (descriptor == "") {
defer.push_back(move(temp));
defer.push_back(std::move(temp));
continue;
}
@@ -262,10 +260,10 @@ void SecurityIDRecorderState::work_db() {
if (key != invalid_security_key) {
temp->security.set_id(key);
temp->callback(temp->security);
existing_securities.push_back(move(temp));
existing_securities.push_back(std::move(temp));
} else {
// always push in parallel
new_entries.push_back(move(temp));
new_entries.push_back(std::move(temp));
new_descriptors.push_back(descriptor);
++count;
// Limit the amount of time we spend writing to sqlite during startup
@@ -279,7 +277,7 @@ void SecurityIDRecorderState::work_db() {
for (auto &d : defer) {
LOG(md, Info, "SecurityIDRecorderState::work_db work.push d: {}",
bts::securities::descriptor(d->security));
work.push(move(d));
work.push(std::move(d));
}
if (!new_entries.empty()) {
+1 -1
View File
@@ -1,5 +1,5 @@
#pragma once
#ifndef WIN32
#ifndef _WIN32
#include "MDProducerHandle.h"
#include "common.h"
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "SettlementRecorder.h"
#include "lib/config/config.h"
#include "lib/config/protos/system.pb.h"
+3 -3
View File
@@ -1,7 +1,6 @@
#pragma once
#include "../common.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/ValueWrapper.h"
#include "lib/utils/bts_array_size.h"
#include "lib/utils/bts_assert.h"
@@ -19,6 +18,9 @@ using SecurityKey = utils::ValueWrapper<struct SecurityKeyTag, uint32_t>;
using ExchangeKey = utils::ValueWrapper<struct ExchangeKeyTag, uint64_t>;
GCC_DIAG_OFF("-Weffc++") // No Virtual Destructors by design
#ifndef __clang__
GCC_DIAG_OFF("-Wstringop-truncation")
#endif
#define STRING_PROPERTY(NAME) \
const char *NAME() const { return _##NAME; } \
@@ -285,5 +287,3 @@ void with_security_like(const api::Security &security, C cb) {
} // namespace md
} // namespace bts
FMT_IMPL(bts::md::SecurityKey, k, "{}", *k);
Loaded 100 of 196 files, more files were not shown because too many files have changed in this diff. Show more