Skip to content

Commit

Permalink
VER: Release 0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen authored Dec 17, 2024
2 parents 1e60392 + ec5a075 commit 5ad9b35
Show file tree
Hide file tree
Showing 20 changed files with 330 additions and 312 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Changelog

## 0.25.0 - TBD
## 0.26.0 - 2024-12-17

### Breaking changes
- Removed deprecated `Packaging` enum and `packaging` field that's no longer supported
by the API
- Renamed `VersionUpgradePolicy::Upgrade` to `UpgradeToV2` in preparation for a future
DBN version 3

### Enhancements
- Created separate namespaces for each DBN version to create a consistent way to refer
to record types from a particular DBN version regardless of whether the record changed
between versions

## 0.25.0 - 2024-11-12

### Enhancements
- Added new IntelligentCross venues `ASPN`, `ASMT`, and `ASPI`
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.25.0 LANGUAGES CXX)
project("databento" VERSION 0.26.0 LANGUAGES CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)

#
Expand Down
4 changes: 3 additions & 1 deletion cmake/SourcesAndHeaders.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ set(headers
include/databento/symbol_map.hpp
include/databento/symbology.hpp
include/databento/timeseries.hpp
include/databento/v1.hpp
include/databento/v2.hpp
include/databento/with_ts_out.hpp
src/stream_op_helper.hpp
)

