-
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
23 changed files
with
473 additions
and
416 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
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,22 @@ | ||
// 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/historical.hpp> | ||
#include <iostream> | ||
|
||
using namespace databento; | ||
|
||
static constexpr auto kApiKey = "YOUR_API_KEY"; | ||
|
||
int main() { | ||
auto client = HistoricalBuilder{}.SetKey(kApiKey).Build(); | ||
client.TimeseriesGetRange("GLBX.MDP3", "2022-06-10", "2022-06-11", {"ES"}, | ||
Schema::Trades, SType::SmartDeprecated, | ||
SType::InstrumentId, {}, {}, | ||
[](const Record& record) { | ||
const auto& trade_msg = record.Get<TradeMsg>(); | ||
std::cout << trade_msg << '\n'; | ||
return KeepGoing::Continue; | ||
}); | ||
auto client = HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build(); | ||
auto print_trades = [](const Record& record) { | ||
const auto& trade_msg = record.Get<TradeMsg>(); | ||
std::cout << 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); | ||
} | ||
// 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.14) | ||
|
||
add_example_target(live-readme readme.cpp) | ||
add_example_target(simple simple.cpp) |
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,40 @@ | ||
// 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 <iostream> | ||
#include <string> | ||
#include <thread> | ||
#include <unordered_map> | ||
|
||
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 handler = [&symbol_mappings](const Record& rec) { | ||
if (rec.Holds<TradeMsg>()) { | ||
auto trade = rec.Get<TradeMsg>(); | ||
std::cout << "Received trade for " | ||
<< symbol_mappings[trade.hd.instrument_id] << ':' << trade | ||
<< '\n'; | ||
} else if (rec.Holds<SymbolMappingMsg>()) { | ||
auto mapping = rec.Get<SymbolMappingMsg>(); | ||
symbol_mappings[mapping.hd.instrument_id] = | ||
mapping.stype_out_symbol.data(); | ||
} | ||
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) |
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
Oops, something went wrong.