Struct Orderbook

Source
pub struct Orderbook { /* private fields */ }

Implementations§

Source§

impl Orderbook

Source

pub fn new(tick_size: f64) -> Self

Examples found in repository?
examples/hello_world.rs (line 6)
3fn main() {
4    let mut reader = csv::Reader::from_path("./data/norm_book_data_300k.csv").unwrap();
5    let tick_size = 0.01;
6    let mut ob = Orderbook::new(tick_size);
7
8    let mut rdr = reader.deserialize::<Event>();
9
10    while let Some(Ok(event)) = rdr.next() {
11        ob.process(event);
12
13        // or if its a raw event
14        // ob.process_raw(
15        //     event.timestamp,
16        //     event.seq,
17        //     event.is_trade,
18        //     event.is_buy,
19        //     event.price,
20        //     event.size,
21        // );
22
23        println!(
24            "{:?} -- {:?} -- {:?}",
25            ob.best_bid(),
26            ob.midprice(),
27            ob.best_ask()
28        );
29    }
30}
Source

pub fn process_raw( &mut self, timestamp: u64, seq: u64, is_trade: bool, is_buy: bool, price: f64, size: f64, )

Source

pub fn process_stream_bbo_raw( &mut self, timestamp: u64, seq: u64, is_trade: bool, is_buy: bool, price: f64, size: f64, ) -> Option<(Option<Level>, Option<Level>)>

Source

pub fn process(&mut self, event: Event)

Examples found in repository?
examples/hello_world.rs (line 11)
3fn main() {
4    let mut reader = csv::Reader::from_path("./data/norm_book_data_300k.csv").unwrap();
5    let tick_size = 0.01;
6    let mut ob = Orderbook::new(tick_size);
7
8    let mut rdr = reader.deserialize::<Event>();
9
10    while let Some(Ok(event)) = rdr.next() {
11        ob.process(event);
12
13        // or if its a raw event
14        // ob.process_raw(
15        //     event.timestamp,
16        //     event.seq,
17        //     event.is_trade,
18        //     event.is_buy,
19        //     event.price,
20        //     event.size,
21        // );
22
23        println!(
24            "{:?} -- {:?} -- {:?}",
25            ob.best_bid(),
26            ob.midprice(),
27            ob.best_ask()
28        );
29    }
30}
Source

pub fn process_stream_bbo( &mut self, event: Event, ) -> Option<(Option<Level>, Option<Level>)>

Source

pub fn best_bid(&self) -> Option<Level>

Examples found in repository?
examples/hello_world.rs (line 25)
3fn main() {
4    let mut reader = csv::Reader::from_path("./data/norm_book_data_300k.csv").unwrap();
5    let tick_size = 0.01;
6    let mut ob = Orderbook::new(tick_size);
7
8    let mut rdr = reader.deserialize::<Event>();
9
10    while let Some(Ok(event)) = rdr.next() {
11        ob.process(event);
12
13        // or if its a raw event
14        // ob.process_raw(
15        //     event.timestamp,
16        //     event.seq,
17        //     event.is_trade,
18        //     event.is_buy,
19        //     event.price,
20        //     event.size,
21        // );
22
23        println!(
24            "{:?} -- {:?} -- {:?}",
25            ob.best_bid(),
26            ob.midprice(),
27            ob.best_ask()
28        );
29    }
30}
Source

pub fn best_ask(&self) -> Option<Level>

Examples found in repository?
examples/hello_world.rs (line 27)
3fn main() {
4    let mut reader = csv::Reader::from_path("./data/norm_book_data_300k.csv").unwrap();
5    let tick_size = 0.01;
6    let mut ob = Orderbook::new(tick_size);
7
8    let mut rdr = reader.deserialize::<Event>();
9
10    while let Some(Ok(event)) = rdr.next() {
11        ob.process(event);
12
13        // or if its a raw event
14        // ob.process_raw(
15        //     event.timestamp,
16        //     event.seq,
17        //     event.is_trade,
18        //     event.is_buy,
19        //     event.price,
20        //     event.size,
21        // );
22
23        println!(
24            "{:?} -- {:?} -- {:?}",
25            ob.best_bid(),
26            ob.midprice(),
27            ob.best_ask()
28        );
29    }
30}
Source

pub fn top_bids(&self, n: usize) -> Vec<Level>

Source

pub fn top_asks(&self, n: usize) -> Vec<Level>

Source

pub fn midprice(&self) -> Option<f64>

Examples found in repository?
examples/hello_world.rs (line 26)
3fn main() {
4    let mut reader = csv::Reader::from_path("./data/norm_book_data_300k.csv").unwrap();
5    let tick_size = 0.01;
6    let mut ob = Orderbook::new(tick_size);
7
8    let mut rdr = reader.deserialize::<Event>();
9
10    while let Some(Ok(event)) = rdr.next() {
11        ob.process(event);
12
13        // or if its a raw event
14        // ob.process_raw(
15        //     event.timestamp,
16        //     event.seq,
17        //     event.is_trade,
18        //     event.is_buy,
19        //     event.price,
20        //     event.size,
21        // );
22
23        println!(
24            "{:?} -- {:?} -- {:?}",
25            ob.best_bid(),
26            ob.midprice(),
27            ob.best_ask()
28        );
29    }
30}
Source

pub fn weighted_midprice(&self) -> Option<f64>

Trait Implementations§

Source§

impl Clone for Orderbook

Source§

fn clone(&self) -> Orderbook

Returns a copy 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 Orderbook

Source§

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

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

impl Default for Orderbook

Source§

fn default() -> Orderbook

Returns the “default value” for a type. 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.