Skip to content

Commit

Permalink
VER: Release 0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen authored Jul 20, 2023
2 parents 58080e0 + db76377 commit fa3e700
Show file tree
Hide file tree
Showing 43 changed files with 572 additions and 303 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ jobs:
fail-fast: false
matrix:
compiler: [clang++, g++]

name: build - ubuntu-latest - ${{ matrix.compiler}}
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand Down Expand Up @@ -54,7 +52,6 @@ jobs:
macos:
name: build - macos-latest - clang++
runs-on: macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -74,3 +71,29 @@ jobs:
run: cmake --build build
- name: Unit tests
run: cd build && ctest --verbose

windows:
name: build - windows-latest - msvc
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
env:
cache-name: cache-vcpkg
with:
path: build/vcpkg_installed
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('./vcpkg.json') }}
- name: CMake configure
run: |
cmake -S . -B build `
-DDATABENTO_ENABLE_UNIT_TESTING=1 `
-DDATABENTO_ENABLE_EXAMPLES=1 `
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_BUILD_TYPE=debug `
-DDATABENTO_USE_EXTERNAL_GTEST=0
- name: CMake build
run: cmake --build build --parallel 10
- name: Unit tests
run: cd build && ctest --verbose --exclude-regex cmake
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
build
CMakeSettings.json
vcpkg_installed
.vs
!*.zst
41 changes: 33 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 0.10.0 - 2023-07-20

#### Enhancements
- Added preliminary support for Windows
- Added `LiveThreaded::BlockForStop` to make it easier to wait for one or more records
before closing the session
- Changed `TimeseriesGetRange` to request a Zstd-compressed result for more efficient
data transfer
- Switched `BatchSubmitJob` to use form data to avoid query param length limit
- Switched `SymbologyResolve` to use POST request with form data to avoid query param
length limit

#### Breaking changes
- Changed size-related fields and `limit` parameters to use `std::uint64_t` for consistency
across architectures

#### Bug fixes
- Removed usage of non-portable `__PRETTY_FUNCTION__`

## 0.9.1 - 2023-07-11

#### Enhancements
Expand All @@ -8,9 +27,9 @@
- Added `RType` getter to `Record`

#### Bug fixes
- Batch live subscriptions to avoid hitting max message length
- Fix bug in Zstd decompression
- Fix `Historical::BatchDownload` truncating file before writing each chunk
- Added batching for live subscriptions to avoid hitting max message length
- Fixed bug in Zstd decompression
- Fixed `Historical::BatchDownload` truncating file before writing each chunk

## 0.9.0 - 2023-06-13

Expand Down Expand Up @@ -44,18 +63,24 @@
- Added initial support for live data with `LiveBlocking` and `LiveThreaded` clients
- Added support for statistics schema
- Added `SystemMsg` and `ErrorMsg` records for use in live data
- Added `strike_price`, `strike_price_currency`, and `instrument_class` to `InstrumentDefMsg`
- Added `strike_price`, `strike_price_currency`, and `instrument_class` to
`InstrumentDefMsg`
- Added `FixedPx` helper class for formatting fixed prices
- Added configurable log receiver `ILogReceiver`
- Added `instrument_class`, `strike_price`, and `strike_price_currency` to definition schema
- Added additional `condition` variants for `DatasetConditionDetail` (degraded, pending, missing)
- Added additional member `last_modified_date` to `DatasetConditionDetail` Added `has_mixed_schema`, `has_mixed_stype_in`, and `ts_out` to `Metadata` to support live data
- Added `instrument_class`, `strike_price`, and `strike_price_currency` to definition
schema
- Added additional `condition` variants for `DatasetConditionDetail` (degraded, pending,
missing)
- Added additional member `last_modified_date` to `DatasetConditionDetail`
- Added `has_mixed_schema`, `has_mixed_stype_in`, and `ts_out` to `Metadata` to support
live data
- Added optional `compression` parameter to `BatchSubmitJob`

#### Breaking changes
- Removed `related` and `related_security_id` from `InstrumentDefMsg`
- Renamed `BatchJob.cost` to `cost_usd` and value now expressed as US dollars
- Renamed `SType::ProductId` to `SType::InstrumentId` and `SType::Native` to `SType::RawSymbol`
- Renamed `SType::ProductId` to `SType::InstrumentId` and `SType::Native` to
`SType::RawSymbol`
- Renamed `RecordHeader::product_id` to `instrument_id`
- Renamed `InstrumentDefMsg::symbol` to `raw_symbol`
- Renamed `SymbolMapping::native_symbol` to `raw_symbol`
Expand Down
46 changes: 33 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
# Project details
#

project("databento" VERSION 0.9.1 LANGUAGES CXX)
project("databento" VERSION 0.10.0 LANGUAGES CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)

