-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathreadme.cpp
More file actions
32 lines (27 loc) · 978 Bytes
/
readme.cpp
File metadata and controls
32 lines (27 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Duplicate of the example usage code from the README.md to ensure
// it compiles and to be able to clang-format it.
// NOLINTBEGIN(google-build-using-namespace)
#include <chrono>
#include <databento/live.hpp>
#include <databento/symbol_map.hpp>
#include <iostream>
#include <thread>
using namespace databento;
int main() {
PitSymbolMap symbol_mappings;
auto client =
LiveBuilder{}.SetKeyFromEnv().SetDataset(Dataset::GlbxMdp3).BuildThreaded();
auto handler = [&symbol_mappings](const Record& rec) {
symbol_mappings.OnRecord(rec);
if (const auto* trade = rec.GetIf<TradeMsg>()) {
std::cout << "Received trade for " << symbol_mappings[trade->hd.instrument_id]
<< ':' << *trade << '\n';
}
return KeepGoing::Continue;
};
client.Subscribe({"ES.FUT"}, Schema::Trades, SType::Parent);
client.Start(handler);
std::this_thread::sleep_for(std::chrono::seconds{10});
return 0;
}
// NOLINTEND(google-build-using-namespace)