Skip to main content

NormalizedTick

Struct NormalizedTick 

Source
pub struct NormalizedTick {
    pub exchange: Exchange,
    pub symbol: String,
    pub price: Decimal,
    pub quantity: Decimal,
    pub side: Option<TradeSide>,
    pub trade_id: Option<String>,
    pub exchange_ts_ms: Option<u64>,
    pub received_at_ms: u64,
}
Expand description

Canonical normalized tick — exchange-agnostic.

Fields§

§exchange: Exchange

Source exchange.

§symbol: String

Instrument symbol in the canonical form used by this crate.

§price: Decimal

Trade price (exact decimal, never f64).

§quantity: Decimal

Trade quantity (exact decimal).

§side: Option<TradeSide>

Direction of the aggressing order, if available from the exchange.

§trade_id: Option<String>

Exchange-assigned trade identifier, if available.

§exchange_ts_ms: Option<u64>

Exchange-side timestamp (ms since Unix epoch), if included in the feed.

§received_at_ms: u64

Local system-clock timestamp when this tick was received.

Implementations§

Source§

impl NormalizedTick

Source

pub fn value(&self) -> Decimal

Notional trade value: price × quantity.

Returns the total value transferred in this trade. Useful for VWAP calculations and volume-weighted aggregations without requiring callers to multiply at every use site.

See also volume_notional, notional_value, and dollar_value, which are all aliases.

Source

pub fn age_ms(&self, now_ms: u64) -> u64

Age of this tick in milliseconds relative to now_ms.

Returns now_ms - received_at_ms, saturating at zero (never negative). Useful for staleness checks: tick.age_ms(now) > threshold_ms.

See also quote_age_ms, which is an alias.

Source

pub fn is_stale(&self, now_ms: u64, threshold_ms: u64) -> bool

Returns true if this tick is older than threshold_ms relative to now_ms.

Equivalent to self.age_ms(now_ms) > threshold_ms. Use this for filtering stale ticks before passing them into aggregation pipelines.

Source

pub fn is_buy(&self) -> bool

Returns true if the tick is a buyer-initiated trade.

Returns false if side is Sell or None (side unknown).

Source

pub fn is_sell(&self) -> bool

Returns true if the tick is a seller-initiated trade.

Returns false if side is Buy or None (side unknown).

Source

pub fn is_neutral(&self) -> bool

Returns true if the trade side is unknown (None).

Many exchanges do not report the aggressor side. This method lets callers explicitly test for the “no side information” case rather than relying on both is_buy() and is_sell() returning false.

Source

pub fn is_large_trade(&self, threshold: Decimal) -> bool

Returns true if the traded quantity meets or exceeds threshold.

Useful for isolating institutional-size trades (“block trades”) from the general flow. The threshold is in the same units as quantity.

Source

pub fn with_side(self, side: TradeSide) -> Self

Return a copy of this tick with the trade side set to side.

Useful in tests and feed normalizers that determine the aggressor side after initial tick construction.

Source

pub fn with_exchange_ts(self, ts_ms: u64) -> Self

Return a copy of this tick with the exchange timestamp set to ts_ms.

Useful in tests and feed normalizers to inject an authoritative exchange timestamp after the tick has already been constructed.

Source

pub fn price_move_from(&self, prev: &NormalizedTick) -> Decimal

Signed price movement from prev to this tick: self.price − prev.price.

Positive when price rose, negative when price fell, zero when unchanged. Only meaningful when both ticks share the same symbol and exchange.

Source

pub fn is_more_recent_than(&self, other: &NormalizedTick) -> bool

Returns true if this tick arrived more recently than other.

Compares received_at_ms timestamps. Equal timestamps return false.

Source

pub fn latency_ms(&self) -> Option<i64>

Transport latency in milliseconds: received_at_ms − exchange_ts_ms.

Returns None if the exchange timestamp is unavailable. A positive value indicates how long the tick took to travel from exchange to this system; negative values suggest clock skew between exchange and consumer.

See also exchange_latency_ms, which is an alias.

Source

pub fn volume_notional(&self) -> Decimal

Notional value of this trade: price × quantity.

Alias for value.

Source

pub fn has_exchange_ts(&self) -> bool

Returns true if this tick carries an exchange-provided timestamp.

When false, only the local received_at_ms is available. Use latency_ms to measure round-trip latency when this returns true.

Source

pub fn side_str(&self) -> &'static str

Human-readable trade direction: "buy", "sell", or "unknown".

Source

pub fn is_round_lot(&self) -> bool

Returns true if the quantity is a whole number (no fractional part).

Useful for detecting atypical fractional order sizes, or as a simple round-lot check in integer-quantity markets.

Source

pub fn is_same_symbol_as(&self, other: &NormalizedTick) -> bool

Returns true if this tick’s symbol matches other’s symbol exactly.

Source

pub fn price_distance_from(&self, other: &NormalizedTick) -> Decimal

Absolute price difference between this tick and other.

Returns |self.price - other.price|. Useful for computing price drift between two ticks of the same instrument without caring about direction.

Source

pub fn exchange_latency_ms(&self) -> Option<i64>

Signed latency between the local receipt timestamp and the exchange timestamp, in milliseconds.

Alias for latency_ms.

Source

pub fn is_notional_large_trade(&self, threshold: Decimal) -> bool

Returns true if the notional value of this trade (price × quantity) exceeds threshold.

Unlike is_large_trade (which compares raw quantity), this method uses the trade’s dollar value, making it useful for comparing block-trade size across instruments with different prices.

Source

pub fn is_zero_price(&self) -> bool

Returns true if this tick’s price is zero.

A zero price typically indicates a malformed or uninitialized tick.

Source

pub fn is_fresh(&self, now_ms: u64, max_age_ms: u64) -> bool

Returns true if the tick is still fresh relative to now_ms.

“Fresh” means the tick arrived within the last max_age_ms milliseconds. Returns false when now_ms < ts_ms (clock skew guard).

Source

pub fn is_above(&self, price: Decimal) -> bool

Returns true if this tick’s price is strictly above price.

Source

pub fn is_below(&self, price: Decimal) -> bool

Returns true if this tick’s price is strictly below price.

Source

pub fn is_at(&self, price: Decimal) -> bool

Returns true if this tick’s price equals price.

Source

pub fn is_aggressive(&self) -> bool

Returns true if the tick has a definite direction (buy or sell).

Neutral ticks (where side is None) return false.

Source

pub fn price_diff_from(&self, other: &NormalizedTick) -> Decimal

👎Deprecated since 2.2.0:

