Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions crates/thetadatadx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ harness = false
[[bench]]
name = "streaming_throughput"
harness = false
required-features = ["__internal"]

[[bench]]
# Drives `fpss::__test_internals::{decode_frame, DeltaState}` against
Expand Down Expand Up @@ -365,10 +366,10 @@ required-features = ["__test-helpers"]
# Data-format layer micro-benchmarks. These exercise the internal `tdbe`
# module directly: the FIT/FIE nibble codecs, the Black-Scholes Greek
# primitives, the `Price` fixed-point conversions, the enum lookups, and
# the tick field accessors. `bench_fit` / `bench_fie` / `bench_greeks`
# reach the codec and full Black-Scholes surfaces re-exported behind
# `__internal`; `bench_enums` / `bench_price` / `bench_tick` ride the
# stable public types.
# the tick field accessors. `bench_fit` / `bench_fie` / `bench_greeks` /
# `bench_price` reach the codec, full Black-Scholes, and fixed-point price
# encoding surfaces re-exported behind `__internal`; `bench_enums` /
# `bench_tick` ride the stable public types.
[[bench]]
name = "bench_fit"
harness = false
Expand All @@ -382,6 +383,7 @@ required-features = ["__internal"]
[[bench]]
name = "bench_price"
harness = false
required-features = ["__internal"]

[[bench]]
name = "bench_greeks"
Expand Down
2 changes: 1 addition & 1 deletion crates/thetadatadx/benches/bench_price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn bench_price_new_1000(c: &mut Criterion) {
let mut sum = 0i32;
for i in 0..1000i32 {
let p = Price::new(black_box(15000 + i), black_box(8));
sum += p.value;
sum += p.value();
}
black_box(sum);
});
Expand Down
2 changes: 1 addition & 1 deletion crates/thetadatadx/src/flatfiles/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(crate) fn data_indices(fmt: &[DataType], price_type_idx: Option<usize>) -> V
.collect()
}

/// Per-row PRICE_TYPE exponent for `crate::tdbe::Price` decoding.
/// Per-row PRICE_TYPE exponent for `crate::tdbe::types::price::Price` decoding.
///
/// When PRICE_TYPE is in the schema, the value at that column is the
/// vendor `price_type` field (real price = `value * 10^(price_type - 10)`).
Expand Down
21 changes: 15 additions & 6 deletions crates/thetadatadx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,26 @@ pub use crate::tdbe::types::tick::{
TradeGreeksSecondOrderTick, TradeGreeksThirdOrderTick, TradeQuoteTick, TradeTick,
};

// ─── Enums and price wrapper ──────────────────────────────────────────────────
// ─── Enums ────────────────────────────────────────────────────────────────────

pub use crate::tdbe::types::enums::{
DataType, Interval, RateType, RemoveReason, RequestType, Right, SecType, StreamMsgType,
StreamResponseType, Venue, Version,
};
// `Price` plus the `PriceError` its fallible constructor
// (`Price::with_value_and_type`) returns and the `MAX_PRICE_TYPE` bound
// that constructor validates against — the public fixed-point price
// surface.
pub use crate::tdbe::types::price::{Price, PriceError, MAX_PRICE_TYPE};
/// Variable-precision fixed-point price encoding (`value` / `price_type`
/// mantissa-and-exponent pair) and its supporting types: the validated
/// `PriceType` exponent, the `PriceError` its fallible constructor returns,
/// and the `MAX_PRICE_TYPE` bound that constructor validates against.
///
/// This is a wire-encoding detail: a client receives decoded prices
/// (`f64` dollars on the tick rows) and never sees, sets, or reasons about
/// the raw `(value, price_type)` pair. The encoding therefore stays off the
/// public API. Only available when the `__internal` feature is enabled, for
/// workspace tools, bindings, and the data-format benches. NOT a stable
/// public surface — external crates MUST NOT enable that feature.
#[cfg(feature = "__internal")]
#[doc(hidden)]
pub use crate::tdbe::types::price::{Price, PriceError, PriceType, MAX_PRICE_TYPE};

// ─── Offline Black-Scholes (Greeks + implied volatility) ─────────────────────

Expand Down
2 changes: 1 addition & 1 deletion crates/thetadatadx/src/mdds/decode/extract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn extract_text_column(table: &proto::DataTable, header: &str) -> Vec<Option
pub fn extract_price_column(
table: &proto::DataTable,
header: &str,
) -> Vec<Option<crate::tdbe::Price>> {
) -> Vec<Option<crate::tdbe::types::price::Price>> {
let Some(col_idx) = resolve_column(table, header, "Price") else {
return vec![];
};
Expand Down
22 changes: 13 additions & 9 deletions crates/thetadatadx/src/tdbe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,24 @@ pub mod time;
pub mod types;

// Module-root facade. The data-format layer keeps a complete, flat
// re-export surface so internal callers reach `crate::tdbe::Price`,
// `crate::tdbe::Error`, `crate::tdbe::CalendarStatus`, and the tick types
// without threading the full submodule path, and so the crate root can
// re-export from one coherent place. The crate's curated public surface
// (see `lib.rs`) reaches several of these through the longer submodule
// path, so `unused_imports` is allowed on the facade rather than trimming
// it to whichever items today's callers happen to reach the short way.
// re-export surface so internal callers reach `crate::tdbe::Error`,
// `crate::tdbe::CalendarStatus`, and the tick types without threading the
// full submodule path, and so the crate root can re-export from one
// coherent place. The crate's curated public surface (see `lib.rs`) reaches
// several of these through the longer submodule path, so `unused_imports`
// is allowed on the facade rather than trimming it to whichever items
// today's callers happen to reach the short way.
//
// The fixed-point price encoding (`types::price::Price` and friends) is
// deliberately NOT on this facade: it is a wire-internal detail the decode
// layer reaches through the full `types::price` leaf path, never a short
// `crate::tdbe::Price` alias, so the encoding cannot drift onto the public
// surface through the convenience re-export.
#[allow(unused_imports)]
pub use error::Error;
#[allow(unused_imports)]
pub use types::enums::{
CalendarStatus, DataType, Interval, RateType, RequestType, Right, SecType, Venue, Version,
};
#[allow(unused_imports)]
pub use types::price::Price;
#[allow(unused_imports)]
pub use types::tick::*;
5 changes: 3 additions & 2 deletions crates/thetadatadx/src/tdbe/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ mod generated;
// Flat facade for the `types` submodule. Callers and the crate root
// reach the leaf modules (`types::tick`, `types::enums`, `types::price`)
// directly, so `unused_imports` is allowed on the convenience surface.
//
// The fixed-point price encoding (`price::Price` and friends) is wire-internal
// and stays off this facade; the decode layer reaches `types::price` directly.
#[allow(unused_imports)]
pub use enums::*;
#[allow(unused_imports)]
pub use price::{Price, PriceError, MAX_PRICE_TYPE};
#[allow(unused_imports)]
pub use tick::*;
Loading
Loading