architect_api/symbology/
execution_info.rs

1use super::ExecutionVenue;
2use derive_more::Display;
3use rust_decimal::Decimal;
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6use strum_macros::{EnumString, IntoStaticStr};
7
8/// Information about a symbol related to its execution route.
9#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
10pub struct ExecutionInfo {
11    pub execution_venue: ExecutionVenue,
12    /// If the execution venue has stable symbology, this may be populated
13    pub exchange_symbol: Option<String>,
14    pub tick_size: TickSize,
15    pub step_size: Decimal,
16    pub min_order_quantity: Decimal,
17    pub min_order_quantity_unit: MinOrderQuantityUnit,
18    pub is_delisted: bool,
19    pub initial_margin: Option<Decimal>,
20    pub maintenance_margin: Option<Decimal>,
21}
22
23#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
24#[serde(rename_all = "snake_case")]
25pub enum TickSize {
26    #[schemars(title = "Simple|Decimal")]
27    Simple(Decimal),
28    /// List of (threshold, tick_size) pairs.  For price greater than or equal
29    /// to each threshold, the tick size is the corresponding value.
30    #[schemars(title = "Varying")]
31    Varying { thresholds: Vec<(Decimal, Decimal)> },
32}
33
34impl TickSize {
35    pub fn simple(tick_size: Decimal) -> Self {
36        Self::Simple(tick_size)
37    }
38}
39
40// TODO: un snake_case this
41#[derive(
42    Default,
43    Debug,
44    Display,
45    Clone,
46    Copy,
47    EnumString,
48    IntoStaticStr,
49    Serialize,
50    Deserialize,
51    JsonSchema,
52)]
53#[cfg_attr(feature = "juniper", derive(juniper::GraphQLEnum))]
54#[serde(tag = "unit", rename_all = "snake_case")]
55#[strum(serialize_all = "snake_case")]
56pub enum MinOrderQuantityUnit {
57    #[default]
58    #[schemars(title = "Base")]
59    Base,
60    #[schemars(title = "Quote")]
61    Quote,
62}
63
64#[cfg(feature = "postgres")]
65crate::to_sql_str!(MinOrderQuantityUnit);