Use price_move_from instead

Signed price difference: self.price - other.price.

Alias for price_move_from.

Source

pub fn is_micro_trade(&self, threshold: Decimal) -> bool

Returns true if the trade quantity is strictly less than threshold.

The inverse of is_large_trade.

Source

pub fn is_buying_pressure(&self, midpoint: Decimal) -> bool

Returns true if this tick occurred above the given midpoint price.

A tick above the midpoint is typically associated with buying pressure.

Source

pub fn age_secs(&self, now_ms: u64) -> f64

Age of this tick in seconds: (now_ms - received_at_ms) / 1000.0.

Returns 0.0 if now_ms is before received_at_ms.

Source

pub fn is_same_exchange_as(&self, other: &NormalizedTick) -> bool

Returns true if this tick originated from the same exchange as other.

Source

pub fn quote_age_ms(&self, now_ms: u64) -> u64

👎Deprecated since 2.2.0:

Use age_ms instead

Age of this tick in milliseconds: now_ms - received_at_ms.

Alias for age_ms.

Source

pub fn notional_value(&self) -> Decimal

👎Deprecated since 2.2.0:

Use value instead

Notional value of this tick: price × quantity.

Alias for value.

Source

pub fn is_high_value_tick(&self, threshold: Decimal) -> bool

👎Deprecated since 2.2.0:

Use is_notional_large_trade instead

Returns true if the notional value (price × quantity) exceeds threshold.

Alias for is_notional_large_trade.

Source

pub fn side_as_str(&self) -> Option<&'static str>

Returns the trade side as a string slice: "buy", "sell", or None.

Source

pub fn is_above_price(&self, reference: Decimal) -> bool

👎Deprecated since 2.2.0:

Use is_above instead

Returns true if this tick’s price is strictly above reference.

Alias for is_above.

Source

pub fn price_change_from(&self, reference: Decimal) -> Decimal

Signed price change relative to reference: self.price - reference.

Source

pub fn is_market_open_tick( &self, session_start_ms: u64, session_end_ms: u64, ) -> bool

Returns true if this tick’s received_at_ms falls within a trading session window.

Source

pub fn is_at_price(&self, target: Decimal) -> bool

👎Deprecated since 2.2.0:

Use is_at instead

Returns true if this tick’s price exactly equals target.

Alias for is_at.

Source

pub fn is_below_price(&self, reference: Decimal) -> bool

👎Deprecated since 2.2.0:

Use is_below instead

Returns true if this tick’s price is strictly below reference.

Alias for is_below.

Source

pub fn is_round_number(&self, step: Decimal) -> bool

Returns true if this tick’s price is divisible by step with no remainder.

Useful for identifying round-number price levels (e.g., step = 100). Returns false if step is zero.

Source

pub fn signed_quantity(&self) -> Decimal

Returns the trade quantity signed by side: +quantity for Buy, -quantity for Sell, 0 for unknown.

Source

pub fn as_price_level(&self) -> (Decimal, Decimal)

Returns (price, quantity) as a convenient tuple.

Source

pub fn quantity_above(&self, threshold: Decimal) -> bool

Returns true if this tick’s quantity is strictly above threshold.

Source

pub fn is_recent(&self, threshold_ms: u64, now_ms: u64) -> bool

👎Deprecated since 2.2.0:

Use is_fresh(now_ms, threshold_ms) instead

Returns true if this tick was received within threshold_ms of now_ms.

Alias for is_fresh(now_ms, threshold_ms).

Source

pub fn is_buy_side(&self) -> bool

👎Deprecated since 2.2.0:

Use is_buy instead

Returns true if this tick is on the buy side.

Alias for is_buy.

Source

pub fn is_sell_side(&self) -> bool

👎Deprecated since 2.2.0:

Use is_sell instead

Returns true if this tick is on the sell side.

Alias for is_sell.

Source

pub fn is_zero_quantity(&self) -> bool

Returns true if this tick’s quantity is zero (may indicate a cancel or correction).

Source

pub fn is_within_spread(&self, bid: Decimal, ask: Decimal) -> bool

Returns true if this tick’s price is strictly between bid and ask.

Source

pub fn is_away_from_price(&self, reference: Decimal, threshold: Decimal) -> bool

Returns true if this tick’s price deviates from reference by more than threshold.

Source

pub fn is_large_tick(&self, threshold: Decimal) -> bool

👎Deprecated since 2.2.0:

Use is_large_trade instead

Returns true if this tick’s quantity is strictly above threshold.

Note: unlike is_large_trade which uses >=, this method uses strict > for backwards compatibility.

Source

pub fn price_in_range(&self, low: Decimal, high: Decimal) -> bool

Returns true if this tick’s price is within [low, high] (inclusive).

Source

pub fn rounded_price(&self, tick_size: Decimal) -> Decimal

Price rounded down to the nearest multiple of tick_size.

Returns the original price if tick_size is zero.

Source

pub fn is_large_spread_from( &self, other: &NormalizedTick, threshold: Decimal, ) -> bool

Returns true if the absolute price difference from other exceeds threshold.

Source

pub fn volume_notional_f64(&self) -> f64

Notional value of this tick as f64 (price × quantity).

Source

pub fn price_velocity( &self, prev: &NormalizedTick, dt_ms: u64, ) -> Option<Decimal>

Rate of price change relative to a prior tick: (price - prev.price) / dt_ms.

Returns None if dt_ms is zero (same timestamp).

Source

pub fn is_reversal(&self, prev: &NormalizedTick, min_move: Decimal) -> bool

Returns true if price reversed direction by at least min_move from prev.

A reversal means the direction of (self.price - prev.price) is opposite to the direction of (prev.price - prev_prev.price), and the magnitude ≥ min_move. This two-argument form checks: |self.price - prev.price| >= min_move.

Source

pub fn spread_crossed( bid_tick: &NormalizedTick, ask_tick: &NormalizedTick, ) -> bool

Returns true if a trade crossed the spread: bid_tick.price >= ask_tick.price.

A spread-crossed condition indicates an aggressive order consumed the best opposing quote.

Source

pub fn dollar_value(&self) -> Decimal

Dollar (notional) value of this tick: price * quantity.

Alias for value.

Source

pub fn contract_value(&self, multiplier: Decimal) -> Decimal

Contract value using a futures/options multiplier: price * quantity * multiplier.

Source

pub fn tick_imbalance(ticks: &[NormalizedTick]) -> Option<f64>

Tick imbalance: (buy_qty - sell_qty) / total_qty across a tick slice.

