Skip to content

Commit

Permalink
VER: Release 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen authored May 17, 2023
2 parents 011fe5e + 6098721 commit 97fa0dd
Show file tree
Hide file tree
Showing 23 changed files with 473 additions and 416 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.8.0 - 2023-05-16
- Changed `end` and `end_date` to optional to support new forward-fill behaviour
- Renamed `booklevel` MBP field to `levels` for brevity and consistent naming
- Removed `open_interest_qty` and `cleared_volume` fields from definitions schema
that were always unset

## 0.7.0 - 2023-04-28
- Added initial support for live data with `LiveBlocking` and `LiveThreaded` clients
- Added support for statistics schema
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
# Project details
#

project("databento" VERSION 0.7.0 LANGUAGES CXX)
project("databento" VERSION 0.8.0 LANGUAGES CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)

#
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ int main() {
if (rec.Holds<TradeMsg>()) {
auto trade = rec.Get<TradeMsg>();
std::cout << "Received trade for "
<< symbol_mappings[trade.hd.instrument_id] << ':'
<< trade << '\n';
<< symbol_mappings[trade.hd.instrument_id] << ':' << trade
<< '\n';
} else if (rec.Holds<SymbolMappingMsg>()) {
auto mapping = rec.Get<SymbolMappingMsg>();
symbol_mappings[mapping.hd.instrument_id] =
Expand Down Expand Up @@ -124,17 +124,16 @@ Here is a simple program that fetches 10 minutes worth of historical trades for
using namespace databento;

int main() {
auto client =
HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build();
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);
client.TimeseriesGetRange("GLBX.MDP3",
{"2022-06-10T14:30", "2022-06-10T14:40"},
kAllSymbols, Schema::Trades, SType::RawSymbol,
SType::InstrumentId, {}, {}, print_trades);
}
```

Expand Down
11 changes: 7 additions & 4 deletions cmake/StandardSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,11 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_LTO)
endif()

option(${PROJECT_NAME_UPPERCASE}_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." ON)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
if(${PROJECT_NAME_UPPERCASE}_ENABLE_CCACHE)
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "Found and enabled ccache")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/StaticAnalyzers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_CLANG_TIDY)
CMAKE_CXX_CLANG_TIDY ${CLANGTIDY}
-extra-arg=-Wno-unknown-warning-option
)
message("Clang-Tidy finished setting up.")
message(STATUS "Clang-Tidy finished setting up.")
else()
message(SEND_ERROR "Clang-Tidy requested but executable not found.")
endif()
Expand All @@ -31,7 +31,7 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_CPPCHECK)
# Ignore third-party dependencies
-i${CMAKE_BINARY_DIR}
)
message("Cppcheck finished setting up.")
message(STATUS "Cppcheck finished setting up.")
else()
message(SEND_ERROR "Cppcheck requested but executable not found.")
endif()
Expand Down
2 changes: 1 addition & 1 deletion example/historical/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)

add_example_target(batch batch.cpp)
add_example_target(metadata metadata.cpp)
add_example_target(readme readme.cpp)
add_example_target(historical-readme readme.cpp)
add_example_target(symbology-resolve symbology_resolve.cpp)
add_example_target(timeseries-get-range timeseries_get_range.cpp)
add_example_target(timeseries-get-range-to-file timeseries_get_range_to_file.cpp)
6 changes: 3 additions & 3 deletions example/historical/batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
int main() {
auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();

const auto job =
client.BatchSubmitJob(databento::dataset::kGlbxMdp3, "2022-08-26",
"2022-09-27", {"GEZ2"}, databento::Schema::Trades);
const auto job = client.BatchSubmitJob(databento::dataset::kGlbxMdp3,
{"GEZ2"}, databento::Schema::Trades,
{"2022-08-26", "2022-09-27"});
const auto all_jobs = client.BatchListJobs();

const auto all_job_it = std::find_if(
Expand Down
14 changes: 8 additions & 6 deletions example/historical/metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main() {
std::cout << '\n';

const auto dataset_conditions = client.MetadataGetDatasetCondition(
"GLBX.MDP3", "2019-06-01", "2019-08-01");
"GLBX.MDP3", {"2019-06-01", "2019-08-01"});
std::cout << "Conditions:\n";
for (const auto& dataset_condition : dataset_conditions) {
std::cout << "- " << dataset_condition << "\n";
Expand All @@ -62,8 +62,9 @@ int main() {
}
std::cout << '\n';

const auto record_count = client.MetadataGetRecordCount(
kGlbxMdp3, "2020-12-28", "2020-12-29", {"ESH1"}, databento::Schema::Mbo);
const auto record_count =
client.MetadataGetRecordCount(kGlbxMdp3, {"2020-12-28", "2020-12-29"},
{"ESH1"}, databento::Schema::Mbo);
std::cout << "Record count: " << record_count << "\n\n";

const auto live_unit_prices =
Expand All @@ -90,13 +91,14 @@ int main() {
<< "\n\n";

const std::size_t billable_size = client.MetadataGetBillableSize(
kGlbxMdp3, "2020-12-28", "2020-12-29", {"ESH1"}, databento::Schema::Mbo,
kGlbxMdp3, {"2020-12-28", "2020-12-29"}, {"ESH1"}, databento::Schema::Mbo,
databento::SType::RawSymbol, {});
std::cout << "Billable size (uncompressed binary bytes): " << billable_size
<< "\n\n";

const auto cost = client.MetadataGetCost(
kGlbxMdp3, "2020-12-28", "2020-12-29", {"ESH1"}, databento::Schema::Mbo);
const auto cost =
client.MetadataGetCost(kGlbxMdp3, {"2020-12-28", "2020-12-29"}, {"ESH1"},
databento::Schema::Mbo);
std::cout << "Cost (in cents): " << cost << '\n';

return 0;
Expand Down
22 changes: 11 additions & 11 deletions example/historical/readme.cpp
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)
10 changes: 6 additions & 4 deletions example/historical/symbology_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
#include <iostream>
#include <vector>

#include "databento/datetime.hpp"
#include "databento/enums.hpp"
#include "databento/historical.hpp"
#include "databento/symbology.hpp"

int main(int argc, char* argv[]) {
if (argc < 7) {
if (argc < 6) {
std::cerr << "USAGE: symbology-resolve <DATASET> <STYPE_IN> <STYPE_OUT> "
"<START_DATE> <END_DATE> <SYMBOLS...>\n";
"<DATE> <SYMBOLS...>\n";
return EX_USAGE;
}
const auto stype_in = databento::FromString<databento::SType>(argv[2]);
Expand All @@ -22,8 +23,9 @@ int main(int argc, char* argv[]) {
}

auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();
const databento::SymbologyResolution resolution = client.SymbologyResolve(
argv[1], argv[4], argv[5], symbols, stype_in, stype_out);
const databento::SymbologyResolution resolution =
client.SymbologyResolve(argv[1], symbols, stype_in, stype_out,
databento::DateTimeRange<std::string>{argv[4]});
std::cout << resolution << '\n';

return 0;
Expand Down
2 changes: 1 addition & 1 deletion example/historical/timeseries_get_range.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main() {
const databento::UnixNanos end = DateToUnixNanos(2022, 10, 4);
const auto limit = 1000;
client.TimeseriesGetRange(
databento::dataset::kGlbxMdp3, start, end, {"ESZ2"},
databento::dataset::kGlbxMdp3, {start, end}, {"ESZ2"},
databento::Schema::Trades, databento::SType::RawSymbol,
databento::SType::InstrumentId, limit,
[](databento::Metadata&& metadata) { std::cout << metadata << '\n'; },
Expand Down
2 changes: 1 addition & 1 deletion example/historical/timeseries_get_range_to_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {
auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();
const auto limit = 1000;
databento::DbnFileStore dbn_file_store = client.TimeseriesGetRangeToFile(
databento::dataset::kGlbxMdp3, "2022-10-03T00:00", "2022-10-04T00:00",
databento::dataset::kGlbxMdp3, {"2022-10-03T00:00", "2022-10-04T00:00"},
{"ESZ2"}, databento::Schema::Ohlcv1M, databento::SType::RawSymbol,
databento::SType::InstrumentId, limit,
"ESZ2-ohlcv1m-20201003-20201004.dbn.zst");
Expand Down
1 change: 1 addition & 0 deletions example/live/CMakeLists.txt
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)
40 changes: 40 additions & 0 deletions example/live/readme.cpp
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)
13 changes: 13 additions & 0 deletions include/databento/datetime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <cstdint>
#include <ratio> // nano
#include <string>
#include <utility>

namespace databento {
// Nanoseconds since the UNIX epoch.
Expand All @@ -16,4 +17,16 @@ std::string ToString(UnixNanos unix_nanos);
std::string ToString(TimeDeltaNanos td_nanos);
// Converts a YYYYMMDD integer to a YYYY-MM-DD string.
std::string DateFromIso8601Int(std::uint32_t date_int);

template <typename T>
struct DateTimeRange {
explicit DateTimeRange(T start_) : DateTimeRange{std::move(start_), {}} {}
// underscore to prevent shadowing
DateTimeRange(T start_, T end_)
: start{std::move(start_)}, end{std::move(end_)} {}

T start;
T end;
};
using DateRange = DateTimeRange<std::string>;
} // namespace databento
Loading

0 comments on commit 97fa0dd

Please sign in to comment.