#
Expand All @@ -24,7 +24,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(cmake/StandardSettings.cmake)
include(cmake/StaticAnalyzers.cmake)
include(cmake/Utils.cmake)
message(STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION}...\n")
message(STATUS "Started CMake for ${PROJECT_NAME} v${PROJECT_VERSION}...")

if(NOT CMAKE_BUILD_TYPE)
if(IS_MAIN_PROJECT)
Expand All @@ -41,7 +41,7 @@ endif()
#

if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.\n")
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there.")
endif()

#
Expand All @@ -51,7 +51,7 @@ endif()
include(TestBigEndian)
test_big_endian(IS_BIG_ENDIAN)
if(IS_BIG_ENDIAN)
message(FATAL_ERROR "Big-endian platforms aren't supported because DBN parsing assumes the data is little-endian and in native byte order.\n")
message(FATAL_ERROR "Big-endian platforms aren't supported because DBN parsing assumes the data is little-endian and in native byte order.")
endif()

#
Expand Down Expand Up @@ -94,7 +94,7 @@ set_target_properties(
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}"
)

message(STATUS "Added all header and implementation files.\n")
message(STATUS "Added all header and implementation files.")

#
# Set the project standard and warnings
Expand All @@ -110,7 +110,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE -fstandalone-debug)
endif()

verbose_message("Applied compiler warnings.\n")
verbose_message("Applied compiler warnings.")

