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
John Colvin d24becd052 fix: Ensure LadderGridHost's price_comparer isn't null
Initialize it w/ reasonable default when LadderGridHost is constructed.

Bugs (fixed):
  * Sometimes the OrderBook's ladder panel throws a null ref ex when the
    orders collection changes

  Cause: The orders collection changed callback references the ladder's
  price_comparer, which may be null since it isn't initialized until the
  DataContextChanged event fires (the relative order of these events is
  non-deterministic)
2023-11-02 14:15:58 -04:00
John Colvin 13251f5c06 fix: Add special-case tick logic for [non-perp] futs at Deribit
Unlike any other securities supported by our system, these use
TickFactors of 25/10 (e.g., 10.0, 12.5, 15.0, etc.)
2023-11-02 13:55:36 -04:00
John Colvin 03b9aaa0e8 fix: Dispose BBOVM's md poll loop
Bugs (fixed):
  * Memory Leak! The md poll loop (instance var) in BBOVM is never
    disposed
2023-11-02 12:47:58 -04:00
Mohammad Arham 32d127fd84 added log to chec user input 2023-10-18 09:34:00 -07:00
John Colvin 3cb69c7520 fix build: Pass 'shell=true' to subprocess.run
Otherwise it doesn't evaluate the command string properly
2023-10-17 13:50:38 -04:00
John Colvin 47e897d038 feat: Resurrect VolSurfaceAdvancedSettings 2023-10-17 13:50:38 -04:00
John Colvin 126ec169ea refactor: Remove useless param 2023-10-17 13:49:13 -04:00
John Colvin 84953df12c dev: Copy docker/sparkd dir from development branch
So we can build prod in devcontainer
2023-10-17 13:34:23 -04:00
John Colvin e8322183ec Update externals to get emumba-deribit deb w/out LICENSE check 2023-10-17 13:33:01 -04:00
Mohammad Arham 30ba7ecd19 added logs for _default_abs_moves 2023-10-10 15:14:28 -07:00
Mohammad Arham db6b34c6a8 changd default_abs_moves from hard coded to config 2023-10-05 23:17:02 -07:00
Taha Afzal 4dbafcab91 TaskingEye can shoot deep in the book as well 2023-08-18 05:44:12 +00:00
Taha Afzal 9fd7f8a0a6 Adding security list for TaskingEye Algo 2023-08-17 21:33:40 +00:00
147 changed files with 3615 additions and 1113 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 -1
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,3 +51,4 @@ trace_data/
/.venv*/*
.cache/
src/web/api/tsconfig.*.g.json
**/.devcontainer
+4 -7
View File
@@ -1,9 +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 -37
View File
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project(spark)
set(CMAKE_CXX_STANDARD 20)
if(WIN32)
set(platform "windows")
@@ -13,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(
@@ -50,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)
@@ -77,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.
Submodule docker/linux deleted from 6537812262.
+141
View File
@@ -0,0 +1,141 @@
FROM ubuntu:latest
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York
# light deps (should be quick to download/install)
RUN apt-get update && apt-get install -y \
ca-certificates \
curl \
gnupg \
liblttng-ust-dev \
libpcap0.8-dev \
locales \
ninja-build \
software-properties-common \
sqlite3 \
tzdata
# clang
RUN apt-get update && apt-get install -y \
clang-13 \
clang-format-13 \
clangd-13 \
clang-15 \
clang-format-15 \
clangd-15
# g++
RUN apt-get update && apt-get install -y \
g++-11 \
g++-12
# python
RUN apt-get update && apt-get install -y \
python3-pip \
python3-venv \
&& python3 -m pip install --upgrade pip
# dotnet
RUN apt-get update && apt-get install -y \
dotnet7
# ssh
RUN apt-get update && apt-get install -y \
libssh2-1-dev \
openssh-server
# 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 \
&& 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
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
# ccache is done here so that ccache sees clang++ installed, not clang-10
RUN apt-get update && apt-get install -y \
ccache
# emumba (light deps)
RUN apt-get update && apt-get install -y \
build-essential \
doxygen \
python3-sphinx \
graphviz \
libgtest-dev \
libssl-dev \
rapidjson-dev \
zlib1g-dev \
pkg-config
# emumba (boost)
RUN apt-get update && apt-get install -y \
libboost-filesystem-dev \
libboost-program-options-dev \
libboost-test-dev \
libboost-date-time-dev
# dev utils
RUN apt-get update && apt-get install -y \
fish \
git-all \
sudo \
vim \
wget
# set up default executables (update-alternatives)
RUN \
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-13 100; \
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-13 100; \
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-13 100; \
update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-13 100; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-11 100; \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 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-13; \
ln -s /usr/bin/ccache /usr/local/bin/clang++-13; \
ln -s /usr/bin/ccache /usr/local/bin/clang-15; \
ln -s /usr/bin/ccache /usr/local/bin/clang++-15; \
ln -s /usr/bin/ccache /usr/local/bin/gcc; \
ln -s /usr/bin/ccache /usr/local/bin/g++; \
ln -s /usr/bin/ccache /usr/local/bin/gcc-11; \
ln -s /usr/bin/ccache /usr/local/bin/g++-11; \
ln -s /usr/bin/ccache /usr/local/bin/gcc-12; \
ln -s /usr/bin/ccache /usr/local/bin/g++-12
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"
+64
View File
@@ -0,0 +1,64 @@
[dev containers]: https://code.visualstudio.com/docs/devcontainers/containers
[dev containers ext]: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers
[docker repo sparkd-dev]: https://hub.docker.com/repository/docker/bluetradingsystems/sparkd-dev/general
# Sparkd Dev Container
## How to create a VS Code [Dev Container][dev containers]
1. Make sure the **[Dev Containers][dev containers ext]** extension is installed
1. Make sure your Docker image is up to date
```
docker pull bluetradingsystems/sparkd-dev:latest
```
1. Copy **devcontainer.json** from this folder to **$workspaceFolder/.devcontainer/**.
1. In the VS Code Command Palette, run **Dev Containers: Reopen in Container**
---
## How to create a Sparkd Container in the terminal (without VS Code)
1. Make sure your Docker image is up to date
```
docker pull bluetradingsystems/sparkd-dev:latest
```
2. Start the container
```
# Replace <cont_name> with a name for the container. The container's
# "$HOME" dir will be mounted to "$HOME/.sparkd-dev/mounts/<cont_name> on
# the host
./start_docker.sh --container <cont_name> --mount-existing
```
* *Replace <cont_name> with a name for the container*
* *The container's `$HOME` dir will be mounted to
`$HOME/.sparkd-dev/mounts<cont_name>` on the host*<br>
* *Run: `./start_docker.sh --help` to see additional options*
3. *(Optional) Attach VS Code to the running container.*<br>
Run **Dev Containers: Attach to Running Container** from the command palette,
then select your container in the dropdown
---
## How to update the Docker image
1. Change the image by modifying the Dockerfile (don't tag arbitrary
images on your machine and push them to our repo on Docker Hub)
1. After modifying the Dockerfile, (re)build the image
```
# Run in this dir
docker build -t bluetradingsystems/sparkd-dev:latest .
```
***Note:** Your docker login must have write permissions to push to the
[sparkd-dev][docker repo sparkd-dev] repository*
2. Commit the changes to Dockerfile in git
3. Push the new image to Docker Hub
```
docker push bluetradingsystems/sparkd-dev:latest
```
***Note:** The image doesn't have to be on Docker Hub, we can simply build
it from scratch on our local machines (with the Dockerfile). However, this
takes time. It is significantly quicker to download a prebuilt image, so we
store it on a remote repository to save time when setting up a new dev
machine.*
+123
View File
@@ -0,0 +1,123 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
if [[ ! -v XDG_CONFIG_HOME ]]; then
export XDG_CONFIG_HOME="$HOME/.config"
fi
export PATH="$HOME/.local/bin:$PATH"
+25
View File
@@ -0,0 +1,25 @@
if ! set -q XDG_CONFIG_HOME
set -g XDG_CONFIG_HOME "$HOME/.config"
end
set fish_config_home $XDG_CONFIG_HOME/fish
if test -f "$fish_config_home/aliases.fish"
source "$fish_config_home/aliases.fish"
end
# enable general colors and case insensitive search in 'less'
set -x LESS "$LESS -R -Q -I"
set -x LC_ALL en_US.UTF-8
# enable syntax highlighting in 'less'
# set highlight color scheme in 'less' (fg)(bg)
set -g LESS_TERMCAP_md (tput bold)(tput setaf 36)
set -g LESS_TERMCAP_me (tput sgr0)
set -g LESS_TERMCAP_so (tput setaf 232)(tput setab 49)
set -q TERM
if test $status != 0; or test $TERM = 'xterm'
set -g TERM 'xterm-256color'
end
# Fix impossible-to-see navy blue command text color
set fish_color_command F8F8F2
set -g PATH "$HOME/.local/bin" "$PATH"
+33
View File
@@ -0,0 +1,33 @@
{
"image": "bluetradingsystems/sparkd-dev:latest",
// 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",
"-p",
"8000:8000",
"-p",
"8001:8001",
"-p",
"8002:8002",
"-p",
"8003:8003"
],
"mounts": [
"source=${localEnv:HOME}/.bts/devcontainer-mounts/${devcontainerId},target=/home/bts,type=bind"
]
}
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
this_dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
repo_dir="$(cd "$this_dir" && git rev-parse --show-toplevel)"
tools_dir="$repo_dir/tools"
gen_tag="GENERATED BY $(basename "${BASH_SOURCE[0]}")"
function copy_if_not_exist() {
src="$1"
dest="$2"
if [[ ! -e "$src" ]]; then
echo "Unable to copy $src to $dest. Source file doesn't exist"
exit 1
fi
if [[ ! -e "$dest" ]]; then
cp "$src" "$dest"
fi
}
# Init bashrc
echo "Initializing bashrc"
copy_if_not_exist "$this_dir/bashrc" "$HOME/.bashrc"
# Init fish config
echo "Initializing fish config"
fish_cfg_dir="$HOME/.config/fish/"
mkdir -p "$fish_cfg_dir"
exec "$tools_dir/write_tag_block.sh" \
--tag "$gen_tag" \
--replace \
--in-place \
--file "$fish_cfg_dir/config.fish" \
--text "$(cat "$this_dir/config.fish")"
+250
View File
@@ -0,0 +1,250 @@
#!/usr/bin/env bash
function _exit() {
if [[ "$#" -gt 1 ]]; then
# When there are multiple args, the last arg is the exit code.
echo "${@:1:($# - 1)}"
exit "${@: -1}"
fi
echo "$1"
exit 0
}
help_text="\
Add or update a user's uid
This script is intended to be run in a Docker container as a means to obtain
file permissions in mounted directories owned by the specified UID.
Usage: set_user.sh [OPTIONS] USER UID
Positionals:
USER The name of the user
Options:
--user USER The name of the user (defaults to 'bts')
--uid UID The new uid to give USER (defaults to '1000')
--group GROUP The primary group to give USER (defaults to USER)
--gid GID The primary gid to give USER (defaults to UID)
--pass PASSWORD The password to give USER (defaults to USER, only applies
if USER hasn't been created yet)
--modify-existing Update UID/GID even if USER already exists
-h,--help Print this help message and exit
"
function _add_group() {
if [[ "$#" -ne 2 ]]; then
_exit "'_add_group' requires exactly 2 args (group, gid). Received $#." 1
fi
local group="$1"
local gid="$2"
# Check if gid already exists
local existing_group=""
existing_group="$(getent group "$gid" | cut -d : -f 1)"
if [[ -n "$existing_group" ]]; then
if [[ "$existing_group" != "$group" ]]; then
echo "\
The gid '$gid' is already in use by group '$existing_group' (will not rename \
the group)"
fi
return
fi
# Check if group with same name already exists
local existing_gid=""
existing_gid="$(getent group "$group" | cut -d : -f 3)"
if [[ -n "$existing_gid" ]]; then
# The group already exists. Only modify if --modify-existing was specified.
if [[ "$modify_existing" -eq 0 ]]; then
_exit "\
The group '$group' already exists with gid '$existing_gid'.
Specify --modify-existing to change the gid anyways." 1
fi
echo "Changing gid for group '$group' from '$existing_gid' to '$gid'"
groupmod -g "$gid" "$group"
else
# The group doesn't exist. Add it
echo "Adding group '$group:$gid'"
groupadd -g "$gid" "$group"
fi
}
function _add_user() {
local user="$1"
local uid="$2"
local group="$3"
local gid="$4"
local pass="$5"
if [[ "$#" -ne 5 ]]; then
_exit "'_add_user' requires exactly 5 args (user, uid, group, gid, pass). \
Received $#." 1
fi
# Check if uid is being used by another user
local existing_user=""
existing_user="$(getent passwd "$uid" | cut -d : -f 1)"
if [[ -n "$existing_user" ]]; then
if [[ "$existing_user" != "$user" ]]; then
_exit "The uid '$uid' is already in use by user '$existing_user'." 1
fi
echo "The user '$user' already has the specified uid '$uid'."
# Modify gid if necessary
local existing_gid=""
existing_gid="$(id -g "$user" 2> /dev/null)"
if [[ "$existing_gid" = "$gid" ]]; then
echo "The user '$user' already has the specified gid '$gid'."
return
fi
if [[ "$modify_existing" -eq 0 ]]; then
_exit "\
The user '$user' is associated with the primary group '$existing_gid'.
Specify --modify-existing to change the gid anyways." 1
fi
echo "Changing primary group for '$user' from '$existing_gid' to '$gid'."
usermod -g "$gid" "$user"
return
fi
# Check if user with same name already exists
local existing_uid=""
existing_uid="$(id -u "$user" 2> /dev/null)"
if [[ -n "$existing_uid" ]]; then
if [[ "$existing_uid" = "$uid" ]]; then
_exit "The user '$user' already has the specified uid '$uid'" 0
fi
if [[ "$modify_existing" -eq 0 ]]; then
_exit "\
User '$user' already exists with uid '$existing_uid'.
Specify --modify-existing to change the uid anyways." 1
fi
echo "Changing uid for user '$user' from '$existing_uid' to '$uid'"
if ! usermod -u "$uid" -g "$gid" "$user"; then
_exit "usermod exited with code $?" 1
fi
return
fi
# The user doesn't exist. Add it
echo "Adding user '$user:$uid' (group='$group:$gid', password='$pass')"
useradd -m -u "$uid" -g "$gid" -G sudo --password "$(openssl passwd -1 "$pass")" "$user"
}
function _update_fish_dir_perms() {
local user="$1"
local uid="$2"
local gid="$3"
# When a fish shell session starts, a temp dir named '/tmp/fish.<user>' is
# created with the user's current uid/gid. If such a dir exists for the
# specified USER, make sure the uid/gid match the new values.
fish_dir="/tmp/fish.$user"
if [[ -d "$fish_dir" ]]; then
perms="$uid:$gid"
existing_perms="$(stat -c %u:%g "$fish_dir")"
if [[ "$existing_perms" != "$perms" ]]; then
echo "Changing uid:gid for dir '$fish_dir' from '$existing_perms' to '$perms'"
chown -R "$perms" "$fish_dir"
fi
fi
}
user=""
group=""
pass=""
declare -i uid=0
declare -i gid=0
declare -i modify_existing=0
while [[ $# -gt 0 ]]; do
case "$1" in
--user)
if [[ -z "$2" ]]; then
_exit "USER (--user) must be non-empty" 1
elif [[ "$2" = "root" ]]; then
_exit "USER (--user) cannot be 'root'" 1
fi
user="$2"
shift 2
;;
--group)
if [[ -z "$2" ]]; then
_exit "GROUP (--group) must be non-empty" 1
elif [[ "$2" = "root" ]]; then
_exit "GROUP (--group) cannot be 'root'" 1
fi
group="$2"
shift 2
;;
--uid)
if [[ -z "$2" ]]; then
_exit "UID (--uid) must be non-empty" 1
fi
uid="$2"
shift 2
;;
--gid)
if [[ -z "$2" ]]; then
_exit "GID (--gid) must be non-empty" 1
fi
gid="$2"
shift 2
;;
--pass)
if [[ -z "$2" ]]; then
_exit "PASS (--pass) must be non-empty" 1
fi
pass="$2"
shift 2
;;
--modify-existing)
modify_existing=1
shift 1
;;
-h)
;&
--help)
_exit "$help_text" 0
;;
*)
if [[ -z "$1" ]]; then
_exit "Invalid positional argument '$1'" 1
elif [[ -z "$user" ]]; then
user="$1"
elif [[ -z "$uid" ]]; then
uid="$1"
else
_exit "Unexpected argument '$1'" 1
fi
shift 1
;;
esac
done
if [[ -z "$user" ]]; then
user="bts"
fi
if [[ $uid -eq 0 ]]; then
uid=1000
fi
# In general, a user's primary group/gid matches the user's name/uid.
# If group/gid args weren't specified, set them to name/uid.
if [[ -z "$group" ]]; then
group="$user"
fi
if [[ $gid -eq 0 ]]; then
gid=$uid
fi
if [[ -z "$pass" ]]; then
pass="$user"
fi
_add_group "$group" "$gid"
_add_user "$user" "$uid" "$group" "$gid" "$pass"
_update_fish_dir_perms "$user" "$uid" "$gid"
+230
View File
@@ -0,0 +1,230 @@
#!/usr/bin/env bash
function _exit() {
if [[ "$#" -gt 1 ]]; then
# When there are multiple args, the last arg is the exit code.
echo "${@:1:($# - 1)}"
exit "${@: -1}"
fi
echo "$1"
exit 0
}
help_text="\
Start a docker dev container
Usage: start_docker.sh [OPTIONS] image container
Positionals:
image The image to instantiate
container The name for the container
Options:
-u,--user USER The user to add in the container (defaults to 'bts')
-p,--pass PASS The password for USER in the container (defaults to USER)
-i,--image IMAGE The image to instantiate (defaults to 'bluetradingsystems/sparkd-dev:latest')
-c,--container CONT The name for the container
-m,--mount MOUNT The name for the folder (outside the container) to create/mount to the home
directory in the container. Mount folders are added here: $mount_prefix
--mount-existing Mount the specified dir even if it already exists
--port <cont_port>:<host_port> OR [<cont_port>:<host_port>,...] Port mapping(s). May be
specified multiple times.
-h,--help Print this help message and exit
"
mount_prefix="$HOME/.sparkd-dev/mounts"
declare docker_user=""
declare docker_pass=""
declare image_name=""
declare cont_name=""
declare mount_name=""
declare -i mount_existing=0
declare -a port_mappings=()
while [[ $# -gt 0 ]]; do
case "$1" in
-u)
;&
--user)
if [[ -z "$2" ]]; then
_exit "User (-u,--user) must be non-empty" 1
fi
docker_user="$2"
shift 2
;;
-p)
;&
--pass)
if [[ -z "$2" ]]; then
_exit "Password (-p,--pass) must be non-empty" 1
fi
docker_pass="$2"
shift 2
;;
-i)
;&
--image)
if [[ -n "$image_name" ]]; then
_exit "Unexpected argument '$1'" 1
elif [[ -z "$2" ]]; then
_exit "Image (-i,--image) must be non-empty" 1
fi
image_name="$2"
shift 2
;;
-c)
;&
--container)
if [[ -n "$cont_name" ]]; then
_exit "Unexpected argument '$1'" 1
elif [[ -z "$2" ]]; then
_exit "Container (-c,--container) must be non-empty" 1
fi
cont_name="$2"
shift 2
;;
--port)
# Parse port(s) arg, and append the result to 'port_mappings'
# Note: port(s) may be specified in bracketed notation:
# [a:b,c:d,...,y:z]
next_ports="$(echo "$2" | sed -e 's/\[//g' -e 's/\]//g' -e 's/,/ /g')"
if [[ "${#port_mappings[@]}" -gt 0 ]]; then
next_ports=" $next_ports"
fi
port_mappings+=("$next_ports")
shift 2
;;
-m)
;&
--mount)
if [[ -z "$2" ]]; then
echo "Mount (-m,--mount) must be non-empty"
fi
mount_name="$2"
shift 2
;;
--mount-existing)
mount_existing=1
shift 1
;;
-h)
;&
--help)
_exit "$help_text" 0
;;
*)
if [[ -z "$1" ]]; then
_exit "Invalid positional argument '$1'" "$help_text" 1
elif [[ -z "$image_name" ]]; then
image_name="$1"
elif [[ -z "$cont_name" ]]; then
cont_name="$1"
else
_exit "Unexpected argument '$1'" "$help_text" 1
fi
shift 1
;;
esac
done
if [[ -z "$image_name" ]]; then
image_name="bluetradingsystems/sparkd-dev:latest"
fi
host_name="$(hostname)"
if [[ -n "$cont_name" ]]; then
host_name="$host_name.$cont_name"
fi
if [[ -z "$mount_name" ]]; then
mount_name="$cont_name"
fi
if [[ -z "$mount_name" && -z "$cont_name" ]]; then
_exit "Please specify mount (-m,--mount) and/or container (-c,--container)" 1
fi
if [[ -z "$docker_user" ]]; then
docker_user="bts"
fi
if [[ "$docker_user" = "root" ]]; then
_exit "USER (--user) cannot be 'root'" 1
fi
cont_home="/home/$docker_user"
home_src="$mount_prefix/$mount_name"
home_tgt="$cont_home"
this_dir="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
repo_src="$(cd "$this_dir" && git rev-parse --show-toplevel)"
repo_tgt="$cont_home/spark"
working_dir="$cont_home"
if [[ $mount_existing -eq 0 && -e "$home_src" ]]; then
# Don't overwrite existing dir (might be mounted in another container)
_exit "Mount dir '$home_src' already exists (use --mount-existing to mount \
an existing directory)" 1
fi
mkdir -p "$home_src"
if [[ "${#port_mappings[@]}" -eq 0 ]]; then
port_mappings=("8000:8000" "8001:8001" "8002:8002" "8003:8003")
fi
# Adapt port_mappings into args for `docker run` by prepending "-p " to each
# item
declare -a docker_port_args=()
for port_mapping in "${port_mappings[@]}"; do
docker_port_args+=("-p $port_mapping")
done
echo "Starting container '$cont_name'
image_name : $image_name
cont_name : $cont_name
home_src : $home_src
home_tgt : $home_tgt
repo_src : $repo_src
repo_tgt : $repo_tgt
working dir : $working_dir
ports : ${port_mappings[*]}
"
# DON'T wrap $docker_port_args in quotes. We want bash to split args by
# whitespace
docker run \
--net bridge \
-h "$host_name" \
-e "TZ=America/New_York" \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--name "$cont_name" \
-v "$home_src:$home_tgt" \
-v "$repo_src:$repo_tgt" \
-w "$working_dir" \
${docker_port_args[*]} \
--shm-size=4024m \
-t \
-i \
-d \
-e DISPLAY="$DISPLAY" \
"$image_name"
# Add user w/ same uid and gid as the current user outside of docker, so the
# user inside the docker has file permissions in the mounted dir.
docker_group="$docker_user"
docker_uid="$(id -u "$USER")"
docker_gid="$(id -g "$USER")"
if [[ -z "$docker_pass" ]]; then
docker_pass="$docker_user"
fi
docker exec -u root -it "$cont_name" "$repo_tgt/docker/sparkd/dev/set_user.sh" \
--user "$docker_user" \
--uid "$docker_uid" \
--group "$docker_group" \
--gid "$docker_gid" \
--pass "$docker_pass"
# Run same script VS Code runs to initialize the container
docker exec -u "$docker_user" -it "$cont_name" "$repo_tgt/docker/sparkd/dev/devcontainer_post_create.sh"
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
function print_help_and_exit() {
cat <<EOF
Open a shell inside the docker container
Usage: docker_shell.sh [OPTIONS] [CONTAINER]
Options:
-u,--user The user to login with in the container (defaults to the current user)
-c,--container The container name (may also be specified as positional arg)
-h,--help Print this help message and exit
EOF
exit "$1"
}
declare docker_user=""
declare cont_name=""
while [[ $# -gt 0 ]]; do
case "$1" in
-u)
;&
--user)
if [[ -z "$2" ]]; then
echo "User (-u,--user) must be non-empty"
print_help_and_exit 1
fi
docker_user="$2"
shift 2
;;
-h)
;&
--help)
print_help_and_exit 0
;;
-c)
;&
--container)
shift 1
;&
*)
if [[ ! -z "$cont_name" ]]; then
echo "Unexpected argument '$1'"
print_help_and_exit 1
fi
cont_name="$1"
shift 1
;;
esac
done
if [[ -z "$cont_name" ]]; then
echo "Please specify the container ([-c,--container])"
print_help_and_exit 1
fi
if [[ -z "$docker_user" ]]; then
docker_user="$USER"
fi
docker exec -u "$docker_user" -it "$cont_name" bash
+233
View File
@@ -0,0 +1,233 @@
#!/usr/bin/env bash
mount_prefix="$HOME/.spark-dev/mounts"
function print_help_and_exit() {
cat <<EOF
Start a docker dev container
Usage: start_docker.sh [OPTIONS] image container
Positionals:
image The image to instantiate
container The name for the container
Options:
-u,--user USER The user to add in the container (defaults to the current user)
-p,--pass PASS The password for USER in the container (defaults to USER)
-i,--image IMAGE The image to instantiate
-c,--container CONT The name for the container
-m,--mount MOUNT The name for the folder (outside the container) to create/mount to the home
directory in the container. Mount folders are added here: $mount_prefix
--mount-existing Mount the specified dir even if it already exists
--port <cont_port>:<host_port> OR [<cont_port>:<host_port>,...] Port mapping(s). May be
specified multiple times.
-h,--help Print this help message and exit
EOF
exit "$1"
}
declare docker_user=""
declare docker_pass=""
declare image_name=""
declare cont_name=""
declare mount_name=""
declare -i mount_existing=0
declare -a port_mappings=()
while [[ $# -gt 0 ]]; do
case "$1" in
-u)
;&
--user)
if [[ -z "$2" ]]; then
echo "User (-u,--user) must be non-empty"
print_help_and_exit 1
fi
docker_user="$2"
shift 2
;;
-p)
;&
--pass)
if [[ -z "$2" ]]; then
echo "Password (-p,--pass) must be non-empty"
print_help_and_exit 1
fi
docker_pass="$2"
shift 2
;;
-i)
;&
--image)
if [[ -n "$image_name" ]]; then
echo "Unexpected argument '$1'"
print_help_and_exit 1
elif [[ -z "$2" ]]; then
echo "Image (-i,--image) must be non-empty"
print_help_and_exit 1
fi
image_name="$2"
shift 2
;;
-c)
;&
--container)
if [[ -n "$cont_name" ]]; then
echo "Unexpected argument '$1'"
print_help_and_exit 1
elif [[ -z "$2" ]]; then
echo "Container (-c,--container) must be non-empty"
print_help_and_exit 1
fi
cont_name="$2"
shift 2
;;
--port)
# Parse port(s) arg, and append the result to 'port_mappings'
# Note: port(s) may be specified in bracketed notation:
# [a:b,c:d,...,y:z]
next_ports="$(echo "$2" | sed -e 's/\[//g' -e 's/\]//g' -e 's/,/ /g')"
if [[ "${#port_mappings[@]}" -gt 0 ]]; then
next_ports=" $next_ports"
fi
port_mappings+=("$next_ports")
shift 2
;;
-m)
;&
--mount)
if [[ -z "$2" ]]; then
echo "Mount (-m,--mount) must be non-empty"
fi
mount_name="$2"
shift 2
;;
--mount-existing)
mount_existing=1
shift 1
;;
-h)
;&
--help)
print_help_and_exit 0
;;
*)
if [[ -z "$1" ]]; then
echo "Invalid positional argument '$1'"
print_help_and_exit 1
elif [[ -z "$image_name" ]]; then
image_name="$1"
elif [[ -z "$cont_name" ]]; then
cont_name="$1"
else
echo "Unexpected argument '$1'"
print_help_and_exit 1
fi
shift 1
;;
esac
done
if [[ -z "$image_name" ]]; then
image_name="bluetradingsystems/spark-crypto-dev"
fi
host_name="$(hostname)"
if [[ -n "$cont_name" ]]; then
host_name="$host_name.$cont_name"
fi
if [[ -z "$mount_name" ]]; then
mount_name="$cont_name"
fi
if [[ -z "$mount_name" && -z "$cont_name" ]]; then
echo "Please specify mount (-m,--mount) and/or container (-c,--container)"
print_help_and_exit 1
fi
if [[ -z "$docker_user" ]]; then
docker_user="$USER"
fi
home_src=$mount_prefix/$mount_name
home_tgt=$HOME
repo_src=$(git rev-parse --show-superproject-working-tree)
repo_tgt=$HOME/$(basename "$repo_src")
working_dir=$HOME
if [[ $mount_existing -eq 0 && -e "$home_src" ]]; then
# Don't overwrite existing dir (might be mounted in another container)
echo "Mount dir '$home_src' already exists (use --mount-existing to mount an existing directory)"
print_help_and_exit 1
fi
mkdir -p "$home_src"
if [[ "${#port_mappings[@]}" -eq 0 ]]; then
port_mappings=("8000:8000" "8001:8001" "8002:8002" "8003:8003")
fi
# Adapt port_mappings into args for `docker run` by prepending "-p " to each
# item
declare -a docker_port_args=()
for port_mapping in "${port_mappings[@]}"; do
docker_port_args+=("-p $port_mapping")
done
echo "Starting container '$cont_name'
image_name : $image_name
cont_name : $cont_name
home_src : $home_src
home_tgt : $home_tgt
repo_src : $repo_src
repo_tgt : $repo_tgt
working dir : $working_dir
ports : ${port_mappings[*]}
"
# DON'T wrap $docker_port_args in quotes. We want bash to split args by
# whitespace
docker run \
--net bridge \
-h "$host_name" \
-e "TZ=America/New_York" \
--cap-add=SYS_PTRACE \
--security-opt seccomp=unconfined \
--name "$cont_name" \
-v "$home_src:$home_tgt" \
-v "$repo_src:$repo_tgt" \
-w "$working_dir" \
${docker_port_args[*]} \
--shm-size=4024m \
-t \
-i \
-d \
-e DISPLAY="$DISPLAY" \
"$image_name" \
bash
# Add user w/ same uid and gid as the current user outside of docker, so the
# user inside the docker has file permissions in the mounted dir.
docker_group="$docker_user"
docker_user_uid="$(id -u "$USER")"
docker_user_gid="$(id -g "$USER")"
echo "Adding user in container '$cont_name'
name : $docker_user
uid : $docker_user_uid
gid : $docker_user_gid"
if [[ -z "$docker_pass" ]]; then
docker_pass="$docker_user"
echo "Giving user '$docker_user' a secure password: $docker_pass"
fi
docker exec -u root -it "$cont_name" groupadd -g "$docker_user_gid" "$docker_group"
docker exec -u root -it "$cont_name" useradd -u "$docker_user_uid" -g "$docker_user_gid" "$docker_user"
docker exec -u root -it "$cont_name" usermod --password "$(openssl passwd -1 "$docker_pass")" "$docker_user"
docker exec -u root -it "$cont_name" usermod -aG sudo "$docker_user"
docker exec -u root -it "$cont_name" "$repo_tgt/externals/src/emumba/install_emumba-deribit-connector.sh"
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
@@ -14,7 +14,7 @@ namespace mbts.spark {
class VolSurfaceAdvancedSettingsEditorVM : ViewModelBase {
readonly VolSurfaceAdvancedSettings _settings;
public VolSurfaceAdvancedSettingsEditorVM(VolSurfaceAdvancedSettings settings, string vs_name, Action<VolSurfaceAdvancedSettings> commit) {
public VolSurfaceAdvancedSettingsEditorVM(VolSurfaceAdvancedSettings settings, string vs_name) {
_settings = settings;
_settings.theo_handle_measure = VolSurfaceEnums.GeneralChangeMeasure.Absolute;
_settings.slide_handle_measure = VolSurfaceEnums.GeneralChangeMeasure.Percentage;
@@ -23,7 +23,7 @@ namespace mbts.spark {
if (_settings.precomputed_theo_handles == null)
_settings.precomputed_theo_handles = new List<double>();
vol_surface_name = vs_name;
this.commit = new DelegateCommand(() => request_commit?.Invoke(ProtobufSerializationHelper.clone(_settings)));
commit = new DelegateCommand(() => request_commit?.Invoke(ProtobufSerializationHelper.clone(_settings)));
}
public event Action<VolSurfaceAdvancedSettings> request_commit;
+18 -15
View File
@@ -121,21 +121,24 @@ namespace mbts.spark {
if (settings == null) {
return null;
}
// return new VolSurfaceAdvancedSettingsEditor {
// DataContext = new VolSurfaceAdvancedSettingsEditorVM(
// VolSurfaceUtilityFunctions.clone_proto(settings.advanced_settings),
// settings.core_settings.vol_surface_name,
// advanced_settings => {
// var current_settings = _get_volsurface_settings();
// if (current_settings == null) BTSMessageBox.Show("Error changing settings", "VS Settings", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error, true, true, true);
// else {
// current_settings.advanced_settings = advanced_settings;
// _model.set_candidate_settings(current_settings);
// }
// }
// )
// };
return null;
var vm = new VolSurfaceAdvancedSettingsEditorVM(
VolSurfaceUtilityFunctions.clone_proto(settings.advanced_settings),
settings.core_settings.vol_surface_name);
vm.request_commit += commit_advanced_settings;
return new VolSurfaceAdvancedSettingsEditor {
DataContext = vm
};
async void commit_advanced_settings(VolSurfaceAdvancedSettings value) {
var current_settings = await _get_volsurface_settings();
if (current_settings == null) {
BTSMessageBox.Show("Error changing settings", "VS Settings");
}
else {
current_settings.advanced_settings = value;
_model.set_candidate_settings(current_settings);
}
}
}
Window? mk_grid_settings_win() {
@@ -9,26 +9,34 @@ namespace mbts.analytics
[ProtoBuf.ProtoContract(Name = "VolSurfaceAdvancedSettings")]
public class VolSurfaceAdvancedSettings
{
public static VolSurfaceAdvancedSettings Default =>
new() {
number_of_cashed_saved_days = double.NaN,
precomputed_theo_handles = new(0),
theo_handle_measure = VolSurfaceEnums.GeneralChangeMeasure.Absolute,
precomputed_slide_handles = new(0),
slide_handle_measure = VolSurfaceEnums.GeneralChangeMeasure.Percentage,
publish_from_client = false,
publish_from_client_user = string.Empty,
strike_normalization_axis = VolSurfaceEnums.VolCurveStrikeAxis.RawStrike,
};
[ProtoBuf.ProtoMember(1)]
[System.ComponentModel.DefaultValue(Double.NaN)]
public double number_of_cashed_saved_days;
[ProtoBuf.ProtoMember(10)]
public List<double> precomputed_theo_handles;
[ProtoBuf.ProtoMember(15)]
[System.ComponentModel.DefaultValue(VolSurfaceEnums.GeneralChangeMeasure.Absolute)]
public VolSurfaceEnums.GeneralChangeMeasure theo_handle_measure;
[ProtoBuf.ProtoMember(20)]
public List<double> precomputed_slide_handles;
[ProtoBuf.ProtoMember(25)]
[System.ComponentModel.DefaultValue(VolSurfaceEnums.GeneralChangeMeasure.Percentage)]
public VolSurfaceEnums.GeneralChangeMeasure slide_handle_measure;
[ProtoBuf.ProtoMember(30)]
//[System.ComponentModel.DefaultValue(false)]
public bool publish_from_client;
[ProtoBuf.ProtoMember(40)]
@@ -38,5 +46,11 @@ namespace mbts.analytics
[ProtoBuf.ProtoMember(50)]
[System.ComponentModel.DefaultValue(VolSurfaceEnums.VolCurveStrikeAxis.RawStrike)]
public VolSurfaceEnums.VolCurveStrikeAxis strike_normalization_axis;
public void ensure_no_nulls() {
precomputed_theo_handles ??= new(0);
precomputed_slide_handles ??= new(0);
publish_from_client_user ??= string.Empty;
}
}
}
@@ -25,7 +25,8 @@ namespace mbts.analytics {
volpath_settings = new(),
safety_limits = new(),
},
polynomial_model_settings = new()
polynomial_model_settings = new(),
advanced_settings = VolSurfaceAdvancedSettings.Default
};
[ProtoMember(10)]
@@ -79,6 +80,8 @@ namespace mbts.analytics {
if (core_settings.time_settings == null) {
core_settings.time_settings = new VolSurfaceTimeSettings();
}
advanced_settings ??= VolSurfaceAdvancedSettings.Default;
advanced_settings.ensure_no_nulls();
return this;
}
}
@@ -40,10 +40,8 @@ namespace mbts.analytics {
/// last computed min/max driver for each exp
private IDictionary<VolSurfaceExpiration, Tuple<double, double>>
_computed_driver_range_map = new Dictionary<VolSurfaceExpiration, Tuple<double, double>>();
private readonly IEnumerable<double> _default_abs_moves =
new double[] { 300, -200, -125, -100, -75, -50, -25, 0, 25, 50, 75, 100, 125, 200, 300 };
private readonly IEnumerable<double> _default_abs_moves = config.Configuration.get<bts.config.VolSurface>().default_abs_moves;
private readonly double _cushion_percentage = 25.0;
public event
Action<IDictionary<VolSurfaceExpiration, IEnumerable<Theos>>, double, double> on_theos =
(o, vt, tt) => { };
@@ -52,7 +50,7 @@ namespace mbts.analytics {
(o, vt, tt) => { };
public VolSurfaceInterpGreeksProducer(int vs_id) {
Log.Gen.info($"VolSurfaceInterpGreeksProducer.cons vs_id: {vs_id}");
Log.Gen.info($"VolSurfaceInterpGreeksProducer.cons vs_id: {vs_id}, _default_abs_moves: {string.Join(", ", _default_abs_moves)}");
_vs_id = vs_id;
}
@@ -72,7 +70,7 @@ namespace mbts.analytics {
}
public void set_vol_data(VolSurfaceInput vs_input) {
Log.Gen.info($"VolSurfaceInterpGreeksProducer.set_vol_data vs_id: {_vs_id}");
Log.Gen.info($"VolSurfaceInterpGreeksProducer.set_vol_data vs_id: {_vs_id} precomputed_theo_handles?: {string.Join(", ", (vs_input?.surface_settings?.advanced_settings?.precomputed_theo_handles).empty_if_null())}");
_vs_input = vs_input != null ? VolSurfaceUtilityFunctions.clone_proto(vs_input) : null;
_compute_and_fire(InputType.Vol);
}
@@ -0,0 +1,58 @@
<Window
x:Class="mbts.ui.shell.VolSurfaceAdvancedSettingsEditor"
x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:mbts.ui.controls"
xmlns:cv="clr-namespace:mbts.ui.converters"
Title="{Binding vol_surface_name, StringFormat='{}Advanced Settings \&apos;{0}\&apos;'}"
Style="{StaticResource BTSDialog}"
SizeToContent="WidthAndHeight"
TextElement.FontSize="10">
<StackPanel>
<Grid Margin="5" Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="label"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<GroupBox Grid.ColumnSpan="2" Padding="3">
<GroupBox.Header>
<TextBlock Text="Theos" FontWeight="Bold"/>
</GroupBox.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="label"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<c:RadioButtonsControl Grid.ColumnSpan="2" Margin="0,0,0,5" ItemsSource="{Binding general_change_measures}" SelectedItem="{Binding theo_handle_measure}" IsEnabled="False"/>
<TextBlock Grid.Row="1" Text="Precomputed Handles" VerticalAlignment="Center"/>
<TextBox
x:Name="PART_Handles"
Validation.ErrorTemplate="{x:Null}"
Grid.Row="1"
Grid.Column="1"
Width="160"
Margin="5,0,0,0"
Text="{Binding precomputed_theo_handles, Converter={x:Static cv:EnumerableDoubleStringConverter.Instance}}" />
</Grid>
</GroupBox>
<TextBlock Visibility="Collapsed" Grid.Row="1" VerticalAlignment="Center" Margin="5,0,0,0" Text="Num Cash Saved Days" />
<c:TickUpDownDouble Visibility="Collapsed" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Margin="14,5,5,5" Value="{Binding number_of_cash_saved_days}"/>
<TextBlock Grid.Row="2" VerticalAlignment="Center" Margin="5,0,0,0" Text="Strike Normalization Axis"/>
<ComboBox Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch" Margin="14,5,5,5" ItemsSource="{Binding strike_normalization_axes}" SelectedValue="{Binding selected_strike_normalization_axis}"/>
<CheckBox Grid.Row="3" Margin="7,0,0,0" Content="Publish From Client" IsChecked="{Binding publish_from_client}"/>
</Grid>
<c:DialogSkirtOKCancel OKCommand="{Binding commit}" />
</StackPanel>
</Window>
@@ -0,0 +1,11 @@
namespace mbts.ui.shell {
using System.Windows;
/// <summary>
/// Interaction logic for VolSurfaceAdvancedSettingsEditor.xaml
/// </summary>
partial class VolSurfaceAdvancedSettingsEditor : Window {
public VolSurfaceAdvancedSettingsEditor() =>
InitializeComponent();
}
}
@@ -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();
@@ -87,7 +87,7 @@ namespace mbts.spark {
length = _initial_row_count,
};
LadderPriceList _pending_price_list = null;
IComparer<double> _price_comparer;
IComparer<double> _price_comparer = MathUtils.epsilon_comparer.reverse();
double _last_origin_price;
readonly MarketBreakLines _mkt_break_lines;
NativePriceSize _last_trade;
@@ -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>
@@ -14,6 +14,9 @@ namespace mbts.spark {
uint _bid_size, _ask_size;
ulong _time;
public BBOVM() =>
_dispose = Disposable.Create(() => Disposable.dispose(ref _md_poll));
public SecurityImmutable? security => _security_md?.security;
public SecurityMD? security_md {
get => _security_md;
@@ -63,7 +63,11 @@ namespace mbts {
if (ticks_per_base.is_int()) {
return true;
}
return tick.tick_unit > tick.tick_base && tick.tick_base == 1;
// The Log10 check accounts for [non-perp] futures at Deribit, which use TickFactors 25/10
// (e.g., 10.0, 12.5, 15.0, etc.). It was added 11/02/2023, when it replaced the
// commented out line below.
// return tick.tick_unit > tick.tick_base && tick.tick_base == 1;
return tick.tick_unit > tick.tick_base && Math.Log10(tick.tick_base).is_int();
}
public static bool is_valid(this RegionalTickFactors regional_tick) =>
@@ -667,7 +671,8 @@ namespace mbts {
if (negate) {
value = -value;
}
var text = core_impl();
var text = tick.tick_unit == 25 && tick.tick_base == 10 ?
deribit_future_impl() : core_impl();
if (!settings.show_zero_integer) {
// Hide the integer if its zero. This could be better optimized,
// but speed shouldn't be an issue, so it doesn't seem worth the time/effort.
@@ -721,6 +726,37 @@ namespace mbts {
return "Overflow";
}
}
string deribit_future_impl() {
try {
// TODO: Replace this hack with a suitable long term solution
//
// The hack: [non-perp] futures at Deribit tick in units of '2.5' (e.g., 10.0, 12.5,
// 15.0, etc.). However, this battle-tested impl is predicated on the tick base being
// a multiple of the tick unit. So, to avoid changing key battle-tested logic, let's
// do the following:
// 1) Round the value to the nearest multiple of '2.5' (the tick size)
// 2) Format the rounded value with normal tick factors (unit 5, base 10),
// (ticks of the sort this method was designed to expect).
var tuf = tick.tick_unit_frac<T>();
var total_ticks = value / tuf;
long total_ticks_l = NumericCastConverter<T, long>.convert(value / tuf);
var rounded_total_ticks = NumericCastConverter<long, T>.convert(total_ticks_l);
var rem = value - (rounded_total_ticks * tuf);
var unit_rem = rem / tuf;
Log.assert(unit_rem <= T.One && unit_rem >= T.Zero);
// Check if unit_rem closer to T.One, or T.Zero. Round accordingly
if (T.One - unit_rem <= unit_rem - T.Zero) {
// round up
rounded_total_ticks++;
}
var rounded_val = tuf * rounded_total_ticks;
return _format_tick(new TickFactors(10, 5), rounded_val, settings);
} catch (OverflowException ex) {
Log.Ui.warn($"Arithmetic overflow exception in format_tick (tick:{tick}, value:{value}):{ex}");
return "Overflow";
}
}
}
static T _round_tick<T>(T tick_unit_frac, T input) where T : IFloatingPointIeee754<T> =>
@@ -134,8 +134,20 @@ namespace bts.data.ticks {
static TickFactors _inflate_to_base(TickFactors tick_factors, double new_base) =>
new TickFactors(new_base, tick_factors.tick_unit * new_base / tick_factors.tick_base);
static bool _check_tick_size(double tick_size) =>
tick_size > 0 && (tick_size <= 0.5 || MathUtils.is_int(tick_size));
static bool _check_tick_size(double tick_size) {
if (!tick_size.is_real_positive()) {
return false;
}
if (tick_size <= 0.5 || tick_size.is_int()) {
return true;
}
// Check if tick size represents quarters (i.e., `tick_size=0.25 * 10^c` for some int c).
// Note: this check is designed specifically to support (non-perp) futures at Deribit
if (Math.Log10(tick_size / 0.25).is_int()) {
return true;
}
return false;
}
struct SpecKey : IEquatable<SpecKey> {
public readonly uint denominator, display_digits;
@@ -209,6 +209,17 @@ namespace mbts.spark {
}
public static decimal round_to_tick(decimal tick_size, decimal value) {
if (tick_size == (decimal)2.5) {
// This is a special case for [non-perp] futures at Deribit, which tick in 25/10
// (unit/base). While this code looks harmless enough, and should work for all ticks in
// theory, let's be extra safe and only apply the change to a specific case (when
// tick_size == 2.5).
// Note: Making the ticks code work for such a wide range of tick factors was no easy
// task, and involved overcoming a plethora of obscure rounding errors along the way.
var n_ticks = value / tick_size;
var simple_round = tick_size * n_ticks;
return simple_round;
}
decimal intpart = (long)value;
decimal floatpart = value % 1;
floatpart = ((int)(floatpart / tick_size)) * tick_size;
@@ -293,6 +304,11 @@ namespace mbts.spark {
if (!tf.low_tick.Equals(tf.high_tick) || !tf.is_valid() || tf.low_tick.is_integer())
return null;
var ticks_per_dollar = (uint)(tf.low_tick.tick_base / tf.low_tick.tick_unit);
// Note: this check was introduced specifically to account for [non-perp] Futures at
// Deribit, which use TickFactors 25/10 (e.g., 10.0, 12.5, 15.0, etc.).
if (ticks_per_dollar == 0) {
return null;
}
// if ticks_per_row is greater than ticks_per_dollar, round to a multiple of ticks_per_dollar
if (ticks_per_row > ticks_per_dollar) {
return (uint)(ticks_per_dollar * Math.Floor((double)(ticks_per_row / ticks_per_dollar)));
-1
View File
@@ -1 +0,0 @@
set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/MarketDataSubscriptionParams.proto;api/md/binance/BinanceDepthStreamParams.proto;api/md/binance/BinanceMarketDataSubscriptionParams.proto;api/md/deribit/DeribitMarketDataSubscriptionParams.proto;api/md/ftx/FTXDepthStreamParams.proto;api/md/ftx/FTXMarketDataSubscriptionParams.proto;api/md/glbx/GlbxMarketDataSubscriptionParams.proto;api/md/huobi/HuobiMarketDataSubscriptionParams.proto;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/AnalyticsService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;communincation/websockets/tests/WebsocketSyncClientTests.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/SecurityMetadataCollection.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;config/tests/HTTPServer.cpp;config/tests/config_ref_tests.cpp;config/tests/config_tests.cpp;config/text_format/text_format.cpp;domain/AggressorSide.cpp;domain/NewOrder.cpp;domain/OrderDefinition.cpp;domain/OrderStatus.cpp;domain/OrderUpdate.cpp;domain/Side.cpp;domain/TimeInForce.cpp;domain_model/Security.cpp;domain_model/Security.proto;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/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.cpp;jetfix/codec/FIXArray.cpp;jetfix/common/OutFIX.cpp;jetfix/connection/AsyncReader.cpp;jetfix/connection/IConnection.cpp;jetfix/connection/SocketConnection.cpp;jetfix/gateway/CoreGateway.cpp;jetfix/gateway/JetFIXGatLine truncated
-1
View File
@@ -1 +0,0 @@
set(sources api/analytics/ExpirationDriver.proto;api/analytics/TimeWeightedInterpolatedDriver.proto;api/apicore.proto;api/apigateway.proto;api/apioptions.proto;api/core/ApiClientInterop.cpp;api/core/ApiServerInterop.cpp;api/domain/Currency.proto;api/domain/SecurityCriteria.proto;api/domain/SecurityCriteriaClause.proto;api/domain/SecurityExpiration.proto;api/domain/SecurityMetadata.proto;api/domain/SecurityMetadataCollection.proto;api/domain/SecurityMetadataItem.proto;api/domain/SecurityType.proto;api/domain/TickDisplayRule.proto;api/domain/TickDisplaySettings.proto;api/domain/TickFactors.proto;api/domain/Venue.proto;api/io/URL.proto;api/md/MarketDataSubscriptionParams.proto;api/md/binance/BinanceDepthStreamParams.proto;api/md/binance/BinanceMarketDataSubscriptionParams.proto;api/md/deribit/DeribitMarketDataSubscriptionParams.proto;api/md/ftx/FTXDepthStreamParams.proto;api/md/ftx/FTXMarketDataSubscriptionParams.proto;api/md/glbx/GlbxMarketDataSubscriptionParams.proto;api/md/huobi/HuobiMarketDataSubscriptionParams.proto;api/public/ApiServer.cpp;api/public/ClientChannel.cpp;api/public/QuickbusClientChannel.cpp;api/public/ServerChannel.cpp;api/public/ServiceContext.cpp;api/service_helpers/AdminServiceUtils.cpp;api/service_helpers/AlgoServiceUtils.cpp;api/service_helpers/PositionUtilities.cpp;api/services/AdminService.proto;api/services/AlgoDefinitionService.proto;api/services/AlgoService.proto;api/services/AnalyticsService.proto;api/services/ApiUnitTestService.proto;api/services/AuthService.proto;api/services/BasePositionService.proto;api/services/ErrorReportService.proto;api/services/HelloService.proto;api/services/MBOService.proto;api/services/MarginService.proto;api/services/MarketDataAuxiliaryService.proto;api/services/MarketDataRelay.proto;api/services/MarketDataService.proto;api/services/MoneyFileService.proto;api/services/OrderService.proto;api/services/OutOfProcessURLListener.proto;api/services/PersistenceService.proto;api/services/PositionService.proto;api/services/ShellDiagnosticService.proto;api/services/ShellLatencyService.proto;api/services/SyntheticSecurityService.proto;api/test/ApiTests.cpp;api/test/HelloServiceServer.cpp;config/ConfigCheck.cpp;config/ConfigDownloader.cpp;config/ConfigErrorCollector.cpp;config/ConfigLog.cpp;config/ConfigPropertyEvaluator.cpp;config/ConfigValueQueue.cpp;config/ConfigurationException.cpp;config/ConfigurationState.cpp;config/PreprocessInputStream.cpp;config/config.cpp;config/defaults/MarketData.conf;config/defaults/Ports.conf;config/defaults/SecurityMetadataCollection.conf;config/defaults/Symbols.conf;config/defaults/cme_reference_data.conf;config/defaults/edge.conf;config/defaults/jetfix.conf;config/defaults/keycode.conf;config/defaults/logging.conf;config/defaults/orderman_cfg.conf;config/defaults/orders_fills_cleanup.conf;config/defaults/position_cfg.conf;config/defaults/span.conf;config/defaults/spreader.conf;config/defaults/testkeys.conf;config/defaults/threads.conf;config/defaults/toggles.conf;config/extensions/extensions.proto;config/invalid/invalid.proto;config/protos/algo_types.proto;config/protos/cme_reference_data.proto;config/protos/exchange_sim_cfg.proto;config/protos/jetfix.proto;config/protos/keycode.proto;config/protos/logging.proto;config/protos/market_data.proto;config/protos/mercury_cfg.proto;config/protos/orderman_cfg.proto;config/protos/orders_fills_cleanup.proto;config/protos/perflog_cfg.proto;config/protos/ports.proto;config/protos/position_cfg.proto;config/protos/quickbus_cfg.proto;config/protos/span.proto;config/protos/spartan.proto;config/protos/spreader.proto;config/protos/subprocess.proto;config/protos/symbols.proto;config/protos/system.proto;config/protos/testkeys.proto;config/protos/threads.proto;config/protos/toggles.proto;config/protos/ui.proto;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/Security.proto;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/QueryParams.cpp;io/URL.cpp;io/http/CurlHandle.cpp;io/http/HTTPClient.cpp;io/http/HTTPHeaders.cpp;io/http/HTTPRequest.cpp;io/http/HTTPResponse.cpp;io/websocket/WebsocketClient.cpp;io/websocket/WebsocketClientConfiguration.cpp;io/websocket/WebsocketError.cpp;io/websocket/WebsocketMessage.cpp;io/websocket/WebsocketSSLClientInternal.cpp;io/websocket/tests/WebsocketClientTests.cpp;logging/LoggerHub.cpp;logging/Sink.cpp;logging/logging.cpp;logging/tests/logging_tests.cpp;md/CCApiDepthWalker.cpp;md/CCApiListenerAdaptor.cpp;md/CCApiRequestor.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/MarketDataLine truncated
+62 -148
View File
@@ -1,170 +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
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)
target_link_libraries(
libspark
libcurl
debug
fmtd
optimized
fmt
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@)
+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 {
+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
@@ -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
@@ -0,0 +1,22 @@
VolSurface {
value {
default_abs_moves: -600
default_abs_moves: -300
default_abs_moves: -200
default_abs_moves: -125
default_abs_moves: -100
default_abs_moves: -75
default_abs_moves: -50
default_abs_moves: -25
default_abs_moves: 0
default_abs_moves: 25
default_abs_moves: 50
default_abs_moves: 75
default_abs_moves: 100
default_abs_moves: 125
default_abs_moves: 200
default_abs_moves: 300
default_abs_moves: 600
}
}
@@ -0,0 +1,6 @@
syntax = 'proto2';
package bts.config;
message VolSurface {
repeated double default_abs_moves = 1;
}
+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
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#ifndef WIN32
#ifndef _WIN32
#include <bits/stdint-uintn.h>
#endif
#include <cstdint>
+2 -1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <ostream>
#include <string>
#include <vector>
namespace bts::io::websocket {
+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
+7 -1
View File
@@ -4,6 +4,7 @@
#include <fmt/ostream.h>
#include <iostream>
#include <type_traits>
#include <vector>
namespace bts {
namespace log {
@@ -12,7 +13,12 @@ template <class Tuple, std::size_t... Is>
std::string format_tuple(
const char *msg_template, Tuple const &t, std::index_sequence<Is...>) {
try {
return fmt::format(msg_template, std::get<Is>(t)...);
using ctx = fmt::format_context;
std::vector<fmt::basic_format_arg<ctx>> fmt_args;
(fmt_args.push_back(fmt::detail::make_arg<ctx>(std::get<Is>(t))), ...);
return fmt::vformat(
msg_template,
fmt::basic_format_args<ctx>(fmt_args.data(), fmt_args.size()));
} catch (fmt::format_error const &e) {
return fmt::format(
"Bad log message template: '{}' Error: '{}'", msg_template, e.what());
+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
View File
@@ -4,6 +4,8 @@
#include "lib/utils/bts_chrono.h"
#include "lib/logging/logging.h"
#include <fmt/chrono.h>
namespace bts {
int logging_tests;
+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();
}
+4
View File
@@ -4,9 +4,11 @@
#include "MDProducerHandle.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>
@@ -169,3 +171,5 @@ class MBOProcessor {
namespace std {
std::ostream &operator<<(std::ostream &os, const 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();
}
+3
View File
@@ -1,6 +1,9 @@
#pragma once
#include "lib/core/ValueWrapper.h"
#include <cstdint>
namespace bts::md {
using MarketDataListenerID =
+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
View File
@@ -18,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; } \
+2 -2
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "SyntheticSecurityService.h"
#include "lib/api/public/ServiceContext.h"
@@ -43,7 +43,7 @@ SyntheticSecurityService::SyntheticSecurityService(api::ServiceContext &context)
// load securities
std::set<md::UserSymbol> symbols;
md::get_system_md_symbols(api::VENUE_BTS, api::SECURITYTYPE_UNSET, symbols);
md::db::load_securities(symbols, [=](const api::Security &security) {
md::db::load_securities(symbols, [=, this](const api::Security &security) {
if (security.Contract_case() == api::Security::kSynthetic) {
auto key = SecurityKey(security.id());
_me->synthetics.insert(std::make_pair(key, security));
-1
View File
@@ -1,7 +1,6 @@
#pragma once
#include "lib/md/coconut2.h"
#include "lib/utils/optional.h"
#include <set>
#include <string>
#include <vector>
+11 -9
View File
@@ -98,17 +98,19 @@ struct MDConsumerGroup {
{"exch", Venue_Name(symbol.exchange()).substr(6) /*VENUE_*/});
stats.publish(std::make_shared<metrics::LazyCounterMetricL>(
"spark_md_book_updates",
[=]() { return channel.direct_count() + channel.implied_count(); },
[=, this]() {
return channel.direct_count() + channel.implied_count();
},
labels));
stats.publish(std::make_shared<metrics::LazyCounterMetricL>(
"spark_md_security_count",
[=]() { return channel.security_count(); }, labels));
[=, this]() { return channel.security_count(); }, labels));
stats.publish(std::make_shared<metrics::LazyCounterMetricL>(
"spark_md_trade_count", [=]() { return channel.trade_count(); },
labels));
"spark_md_trade_count",
[=, this]() { return channel.trade_count(); }, labels));
stats.publish(std::make_shared<metrics::LazyCounterMetricD>(
"spark_md_gap_count",
[=]() {
[=, this]() {
auto g = channel.gap_count();
return g == 0 ? os::nan() : g;
},
@@ -231,7 +233,7 @@ class QueryServerImpl : public IQueryServer {
_groups.shrink_to_fit();
_sub = client.on_consumer().subscribe(
[=](const MDConsumer &c) { handle_recovery(c); });
[=, this](const MDConsumer &c) { handle_recovery(c); });
subscribe_securities();
}
QueryServerImpl(const QueryServerImpl &) = delete;
@@ -586,7 +588,7 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
const MDRequest &request,
const std::function<void(const MDReply &)> &reply) override {
TimeStamp start = TimeStamp::now();
_threadpool.post([=]() {
_threadpool.post([=, this]() {
google::protobuf::Arena arena;
MDReply *preply =
google::protobuf::Arena::CreateMessage<MDReply>(&arena);
@@ -633,7 +635,7 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
const api::VoidMessage &,
const std::function<void(const ExpirationNameListReply &)> &reply)
override {
_threadpool.post([=]() {
_threadpool.post([=, this]() {
google::protobuf::Arena arena;
ExpirationNameListReply *preply =
google::protobuf::Arena::CreateMessage<ExpirationNameListReply>(
@@ -647,7 +649,7 @@ struct MDRelayServer : bts::co2::AuthenticatedMarketDataRelayBase {
const api::AuthToken &,
const SecurityKeyList &keys,
const std::function<void(const api::SecurityList &)> &reply) override {
_threadpool.post([=]() {
_threadpool.post([=, this]() {
google::protobuf::Arena arena;
api::SecurityList *preply =
google::protobuf::Arena::CreateMessage<api::SecurityList>(&arena);
+4 -4
View File
@@ -279,7 +279,7 @@ class RelayClient {
}
_rpc.requestmd(
_request,
[=](const api::Result<MDReply> &r) {
[=, this](const api::Result<MDReply> &r) {
receive_md(r);
cont();
},
@@ -292,7 +292,7 @@ class RelayClient {
_writer.write(*result.value(), &has_new_security);
// If the reply included and we have a consumer have it scan them
if (has_new_security && _pconsumer) {
scan_securities_thread().post([=]() {
scan_securities_thread().post([=, this]() {
auto count = _pconsumer->scan_securities(true);
LOG(md, Info, "Discovered {} securities.", count);
});
@@ -335,11 +335,11 @@ struct RelayScheduler {
void run() {
if (running) {
utils::TimeStamp start = utils::TimeStamp::now();
_client.request_md([=]() {
_client.request_md([=, this]() {
int64_t elapsed_ms =
(utils::TimeStamp::now() - start).milliseconds();
int64_t delay = (_interval - elapsed_ms) / speed_factor;
_ctx.post([=]() { run(); }, std::max(delay, (int64_t)0));
_ctx.post([=, this]() { run(); }, std::max(delay, (int64_t)0));
});
}
}
+5 -5
View File
@@ -165,7 +165,7 @@ class Co2Tests {
"}");
}
#ifndef WIN32
#ifndef _WIN32
void test_security_id_recorder(const std::string &db_name) {
// Verify callbacks happen after work complete
auto db1 = sqlite::open_db(db_name.c_str());
@@ -1037,7 +1037,7 @@ class Co2Tests {
REQUIRE(security_count == 5);
}
#ifndef WIN32
#ifndef _WIN32
void test_settlement_recorder() {
using namespace datetime;
security_key k1 = 401, k2 = 402;
@@ -1136,7 +1136,7 @@ TEST_CASE("CO2Tests", "[md]") {
co2_tests->setup();
#ifndef WIN32
#ifndef _WIN32
SECTION("test_security_id_recorder") {
co2_tests->test_security_id_recorder(":memory:");
co2_tests->test_security_id_recorder("file::memory:?cache=shared");
@@ -1175,7 +1175,7 @@ TEST_CASE("CO2Tests", "[md]") {
SECTION("test_retry_unresolved_spread") {
co2_tests->test_retry_unresolved_spread();
}
#ifndef WIN32
#ifndef _WIN32
SECTION("test_settlement_recorder") {
co2_tests->test_settlement_recorder();
}
@@ -1238,7 +1238,7 @@ struct Co2IndexTests {
temp->security.mutable_glbx()->set_exchange_id(id);
temp->exchange_id = id;
temp->handle.key(count);
index.add_security(id, move(temp));
index.add_security(id, std::move(temp));
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
#ifndef WIN32
#ifndef _WIN32
#include "OnixsUtils.h"
#include "lib/config/config.h"
#include "lib/config/protos/market_data.pb.h"
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "boost/filesystem.hpp"
#include "lib/utils/optional.h"
#include <optional>
namespace bts {
namespace md {
@@ -31,13 +31,12 @@ void BookUtils::change_unit_qty(
int unit_qty) {
//
bts_assert(unit_qty > 0);
int mlev = 0, mlev_qty_used = 0;
int mlev_qty_used = 0;
std::vector<md::PriceSize> unit_lev_span;
for (uint32_t i = 0; i < book_in.size();) {
int mlev_qty_rem = book_in[i].size() - mlev_qty_used;
if (mlev_qty_rem == 0) {
mlev_qty_used = 0;
mlev++;
i++;
continue;
}
@@ -49,7 +48,6 @@ void BookUtils::change_unit_qty(
} else {
unit_lev_span.emplace_back(book_in[i].int_price(), mlev_qty_rem);
mlev_qty_used = 0;
mlev++;
i++;
}
} else {
Loaded 100 of 147 files, more files were not shown because too many files have changed in this diff. Show more