Skip to content

Commit 011fe5e

Browse files
authored
VER: Release 0.7.0
2 parents 1a5d5f6 + c96a673 commit 011fe5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1676
-558
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} \
3333
-DDATABENTO_ENABLE_UNIT_TESTING=1 \
3434
-DDATABENTO_ENABLE_EXAMPLES=1 \
35-
-DDATABENTO_ENABLE_CLANG_TIDY=1
35+
-DDATABENTO_ENABLE_CLANG_TIDY=1 \
36+
-DDATABENTO_ENABLE_ASAN=1 \
37+
-DDATABENTO_ENABLE_UBSAN=1
3638
- name: CMake build
3739
run: cmake --build build
3840
- name: Unit tests
@@ -54,6 +56,8 @@ jobs:
5456
-GNinja \
5557
-DDATABENTO_ENABLE_UNIT_TESTING=1 \
5658
-DDATABENTO_ENABLE_EXAMPLES=1 \
59+
-DDATABENTO_ENABLE_ASAN=1 \
60+
-DDATABENTO_ENABLE_UBSAN=1 \
5761
-DOPENSSL_ROOT_DIR=$(brew --prefix openssl@3)
5862
- name: CMake build
5963
run: cmake --build build

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## 0.7.0 - 2023-04-28
4+
- Added initial support for live data with `LiveBlocking` and `LiveThreaded` clients
5+
- Added support for statistics schema
6+
- Added `SystemMsg` and `ErrorMsg` records for use in live data
7+
- Added `strike_price`, `strike_price_currency`, and `instrument_class` to `InstrumentDefMsg`
8+
- Renamed `BatchJob.cost` to `cost_usd` and value now expressed as US dollars
9+
- Added `FixedPx` helper class for formatting fixed prices
10+
- Added configurable log receiver `ILogReceiver`
11+
- Added `instrument_class`, `strike_price`, and `strike_price_currency` to definition schema
12+
- Added additional `condition` variants for `DatasetConditionDetail` (degraded, pending, missing)
13+
- 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
14+
- Removed `related` and `related_security_id` from `InstrumentDefMsg`
15+
- Renamed `SType::ProductId` to `SType::InstrumentId` and `SType::Native` to `SType::RawSymbol`
16+
- Renamed `RecordHeader::product_id` to `instrument_id`
17+
- Renamed `InstrumentDefMsg::symbol` to `raw_symbol`
18+
- Renamed `SymbolMapping::native_symbol` to `raw_symbol`
19+
- Deprecated `SType::Smart` to split into `SType::Parent` and `SType::Continuous`
20+
- Changed `expiration` and `action` type to `UnixNanos`
21+
- Changed some fields to enums in `InstrumentDefMsg`
22+
- Added optional `compression` parameter to `BatchSubmitJob`
23+
- Fixed parsing of `BatchSubmitJob` response
24+
- Fixed invalid read in `DbnDecoder`
25+
- Fixed memory leak in `TryCreateDir`
26+
327
## 0.6.1 - 2023-03-28
428
- Fixed Zstd decoding of files with multiple frames
529
- Removed usage of unreliable `std::ifstream::readsome`

CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
44
# Project details
55
#
66

7-
project("databento" VERSION 0.6.1 LANGUAGES CXX)
7+
project("databento" VERSION 0.7.0 LANGUAGES CXX)
88
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
99

1010
#
@@ -103,6 +103,7 @@ message(STATUS "Added all header and implementation files.\n")
103103
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
104104
include(cmake/CompilerWarnings.cmake)
105105
set_project_warnings(${PROJECT_NAME})
106+
include(cmake/Sanitizers.cmake)
106107

107108
# Ensure std::string debug info is included
108109
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -136,19 +137,20 @@ else()
136137
FetchContent_MakeAvailable(json)
137138
endif()
138139
# cpp-httplib
140+
set(httplib_version 0.11.4)
139141
if(${PROJECT_NAME_UPPERCASE}_USE_EXTERNAL_HTTPLIB)
140-
find_package(httplib 0.11.2 REQUIRED)
142+
find_package(httplib ${httplib_version} REQUIRED)
141143
else()
142144
if(CMAKE_VERSION VERSION_LESS 3.24)
143145
FetchContent_Declare(
144146
httplib
145-
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.11.2.tar.gz
147+
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
146148
)
147149
else()
148150
# DOWNLOAD_EXTRACT_TIMESTAMP added in 3.24
149151
FetchContent_Declare(
150152
httplib
151-
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v0.11.2.tar.gz
153+
URL https://github.com/yhirose/cpp-httplib/archive/refs/tags/v${httplib_version}.tar.gz
152154
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
153155
)
154156
endif()