set(sources
src/batch.cpp
src/compat.cpp
src/datetime.cpp
src/dbn.cpp
src/dbn_constants.hpp
Expand Down Expand Up @@ -65,4 +66,5 @@ set(sources
src/record.cpp
src/symbol_map.cpp
src/symbology.cpp
src/v1.cpp
)
4 changes: 1 addition & 3 deletions include/databento/batch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string>
#include <vector>

#include "databento/enums.hpp" // JobState, Delivery, Packaging, Schema, SType
#include "databento/enums.hpp" // JobState, Delivery, Schema, SType

namespace databento {
// Description of a batch job.
Expand All @@ -31,8 +31,6 @@ struct BatchJob {
SplitDuration split_duration;
std::uint64_t split_size;
bool split_symbols;
// NOTE: deprecated and will be removed in a future version
Packaging packaging;
Delivery delivery;
std::uint64_t record_count;
// Size in bytes.
Expand Down
201 changes: 12 additions & 189 deletions include/databento/compat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,201 +4,24 @@
#include <cstddef> // size_t
#include <cstdint>

#include "databento/constants.hpp" // kSymbolCstrLen
#include "databento/datetime.hpp" // UnixNanos
#include "databento/enums.hpp"
#include "databento/record.hpp"
#include "databento/v1.hpp"
#include "databento/v2.hpp"

namespace databento {
static constexpr std::size_t kSymbolCstrLenV1 = 22;
static constexpr std::size_t kSymbolCstrLenV2 = kSymbolCstrLen;
static constexpr std::size_t kSymbolCstrLenV1 = v1::kSymbolCstrLen;
static constexpr std::size_t kSymbolCstrLenV2 = v2::kSymbolCstrLen;

constexpr std::size_t VersionSymbolCstrLen(std::uint8_t version) {
return version < 2 ? kSymbolCstrLenV1 : kSymbolCstrLenV2;
}

using InstrumentDefMsgV2 = InstrumentDefMsg;
using ErrorMsgV2 = ErrorMsg;
using SymbolMappingMsgV2 = SymbolMappingMsg;
using SystemMsgV2 = SystemMsg;

using InstrumentDefMsgV1 = v1::InstrumentDefMsg;
using InstrumentDefMsgV2 = v2::InstrumentDefMsg;
using ErrorMsgV1 = v1::ErrorMsg;
using ErrorMsgV2 = v2::ErrorMsg;
using SymbolMappingMsgV1 = v1::SymbolMappingMsg;
using SymbolMappingMsgV2 = v2::SymbolMappingMsg;
using SystemMsgV1 = v1::SystemMsg;
using SystemMsgV2 = v2::SystemMsg;
// DBN version 1 instrument definition.
struct InstrumentDefMsgV1 {
static bool HasRType(RType rtype) { return rtype == RType::InstrumentDef; }

InstrumentDefMsgV2 ToV2() const;
const char* Currency() const { return currency.data(); }
const char* SettlCurrency() const { return settl_currency.data(); }
const char* SecSubType() const { return secsubtype.data(); }
const char* RawSymbol() const { return raw_symbol.data(); }
const char* Group() const { return group.data(); }
const char* Exchange() const { return exchange.data(); }
const char* Asset() const { return asset.data(); }
const char* Cfi() const { return cfi.data(); }
const char* SecurityType() const { return security_type.data(); }
const char* UnitOfMeasure() const { return unit_of_measure.data(); }
const char* Underlying() const { return underlying.data(); }
const char* StrikePriceCurrency() const {
return strike_price_currency.data();
}

RecordHeader hd;
UnixNanos ts_recv;
std::int64_t min_price_increment;
std::int64_t display_factor;
UnixNanos expiration;
UnixNanos activation;
std::int64_t high_limit_price;
std::int64_t low_limit_price;
std::int64_t max_price_variation;
std::int64_t trading_reference_price;
std::int64_t unit_of_measure_qty;
std::int64_t min_price_increment_amount;
std::int64_t price_ratio;
std::int32_t inst_attrib_value;
std::uint32_t underlying_id;
std::uint32_t raw_instrument_id;
std::int32_t market_depth_implied;
std::int32_t market_depth;
std::uint32_t market_segment_id;
std::uint32_t max_trade_vol;
std::int32_t min_lot_size;
std::int32_t min_lot_size_block;
std::int32_t min_lot_size_round_lot;
std::uint32_t min_trade_vol;
std::array<char, 4> _reserved2;
std::int32_t contract_multiplier;
std::int32_t decay_quantity;
std::int32_t original_contract_size;
std::array<char, 4> _reserved3;
std::uint16_t trading_reference_date;
std::int16_t appl_id;
std::uint16_t maturity_year;
std::uint16_t decay_start_date;
std::uint16_t channel_id;
std::array<char, 4> currency;
std::array<char, 4> settl_currency;
std::array<char, 6> secsubtype;
std::array<char, kSymbolCstrLenV1> raw_symbol;
std::array<char, 21> group;
std::array<char, 5> exchange;
std::array<char, 7> asset;
std::array<char, 7> cfi;
std::array<char, 7> security_type;
std::array<char, 31> unit_of_measure;
std::array<char, 21> underlying;
std::array<char, 4> strike_price_currency;
InstrumentClass instrument_class;
std::array<char, 2> _reserved4;
std::int64_t strike_price;
std::array<char, 6> _reserved5;
MatchAlgorithm match_algorithm;
std::uint8_t md_security_trading_status;
std::uint8_t main_fraction;
std::uint8_t price_display_format;
std::uint8_t settl_price_type;
std::uint8_t sub_fraction;
std::uint8_t underlying_product;
SecurityUpdateAction security_update_action;
std::uint8_t maturity_month;
std::uint8_t maturity_day;
std::uint8_t maturity_week;
UserDefinedInstrument user_defined_instrument;
std::int8_t contract_multiplier_unit;
std::int8_t flow_schedule_type;
std::uint8_t tick_rule;
// padding for alignment
std::array<char, 3> dummy;
};
static_assert(sizeof(InstrumentDefMsgV1) == 360, "Size must match Rust");
static_assert(alignof(InstrumentDefMsgV1) == 8, "Must have 8-byte alignment");

// An error message from the Live Subscription Gateway (LSG). This will never
// be present in historical data.
struct ErrorMsgV1 {
static bool HasRType(RType rtype) { return rtype == RType::Error; }

ErrorMsgV2 ToV2() const;
UnixNanos IndexTs() const { return hd.ts_event; }
const char* Err() const { return err.data(); }

RecordHeader hd;
std::array<char, 64> err;
};
static_assert(sizeof(ErrorMsgV1) == 80, "ErrorMsg size must match Rust");
static_assert(alignof(ErrorMsgV1) == 8, "Must have 8-byte alignment");

/// A symbol mapping message.
struct SymbolMappingMsgV1 {
static bool HasRType(RType rtype) { return rtype == RType::SymbolMapping; }

SymbolMappingMsgV2 ToV2() const;
const char* STypeInSymbol() const { return stype_in_symbol.data(); }
const char* STypeOutSymbol() const { return stype_out_symbol.data(); }

RecordHeader hd;
std::array<char, kSymbolCstrLenV1> stype_in_symbol;
std::array<char, kSymbolCstrLenV1> stype_out_symbol;
// padding for alignment
std::array<char, 4> dummy;
UnixNanos start_ts;
UnixNanos end_ts;
};
static_assert(sizeof(SymbolMappingMsgV1) == 80, "Size must match Rust");
static_assert(alignof(SymbolMappingMsgV1) == 8, "Must have 8-byte alignment");

struct SystemMsgV1 {
static bool HasRType(RType rtype) { return rtype == RType::System; }

SystemMsgV2 ToV2() const;
UnixNanos IndexTs() const { return hd.ts_event; }
const char* Msg() const { return msg.data(); }
bool IsHeartbeat() const {
return std::strncmp(msg.data(), "Heartbeat", 9) == 0;
}

RecordHeader hd;
std::array<char, 64> msg;
};
static_assert(sizeof(SystemMsgV1) == 80, "SystemMsg size must match Rust");
static_assert(alignof(SystemMsgV1) == 8, "Must have 8-byte alignment");

bool operator==(const InstrumentDefMsgV1& lhs, const InstrumentDefMsgV1& rhs);
inline bool operator!=(const InstrumentDefMsgV1& lhs,
const InstrumentDefMsgV1& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
return std::tie(lhs.hd, lhs.err) == std::tie(rhs.hd, rhs.err);
}
inline bool operator!=(const ErrorMsgV1& lhs, const ErrorMsgV1& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const SymbolMappingMsgV1& lhs,
const SymbolMappingMsgV1& rhs) {
return std::tie(lhs.hd, lhs.stype_in_symbol, lhs.stype_out_symbol,
lhs.start_ts, lhs.end_ts) ==
std::tie(rhs.hd, rhs.stype_in_symbol, rhs.stype_out_symbol,
rhs.start_ts, rhs.end_ts);
}
inline bool operator!=(const SymbolMappingMsgV1& lhs,
const SymbolMappingMsgV1& rhs) {
return !(lhs == rhs);
}
inline bool operator==(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
return std::tie(lhs.hd, lhs.msg) == std::tie(rhs.hd, rhs.msg);
}
inline bool operator!=(const SystemMsgV1& lhs, const SystemMsgV1& rhs) {
return !(lhs == rhs);
}
std::string ToString(const InstrumentDefMsgV1& instr_def_msg);
std::ostream& operator<<(std::ostream& stream,
const InstrumentDefMsgV1& instr_def_msg);
std::string ToString(const ErrorMsgV1& err_msg);
std::ostream& operator<<(std::ostream& stream, const ErrorMsgV1& err_msg);
std::string ToString(const SymbolMappingMsgV1& symbol_mapping_msg);
std::ostream& operator<<(std::ostream& stream,
const SymbolMappingMsgV1& symbol_mapping_msg);
std::string ToString(const SystemMsgV1& sys_msg);
std::ostream& operator<<(std::ostream& stream, const SystemMsgV1& sys_msg);
} // namespace databento
15 changes: 1 addition & 14 deletions include/databento/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@ enum class SplitDuration : std::uint8_t {
None,
};

// Represents how a batch job will be packaged.
//
// NOTE: Deprecated now that all batch jobs can be downloaded as a ZIP file.
enum class Packaging : std::uint8_t {
None = 0,
Zip,
TarDeprecated,
};

// Represents how a batch job will be delivered.
enum class Delivery : std::uint8_t {
Download,
Expand Down Expand Up @@ -306,7 +297,7 @@ enum class StatUpdateAction : std::uint8_t {
// How to handle decoding DBN data from a prior version.
enum class VersionUpgradePolicy : std::uint8_t {
AsIs = 0,
Upgrade = 1,
UpgradeToV2 = 1,
};

namespace status_action {
Expand Down Expand Up @@ -462,7 +453,6 @@ const char* ToString(FeedMode mode);
const char* ToString(Compression compression);
const char* ToString(SType stype);
const char* ToString(SplitDuration duration_interval);
const char* ToString(Packaging packaging);
const char* ToString(Delivery delivery);
const char* ToString(JobState state);
const char* ToString(DatasetCondition condition);
Expand All @@ -487,7 +477,6 @@ std::ostream& operator<<(std::ostream& out, FeedMode mode);
std::ostream& operator<<(std::ostream& out, Compression compression);
std::ostream& operator<<(std::ostream& out, SType stype);
std::ostream& operator<<(std::ostream& out, SplitDuration duration_interval);
std::ostream& operator<<(std::ostream& out, Packaging packaging);
std::ostream& operator<<(std::ostream& out, Delivery delivery);
std::ostream& operator<<(std::ostream& out, JobState state);
std::ostream& operator<<(std::ostream& out, DatasetCondition condition);
Expand Down Expand Up @@ -522,8 +511,6 @@ SType FromString(const std::string& str);
template <>
SplitDuration FromString(const std::string& str);
template <>
Packaging FromString(const std::string& str);
template <>
Delivery FromString(const std::string& str);
template <>
JobState FromString(const std::string& str);
Expand Down
12 changes: 5 additions & 7 deletions include/databento/historical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "databento/datetime.hpp" // DateRange, DateTimeRange, UnixNanos
#include "databento/dbn_file_store.hpp"
#include "databento/detail/http_client.hpp" // HttpClient
#include "databento/enums.hpp" // BatchState, Delivery, DurationInterval, Packaging, Schema, SType
#include "databento/enums.hpp" // BatchState, Delivery, DurationInterval, Schema, SType
#include "databento/metadata.hpp" // DatasetConditionDetail, DatasetRange, FieldDetail, PublisherDetail, UnitPricesForMode
#include "databento/symbology.hpp" // SymbologyResolution
#include "databento/timeseries.hpp" // KeepGoing, MetadataCallback, RecordCallback
Expand Down Expand Up @@ -52,19 +52,17 @@ class Historical {
Encoding encoding, Compression compression,
bool pretty_px, bool pretty_ts, bool map_symbols,
bool split_symbols, SplitDuration split_duration,
std::uint64_t split_size, Packaging packaging,
Delivery delivery, SType stype_in, SType stype_out,
std::uint64_t limit);
std::uint64_t split_size, Delivery delivery,
SType stype_in, SType stype_out, std::uint64_t limit);
BatchJob BatchSubmitJob(const std::string& dataset,
const std::vector<std::string>& symbols,
Schema schema,
const DateTimeRange<std::string>& datetime_range,
Encoding encoding, Compression compression,
bool pretty_px, bool pretty_ts, bool map_symbols,
bool split_symbols, SplitDuration split_duration,
std::uint64_t split_size, Packaging packaging,
Delivery delivery, SType stype_in, SType stype_out,
std::uint64_t limit);
std::uint64_t split_size, Delivery delivery,
SType stype_in, SType stype_out, std::uint64_t limit);
std::vector<BatchJob> BatchListJobs();
std::vector<BatchJob> BatchListJobs(const std::vector<JobState>& states,
UnixNanos since);
Expand Down
2 changes: 1 addition & 1 deletion include/databento/live.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class LiveBuilder {
std::string key_;
std::string dataset_;
bool send_ts_out_{false};
VersionUpgradePolicy upgrade_policy_{VersionUpgradePolicy::Upgrade};
VersionUpgradePolicy upgrade_policy_{VersionUpgradePolicy::UpgradeToV2};
std::chrono::seconds heartbeat_interval_{};
};
} // namespace databento
Loading

0 comments on commit 5ad9b35

Please sign in to comment.