-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
1,640 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
// 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 <databento/constants.hpp> | ||
#include <databento/dbn.hpp> | ||
#include <databento/historical.hpp> | ||
#include <databento/symbol_map.hpp> | ||
#include <iostream> | ||
|
||
using namespace databento; | ||
|
||
int main() { | ||
auto client = HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build(); | ||
auto print_trades = [](const Record& record) { | ||
TsSymbolMap symbol_map; | ||
auto decode_symbols = [&symbol_map](const Metadata& metadata) { | ||
symbol_map = metadata.CreateSymbolMap(); | ||
}; | ||
auto print_trades = [&symbol_map](const Record& record) { | ||
const auto& trade_msg = record.Get<TradeMsg>(); | ||
std::cout << trade_msg << '\n'; | ||
std::cout << "Received trade for " << symbol_map.At(trade_msg) << ": " | ||
<< trade_msg << '\n'; | ||
return KeepGoing::Continue; | ||
}; | ||
client.TimeseriesGetRange("GLBX.MDP3", | ||
{"2022-06-10T14:30", "2022-06-10T14:40"}, | ||
kAllSymbols, Schema::Trades, SType::RawSymbol, | ||
SType::InstrumentId, {}, {}, print_trades); | ||
client.TimeseriesGetRange( | ||
"GLBX.MDP3", {"2022-06-10T14:30", "2022-06-10T14:40"}, {"ESM2", "NQZ2"}, | ||
Schema::Trades, SType::RawSymbol, SType::InstrumentId, {}, decode_symbols, | ||
print_trades); | ||
} | ||
// NOLINTEND(google-build-using-namespace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include <cstdint> // uint32_t | ||
|
||
#include "databento/dbn.hpp" // Metadata | ||
#include "databento/iwritable.hpp" | ||
#include "databento/record.hpp" | ||
#include "databento/with_ts_out.hpp" | ||
|
||
namespace databento { | ||
class DbnEncoder { | ||
public: | ||
explicit DbnEncoder(const Metadata& metadata, IWritable* output); | ||
|
||
static void EncodeMetadata(const Metadata& metadata, IWritable* output); | ||
static void EncodeRecord(const Record& record, IWritable* output); | ||
|
||
template <typename R> | ||
void EncodeRecord(const R& record) { | ||
static_assert( | ||
has_header_v<R>, | ||
"must be a DBN record struct with an `hd` RecordHeader field"); | ||
EncodeRecord(Record{&record.hd}); | ||
} | ||
template <typename R> | ||
void EncodeRecord(const WithTsOut<R> record) { | ||
static_assert( | ||
has_header_v<R>, | ||
"must be a DBN record struct with an `hd` RecordHeader field"); | ||
EncodeRecord(Record{&record.rec.hd}); | ||
} | ||
void EncodeRecord(const Record& record); | ||
|
||
private: | ||
static std::uint32_t CalcLength(const Metadata& metadata); | ||
|
||
IWritable* output_; | ||
}; | ||
} // namespace databento |
Oops, something went wrong.