README.md

Lines changed: 81 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,19 @@
44
[![license](https://img.shields.io/github/license/databento/databento-cpp?color=blue)](./LICENSE)
55

66
The official C++ client library for [Databento](https://databento.com).
7-
The client supports both streaming live and historical data through similar interfaces.
8-
9-
**Please note:** this client currently only supports historical data and is under active development as Databento prepares to launch live data.
7+
The client supports both streaming real-time and historical market data through similar interfaces.
108

119
## Usage
1210

13-
A simple program that fetches a day's worth of historical trades for all ES symbols and prints it looks like this:
14-
15-
```cpp
16-
#include <databento/historical.hpp>
17-
#include <iostream>
18-
19-
using namespace databento;
20-
21-
static constexpr auto kApiKey = "YOUR_API_KEY";
22-
23-
int main() {
24-
auto client = HistoricalBuilder{}.SetKey(kApiKey).Build();
25-
client.TimeseriesGetRange("GLBX.MDP3", "2022-06-10", "2022-06-11", {"ES"},
26-
Schema::Trades, SType::Smart, SType::ProductId, {},
27-
{}, [](const Record& record) {
28-
const auto& trade_msg = record.Get<TradeMsg>();
29-
std::cout << trade_msg << '\n';
30-
return KeepGoing::Continue;
31-
});
32-
}
33-
```
34-
35-
To run this program, replace `YOUR_API_KEY` with an actual API key.
11+
The minimum C++ standard is C++11 and the minimum CMake version is 3.14.
3612

37-
Additional example standalone executables are provided in the [examples](./examples) directory.
38-
These examples can be compiled by enabling the cmake option `DATABENTO_ENABLE_EXAMPLES` with `-DDATABENTO_ENABLE_EXAMPLES=1` during the configure step.
39-
40-
### Documentation
41-
42-
More detailed examples and the full API documentation can be found on the [Databento doc site](https://docs.databento.com/getting-started).
13+
### Integration
4314

44-
## Integration
15+
The easiest way to use our library is by embedding it with [CMake FetchContent](https://cmake.org/cmake/help/v3.11/module/FetchContent.html).
16+
Your `CMakeLists.txt` should look something like the following:
4517

46-
databento-cpp can be integrated into C++ projects in a couple of different ways.
47-
48-
### Embedded
49-
50-
The easiest way to integrate databento-cpp into your project is using CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html).
51-
The minimum supported CMake version is 3.14.
5218
```cmake
19+
# CMakeLists.txt
5320
include(FetchContent)
5421
5522
FetchContent_Declare(
@@ -63,9 +30,10 @@ add_library(my_library)
6330
target_link_libraries(my_library PRIVATE databento::databento)
6431
```
6532

66-
### System
33+
Alternatively, you can clone the source code from GitHub [here](https://github.com/databento/databento-cpp).
34+
35+
To install the library at the system level, build and install it with the following:
6736

68-
To install databento-cpp at the system level, clone the repo, build, and install with CMake.
6937
```sh
7038
git clone https://github.com/databento/databento-cpp
7139
cd databento-cpp
@@ -78,17 +46,17 @@ cmake --build build --target databento
7846
cmake --install build
7947
```
8048

81-
Then in your project's `CMakeLists.txt`, add the following:
49+
In your project's `CMakeLists.txt`, add the following:
50+
8251
```cmake
83-
find_package(databento 0.6.1 REQUIRED)
84-
add_library(my_library)
85-
target_link_libraries(my_library PRIVATE databento::databento)
52+
# CMakeLists.txt
53+
find_package(databento REQUIRED)
54+
target_link_libraries(your_target PRIVATE databento::databento)
8655
```
8756

88-
## Requirements
57+
### Dependencies
8958

90-
The minimum C++ standard is C++11 and CMake 3.14.
91-
The library has the following dependencies:
59+
You'll need to ensure the following dependencies are installed:
9260
- [OpenSSL](https://www.openssl.org/)
9361
- [Libcrypto](https://www.openssl.org/docs/man3.0/man7/crypto.html)
9462
- [Zstandard (zstd)](https://github.com/facebook/zstd)
@@ -99,75 +67,85 @@ By default, cpp-httplib and nlohmann\_json are downloaded by CMake as part of th
9967
If you would like to use a local version of these libraries, enable the CMake flag
10068
`DATABENTO_ENABLE_EXTERNAL_HTTPLIB` or `DATABENTO_ENABLE_EXTERNAL_JSON`.
10169

102-
The other two dependencies (zstd and OpenSSL) are available in most package managers.
103-
For example, on Ubuntu and Debian:
104-
```sh
105-
sudo apt install libssl-dev libzstd-dev
106-
```
70+
### Live
10771

108-
## Building locally
72+
Real-time and intraday replay is provided through the Live clients.
73+
Here is a simple program that fetches 10 seconds of trades for all ES mini futures:
10974

110-
databento-cpp uses [CMake](https://cmake.org/) as its build system, with a minimum version of 3.14.
111-
Building with `cmake` is a two step process: first configuring, then building.
112-
```sh
113-
cmake -S . -B build # configure
114-
cmake --build build -- -j $(nproc) # build all targets with all cores
115-
```
75+
```cpp
76+
#include <chrono>
77+
#include <databento/live.hpp>
78+
#include <iostream>
79+
#include <string>
80+
#include <thread>
81+
#include <unordered_map>
11682

117-
### Testing
83+
using namespace databento;
11884

119-
Tests are located in the `test` directory.
120-
They're written using [GoogleTest (gtest)](https://github.com/google/googletest).
121-
The test target is `databentoTests` and can be build and run with the following commands:
122-
```sh
123-
cmake -S . -B build -DDATABENTO_ENABLE_UNIT_TESTING=1 # configure
124-
cmake --build build --target databentoTests # build
125-
build/test/databentoTests # run
85+
int main() {
86+
std::unordered_map<std::uint32_t, std::string> symbol_mappings;
87+
88+
auto client = LiveBuilder{}
89+
.SetKey("$YOUR_API_KEY")
90+
.SetDataset("GLBX.MDP3")
91+
.BuildThreaded();
92+
93+
auto handler = [&symbol_mappings](const Record& rec) {
94+
if (rec.Holds<TradeMsg>()) {
95+
auto trade = rec.Get<TradeMsg>();
96+
std::cout << "Received trade for "
97+
<< symbol_mappings[trade.hd.instrument_id] << ':'
98+
<< trade << '\n';
99+
} else if (rec.Holds<SymbolMappingMsg>()) {
100+
auto mapping = rec.Get<SymbolMappingMsg>();
101+
symbol_mappings[mapping.hd.instrument_id] =
102+
mapping.stype_out_symbol.data();
103+
}
104+
return KeepGoing::Continue;
105+
};
106+
107+
client.Subscribe({"ES.FUT"}, Schema::Trades, SType::Parent);
108+
client.Start(handler);
109+
std::this_thread::sleep_for(std::chrono::seconds{10});
110+
return 0;
111+
}
126112
```
113+
To run this program, replace `$YOUR_API_KEY` with an actual API key.
127114

128-
By default, it's assumed google test is installed already, if instead you'd like CMake to
129-
download it for you, disable the `DATABENTO_USE_EXTERNAL_GTEST` flag:
130-
```sh
131-
cmake -S . -B build \
132-
-DDATABENTO_ENABLE_UNIT_TESTING=1 \
133-
-DDATABENTO_USE_EXTERNAL_GTEST=0
134-
```
115+
### Historical
135116

136-
### Formatting
117+
Here is a simple program that fetches 10 minutes worth of historical trades for the entire CME Globex market:
137118

138-
databento-cpp uses [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) with Google's style.
139-
`clang-format` usually comes installed with [clang](https://clang.llvm.org/).
140-
You can run `clang-format` against all the files in `databento-cpp` with the following command:
141-
```sh
142-
cmake --build build --target clang-format
143-
```
119+
```cpp
120+
#include <databento/constants.hpp>
121+
#include <databento/historical.hpp>
122+
#include <iostream>
144123

145-
### Linting
124+
using namespace databento;
146125

147-
databento-cpp uses Clang-Tidy and Cppcheck for linting and detecting potential mistakes.
148-
Both can be enabled to run as part of compilation through CMake flags.
149-
```sh
150-
cmake -S . -B build -DDATABENTO_ENABLE_CLANG_TIDY=1 -DDATABENTO_ENABLE_CPPCHECK=1
151-
cmake --build build # compiles code, and runs Clang-Tidy and Cppcheck
126+
int main() {
127+
auto client =
128+
HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build();
129+
auto print_trades = [](const Record& record) {
130+
const auto& trade_msg = record.Get<TradeMsg>();
131+
std::cout << trade_msg << '\n';
132+
return KeepGoing::Continue;
133+
};
134+
client.TimeseriesGetRange(
135+
"GLBX.MDP3", "2022-06-10T14:30", "2022-06-10T14:40",
136+
kAllSymbols, Schema::Trades, SType::RawSymbol,
137+
SType::InstrumentId, {}, {}, print_trades);
138+
}
152139
```
153140

154-
### macOS
141+
To run this program, replace `$YOUR_API_KEY` with an actual API key.
155142

156-
To setup OpenSSL and zstd, run the following:
157-
```sh
158-
brew install openssl zstd
159-
# Add it to the PATH so cmake can find it
160-
export "$PATH:$HOMEBREW_PREFIX/opt/openssl/bin"
161-
```
143+
Additional example standalone executables are provided in the [examples](./examples) directory.
144+
These examples can be compiled by enabling the cmake option `DATABENTO_ENABLE_EXAMPLES` with `-DDATABENTO_ENABLE_EXAMPLES=1` during the configure step.
162145

163-
For linting on macOS, the best way to install clang-tidy and clang-format is to install all of LLVM
164-
and symlink the binaries to some place in your `PATH`.
165-
```sh
166-
brew install llvm
167-
ln -s $(brew --prefix llvm)/bin/clang-tidy $HOME/.local/bin/
168-
ln -s $(brew --prefix llvm)/bin/clang-format $HOME/.local/bin/
169-
ln -s $(brew --prefix llvm)/bin/run-clang-format $HOME/.local/bin/
170-
```
146+
## Documentation
147+
148+
You can find more detailed examples and the full API documentation on the [Databento doc site](https://docs.databento.com/getting-started?historical=cpp&live=cpp).
171149

172150
## License
173151

cmake/CompilerWarnings.cmake

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,9 @@ function(set_project_warnings project_name)
5959
-Wdouble-promotion # warn if float is implicit promoted to double
6060
-Wformat=2 # warn on security issues around functions that format output
6161
# (ie printf)
62+
-Wimplicit-fallthrough # warn on switch labels without break
6263
)
6364

64-
if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
65-
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
66-
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
67-
endif()
68-
6965
set(GCC_WARNINGS
7066
${CLANG_WARNINGS}
7167
-Wmisleading-indentation # warn if indentation implies blocks where blocks
@@ -75,8 +71,15 @@ function(set_project_warnings project_name)
7571
-Wlogical-op # warn about logical operations being used where bitwise were
7672
# probably wanted
7773
-Wuseless-cast # warn if you perform a cast to the same type
74+
-Wno-ignored-attributes
7875
)
7976

77+
if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
78+
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
79+
set(GCC_WARNINGS ${GCC_WARNINGS} -Werror)
80+
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
81+
endif()
82+
8083
if(MSVC)
8184
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
8285
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
@@ -87,7 +90,7 @@ function(set_project_warnings project_name)
8790
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
8891
endif()
8992

90-
target_compile_options(${project_name} PUBLIC ${PROJECT_WARNINGS})
93+
add_compile_options(${PROJECT_WARNINGS})
9194

9295
if(NOT TARGET ${project_name})
9396
message(AUTHOR_WARNING "${project_name} is not a target, thus no compiler warning were added.")

cmake/Sanitizers.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function(enable_sanitizer sanitizer)
2+
# Add for all targets
3+
add_compile_options(-fsanitize=${sanitizer})
4+
add_link_options(-fsanitize=${sanitizer})
5+
message(STATUS "Enabled ${sanitizer} sanitizer.")
6+
endfunction()
7+
8+
if(${PROJECT_NAME_UPPERCASE}_ENABLE_ASAN)
9+
enable_sanitizer("address")
10+
endif()
11+
if(${PROJECT_NAME_UPPERCASE}_ENABLE_TSAN)
12+
enable_sanitizer("thread")
13+
endif()
14+
if(${PROJECT_NAME_UPPERCASE}_ENABLE_UBSAN)
15+
enable_sanitizer("undefined")
16+
endif()

0 commit comments

Comments
 (0)