Buy ticks are those with side == Some(TradeSide::Buy). Returns None if total quantity is zero.

Source

pub fn quote_midpoint( bid: &NormalizedTick, ask: &NormalizedTick, ) -> Option<Decimal>

Theoretical quote midpoint: (bid.price + ask.price) / 2.

Returns None if either tick has a non-positive price or if the bid price exceeds the ask price (crossed market).

Source

pub fn buy_volume(ticks: &[NormalizedTick]) -> Decimal

Total quantity across all buy-initiated ticks in a slice.

Filters ticks where side == Some(TradeSide::Buy) and sums their quantities. Returns Decimal::ZERO for an empty slice or one with no buy ticks.

Source

pub fn sell_volume(ticks: &[NormalizedTick]) -> Decimal

Total quantity across all sell-initiated ticks in a slice.

Filters ticks where side == Some(TradeSide::Sell) and sums their quantities. Returns Decimal::ZERO for an empty slice or one with no sell ticks.

Source

pub fn price_range(ticks: &[NormalizedTick]) -> Option<Decimal>

Price range across a slice of ticks: max(price) − min(price).

Returns None if the slice is empty.

Source

pub fn average_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Arithmetic mean price across a slice of ticks.

Returns None if the slice is empty.

Source

pub fn vwap(ticks: &[NormalizedTick]) -> Option<Decimal>

Volume-weighted average price (VWAP) across a slice of ticks.

Computes Σ(price × quantity) / Σ(quantity). Returns None if the slice is empty or total volume is zero.

Source

pub fn count_above_price(ticks: &[NormalizedTick], threshold: Decimal) -> usize

Count of ticks whose price is strictly above threshold.

Source

pub fn count_below_price(ticks: &[NormalizedTick], threshold: Decimal) -> usize

Count of ticks whose price is strictly below threshold.

Source

pub fn total_notional(ticks: &[NormalizedTick]) -> Decimal

Total notional value (Σ price × quantity) across all ticks.

Source

pub fn buy_notional(ticks: &[NormalizedTick]) -> Decimal

Total notional for buy-side ticks (side == Some(TradeSide::Buy)).

Source

pub fn sell_notional(ticks: &[NormalizedTick]) -> Decimal

Total notional for sell-side ticks (side == Some(TradeSide::Sell)).

Source

pub fn median_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Median price across a slice of ticks.

Sorts tick prices and returns the middle value (or mean of two middle values for an even-length slice). Returns None for an empty slice.

Source

pub fn net_volume(ticks: &[NormalizedTick]) -> Decimal

Net volume: buy_volume − sell_volume.

Positive means net buying pressure; negative means net selling pressure.

Source

pub fn average_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Average trade quantity: total_volume / tick_count.

Returns None if the slice is empty.

Source

pub fn max_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Maximum single-trade quantity across the slice.

Returns None if the slice is empty.

Source

pub fn min_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Minimum single-trade quantity across the slice.

Returns None if the slice is empty.

Source

pub fn buy_count(ticks: &[NormalizedTick]) -> usize

Number of buy-side ticks in the slice.

Source

pub fn sell_count(ticks: &[NormalizedTick]) -> usize

Number of sell-side ticks in the slice.

Source

pub fn price_momentum(ticks: &[NormalizedTick]) -> Option<f64>

Percentage price change from the first to the last tick.

Returns None if the slice has fewer than 2 ticks or the first tick’s price is zero.

Source

pub fn min_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Minimum price across the slice.

Returns None if the slice is empty.

Source

pub fn max_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Maximum price across the slice.

Returns None if the slice is empty.

Source