#
# Model project dependencies
Expand All @@ -119,18 +119,19 @@ verbose_message("Applied compiler warnings.\n")
include(FetchContent)
# JSON
if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_JSON)
find_package(nlohmann_json 3.11.2 REQUIRED)
find_package(nlohmann_json REQUIRED)
else()
set(json_version 3.11.2)
if(CMAKE_VERSION VERSION_LESS 3.24)
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
URL https://github.com/nlohmann/json/releases/download/v${json_version}/json.tar.xz
)
else()
# DOWNLOAD_EXTRACT_TIMESTAMP added in 3.24
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz
URL https://github.com/nlohmann/json/releases/download/v${json_version}/json.tar.xz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
)
endif()
Expand All @@ -139,10 +140,10 @@ else()
add_system_include_property(nlohmann_json)
endif()
# cpp-httplib
set(httplib_version 0.11.4)
if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_HTTPLIB)
find_package(httplib ${httplib_version} REQUIRED)
find_package(httplib REQUIRED)
else()
set(httplib_version 0.13.1)
if(CMAKE_VERSION VERSION_LESS 3.24)
FetchContent_Declare(
httplib
Expand All @@ -168,6 +169,18 @@ endif()
find_package(Zstd REQUIRED)
find_package(Threads REQUIRED)

#
# Platform-specific dependencies
#
if(WIN32)
find_path(
DIRENT_INCLUDE_DIR "dirent.h"
PATHS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include"
REQUIRED
)
target_include_directories(${PROJECT_NAME} PRIVATE ${DIRENT_INCLUDE_DIR})
endif()

target_link_libraries(
${PROJECT_NAME}
PUBLIC
Expand Down Expand Up @@ -209,7 +222,7 @@ message(STATUS "Finished setting up include directories.")

add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

verbose_message("Project is now aliased as ${PROJECT_NAME}::${PROJECT_NAME}.\n")
verbose_message("Project is now aliased as ${PROJECT_NAME}::${PROJECT_NAME}.")

#
# Format the project using the `clang-format` target (i.e: cmake --build build --target clang-format)
Expand Down Expand Up @@ -318,7 +331,14 @@ if(${PROJECT_NAME_UPPERCASE}_GENERATE_EXPORT_HEADER)
message(STATUS "Generated the export header `${PROJECT_NAME}_export.h` and installed it.")
endif()

message(STATUS "Finished building requirements for installing the package.\n")
message(STATUS "Finished building requirements for installing the package.")

#
# Platform-specific
#
if(WIN32)
add_compile_definitions(NOMINMAX)
endif()

#
# Unit testing setup
Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ You'll need to ensure the following dependencies are installed:
- [Zstandard (zstd)](https://github.com/facebook/zstd)
- [nlohmann\_json (header-only)](https://github.com/nlohmann/json)
- [cpp-httplib (header-only)](https://github.com/yhirose/cpp-httplib)
- [dirent (Windows-only, header-only)](https://github.com/tronkko/dirent)

By default, cpp-httplib and nlohmann\_json are downloaded by CMake as part of the build process.
If you would like to use a local version of these libraries, enable the CMake flag
Expand All @@ -86,10 +87,8 @@ using namespace databento;
int main() {
std::unordered_map<std::uint32_t, std::string> symbol_mappings;

auto client = LiveBuilder{}
.SetKey("$YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildThreaded();
auto client =
LiveBuilder{}.SetKeyFromEnv().SetDataset("GLBX.MDP3").BuildThreaded();

auto handler = [&symbol_mappings](const Record& rec) {
if (rec.Holds<TradeMsg>()) {
Expand All @@ -99,8 +98,7 @@ int main() {
<< '\n';
} else if (rec.Holds<SymbolMappingMsg>()) {
auto mapping = rec.Get<SymbolMappingMsg>();
symbol_mappings[mapping.hd.instrument_id] =
mapping.stype_out_symbol.data();
symbol_mappings[mapping.hd.instrument_id] = mapping.STypeOutSymbol();
}
return KeepGoing::Continue;
};
Expand Down
1 change: 0 additions & 1 deletion cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

function(set_project_warnings project_name)
set(MSVC_WARNINGS
/W4 # Baseline reasonable warnings
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss
# of data
/w14254 # 'operator': conversion from 'type1:field_bits' to
Expand Down
2 changes: 1 addition & 1 deletion cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function(add_clang_format_target)
-i ${sources} ${headers}
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR})
endif()
message(STATUS "Format the project using the `clang-format` target (i.e: cmake --build build --target clang-format).\n")
message(STATUS "Format the project using the `clang-format` target (i.e: cmake --build build --target clang-format).")
endif()
endfunction()

Expand Down
16 changes: 16 additions & 0 deletions cmake/mingw-w64-x86_64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)

# Cross compilers to use for C and C++
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
# Compiler for Windows resource files
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)

# Target environment on the build host system
set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

# Modify default behavior of FIND_XXX() commands
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
4 changes: 1 addition & 3 deletions example/historical/symbology_resolve.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <sysexits.h>

#include <iostream>
#include <vector>

Expand All @@ -12,7 +10,7 @@ int main(int argc, char* argv[]) {
if (argc < 6) {
std::cerr << "USAGE: symbology-resolve <DATASET> <STYPE_IN> <STYPE_OUT> "
"<DATE> <SYMBOLS...>\n";
return EX_USAGE;
return 1;
}
const auto stype_in = databento::FromString<databento::SType>(argv[2]);
const auto stype_out = databento::FromString<databento::SType>(argv[3]);
Expand Down
4 changes: 4 additions & 0 deletions example/historical/timeseries_get_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <ctime>
#include <iomanip>
#include <iostream> // setw
#ifdef _WIN32
// _mkgmtime is equivalent to timegm
#define timegm _mkgmtime
#endif

#include "databento/constants.hpp"
#include "databento/datetime.hpp"
Expand Down
9 changes: 3 additions & 6 deletions example/live/readme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ using namespace databento;
int main() {
std::unordered_map<std::uint32_t, std::string> symbol_mappings;

auto client = LiveBuilder{}
.SetKey("$YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildThreaded();
auto client =
LiveBuilder{}.SetKeyFromEnv().SetDataset("GLBX.MDP3").BuildThreaded();

auto handler = [&symbol_mappings](const Record& rec) {
if (rec.Holds<TradeMsg>()) {
Expand All @@ -26,8 +24,7 @@ int main() {
<< '\n';
} else if (rec.Holds<SymbolMappingMsg>()) {
auto mapping = rec.Get<SymbolMappingMsg>();
symbol_mappings[mapping.hd.instrument_id] =
mapping.stype_out_symbol.data();
symbol_mappings[mapping.hd.instrument_id] = mapping.STypeOutSymbol();
}
return KeepGoing::Continue;
};
Expand Down
6 changes: 3 additions & 3 deletions example/live/simple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main() {
};
auto record_callback = [&symbol_mappings](const databento::Record& rec) {
using databento::RType;
switch (rec.Header().rtype) {
switch (rec.RType()) {
case RType::Mbo: {
auto ohlcv = rec.Get<databento::WithTsOut<databento::MboMsg>>();
std::cout << "Received tick for "
Expand All @@ -58,7 +58,7 @@ int main() {
auto mapping = rec.Get<databento::SymbolMappingMsg>();
std::cout << "Received symbol mapping: " << mapping << '\n';
symbol_mappings.emplace(mapping.hd.instrument_id,
mapping.stype_in_symbol.data());
mapping.STypeInSymbol());
break;
}
case RType::System: {
Expand All @@ -75,7 +75,7 @@ int main() {
}
default: {
std::cerr << "Received unknown record with rtype " << std::hex
<< static_cast<std::uint16_t>(rec.Header().rtype) << '\n';
<< static_cast<std::uint16_t>(rec.RType()) << '\n';
}
}
return databento::KeepGoing::Continue;
Expand Down
Loading

0 comments on commit fa3e700

Please sign in to comment.