Skip to content

Commit 97fa0dd

Browse files
authored
VER: Release 0.8.0
2 parents 011fe5e + 6098721 commit 97fa0dd

23 files changed

+473
-416
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.8.0 - 2023-05-16
4+
- Changed `end` and `end_date` to optional to support new forward-fill behaviour
5+
- Renamed `booklevel` MBP field to `levels` for brevity and consistent naming
6+
- Removed `open_interest_qty` and `cleared_volume` fields from definitions schema
7+
that were always unset
8+
39
## 0.7.0 - 2023-04-28
410
- Added initial support for live data with `LiveBlocking` and `LiveThreaded` clients
511
- Added support for statistics schema

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
44
# Project details
55
#
66

7-
project("databento" VERSION 0.7.0 LANGUAGES CXX)
7+
project("databento" VERSION 0.8.0 LANGUAGES CXX)
88
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)
99

1010
#

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ int main() {
9494
if (rec.Holds<TradeMsg>()) {
9595
auto trade = rec.Get<TradeMsg>();
9696
std::cout << "Received trade for "
97-
<< symbol_mappings[trade.hd.instrument_id] << ':'
98-
<< trade << '\n';
97+
<< symbol_mappings[trade.hd.instrument_id] << ':' << trade
98+
<< '\n';
9999
} else if (rec.Holds<SymbolMappingMsg>()) {
100100
auto mapping = rec.Get<SymbolMappingMsg>();
101101
symbol_mappings[mapping.hd.instrument_id] =
@@ -124,17 +124,16 @@ Here is a simple program that fetches 10 minutes worth of historical trades for
124124
using namespace databento;
125125

126126
int main() {
127-
auto client =
128-
HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build();
127+
auto client = HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build();
129128
auto print_trades = [](const Record& record) {
130129
const auto& trade_msg = record.Get<TradeMsg>();
131130
std::cout << trade_msg << '\n';
132131
return KeepGoing::Continue;
133132
};
134-
client.TimeseriesGetRange(
135-
"GLBX.MDP3", "2022-06-10T14:30", "2022-06-10T14:40",
136-
kAllSymbols, Schema::Trades, SType::RawSymbol,
137-
SType::InstrumentId, {}, {}, print_trades);
133+
client.TimeseriesGetRange("GLBX.MDP3",
134+
{"2022-06-10T14:30", "2022-06-10T14:40"},
135+
kAllSymbols, Schema::Trades, SType::RawSymbol,
136+
SType::InstrumentId, {}, {}, print_trades);
138137
}
139138
```
140139

cmake/StandardSettings.cmake

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_LTO)
8282
endif()
8383

8484
option(${PROJECT_NAME_UPPERCASE}_ENABLE_CCACHE "Enable the usage of Ccache, in order to speed up rebuild times." ON)
85-
find_program(CCACHE_FOUND ccache)
86-
if(CCACHE_FOUND)
87-
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
88-
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
85+
if(${PROJECT_NAME_UPPERCASE}_ENABLE_CCACHE)
86+
find_program(CCACHE_FOUND ccache)
87+
if(CCACHE_FOUND)
88+
message(STATUS "Found and enabled ccache")
89+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
90+
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
91+
endif()
8992
endif()

cmake/StaticAnalyzers.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_CLANG_TIDY)
55
CMAKE_CXX_CLANG_TIDY ${CLANGTIDY}
66
-extra-arg=-Wno-unknown-warning-option
77
)
8-
message("Clang-Tidy finished setting up.")
8+
message(STATUS "Clang-Tidy finished setting up.")
99
else()
1010
message(SEND_ERROR "Clang-Tidy requested but executable not found.")
1111
endif()
@@ -31,7 +31,7 @@ if(${PROJECT_NAME_UPPERCASE}_ENABLE_CPPCHECK)
3131
# Ignore third-party dependencies
3232
-i${CMAKE_BINARY_DIR}
3333
)
34-
message("Cppcheck finished setting up.")
34+
message(STATUS "Cppcheck finished setting up.")
3535
else()
3636
message(SEND_ERROR "Cppcheck requested but executable not found.")
3737
endif()

example/historical/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.14)
22

33
add_example_target(batch batch.cpp)
44
add_example_target(metadata metadata.cpp)
5-
add_example_target(readme readme.cpp)
5+
add_example_target(historical-readme readme.cpp)
66
add_example_target(symbology-resolve symbology_resolve.cpp)
77
add_example_target(timeseries-get-range timeseries_get_range.cpp)
88
add_example_target(timeseries-get-range-to-file timeseries_get_range_to_file.cpp)

example/historical/batch.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
int main() {
1010
auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();
1111

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

1717
const auto all_job_it = std::find_if(

example/historical/metadata.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ int main() {
4444
std::cout << '\n';
4545

4646
const auto dataset_conditions = client.MetadataGetDatasetCondition(
47-
"GLBX.MDP3", "2019-06-01", "2019-08-01");
47+
"GLBX.MDP3", {"2019-06-01", "2019-08-01"});
4848
std::cout << "Conditions:\n";
4949
for (const auto& dataset_condition : dataset_conditions) {
5050
std::cout << "- " << dataset_condition << "\n";
@@ -62,8 +62,9 @@ int main() {
6262
}
6363
std::cout << '\n';
6464

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

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

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

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

102104
return 0;

example/historical/readme.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
// Duplicate of the example usage code from the README.md to ensure
22
// it compiles and to be able to clang-format it.
33
// NOLINTBEGIN(google-build-using-namespace)
4+
#include <databento/constants.hpp>
45
#include <databento/historical.hpp>
56
#include <iostream>
67

78
using namespace databento;
89

9-
static constexpr auto kApiKey = "YOUR_API_KEY";
10-
1110
int main() {
12-
auto client = HistoricalBuilder{}.SetKey(kApiKey).Build();
13-
client.TimeseriesGetRange("GLBX.MDP3", "2022-06-10", "2022-06-11", {"ES"},
14-
Schema::Trades, SType::SmartDeprecated,
15-
SType::InstrumentId, {}, {},
16-
[](const Record& record) {
17-
const auto& trade_msg = record.Get<TradeMsg>();
18-
std::cout << trade_msg << '\n';
19-
return KeepGoing::Continue;
20-
});
11+
auto client = HistoricalBuilder{}.SetKey("$YOUR_API_KEY").Build();
12+
auto print_trades = [](const Record& record) {
13+
const auto& trade_msg = record.Get<TradeMsg>();
14+
std::cout << trade_msg << '\n';
15+
return KeepGoing::Continue;
16+
};
17+
client.TimeseriesGetRange("GLBX.MDP3",
18+
{"2022-06-10T14:30", "2022-06-10T14:40"},
19+
kAllSymbols, Schema::Trades, SType::RawSymbol,
20+
SType::InstrumentId, {}, {}, print_trades);
2121
}
2222
// NOLINTEND(google-build-using-namespace)

example/historical/symbology_resolve.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
#include <iostream>
44
#include <vector>
55

6+
#include "databento/datetime.hpp"
67
#include "databento/enums.hpp"
78
#include "databento/historical.hpp"
89
#include "databento/symbology.hpp"
910

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

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

2931
return 0;

example/historical/timeseries_get_range.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main() {
2424
const databento::UnixNanos end = DateToUnixNanos(2022, 10, 4);
2525
const auto limit = 1000;
2626
client.TimeseriesGetRange(
27-
databento::dataset::kGlbxMdp3, start, end, {"ESZ2"},
27+
databento::dataset::kGlbxMdp3, {start, end}, {"ESZ2"},
2828
databento::Schema::Trades, databento::SType::RawSymbol,
2929
databento::SType::InstrumentId, limit,
3030
[](databento::Metadata&& metadata) { std::cout << metadata << '\n'; },

example/historical/timeseries_get_range_to_file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ int main() {
1414
auto client = databento::HistoricalBuilder{}.SetKeyFromEnv().Build();
1515
const auto limit = 1000;
1616
databento::DbnFileStore dbn_file_store = client.TimeseriesGetRangeToFile(
17-
databento::dataset::kGlbxMdp3, "2022-10-03T00:00", "2022-10-04T00:00",
17+
databento::dataset::kGlbxMdp3, {"2022-10-03T00:00", "2022-10-04T00:00"},
1818
{"ESZ2"}, databento::Schema::Ohlcv1M, databento::SType::RawSymbol,
1919
databento::SType::InstrumentId, limit,
2020
"ESZ2-ohlcv1m-20201003-20201004.dbn.zst");

example/live/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
cmake_minimum_required(VERSION 3.14)
22

3+
add_example_target(live-readme readme.cpp)
34
add_example_target(simple simple.cpp)

example/live/readme.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Duplicate of the example usage code from the README.md to ensure
2+
// it compiles and to be able to clang-format it.
3+
// NOLINTBEGIN(google-build-using-namespace)
4+
#include <chrono>
5+
#include <databento/live.hpp>
6+
#include <iostream>
7+
#include <string>
8+
#include <thread>
9+
#include <unordered_map>
10+
11+
using namespace databento;
12+
13+
int main() {
14+
std::unordered_map<std::uint32_t, std::string> symbol_mappings;
15+
16+
auto client = LiveBuilder{}
17+
.SetKey("$YOUR_API_KEY")
18+
.SetDataset("GLBX.MDP3")
19+
.BuildThreaded();
20+
21+
auto handler = [&symbol_mappings](const Record& rec) {
22+
if (rec.Holds<TradeMsg>()) {
23+
auto trade = rec.Get<TradeMsg>();
24+
std::cout << "Received trade for "
25+
<< symbol_mappings[trade.hd.instrument_id] << ':' << trade
26+
<< '\n';
27+
} else if (rec.Holds<SymbolMappingMsg>()) {
28+
auto mapping = rec.Get<SymbolMappingMsg>();
29+
symbol_mappings[mapping.hd.instrument_id] =
30+
mapping.stype_out_symbol.data();
31+
}
32+
return KeepGoing::Continue;
33+
};
34+
35+
client.Subscribe({"ES.FUT"}, Schema::Trades, SType::Parent);
36+
client.Start(handler);
37+
std::this_thread::sleep_for(std::chrono::seconds{10});
38+
return 0;
39+
}
40+
// NOLINTEND(google-build-using-namespace)

include/databento/datetime.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <cstdint>
55
#include <ratio> // nano
66
#include <string>
7+
#include <utility>
78

89
namespace databento {
910
// Nanoseconds since the UNIX epoch.
@@ -16,4 +17,16 @@ std::string ToString(UnixNanos unix_nanos);
1617
std::string ToString(TimeDeltaNanos td_nanos);
1718
// Converts a YYYYMMDD integer to a YYYY-MM-DD string.
1819
std::string DateFromIso8601Int(std::uint32_t date_int);
20+
21+
template <typename T>
22+
struct DateTimeRange {
23+
explicit DateTimeRange(T start_) : DateTimeRange{std::move(start_), {}} {}
24+
// underscore to prevent shadowing
25+
DateTimeRange(T start_, T end_)
26+
: start{std::move(start_)}, end{std::move(end_)} {}
27+
28+
T start;
29+
T end;
30+
};
31+
using DateRange = DateTimeRange<std::string>;
1932
} // namespace databento

0 commit comments

Comments
 (0)