pub fn price_std_dev(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of tick prices across the slice.

Returns None if the slice has fewer than 2 elements.

Source

pub fn buy_sell_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of buy volume to sell volume.

Returns None if sell volume is zero.

Source

pub fn largest_trade(ticks: &[NormalizedTick]) -> Option<&NormalizedTick>

Returns the tick with the highest quantity in the slice.

Returns None if the slice is empty.

Source

pub fn large_trade_count(ticks: &[NormalizedTick], threshold: Decimal) -> usize

Count of ticks whose quantity strictly exceeds threshold.

Source

pub fn price_iqr(ticks: &[NormalizedTick]) -> Option<Decimal>

Interquartile range (Q3 − Q1) of tick prices.

Returns None if the slice has fewer than 4 elements.

Source

pub fn fraction_buy(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks that are buy-side.

Returns None if the slice is empty.

Source

pub fn std_quantity(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of trade quantities across the slice.

Returns None if the slice has fewer than 2 elements.

Source

pub fn buy_pressure(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of sided volume that is buy-initiated: buy_vol / (buy_vol + sell_vol).

Returns None if there are no sided ticks.

Source

pub fn average_notional(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean notional value (price × quantity) per trade across the slice.

Returns None if the slice is empty.

Source

pub fn count_neutral(ticks: &[NormalizedTick]) -> usize

Count of ticks with no known side (neither buy nor sell).

Source

pub fn recent(ticks: &[NormalizedTick], n: usize) -> &[NormalizedTick]

Returns the last n ticks from the slice.

If n >= ticks.len(), returns the full slice.

Source

pub fn price_linear_slope(ticks: &[NormalizedTick]) -> Option<f64>

OLS linear regression slope of price over tick index.

A positive slope indicates prices are rising across the slice. Returns None if the slice has fewer than 2 ticks.

Source

pub fn notional_std_dev(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of per-trade notional values (price × quantity).

Returns None if the slice has fewer than 2 elements.

Source

pub fn monotone_up(ticks: &[NormalizedTick]) -> bool

Returns true if prices in the slice are non-decreasing (each ≥ previous).

Returns true for slices with 0 or 1 ticks.

Source

pub fn monotone_down(ticks: &[NormalizedTick]) -> bool

Returns true if prices in the slice are non-increasing (each ≤ previous).

Returns true for slices with 0 or 1 ticks.

Source

pub fn volume_at_price(ticks: &[NormalizedTick], price: Decimal) -> Decimal

Total quantity traded at exactly price.

Source

pub fn last_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Price of the most recent tick in the slice.

Returns None if the slice is empty.

Source

pub fn longest_buy_streak(ticks: &[NormalizedTick]) -> usize

Length of the longest consecutive run of buy-sided ticks.

Source

pub fn longest_sell_streak(ticks: &[NormalizedTick]) -> usize

Length of the longest consecutive run of sell-sided ticks.

Source

pub fn price_at_max_volume(ticks: &[NormalizedTick]) -> Option<Decimal>

Price level with the highest total traded quantity in the slice.

Returns None if the slice is empty.

Source

pub fn recent_volume(ticks: &[NormalizedTick], n: usize) -> Decimal

Total quantity of the last n ticks.

If n >= ticks.len(), returns total volume of all ticks.

Source

pub fn first_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Price of the first tick in the slice.

Returns None if the slice is empty.

Source

pub fn price_return_pct(ticks: &[NormalizedTick]) -> Option<f64>

Percentage return from first to last tick price: (last − first) / first.

Returns None if the slice has fewer than 2 ticks or the first price is zero.

Source

pub fn volume_above_price(ticks: &[NormalizedTick], price: Decimal) -> Decimal

Total quantity traded strictly above price.

Source

pub fn volume_below_price(ticks: &[NormalizedTick], price: Decimal) -> Decimal

Total quantity traded strictly below price.

Source

pub fn quantity_weighted_avg_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Quantity-weighted average price (VWAP) across all ticks.

Returns None if the slice is empty or total quantity is zero.

Source

pub fn tick_count_above_price(ticks: &[NormalizedTick], price: Decimal) -> usize

Number of ticks with price strictly above price.

Source

pub fn tick_count_below_price(ticks: &[NormalizedTick], price: Decimal) -> usize

Number of ticks with price strictly below price.

Source

pub fn price_at_percentile( ticks: &[NormalizedTick], percentile: f64, ) -> Option<Decimal>

Approximate price at the given percentile (0.0–1.0) by sorting tick prices.

Returns None if the slice is empty or percentile is outside [0, 1].

Source

pub fn unique_price_count(ticks: &[NormalizedTick]) -> usize

Number of distinct prices in the tick slice.

Source

pub fn avg_inter_tick_spread(ticks: &[NormalizedTick]) -> Option<f64>

Average absolute price difference between consecutive ticks.

Returns None if fewer than 2 ticks.

Source

pub fn largest_sell(ticks: &[NormalizedTick]) -> Option<Decimal>

Largest single-trade quantity among sell-side ticks.

Returns None if there are no sell-side ticks.

Source

pub fn largest_buy(ticks: &[NormalizedTick]) -> Option<Decimal>

Largest single-trade quantity among buy-side ticks.

Returns None if there are no buy-side ticks.

Source

pub fn trade_count(ticks: &[NormalizedTick]) -> usize

Total number of ticks in the slice (alias for slice.len()).

Source

pub fn price_acceleration(ticks: &[NormalizedTick]) -> Option<f64>

Price acceleration: change in price velocity between consecutive ticks.

Returns the difference of the last two consecutive price changes. Returns None if fewer than 3 ticks.

Source

pub fn buy_sell_diff(ticks: &[NormalizedTick]) -> Decimal

Net difference between buy volume and sell volume.

Positive means more buying pressure, negative means more selling pressure.

Source

pub fn is_aggressive_buy(tick: &NormalizedTick, avg_buy_qty: Decimal) -> bool

Returns true if the tick is a buy that exceeds the average buy quantity.

Source

pub fn is_aggressive_sell(tick: &NormalizedTick, avg_sell_qty: Decimal) -> bool

Returns true if the tick is a sell that exceeds the average sell quantity.

Source

pub fn notional_volume(ticks: &[NormalizedTick]) -> Decimal

Total notional value: sum of price * quantity across all ticks.

Source

pub fn weighted_side_score(ticks: &[NormalizedTick]) -> Option<f64>

Weighted side score: buy_volume - sell_volume normalized by total volume.

Returns a value in [-1, 1], or None if total volume is zero.

Source

pub fn time_span_ms(ticks: &[NormalizedTick]) -> Option<u64>

Time span in milliseconds between the first and last tick.

Returns None if fewer than 2 ticks.

Source

pub fn price_above_vwap_count(ticks: &[NormalizedTick]) -> Option<usize>

Count of ticks with price above the VWAP of the slice.

Returns None if VWAP cannot be computed (empty or zero total volume).

Source

pub fn avg_trade_size(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean quantity per trade across all ticks.

Returns None if the slice is empty.

Source

pub fn volume_concentration(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total volume contributed by the largest quarter of trades.

Trades are sorted by quantity descending; the top 25% (rounded up) are summed and divided by total volume. Returns None if total volume is zero or the slice is empty.

Source

pub fn trade_imbalance_score(ticks: &[NormalizedTick]) -> Option<f64>

Signed trade imbalance: (buy_count − sell_count) / total.

Returns a value in [-1, 1]. Returns None if the slice is empty.

Source

pub fn buy_avg_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Average price of buy-side ticks.

Returns None if there are no buy-side ticks.

Source

pub fn sell_avg_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Average price of sell-side ticks.

Returns None if there are no sell-side ticks.

Source

pub fn price_skewness(ticks: &[NormalizedTick]) -> Option<f64>

Skewness of the price distribution across ticks.

Uses the standard moment-based formula. Returns None if fewer than 3 ticks or if the standard deviation is zero.

Source

pub fn quantity_skewness(ticks: &[NormalizedTick]) -> Option<f64>

Skewness of the quantity distribution across ticks.

Uses the standard moment-based formula. Returns None if fewer than 3 ticks or if the standard deviation is zero.

Source

pub fn price_entropy(ticks: &[NormalizedTick]) -> Option<f64>

Shannon entropy of the price distribution across ticks.

Each unique price is treated as a category. Returns None if the slice is empty or all ticks have the same price (zero entropy is returned as Some(0.0)).

Source

pub fn price_kurtosis(ticks: &[NormalizedTick]) -> Option<f64>

Excess kurtosis of the price distribution across ticks.

Returns None if fewer than 4 ticks or if the standard deviation is zero.

Source

pub fn high_volume_tick_count( ticks: &[NormalizedTick], threshold: Decimal, ) -> usize

Count of ticks whose quantity exceeds threshold.

Source

pub fn vwap_spread(ticks: &[NormalizedTick]) -> Option<Decimal>

Difference between the buy-side average price and the sell-side average price (buy_avg - sell_avg).

A positive value means buyers paid more on average than sellers; a negative value is unusual (market microstructure artifact). Returns None if either side has no ticks.

Source

pub fn avg_buy_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean quantity of buy-side ticks.

Returns None if there are no buy-side ticks.

Source

pub fn avg_sell_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean quantity of sell-side ticks.

Returns None if there are no sell-side ticks.

Source

pub fn price_mean_reversion_score(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of prices that are below the VWAP (mean-reversion pressure).

Values close to 0.5 suggest equilibrium; values far from 0.5 suggest directional bias. Returns None if VWAP cannot be computed.

Source

pub fn largest_price_move(ticks: &[NormalizedTick]) -> Option<Decimal>

Largest absolute price move between consecutive ticks.

Returns None if fewer than 2 ticks.

Source

pub fn tick_rate(ticks: &[NormalizedTick]) -> Option<f64>

Number of ticks per millisecond of elapsed time.

Returns None if fewer than 2 ticks or the time span is zero.

Source

pub fn buy_notional_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total notional volume that comes from buy-side trades.

Returns None if total notional volume is zero or the slice is empty.

Source

pub fn price_range_pct(ticks: &[NormalizedTick]) -> Option<f64>

Price range as a percentage of the minimum price.

(max_price - min_price) / min_price * 100. Returns None if the slice is empty or the minimum price is zero.

Source

pub fn buy_side_dominance(ticks: &[NormalizedTick]) -> Option<f64>

Buy-side dominance: buy_volume / (buy_volume + sell_volume).

Returns a value in [0, 1]. Returns None if both sides are zero.

Source

pub fn volume_weighted_price_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of price weighted by quantity.

Uses VWAP as the mean. Returns None if empty or VWAP cannot be computed.

Source

pub fn last_n_vwap(ticks: &[NormalizedTick], n: usize) -> Option<Decimal>

VWAP computed over just the last n ticks.

Returns None if n is 0 or the slice has no ticks, or if total volume of the window is zero.

Source

pub fn price_autocorrelation(ticks: &[NormalizedTick]) -> Option<f64>

Lag-1 autocorrelation of the price series across ticks.

Uses the Pearson formula on consecutive price pairs. Returns None if fewer than 3 ticks or if the variance is zero.

Source

pub fn net_trade_direction(ticks: &[NormalizedTick]) -> i64

Net trade direction score: (buy_count - sell_count) as a signed integer.

Source

pub fn sell_side_notional_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total notional volume that comes from sell-side trades.

Returns None if total notional volume is zero or the slice is empty.

Source

pub fn price_oscillation_count(ticks: &[NormalizedTick]) -> usize

Count of price direction reversals (sign changes in consecutive moves).

Returns 0 if fewer than 3 ticks.

Source

pub fn realized_spread(ticks: &[NormalizedTick]) -> Option<Decimal>

Realized spread: mean buy price minus mean sell price.

A positive value suggests buys are executed at higher prices than sells (typical in a two-sided market). Returns None if either side has no ticks.

Source

pub fn adverse_selection_score(ticks: &[NormalizedTick]) -> Option<f64>

Adverse selection score: fraction of large trades that moved the price against the initiator (proxy for informed trading).

A “large” trade is one with quantity above the window median quantity. Returns None if the slice has fewer than 3 ticks or median is zero.

Source

pub fn price_impact_per_unit(ticks: &[NormalizedTick]) -> Option<f64>

Price impact per unit of volume: |price_return| / total_volume.

Returns None if fewer than 2 ticks or total volume is zero.

Source

pub fn volume_weighted_return(ticks: &[NormalizedTick]) -> Option<f64>

Volume-weighted return: VWAP of returns weighted by quantity.

Computes (p_i - p_{i-1}) / p_{i-1} for each consecutive pair, weighted by qty_i, then sums weighted returns. Returns None if fewer than 2 ticks or total quantity is zero.

Source

pub fn quantity_concentration(ticks: &[NormalizedTick]) -> Option<f64>

Gini-coefficient-style quantity concentration.

sum_i sum_j |q_i - q_j| / (2 * n^2 * mean_q). Returns None if the slice is empty or the mean quantity is zero.

Source

pub fn price_level_volume(ticks: &[NormalizedTick], price: Decimal) -> Decimal

Total volume traded at a specific price level.

Source

pub fn mid_price_drift(ticks: &[NormalizedTick]) -> Option<f64>

Drift of the mid-price proxy across ticks.

Defined as (last_price - first_price) / time_span_ms. Returns None if fewer than 2 ticks or the time span is zero.

Source

pub fn tick_direction_bias(ticks: &[NormalizedTick]) -> Option<f64>

Tick direction bias: fraction of consecutive moves in the same direction.

Counts windows where price[i+1] moved in the same direction as price[i] vs price[i-1]. Returns None if fewer than 3 ticks.

Source

pub fn median_quantity(ticks: &[NormalizedTick]) -> Option<Decimal>

Median trade quantity across all ticks.

Returns None if the slice is empty.

Source

pub fn volume_above_vwap(ticks: &[NormalizedTick]) -> Option<Decimal>

Total volume from ticks priced strictly above the VWAP of the slice.

Returns None if VWAP cannot be computed (empty or zero total quantity).

Source

pub fn inter_arrival_variance(ticks: &[NormalizedTick]) -> Option<f64>

Variance of inter-tick arrival times in milliseconds.

Returns None if fewer than 3 ticks are provided (need ≥ 2 intervals).

Source

pub fn spread_efficiency(ticks: &[NormalizedTick]) -> Option<f64>

Price spread efficiency: net price move divided by total path length.

A value of 1.0 means prices moved directly with no reversals; values near 0.0 indicate heavy oscillation. Returns None if the slice has fewer than 2 ticks or the path length is zero.

Source

pub fn buy_sell_size_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of average buy quantity to average sell quantity.

Returns None if there are no buy ticks or no sell ticks, or if avg sell quantity is zero.

Source

pub fn trade_size_dispersion(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of trade quantities across all ticks.

Returns None if fewer than 2 ticks are provided.

Source

pub fn aggressor_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks for which the trade side is known (non-None).

Returns None for an empty slice.

A value near 1.0 indicates the feed reliably reports aggressor side; a value near 0.0 means most ticks are neutral.

Source

pub fn volume_imbalance_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Signed volume imbalance: (buy_vol − sell_vol) / (buy_vol + sell_vol).

Returns a value in (−1, +1). Positive means net buying pressure, negative means net selling pressure. Returns None when the total known-side volume is zero (all ticks are neutral or the slice is empty).

Source

pub fn price_quantity_covariance(ticks: &[NormalizedTick]) -> Option<f64>

Covariance between price and quantity across the tick slice.

Returns None if fewer than 2 ticks are provided or if any value cannot be converted to f64.

A positive covariance indicates that larger trades tend to occur at higher prices; negative means larger trades skew toward lower prices.

Source

pub fn large_trade_fraction( ticks: &[NormalizedTick], threshold: Decimal, ) -> Option<f64>

Fraction of ticks whose quantity meets or exceeds threshold.

Returns None for an empty slice. The result is in [0.0, 1.0]. Useful for characterising how “institutional” the flow is.

Source

pub fn price_level_density(ticks: &[NormalizedTick]) -> Option<f64>

Number of unique price levels per unit of price range.

Computed as unique_price_count / price_range. Returns None when the slice is empty or the price range is zero (all ticks at one price).

High density implies granular price action; low density implies price jumps between a few discrete levels.

Source

pub fn notional_buy_sell_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of buy-side notional to sell-side notional.

Returns None when there are no sell-side ticks or sell notional is zero. A value above 1.0 means buy-side dollar flow dominates.

Source

pub fn log_return_mean(ticks: &[NormalizedTick]) -> Option<f64>

Mean of tick-to-tick log returns: mean(ln(p_i / p_{i-1})).

Returns None if fewer than 2 ticks are provided or if any price is zero (which would make the log undefined).

Source

pub fn log_return_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of tick-to-tick log returns.

Returns None if fewer than 3 ticks are provided (need at least 2 returns for a meaningful std-dev) or if any price is zero.

Source

pub fn price_overshoot_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of the maximum price to the last price: max_price / last_price.

Returns None for an empty slice or if the last price is zero.

A value above 1.0 indicates that the price overshot the closing level during the window — useful as an intrabar momentum signal.

Source

pub fn price_undershoot_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of the first price to the minimum price: first_price / min_price.

Returns None for an empty slice or if the minimum price is zero.

A value above 1.0 indicates the window opened above its trough, meaning the price undershot the opening level at some point.

Source

pub fn net_notional(ticks: &[NormalizedTick]) -> Decimal

Net notional: buy_notional − sell_notional across the slice.

Positive means net buying pressure in dollar terms; negative means net selling pressure. Returns Decimal::ZERO for empty slices or slices with no sided ticks.

Source

pub fn price_reversal_count(ticks: &[NormalizedTick]) -> usize

Count of price direction reversals across the slice.

A reversal occurs when consecutive price moves change sign (up→down or down→up), ignoring flat moves. Returns 0 for fewer than 3 ticks.

Source

pub fn quantity_kurtosis(ticks: &[NormalizedTick]) -> Option<f64>

Excess kurtosis of trade quantities across the slice.

kurtosis = (Σ((q − mean)⁴ / n) / std_dev⁴) − 3

Returns None if the slice has fewer than 4 ticks or std dev is zero.

Source

pub fn largest_notional_trade( ticks: &[NormalizedTick], ) -> Option<&NormalizedTick>

Reference to the tick with the highest notional value (price × quantity).

Unlike largest_trade which ranks by raw quantity, this method ranks by dollar value, making it suitable for comparing trades across different price levels.

Returns None if the slice is empty.

Source

pub fn twap(ticks: &[NormalizedTick]) -> Option<Decimal>

Time-weighted average price (TWAP) using received_at_ms timestamps.

Each price is weighted by the time interval to the next tick. The last tick carries zero weight (no interval after it). Returns None if fewer than 2 ticks are provided or the total time span is zero.

Source

pub fn neutral_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks whose side is None (no aggressor information).

Returns None for an empty slice. Complement of aggressor_fraction.

Source

pub fn log_return_variance(ticks: &[NormalizedTick]) -> Option<f64>

Variance of tick-to-tick log returns: var(ln(p_i / p_{i-1})).

Returns None if fewer than 3 ticks or any price is non-positive.

Source

pub fn volume_at_vwap(ticks: &[NormalizedTick], tolerance: Decimal) -> Decimal

Total quantity traded at prices within tolerance of the VWAP.

Returns Decimal::ZERO if the slice is empty, VWAP cannot be computed, or no ticks fall within the tolerance band.

Source

pub fn cumulative_volume(ticks: &[NormalizedTick]) -> Vec<Decimal>

Cumulative volume as a Vec of running totals, one entry per tick.

The first entry equals ticks[0].quantity; the last equals the total volume. Returns an empty Vec for an empty slice.

Source

pub fn price_volatility_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of price range to mean price: (max − min) / mean.

A dimensionless measure of relative price dispersion across the slice. Returns None for an empty slice or if the mean is zero.

Source

pub fn notional_per_tick(ticks: &[NormalizedTick]) -> Option<f64>

Mean notional value per tick: total_notional / tick_count.

Alias for average_notional expressed as f64 for ML feature pipelines.

Returns None for an empty slice.

Source

pub fn buy_to_total_volume_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total volume (buy + sell + neutral) that is buy-initiated.

Returns None for an empty slice or when total volume is zero.

Source

pub fn avg_latency_ms(ticks: &[NormalizedTick]) -> Option<f64>

Mean transport latency (ms) for ticks that carry an exchange timestamp.

Averages received_at_ms − exchange_ts_ms over ticks where exchange_ts_ms is Some. Returns None if no such ticks exist.

Source

pub fn price_gini(ticks: &[NormalizedTick]) -> Option<f64>

Gini coefficient of trade prices across the slice.

Measures price inequality: 0 means all trades at the same price, 1 means maximum price dispersion. Returns None if the slice is empty or all prices are zero.

Source

pub fn trade_velocity(ticks: &[NormalizedTick]) -> Option<f64>

Rate of tick arrival: tick_count / time_span_ms.

Returns ticks per millisecond. Returns None if the slice has fewer than 2 ticks or the time span is zero.

Source

pub fn floor_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Minimum price across the slice.

Semantic alias for min_price that matches the “floor” framing used in support/resistance analysis.

Returns None if the slice is empty.

Source

pub fn price_momentum_score(ticks: &[NormalizedTick]) -> Option<f64>

Quantity-weighted mean of signed price changes; positive = net upward momentum.

Source

pub fn vwap_std(ticks: &[NormalizedTick]) -> Option<f64>

Std dev of prices weighted by quantity (dispersion around VWAP).

Source

pub fn price_range_expansion(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks that set a new running high or low (price range expansion events).

Source

pub fn sell_to_total_volume_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total volume classified as sell-side; complement of buy_to_total_volume_ratio.

Source

pub fn notional_std(ticks: &[NormalizedTick]) -> Option<f64>

Std dev of per-tick notional (price × quantity); requires ≥ 2 ticks.

Source

pub fn quantity_autocorrelation(ticks: &[NormalizedTick]) -> Option<f64>

Autocorrelation of trade sizes at lag 1.

Measures whether large (or small) trades tend to follow each other. Returns None if fewer than 3 ticks or variance is zero.

Source

pub fn fraction_above_vwap(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks where price strictly exceeds the VWAP.

Returns None for empty slices or when VWAP cannot be computed.

Source

pub fn max_buy_streak(ticks: &[NormalizedTick]) -> usize

Maximum consecutive buy ticks (by side) within the slice.

Returns 0 if no buy ticks are present.

Source

pub fn max_sell_streak(ticks: &[NormalizedTick]) -> usize

Maximum consecutive sell ticks (by side) within the slice.

Returns 0 if no sell ticks are present.

Source

pub fn side_entropy(ticks: &[NormalizedTick]) -> Option<f64>

Entropy of the trade side distribution across buy, sell, and neutral.

Computed as -Σ p_i * ln(p_i) over the three categories. Zero entropy means all ticks share the same side; higher = more mixed. Returns None for empty slices.

Source

pub fn mean_inter_tick_gap_ms(ticks: &[NormalizedTick]) -> Option<f64>

Mean time gap between consecutive ticks in milliseconds.

Uses received_at_ms. Returns None for fewer than 2 ticks or if all ticks have identical timestamps.

Source

pub fn round_number_fraction( ticks: &[NormalizedTick], step: Decimal, ) -> Option<f64>

Fraction of ticks whose price is a round number divisible by step.

Returns None for empty slices or zero step.

Source

pub fn geometric_mean_quantity(ticks: &[NormalizedTick]) -> Option<f64>

Geometric mean of trade quantities.

Computed as exp(mean(ln(q_i))). Returns None for empty slices or if any quantity is non-positive.

Source

pub fn max_tick_return(ticks: &[NormalizedTick]) -> Option<f64>

Maximum price return (best single tick-to-tick gain) in the slice.

Returns None for fewer than 2 ticks.

Source

pub fn min_tick_return(ticks: &[NormalizedTick]) -> Option<f64>

Minimum price return (worst single tick-to-tick drop) in the slice.

Returns None for fewer than 2 ticks.

Source

pub fn buy_price_mean(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean price of buy-side ticks only; None if no buy ticks present.

Source

pub fn sell_price_mean(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean price of sell-side ticks only; None if no sell ticks present.

Source

pub fn price_efficiency(ticks: &[NormalizedTick]) -> Option<f64>

|last_price − first_price| / Σ|price_i − price_{i-1}|; 1.0 = perfectly directional, near 0 = noisy.

Source

pub fn price_return_skewness(ticks: &[NormalizedTick]) -> Option<f64>

Skewness of tick-to-tick log returns; requires ≥ 5 ticks.

Source

pub fn buy_sell_vwap_spread(ticks: &[NormalizedTick]) -> Option<f64>

Buy VWAP minus sell VWAP; positive = buyers paid more than sellers received.

Source

pub fn above_mean_quantity_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks with quantity above the mean quantity.

Source

pub fn price_unchanged_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks where price equals the previous tick’s price (unchanged price).

Source

pub fn qty_weighted_range(ticks: &[NormalizedTick]) -> Option<f64>

Quantity-weighted price range: Σ(price_i × qty_i) / Σ(qty_i) applied to max/min spread. Returns the difference between quantity-weighted high and low prices.

Source

pub fn sell_notional_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total notional that is sell-side; complement of buy_notional_fraction.

Source

pub fn max_price_gap(ticks: &[NormalizedTick]) -> Option<Decimal>

Maximum absolute price jump between consecutive ticks.

Source

pub fn price_range_velocity(ticks: &[NormalizedTick]) -> Option<f64>

Rate of price range expansion: (high - low) / time_span_ms; requires ≥ 2 ticks with different timestamps.

Source

pub fn tick_count_per_ms(ticks: &[NormalizedTick]) -> Option<f64>

Number of ticks per millisecond of the slice’s time span.

Source

pub fn buy_quantity_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total quantity attributable to buy-side trades.

Source

pub fn sell_quantity_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of total quantity attributable to sell-side trades.

Source

pub fn price_mean_crossover_count(ticks: &[NormalizedTick]) -> Option<usize>

Number of times the price crosses through (or touches) its own window mean.

Source

pub fn notional_skewness(ticks: &[NormalizedTick]) -> Option<f64>

Skewness of per-tick notional values (price × quantity).

Source

pub fn volume_weighted_mid_price(ticks: &[NormalizedTick]) -> Option<Decimal>

Volume-weighted midpoint of the price range: sum(price * quantity) / sum(quantity). Equivalent to VWAP but emphasises price centrality.

Source

pub fn neutral_count(ticks: &[NormalizedTick]) -> usize

Count of ticks with no aggressor side (side == None).

Source

pub fn price_dispersion(ticks: &[NormalizedTick]) -> Option<Decimal>

max_price − min_price; raw price spread across the slice.

Source

pub fn max_notional(ticks: &[NormalizedTick]) -> Option<Decimal>

Maximum per-tick notional (price × quantity) in the slice.

Source

pub fn min_notional(ticks: &[NormalizedTick]) -> Option<Decimal>

Minimum per-tick notional (price × quantity) in the slice.

Source

pub fn below_vwap_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks with price below the slice VWAP.

Source

pub fn trade_notional_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of per-tick notionals (price × quantity); requires ≥ 2 ticks.

Distinct from notional_std_dev (which refers to the notional field); this uses price * quantity directly.

Source

pub fn buy_sell_count_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of buy count to sell count; None if there are no sell ticks.

Source

pub fn price_mad(ticks: &[NormalizedTick]) -> Option<f64>

Mean absolute deviation of prices from the price mean.

Source

pub fn price_range_pct_of_open(ticks: &[NormalizedTick]) -> Option<f64>

Price range expressed as a percentage of the first tick’s price.

Source

pub fn price_mean(ticks: &[NormalizedTick]) -> Option<Decimal>

Mean price of the ticks; equivalent to arithmetic average of all price values.

Source

pub fn uptick_count(ticks: &[NormalizedTick]) -> usize

Number of ticks where price > previous_tick.price (upticks).

Source

pub fn downtick_count(ticks: &[NormalizedTick]) -> usize

Number of ticks where price < previous_tick.price (downticks).

Source

pub fn uptick_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of tick intervals that are upticks.

Source

pub fn quantity_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of quantities across ticks; requires ≥ 2 ticks.

Source

pub fn vwap_deviation_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of (price − VWAP) across ticks; measures how dispersed individual trade prices are around the session VWAP. Returns None if fewer than 2 ticks or total quantity is zero.

Source

pub fn max_consecutive_side_run(ticks: &[NormalizedTick]) -> usize

Length of the longest run of trades on the same side (Buy or Sell). Ticks with no side are skipped. Returns 0 if no sided ticks.

Source

pub fn inter_arrival_cv(ticks: &[NormalizedTick]) -> Option<f64>

Coefficient of variation of inter-arrival times (std dev / mean). Measures burstiness of trade arrival. Returns None if fewer than 2 ticks with received_at_ms or if mean inter-arrival is zero.

Source

pub fn volume_per_ms(ticks: &[NormalizedTick]) -> Option<f64>

Total traded quantity divided by elapsed milliseconds. Returns None if fewer than 2 ticks or elapsed time is zero.

Source

pub fn notional_per_second(ticks: &[NormalizedTick]) -> Option<f64>

Total notional (price × quantity) divided by elapsed seconds. Returns None if fewer than 2 ticks or elapsed time is zero.

Source

pub fn order_flow_imbalance(ticks: &[NormalizedTick]) -> Option<f64>

Net order-flow imbalance: (buy_qty − sell_qty) / total_qty.

Returns a value in [−1, 1]: +1 = all buys, −1 = all sells. Returns None for empty slices or zero total quantity.

Source

pub fn price_qty_up_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of consecutive tick pairs where both price and quantity increased.

Returns None for fewer than 2 ticks.

Source

pub fn running_high_count(ticks: &[NormalizedTick]) -> usize

Count of ticks where price is at an all-time high within the slice (including first tick).

Source

pub fn running_low_count(ticks: &[NormalizedTick]) -> usize

Count of ticks where price is at an all-time low within the slice (including first tick).

Source

pub fn buy_sell_avg_qty_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Mean quantity of buy ticks divided by mean quantity of sell ticks.

Returns None if no buy or sell ticks, or if sell mean is zero.

Source

pub fn max_price_drop(ticks: &[NormalizedTick]) -> Option<Decimal>

Largest price drop between any two consecutive ticks (always ≥ 0).

Returns None for fewer than 2 ticks.

Source

pub fn max_price_rise(ticks: &[NormalizedTick]) -> Option<Decimal>

Largest price rise between any two consecutive ticks (always ≥ 0).

Returns None for fewer than 2 ticks.

Source

pub fn buy_trade_count(ticks: &[NormalizedTick]) -> usize

Count of ticks classified as buy-side trades.

Source

pub fn sell_trade_count(ticks: &[NormalizedTick]) -> usize

Count of ticks classified as sell-side trades.

Source

pub fn price_reversal_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of consecutive tick pairs that reverse price direction. A reversal is when (price[i+1] > price[i]) differs from (price[i] > price[i-1]). Returns None for fewer than 3 ticks.

Source

pub fn near_vwap_fraction( ticks: &[NormalizedTick], band: Decimal, ) -> Option<f64>

Fraction of ticks within band of the slice VWAP.

Returns None for empty slices or when VWAP cannot be computed.

Source

pub fn mean_tick_return(ticks: &[NormalizedTick]) -> Option<f64>

Mean signed return: mean(price_i - price_{i-1}) / price_{i-1} across all consecutive pairs.

Returns None for fewer than 2 ticks.

Source

pub fn passive_buy_count(ticks: &[NormalizedTick]) -> usize

Count of ticks where side == Buy and price is strictly below VWAP (passive buy).

Returns 0 if VWAP cannot be computed.

Source

pub fn passive_sell_count(ticks: &[NormalizedTick]) -> usize

Count of ticks where side == Sell and price is strictly above VWAP (passive sell).

Returns 0 if VWAP cannot be computed.

Source

pub fn quantity_iqr(ticks: &[NormalizedTick]) -> Option<Decimal>

Interquartile range of quantities (Q3 − Q1).

Returns None for fewer than 4 ticks.

Source

pub fn top_quartile_price_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks with price above the 75th percentile of all tick prices in the slice.

Returns None for fewer than 4 ticks.

Source

pub fn buy_notional_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of buy-side notional to total notional (buy_qty·price / total_qty·price). Returns None for empty slices or zero total notional.

Source

pub fn return_std(ticks: &[NormalizedTick]) -> Option<f64>

Standard deviation of tick-to-tick signed returns. Returns None for fewer than 3 ticks (need ≥ 2 returns).

Source

pub fn max_drawdown(ticks: &[NormalizedTick]) -> Option<f64>

Maximum price drawdown from peak: max(peak − price) / peak over the slice.

Returns None for an empty slice or a zero peak price.

Source

pub fn high_to_low_ratio(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of the highest price to the lowest price in the slice.

Returns None for an empty slice or a zero minimum price.

Source

pub fn tick_velocity(ticks: &[NormalizedTick]) -> Option<f64>

Tick arrival rate: tick_count / time_span_ms.

Returns None when the slice has fewer than 2 ticks or the time span is zero.

Source

pub fn notional_decay(ticks: &[NormalizedTick]) -> Option<f64>

Ratio of second-half notional to first-half notional.

Measures whether trading activity is accelerating (> 1) or decelerating (< 1). Returns None for fewer than 2 ticks or zero first-half notional.

Source

pub fn late_price_momentum(ticks: &[NormalizedTick]) -> Option<f64>

Momentum of the second half vs the first half: (mean_price_2 − mean_price_1) / mean_price_1.

Returns None for fewer than 2 ticks or a zero first-half mean.

Source

pub fn consecutive_buys_max(ticks: &[NormalizedTick]) -> usize

Maximum run of consecutive buy-side ticks.

Returns 0 for an empty slice or one with no buy ticks.

Source

pub fn above_mean_qty_fraction(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of ticks where quantity exceeds the mean quantity across the slice.

Returns None for an empty slice.

Source

pub fn side_alternation_rate(ticks: &[NormalizedTick]) -> Option<f64>

Fraction of consecutive tick pairs where the trade side alternates.

Only pairs where both ticks carry a known side are counted. Returns None when fewer than 2 side-annotated ticks are present.

Source

pub fn price_range_per_tick(ticks: &[NormalizedTick]) -> Option<f64>

Price range per tick: (max_price − min_price) / tick_count.

Returns None for an empty slice.

Source

pub fn qty_weighted_price_std(ticks: &[NormalizedTick]) -> Option<f64>

Quantity-weighted standard deviation of price (weighted σ around VWAP).

Returns None for an empty slice or zero total quantity.

Trait Implementations§

Source§

impl Clone for NormalizedTick

Source§

fn clone(&self) -> NormalizedTick

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NormalizedTick

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for NormalizedTick

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for NormalizedTick

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for NormalizedTick

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,