pub struct DepthChart { /* private fields */ }Expand description
Order-book depth chart. Bids are drawn as a cumulative step-area on the left, asks on the right, with a mid-price marker and spread readout.
§Example
use ratatui::{buffer::Buffer, layout::Rect, widgets::Widget};
use tui_chart::{DepthChart};
let chart = DepthChart::new([(99.0, 5.0), (98.0, 9.0)], [(101.0, 4.0), (102.0, 8.0)]);
let area = Rect::new(0, 0, 40, 12);
let mut buf = Buffer::empty(area);
chart.render(area, &mut buf);Implementations§
Source§impl DepthChart
impl DepthChart
Sourcepub fn new(
bids: impl IntoIterator<Item = (f64, f64)>,
asks: impl IntoIterator<Item = (f64, f64)>,
) -> Self
pub fn new( bids: impl IntoIterator<Item = (f64, f64)>, asks: impl IntoIterator<Item = (f64, f64)>, ) -> Self
Create from (price, quantity) bid and ask levels (any order;
non-finite or non-positive-quantity levels are ignored).
Sourcepub fn base_style(self, style: Style) -> Self
pub fn base_style(self, style: Style) -> Self
Base style painted over the whole area (beats the theme).
Sourcepub fn marker(self, v: Marker) -> Self
pub fn marker(self, v: Marker) -> Self
Draw the step-area with dot glyphs (e.g. Marker::Braille for
2×4 sub-cell resolution) instead of eighth blocks (the default).
Sourcepub fn show_spread(self, v: bool) -> Self
pub fn show_spread(self, v: bool) -> Self
Show the spread readout on the top row.
Sourcepub fn bid_depth_at(&self, price: f64) -> f64
pub fn bid_depth_at(&self, price: f64) -> f64
Cumulative bid quantity at or above price (0 inside/above the spread).
Sourcepub fn ask_depth_at(&self, price: f64) -> f64
pub fn ask_depth_at(&self, price: f64) -> f64
Cumulative ask quantity at or below price (0 inside/below the spread).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DepthChart
impl RefUnwindSafe for DepthChart
impl Send for DepthChart
impl Sync for DepthChart
impl Unpin for DepthChart
impl UnsafeUnpin for DepthChart
impl UnwindSafe for DepthChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more