pub enum TickSize {
Simple(Decimal),
Varying {
thresholds: Vec<(Decimal, Decimal)>,
},
}Variants§
Simple(Decimal)
Varying
List of (threshold, tick_size) pairs. For price greater than or equal to each threshold, the tick size is the corresponding value.
For example, if the thresholds are [(100, 0.01), (200, 0.02)], valid prices include:
…199.98, 199.99, 200.00, 200.02, 200.04…
Implementations§
Source§impl TickSize
impl TickSize
pub fn simple(tick_size: Decimal) -> Self
Sourcepub fn increment(&self, price: Decimal, n: i32) -> Option<Decimal>
pub fn increment(&self, price: Decimal, n: i32) -> Option<Decimal>
Increment the price by n ticks. Negative values decrement.
This method assumes:
priceis a valid price (i.e. on a tick and not between ticks)priceis not on or below the first threshold, for negativenthresholdsis non-empty, if tick size isVaryingthresholdsare well-formed[1]
[1] Sequential thresholds must be arithemetically adjacent; e.g.
(100, 0.3), (200, _) is an invalid threshold sequence because
no iteration of ticks can get from 100 to 200.
pub fn decrement(&self, price: Decimal, n: i32) -> Option<Decimal>
Sourcepub fn round_aggressive(&self, price: Decimal, dir: Dir) -> Option<Decimal>
pub fn round_aggressive(&self, price: Decimal, dir: Dir) -> Option<Decimal>
Round the price to make the price more aggressive for the given direction.
Sourcepub fn round_passive(&self, price: Decimal, dir: Dir) -> Option<Decimal>
pub fn round_passive(&self, price: Decimal, dir: Dir) -> Option<Decimal>
Round the price to make the price more passive for the given direction.
pub fn round_up(&self, price: Decimal) -> Option<Decimal>
pub fn round_down(&self, price: Decimal) -> Option<Decimal>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TickSize
impl<'de> Deserialize<'de> for TickSize
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 JsonSchema for TickSize
impl JsonSchema for TickSize
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for TickSize
impl RefUnwindSafe for TickSize
impl Send for TickSize
impl Sync for TickSize
impl Unpin for TickSize
impl UnwindSafe for TickSize
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