RangeBar

Struct RangeBar 

Source
pub struct RangeBar {
Show 20 fields pub open_time: i64, pub close_time: i64, pub open: FixedPoint, pub high: FixedPoint, pub low: FixedPoint, pub close: FixedPoint, pub volume: FixedPoint, pub turnover: i128, pub individual_trade_count: u32, pub agg_record_count: u32, pub first_trade_id: i64, pub last_trade_id: i64, pub data_source: DataSource, pub buy_volume: FixedPoint, pub sell_volume: FixedPoint, pub buy_trade_count: u32, pub sell_trade_count: u32, pub vwap: FixedPoint, pub buy_turnover: i128, pub sell_turnover: i128,
}
Expand description

Range bar with OHLCV data and market microstructure enhancements

Fields§

§open_time: i64

Opening timestamp in microseconds (first trade)

§close_time: i64

Closing timestamp in microseconds (last trade)

§open: FixedPoint

Opening price (first trade price)

§high: FixedPoint

Highest price in bar

§low: FixedPoint

Lowest price in bar

§close: FixedPoint

Closing price (breach trade price)

§volume: FixedPoint

Total volume

§turnover: i128

Total turnover (sum of price * volume)

§individual_trade_count: u32

Total number of individual exchange trades in this range bar Sum of individual_trade_count() from all processed AggTrade records

§agg_record_count: u32

Number of AggTrade records processed to create this range bar NEW: Enables tracking of aggregation efficiency

§first_trade_id: i64

First individual trade ID in this range bar

§last_trade_id: i64

Last individual trade ID in this range bar

§data_source: DataSource

Data source this range bar was created from

§buy_volume: FixedPoint

Volume from buy-side trades (is_buyer_maker = false) Represents aggressive buying pressure

§sell_volume: FixedPoint

Volume from sell-side trades (is_buyer_maker = true) Represents aggressive selling pressure

§buy_trade_count: u32

Number of individual buy-side trades (aggressive buying)

§sell_trade_count: u32

Number of individual sell-side trades (aggressive selling)

§vwap: FixedPoint

Volume Weighted Average Price for the bar Calculated incrementally as: sum(price * volume) / sum(volume)

§buy_turnover: i128

Turnover from buy-side trades (buy pressure)

§sell_turnover: i128

Turnover from sell-side trades (sell pressure)

Implementations§

Source§

impl RangeBar

Source

pub fn new(trade: &AggTrade) -> RangeBar

Create new range bar from opening AggTrade record

Source

pub fn aggregation_efficiency(&self) -> f64

Average number of individual trades per AggTrade record (aggregation efficiency)

Source

pub fn update_with_trade(&mut self, trade: &AggTrade)

Update bar with new AggTrade record (always call before checking breach) Maintains market microstructure metrics incrementally

Source

pub fn is_breach( &self, price: FixedPoint, upper_threshold: FixedPoint, lower_threshold: FixedPoint, ) -> bool

Check if price breaches the range thresholds

§Arguments
  • price - Current price to check
  • upper_threshold - Upper breach threshold (from bar open)
  • lower_threshold - Lower breach threshold (from bar open)
§Returns

true if price breaches either threshold

Trait Implementations§

Source§

impl Clone for RangeBar

Source§

fn clone(&self) -> RangeBar

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 RangeBar

Source§

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

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

impl<'de> Deserialize<'de> for RangeBar

Source§

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

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

impl Serialize for RangeBar

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::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, 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> 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, 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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,