GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - databento/databento-cpp: The official C++ client library for Databento

BranchesTags
Open more actions menu

Latest commit

 

History

615 Commits
615 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
cmake
cmake
 
 
examples
examples
 
 
include/databento
include/databento
 
 
pkg
pkg
 
 
scripts
scripts
 
 
src
src
 
 
tests
tests
 
 
.clang-format
.clang-format
 
 
.clang-tidy
.clang-tidy
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CMakeLists.txt
CMakeLists.txt
 
 
CODE_OF_CONDUCT.md
CODE_OF_CONDUCT.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
vcpkg.json
vcpkg.json
 
 

Repository files navigation

databento-cpp

test license Slack

The official C++ client library for Databento. The client supports both streaming real-time and historical market data through similar interfaces.

Usage

The minimum C++ standard is C++17 and the minimum CMake version is 3.24.

Integration

The easiest way to use our library is by embedding it with CMake FetchContent. Your CMakeLists.txt should look something like the following:

# CMakeLists.txt
cmake_minimum_required(VERSION 3.24)

project(databento_example)
include(FetchContent)

FetchContent_Declare(
  databento
  GIT_REPOSITORY https://github.com/databento/databento-cpp
  GIT_TAG main
)
FetchContent_MakeAvailable(databento)

add_executable(example main.cpp)
target_link_libraries(example PRIVATE databento::databento)

Alternatively, you can clone the source code from GitHub here.

To install the library to /usr, build and install it with the following:

git clone https://github.com/databento/databento-cpp
cd databento-cpp
cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DCMAKE_INSTALL_PREFIX='/usr'
cmake --build build --target databento --parallel
cmake --install build

In your project's CMakeLists.txt, add the following:

# CMakeLists.txt
find_package(databento REQUIRED)
target_link_libraries(example PRIVATE databento::databento)

Dependencies

You'll need to ensure the following dependencies are installed:

  • libdbn_c, the C interface to the DBN library
  • Zstandard (zstd)
  • OpenSSL (minimum version 3.0)
  • Libcrypto
  • nlohmann_json (header-only)
  • cpp-httplib (header-only)
  • date (header-only)

By default, date, 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 DATABENTO_USE_EXTERNAL_DATE, DATABENTO_USE_EXTERNAL_HTTPLIB, or DATABENTO_USE_EXTERNAL_JSON respectively.

libdbn_c is downloaded as a prebuilt library for Linux, macOS, and Windows on x86_64 and ARM64. Other platforms build it from source, which requires a Rust toolchain. To force building from source, enable the DATABENTO_BUILD_DBN_FROM_SOURCE CMake flag. To build it from a local DBN checkout, set DATABENTO_DBN_SOURCE_DIR to that directory.

Ubuntu

Run the following commands to install the dependencies on Ubuntu:

$ sudo apt update
$ sudo apt install libssl-dev libzstd-dev

macOS

On macOS, you can install the dependencies with Homebrew by running the following:

$ brew install openssl@3 zstd

Live

Real-time and intraday replay is provided through the Live clients. Here is a simple program that fetches 10 seconds of trades for all ES mini futures:

#include <chrono>
#include <databento/live.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>
#include <thread>

namespace db = databento;

int main() {
  db::PitSymbolMap symbol_mappings;

  auto client = db::LiveThreaded::Builder()
                    .SetKeyFromEnv()
                    .SetDataset(db::Dataset::GlbxMdp3)
                    .BuildThreaded();

  auto handler = [&symbol_mappings](const db::Record& rec) {
    symbol_mappings.OnRecord(rec);
    if (const auto* trade = rec.GetIf<db::TradeMsg>()) {
      std::cout << "Received trade for " << symbol_mappings[trade->hd.instrument_id]
                << ':' << *trade << '\n';
    }
    return db::KeepGoing::Continue;
  };

  client.Subscribe({"ES.FUT"}, db::Schema::Trades, db::SType::Parent);
  client.Start(handler);
  std::this_thread::sleep_for(std::chrono::seconds{10});
  return 0;
}

To run this program, set the DATABENTO_API_KEY environment variable with an actual API key.

Historical

Here is a simple program that fetches 10 minutes worth of historical trades for two CME futures:

#include <databento/dbn.hpp>
#include <databento/historical.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>

namespace db = databento;

int main() {
  auto client = db::Historical::Builder().SetKey("$YOUR_API_KEY").Build();
  auto store = client.TimeseriesGetRange(
      "GLBX.MDP3", {"2022-06-10T14:30", "2022-06-10T14:40"},
      {"ESM2", "NQZ2"}, db::Schema::Trades);
  auto symbol_map = store.GetMetadata().CreateSymbolMap();
  while (const auto* record = store.NextRecord()) {
    const auto& trade_msg = record->Get<db::TradeMsg>();
    std::cout << "Received trade for " << symbol_map.At(trade_msg) << ": "
              << trade_msg << '\n';
  }
}

To run this program, set the DATABENTO_API_KEY environment variable with an actual API key.

Additional example standalone executables are provided in the example directory. These examples can be compiled by enabling the cmake option DATABENTO_ENABLE_EXAMPLES with -DDATABENTO_ENABLE_EXAMPLES=1 during the configure step.

Documentation

You can find more detailed examples and the full API documentation on the Databento doc site.

License

Distributed under the Apache 2.0 License.

About

The official C++ client library for Databento

databento.com

Topics

binary-encodingdatabentohistorical-datahttplow-latencymarket-datareal-timetcptick-data

Resources

Readme
Apache-2.0 license

Code of conduct

Code of conduct

Contributing

Contributing
Activity
Custom properties

Stars

88 stars

Watchers

9 watching

Forks

29 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.