Skip to main content

Footprint

Struct Footprint 

Source
pub struct Footprint { /* private fields */ }
Expand description

A footprint series: add it with Chart::add_custom_series and feed it with crate::append_trades.

Columns share the slots of the host’s candles (AxisMode::Slots): a column’s time is the open time of its bar. Below 12 CSS px of bar spacing nothing is drawn (the candles stay visible); from 12 px the cells are shaded; from 60 px the volumes are written in them (raise ChartOptions::max_bar_spacing, 50 px by default, to zoom in that far).

§Examples

use ferrochart_core::chart::SeriesOptions;
use ferrochart_core::theme::Theme;
use ferrochart_core::{Chart, ChartOptions};
use ferrochart_orderflow::{Footprint, FootprintOptions, Side, TickColumns, append_trades};

let mut chart = Chart::new(ChartOptions::default());
let fp = Footprint::new(FootprintOptions::new(0.25, 60_000, &Theme::light()))?;
let id = chart.add_custom_series(chart.main_pane(), Box::new(fp), SeriesOptions::default())?;
let trades = TickColumns {
    time: vec![0, 1_000, 61_000],
    price: vec![100.0, 100.25, 100.0],
    size: vec![2.0, 1.0, 5.0],
    side: vec![Side::Buy, Side::Sell, Side::Unknown],
};
append_trades(&mut chart, id, &trades)?;
let fp = chart.custom_series::<Footprint>(id).unwrap();
assert_eq!(fp.grid().columns(), 2);
// 100.0 is level 400: 2 bought; 100.25 is level 401: 1 sold.
assert_eq!(fp.grid().column(0).unwrap().at(400), (0.0, 2.0));
assert_eq!(fp.grid().column(0).unwrap().at(401), (1.0, 0.0));

Implementations§

Source§

impl Footprint

Source

pub fn new(opts: FootprintOptions) -> Result<Self>

An empty footprint.

§Errors

Error::InvalidArgument for a bad price grid, a non-positive timeframe or an imbalance ratio below 1.

Source

pub fn options(&self) -> &FootprintOptions

The options.

Source

pub fn set_display( &mut self, mode: FootprintMode, imbalance_ratio: Option<f64>, colors: FootprintColors, )

Changes what the cells show and their colors (the data stays).

Source

pub fn grid(&self) -> &SparseGrid

The cells: a is sell volume, b buy volume.

Source

pub fn close(&self, i: usize) -> Option<f64>

Last trade price of column i.

Source

pub fn push_trade( &mut self, time: Timestamp, price: f64, size: f64, side: Side, ) -> Result<bool>

Adds one trade; returns whether it opened a column.

§Errors

Error::InvalidArgument for a non-finite price or a negative size; Error::TimeNotIncreasing if its bar is before the last column; Error::OutOfMemory.

Trait Implementations§

Source§

impl Clone for Footprint

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl CustomSeries for Footprint

Source§

fn kind(&self) -> &'static str

Kind name, e.g. "orderflow.heatmap"; renderers that draw it natively declare this name.
Source§

fn axis_mode(&self) -> AxisMode

How the points are placed on the time axis; read once, when added.
Source§

fn times(&self) -> &[Timestamp]

Times of the points, strictly increasing.
Source§

fn extremes(&self, from: usize, to: usize) -> Option<(f64, f64)>

Price extremes of points from..to, for auto scaling. Called every frame, so it must be O(log n) (see crate::plugin::MinMaxIndex).
Source§

fn last_value(&self) -> Option<f64>

Value of the last-value label; None hides it.
Source§

fn crosshair_value(&self, point: usize) -> Option<f64>

Value of point point for the crosshair and magnet.
Source§

fn build( &self, ctx: &SeriesCtx<'_>, from: usize, to: usize, out: &mut FrameBuilder<'_>, )

Portable path: writes the primitives of points from..to (the visible ones and one more on each side). Must not allocate once warmed up.
Source§

fn native_params(&self, ctx: &SeriesCtx<'_>, params: &mut [f32; 8])

Parameters of the native GPU path, e.g. a color-scale range.
Source§

impl Debug for Footprint

Source§

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

Formats the value using the given formatter. 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Downcast<T> for T

Source§

fn downcast(&self) -> &T

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,