nautilus_model/
enums.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Enumerations for the trading domain model.
17
18use std::{str::FromStr, sync::OnceLock};
19
20use ahash::AHashSet;
21use serde::{Deserialize, Deserializer, Serialize, Serializer};
22use strum::{AsRefStr, Display, EnumIter, EnumString, FromRepr};
23
24use crate::enum_strum_serde;
25
26/// Provides conversion from a `u8` value to an enum type.
27pub trait FromU8 {
28    /// Converts a `u8` value to the implementing type.
29    ///
30    /// Returns `None` if the value is not a valid representation.
31    fn from_u8(value: u8) -> Option<Self>
32    where
33        Self: Sized;
34}
35
36/// Provides conversion from a `u16` value to an enum type.
37pub trait FromU16 {
38    /// Converts a `u16` value to the implementing type.
39    ///
40    /// Returns `None` if the value is not a valid representation.
41    fn from_u16(value: u16) -> Option<Self>
42    where
43        Self: Sized;
44}
45
46/// An account type provided by a trading venue or broker.
47#[repr(C)]
48#[derive(
49    Copy,
50    Clone,
51    Debug,
52    Display,
53    Hash,
54    PartialEq,
55    Eq,
56    PartialOrd,
57    Ord,
58    AsRefStr,
59    FromRepr,
60    EnumIter,
61    EnumString,
62)]
63#[strum(ascii_case_insensitive)]
64#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
65#[cfg_attr(
66    feature = "python",
67    pyo3::pyclass(
68        frozen,
69        eq,
70        eq_int,
71        hash,
72        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
73    )
74)]
75pub enum AccountType {
76    /// An account with unleveraged cash assets only.
77    Cash = 1,
78    /// An account which facilitates trading on margin, using account assets as collateral.
79    Margin = 2,
80    /// An account specific to betting markets.
81    Betting = 3,
82}
83
84/// An aggregation source for derived data.
85#[repr(C)]
86#[derive(
87    Copy,
88    Clone,
89    Debug,
90    Display,
91    Hash,
92    PartialEq,
93    Eq,
94    PartialOrd,
95    Ord,
96    AsRefStr,
97    FromRepr,
98    EnumIter,
99    EnumString,
100)]
101#[strum(ascii_case_insensitive)]
102#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
103#[cfg_attr(
104    feature = "python",
105    pyo3::pyclass(
106        frozen,
107        eq,
108        eq_int,
109        hash,
110        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
111    )
112)]
113pub enum AggregationSource {
114    /// The data is externally aggregated (outside the Nautilus system boundary).
115    External = 1,
116    /// The data is internally aggregated (inside the Nautilus system boundary).
117    Internal = 2,
118}
119
120/// The side for the aggressing order of a trade in a market.
121#[repr(C)]
122#[derive(
123    Copy,
124    Clone,
125    Debug,
126    Default,
127    Display,
128    Hash,
129    PartialEq,
130    Eq,
131    PartialOrd,
132    Ord,
133    AsRefStr,
134    FromRepr,
135    EnumIter,
136    EnumString,
137)]
138#[strum(ascii_case_insensitive)]
139#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
140#[cfg_attr(
141    feature = "python",
142    pyo3::pyclass(
143        frozen,
144        eq,
145        eq_int,
146        hash,
147        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
148    )
149)]
150pub enum AggressorSide {
151    /// There was no specific aggressor for the trade.
152    #[default]
153    NoAggressor = 0,
154    /// The BUY order was the aggressor for the trade.
155    Buyer = 1,
156    /// The SELL order was the aggressor for the trade.
157    Seller = 2,
158}
159
160impl FromU8 for AggressorSide {
161    fn from_u8(value: u8) -> Option<Self> {
162        match value {
163            0 => Some(Self::NoAggressor),
164            1 => Some(Self::Buyer),
165            2 => Some(Self::Seller),
166            _ => None,
167        }
168    }
169}
170
171/// A broad financial market asset class.
172#[repr(C)]
173#[derive(
174    Copy,
175    Clone,
176    Debug,
177    Display,
178    Hash,
179    PartialEq,
180    Eq,
181    PartialOrd,
182    Ord,
183    AsRefStr,
184    FromRepr,
185    EnumIter,
186    EnumString,
187)]
188#[strum(ascii_case_insensitive)]
189#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
190#[cfg_attr(
191    feature = "python",
192    pyo3::pyclass(
193        frozen,
194        eq,
195        eq_int,
196        hash,
197        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
198    )
199)]
200#[allow(non_camel_case_types)]
201pub enum AssetClass {
202    /// Foreign exchange (FOREX) assets.
203    FX = 1,
204    /// Equity / stock assets.
205    Equity = 2,
206    /// Commodity assets.
207    Commodity = 3,
208    /// Debt based assets.
209    Debt = 4,
210    /// Index based assets (baskets).
211    Index = 5,
212    /// Cryptocurrency or crypto token assets.
213    Cryptocurrency = 6,
214    /// Alternative assets.
215    Alternative = 7,
216}
217
218impl FromU8 for AssetClass {
219    fn from_u8(value: u8) -> Option<Self> {
220        match value {
221            1 => Some(Self::FX),
222            2 => Some(Self::Equity),
223            3 => Some(Self::Commodity),
224            4 => Some(Self::Debt),
225            5 => Some(Self::Index),
226            6 => Some(Self::Cryptocurrency),
227            7 => Some(Self::Alternative),
228            _ => None,
229        }
230    }
231}
232
233/// The aggregation method through which a bar is generated and closed.
234#[repr(C)]
235#[derive(
236    Copy,
237    Clone,
238    Debug,
239    Display,
240    Hash,
241    PartialEq,
242    Eq,
243    PartialOrd,
244    Ord,
245    AsRefStr,
246    FromRepr,
247    EnumIter,
248    EnumString,
249)]
250#[strum(ascii_case_insensitive)]
251#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
252#[cfg_attr(
253    feature = "python",
254    pyo3::pyclass(
255        frozen,
256        eq,
257        eq_int,
258        hash,
259        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
260    )
261)]
262pub enum BarAggregation {
263    /// Based on a number of ticks.
264    Tick = 1,
265    /// Based on the buy/sell imbalance of ticks.
266    TickImbalance = 2,
267    /// Based on sequential buy/sell runs of ticks.
268    TickRuns = 3,
269    /// Based on traded volume.
270    Volume = 4,
271    /// Based on the buy/sell imbalance of traded volume.
272    VolumeImbalance = 5,
273    /// Based on sequential runs of buy/sell traded volume.
274    VolumeRuns = 6,
275    /// Based on the 'notional' value of the instrument.
276    Value = 7,
277    /// Based on the buy/sell imbalance of trading by notional value.
278    ValueImbalance = 8,
279    /// Based on sequential buy/sell runs of trading by notional value.
280    ValueRuns = 9,
281    /// Based on time intervals with millisecond granularity.
282    Millisecond = 10,
283    /// Based on time intervals with second granularity.
284    Second = 11,
285    /// Based on time intervals with minute granularity.
286    Minute = 12,
287    /// Based on time intervals with hour granularity.
288    Hour = 13,
289    /// Based on time intervals with day granularity.
290    Day = 14,
291    /// Based on time intervals with week granularity.
292    Week = 15,
293    /// Based on time intervals with month granularity.
294    Month = 16,
295    /// Based on time intervals with year granularity.
296    Year = 17,
297    /// Based on fixed price movements (brick size).
298    Renko = 18,
299}
300
301/// The interval type for bar aggregation.
302#[repr(C)]
303#[derive(
304    Copy,
305    Clone,
306    Debug,
307    Default,
308    Display,
309    Hash,
310    PartialEq,
311    Eq,
312    PartialOrd,
313    Ord,
314    AsRefStr,
315    FromRepr,
316    EnumIter,
317    EnumString,
318)]
319#[strum(ascii_case_insensitive)]
320#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
321#[cfg_attr(
322    feature = "python",
323    pyo3::pyclass(
324        frozen,
325        eq,
326        eq_int,
327        hash,
328        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
329    )
330)]
331pub enum BarIntervalType {
332    /// Left-open interval `(start, end]`: start is exclusive, end is inclusive (default).
333    #[default]
334    LeftOpen = 1,
335    /// Right-open interval `[start, end)`: start is inclusive, end is exclusive.
336    RightOpen = 2,
337}
338
339/// Represents the side of a bet in a betting market.
340#[repr(C)]
341#[derive(
342    Copy,
343    Clone,
344    Debug,
345    Display,
346    Hash,
347    PartialEq,
348    Eq,
349    PartialOrd,
350    Ord,
351    AsRefStr,
352    FromRepr,
353    EnumIter,
354    EnumString,
355)]
356#[strum(ascii_case_insensitive)]
357#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
358#[cfg_attr(
359    feature = "python",
360    pyo3::pyclass(
361        frozen,
362        eq,
363        eq_int,
364        hash,
365        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
366    )
367)]
368pub enum BetSide {
369    /// A "Back" bet signifies support for a specific outcome.
370    Back = 1,
371    /// A "Lay" bet signifies opposition to a specific outcome.
372    Lay = 2,
373}
374
375impl BetSide {
376    /// Returns the opposite betting side.
377    #[must_use]
378    pub fn opposite(&self) -> Self {
379        match self {
380            Self::Back => Self::Lay,
381            Self::Lay => Self::Back,
382        }
383    }
384}
385
386impl From<OrderSide> for BetSide {
387    /// Returns the equivalent [`BetSide`] for a given [`OrderSide`].
388    ///
389    /// # Panics
390    ///
391    /// Panics if `side` is [`OrderSide::NoOrderSide`].
392    fn from(side: OrderSide) -> Self {
393        match side {
394            OrderSide::Buy => Self::Back,
395            OrderSide::Sell => Self::Lay,
396            OrderSide::NoOrderSide => panic!("Invalid `OrderSide` for `BetSide`, was {side}"),
397        }
398    }
399}
400
401/// The type of order book action for an order book event.
402#[repr(C)]
403#[derive(
404    Copy,
405    Clone,
406    Debug,
407    Display,
408    Hash,
409    PartialEq,
410    Eq,
411    PartialOrd,
412    Ord,
413    AsRefStr,
414    FromRepr,
415    EnumIter,
416    EnumString,
417)]
418#[strum(ascii_case_insensitive)]
419#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
420#[cfg_attr(
421    feature = "python",
422    pyo3::pyclass(
423        frozen,
424        eq,
425        eq_int,
426        hash,
427        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
428    )
429)]
430pub enum BookAction {
431    /// An order is added to the book.
432    Add = 1,
433    /// An existing order in the book is updated/modified.
434    Update = 2,
435    /// An existing order in the book is deleted/canceled.
436    Delete = 3,
437    /// The state of the order book is cleared.
438    Clear = 4,
439}
440
441impl FromU8 for BookAction {
442    fn from_u8(value: u8) -> Option<Self> {
443        match value {
444            1 => Some(Self::Add),
445            2 => Some(Self::Update),
446            3 => Some(Self::Delete),
447            4 => Some(Self::Clear),
448            _ => None,
449        }
450    }
451}
452
453/// The order book type, representing the type of levels granularity and delta updating heuristics.
454#[repr(C)]
455#[derive(
456    Copy,
457    Clone,
458    Debug,
459    Display,
460    Hash,
461    PartialEq,
462    Eq,
463    PartialOrd,
464    Ord,
465    AsRefStr,
466    FromRepr,
467    EnumIter,
468    EnumString,
469)]
470#[strum(ascii_case_insensitive)]
471#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
472#[allow(non_camel_case_types)]
473#[cfg_attr(
474    feature = "python",
475    pyo3::pyclass(
476        frozen,
477        eq,
478        eq_int,
479        hash,
480        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
481    )
482)]
483pub enum BookType {
484    /// Top-of-book best bid/ask, one level per side.
485    L1_MBP = 1,
486    /// Market by price, one order per level (aggregated).
487    L2_MBP = 2,
488    /// Market by order, multiple orders per level (full granularity).
489    L3_MBO = 3,
490}
491
492impl FromU8 for BookType {
493    fn from_u8(value: u8) -> Option<Self> {
494        match value {
495            1 => Some(Self::L1_MBP),
496            2 => Some(Self::L2_MBP),
497            3 => Some(Self::L3_MBO),
498            _ => None,
499        }
500    }
501}
502
503/// The order contingency type which specifies the behavior of linked orders.
504///
505/// [FIX 5.0 SP2 : ContingencyType <1385> field](https://www.onixs.biz/fix-dictionary/5.0.sp2/tagnum_1385.html).
506#[repr(C)]
507#[derive(
508    Copy,
509    Clone,
510    Debug,
511    Default,
512    Display,
513    Hash,
514    PartialEq,
515    Eq,
516    PartialOrd,
517    Ord,
518    AsRefStr,
519    FromRepr,
520    EnumIter,
521    EnumString,
522)]
523#[strum(ascii_case_insensitive)]
524#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
525#[cfg_attr(
526    feature = "python",
527    pyo3::pyclass(
528        frozen,
529        eq,
530        eq_int,
531        hash,
532        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
533    )
534)]
535pub enum ContingencyType {
536    /// Not a contingent order.
537    #[default]
538    NoContingency = 0,
539    /// One-Cancels-the-Other.
540    Oco = 1,
541    /// One-Triggers-the-Other.
542    Oto = 2,
543    /// One-Updates-the-Other (by proportional quantity).
544    Ouo = 3,
545}
546
547/// The broad currency type.
548#[repr(C)]
549#[derive(
550    Copy,
551    Clone,
552    Debug,
553    Display,
554    Hash,
555    PartialEq,
556    Eq,
557    PartialOrd,
558    Ord,
559    AsRefStr,
560    FromRepr,
561    EnumIter,
562    EnumString,
563)]
564#[strum(ascii_case_insensitive)]
565#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
566#[cfg_attr(
567    feature = "python",
568    pyo3::pyclass(
569        frozen,
570        eq,
571        eq_int,
572        hash,
573        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
574    )
575)]
576pub enum CurrencyType {
577    /// A type of cryptocurrency or crypto token.
578    Crypto = 1,
579    /// A type of currency issued by governments which is not backed by a commodity.
580    Fiat = 2,
581    /// A type of currency that is based on the value of an underlying commodity.
582    CommodityBacked = 3,
583}
584
585/// The instrument class.
586#[repr(C)]
587#[derive(
588    Copy,
589    Clone,
590    Debug,
591    Display,
592    Hash,
593    PartialEq,
594    Eq,
595    PartialOrd,
596    Ord,
597    AsRefStr,
598    FromRepr,
599    EnumIter,
600    EnumString,
601)]
602#[strum(ascii_case_insensitive)]
603#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
604#[cfg_attr(
605    feature = "python",
606    pyo3::pyclass(
607        frozen,
608        eq,
609        eq_int,
610        hash,
611        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
612    )
613)]
614pub enum InstrumentClass {
615    /// A spot market instrument class. The current market price of an instrument that is bought or sold for immediate delivery and payment.
616    Spot = 1,
617    /// A swap instrument class. A derivative contract through which two parties exchange the cash flows or liabilities from two different financial instruments.
618    Swap = 2,
619    /// A futures contract instrument class. A legal agreement to buy or sell an asset at a predetermined price at a specified time in the future.
620    Future = 3,
621    /// A futures spread instrument class. A strategy involving the use of futures contracts to take advantage of price differentials between different contract months, underlying assets, or marketplaces.
622    FuturesSpread = 4,
623    /// A forward derivative instrument class. A customized contract between two parties to buy or sell an asset at a specified price on a future date.
624    Forward = 5,
625    /// A contract-for-difference (CFD) instrument class. A contract between an investor and a CFD broker to exchange the difference in the value of a financial product between the time the contract opens and closes.
626    Cfd = 6,
627    /// A bond instrument class. A type of debt investment where an investor loans money to an entity (typically corporate or governmental) which borrows the funds for a defined period of time at a variable or fixed interest rate.
628    Bond = 7,
629    /// An option contract instrument class. A type of derivative that gives the holder the right, but not the obligation, to buy or sell an underlying asset at a predetermined price before or at a certain future date.
630    Option = 8,
631    /// An option spread instrument class. A strategy involving the purchase and/or sale of multiple option contracts on the same underlying asset with different strike prices or expiration dates to hedge risk or speculate on price movements.
632    OptionSpread = 9,
633    /// A warrant instrument class. A derivative that gives the holder the right, but not the obligation, to buy or sell a security—most commonly an equity—at a certain price before expiration.
634    Warrant = 10,
635    /// A sports betting instrument class. A financialized derivative that allows wagering on the outcome of sports events using structured contracts or prediction markets.
636    SportsBetting = 11,
637    /// A binary option instrument class. A type of derivative where the payoff is either a fixed monetary amount or nothing, depending on whether the price of an underlying asset is above or below a predetermined level at expiration.
638    BinaryOption = 12,
639}
640
641/// The type of event for an instrument close.
642#[repr(C)]
643#[derive(
644    Copy,
645    Clone,
646    Debug,
647    Display,
648    Hash,
649    PartialEq,
650    Eq,
651    PartialOrd,
652    Ord,
653    AsRefStr,
654    FromRepr,
655    EnumIter,
656    EnumString,
657)]
658#[strum(ascii_case_insensitive)]
659#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
660#[cfg_attr(
661    feature = "python",
662    pyo3::pyclass(
663        frozen,
664        eq,
665        eq_int,
666        hash,
667        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
668    )
669)]
670pub enum InstrumentCloseType {
671    /// When the market session ended.
672    EndOfSession = 1,
673    /// When the instrument expiration was reached.
674    ContractExpired = 2,
675}
676
677/// Convert the given `value` to an [`InstrumentCloseType`].
678impl FromU8 for InstrumentCloseType {
679    fn from_u8(value: u8) -> Option<Self> {
680        match value {
681            1 => Some(Self::EndOfSession),
682            2 => Some(Self::ContractExpired),
683            _ => None,
684        }
685    }
686}
687
688/// The liquidity side for a trade.
689#[repr(C)]
690#[derive(
691    Copy,
692    Clone,
693    Debug,
694    Display,
695    Hash,
696    PartialEq,
697    Eq,
698    PartialOrd,
699    Ord,
700    AsRefStr,
701    FromRepr,
702    EnumIter,
703    EnumString,
704)]
705#[strum(ascii_case_insensitive)]
706#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
707#[cfg_attr(
708    feature = "python",
709    pyo3::pyclass(
710        frozen,
711        eq,
712        eq_int,
713        hash,
714        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
715    )
716)]
717#[allow(clippy::enum_variant_names)]
718pub enum LiquiditySide {
719    /// No liquidity side specified.
720    NoLiquiditySide = 0,
721    /// The order passively provided liquidity to the market to complete the trade (made a market).
722    Maker = 1,
723    /// The order aggressively took liquidity from the market to complete the trade.
724    Taker = 2,
725}
726
727/// The status of an individual market on a trading venue.
728#[repr(C)]
729#[derive(
730    Copy,
731    Clone,
732    Debug,
733    Display,
734    Hash,
735    PartialEq,
736    Eq,
737    PartialOrd,
738    Ord,
739    AsRefStr,
740    FromRepr,
741    EnumIter,
742    EnumString,
743)]
744#[strum(ascii_case_insensitive)]
745#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
746#[cfg_attr(
747    feature = "python",
748    pyo3::pyclass(
749        frozen,
750        eq,
751        eq_int,
752        hash,
753        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
754    )
755)]
756pub enum MarketStatus {
757    /// The instrument is trading.
758    Open = 1,
759    /// The instrument is in a pre-open period.
760    Closed = 2,
761    /// Trading in the instrument has been paused.
762    Paused = 3,
763    /// Trading in the instrument has been halted.
764    // Halted = 4,  # TODO: Unfortunately can't use this yet due to Cython (C enum namespacing)
765    /// Trading in the instrument has been suspended.
766    Suspended = 5,
767    /// Trading in the instrument is not available.
768    NotAvailable = 6,
769}
770
771/// An action affecting the status of an individual market on a trading venue.
772#[repr(C)]
773#[derive(
774    Copy,
775    Clone,
776    Debug,
777    Display,
778    Hash,
779    PartialEq,
780    Eq,
781    PartialOrd,
782    Ord,
783    AsRefStr,
784    FromRepr,
785    EnumIter,
786    EnumString,
787)]
788#[strum(ascii_case_insensitive)]
789#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
790#[cfg_attr(
791    feature = "python",
792    pyo3::pyclass(
793        frozen,
794        eq,
795        eq_int,
796        hash,
797        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
798    )
799)]
800pub enum MarketStatusAction {
801    /// No change.
802    None = 0,
803    /// The instrument is in a pre-open period.
804    PreOpen = 1,
805    /// The instrument is in a pre-cross period.
806    PreCross = 2,
807    /// The instrument is quoting but not trading.
808    Quoting = 3,
809    /// The instrument is in a cross/auction.
810    Cross = 4,
811    /// The instrument is being opened through a trading rotation.
812    Rotation = 5,
813    /// A new price indication is available for the instrument.
814    NewPriceIndication = 6,
815    /// The instrument is trading.
816    Trading = 7,
817    /// Trading in the instrument has been halted.
818    Halt = 8,
819    /// Trading in the instrument has been paused.
820    Pause = 9,
821    /// Trading in the instrument has been suspended.
822    Suspend = 10,
823    /// The instrument is in a pre-close period.
824    PreClose = 11,
825    /// Trading in the instrument has closed.
826    Close = 12,
827    /// The instrument is in a post-close period.
828    PostClose = 13,
829    /// A change in short-selling restrictions.
830    ShortSellRestrictionChange = 14,
831    /// The instrument is not available for trading, either trading has closed or been halted.
832    NotAvailableForTrading = 15,
833}
834
835/// Convert the given `value` to an [`OrderSide`].
836impl FromU16 for MarketStatusAction {
837    fn from_u16(value: u16) -> Option<Self> {
838        match value {
839            0 => Some(Self::None),
840            1 => Some(Self::PreOpen),
841            2 => Some(Self::PreCross),
842            3 => Some(Self::Quoting),
843            4 => Some(Self::Cross),
844            5 => Some(Self::Rotation),
845            6 => Some(Self::NewPriceIndication),
846            7 => Some(Self::Trading),
847            8 => Some(Self::Halt),
848            9 => Some(Self::Pause),
849            10 => Some(Self::Suspend),
850            11 => Some(Self::PreClose),
851            12 => Some(Self::Close),
852            13 => Some(Self::PostClose),
853            14 => Some(Self::ShortSellRestrictionChange),
854            15 => Some(Self::NotAvailableForTrading),
855            _ => None,
856        }
857    }
858}
859
860/// The order management system (OMS) type for a trading venue or trading strategy.
861#[repr(C)]
862#[derive(
863    Copy,
864    Clone,
865    Debug,
866    Default,
867    Display,
868    Hash,
869    PartialEq,
870    Eq,
871    PartialOrd,
872    Ord,
873    AsRefStr,
874    FromRepr,
875    EnumIter,
876    EnumString,
877)]
878#[strum(ascii_case_insensitive)]
879#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
880#[cfg_attr(
881    feature = "python",
882    pyo3::pyclass(
883        frozen,
884        eq,
885        eq_int,
886        hash,
887        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
888    )
889)]
890pub enum OmsType {
891    /// There is no specific type of order management specified (will defer to the venue OMS).
892    #[default]
893    Unspecified = 0,
894    /// The netting type where there is one position per instrument.
895    Netting = 1,
896    /// The hedging type where there can be multiple positions per instrument.
897    /// This can be in LONG/SHORT directions, by position/ticket ID, or tracked virtually by
898    /// Nautilus.
899    Hedging = 2,
900}
901
902/// The kind of option contract.
903#[repr(C)]
904#[derive(
905    Copy,
906    Clone,
907    Debug,
908    Display,
909    Hash,
910    PartialEq,
911    Eq,
912    PartialOrd,
913    Ord,
914    AsRefStr,
915    FromRepr,
916    EnumIter,
917    EnumString,
918)]
919#[strum(ascii_case_insensitive)]
920#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
921#[cfg_attr(
922    feature = "python",
923    pyo3::pyclass(
924        frozen,
925        eq,
926        eq_int,
927        hash,
928        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
929    )
930)]
931pub enum OptionKind {
932    /// A Call option gives the holder the right, but not the obligation, to buy an underlying asset at a specified strike price within a specified period of time.
933    Call = 1,
934    /// A Put option gives the holder the right, but not the obligation, to sell an underlying asset at a specified strike price within a specified period of time.
935    Put = 2,
936}
937
938/// The order side for a specific order, or action related to orders.
939#[repr(C)]
940#[derive(
941    Copy,
942    Clone,
943    Debug,
944    Default,
945    Display,
946    Hash,
947    PartialEq,
948    Eq,
949    PartialOrd,
950    Ord,
951    AsRefStr,
952    FromRepr,
953    EnumIter,
954    EnumString,
955)]
956#[strum(ascii_case_insensitive)]
957#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
958#[allow(clippy::enum_variant_names)]
959#[cfg_attr(
960    feature = "python",
961    pyo3::pyclass(
962        frozen,
963        eq,
964        eq_int,
965        hash,
966        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
967    )
968)]
969pub enum OrderSide {
970    /// No order side is specified.
971    #[default]
972    NoOrderSide = 0,
973    /// The order is a BUY.
974    Buy = 1,
975    /// The order is a SELL.
976    Sell = 2,
977}
978
979impl OrderSide {
980    /// Returns the specified [`OrderSideSpecified`] (BUY or SELL) for this side.
981    ///
982    /// # Panics
983    ///
984    /// Panics if `self` is [`OrderSide::NoOrderSide`].
985    #[must_use]
986    pub fn as_specified(&self) -> OrderSideSpecified {
987        match &self {
988            Self::Buy => OrderSideSpecified::Buy,
989            Self::Sell => OrderSideSpecified::Sell,
990            _ => panic!("Order invariant failed: side must be `Buy` or `Sell`"),
991        }
992    }
993}
994
995/// Convert the given `value` to an [`OrderSide`].
996impl FromU8 for OrderSide {
997    fn from_u8(value: u8) -> Option<Self> {
998        match value {
999            0 => Some(Self::NoOrderSide),
1000            1 => Some(Self::Buy),
1001            2 => Some(Self::Sell),
1002            _ => None,
1003        }
1004    }
1005}
1006
1007/// The specified order side (BUY or SELL).
1008#[repr(C)]
1009#[derive(
1010    Copy,
1011    Clone,
1012    Debug,
1013    Display,
1014    Hash,
1015    PartialEq,
1016    Eq,
1017    PartialOrd,
1018    Ord,
1019    AsRefStr,
1020    FromRepr,
1021    EnumIter,
1022    EnumString,
1023)]
1024#[strum(ascii_case_insensitive)]
1025#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1026#[allow(clippy::enum_variant_names)]
1027pub enum OrderSideSpecified {
1028    /// The order is a BUY.
1029    Buy = 1,
1030    /// The order is a SELL.
1031    Sell = 2,
1032}
1033
1034impl OrderSideSpecified {
1035    /// Returns the opposite order side.
1036    #[must_use]
1037    pub fn opposite(&self) -> Self {
1038        match &self {
1039            Self::Buy => Self::Sell,
1040            Self::Sell => Self::Buy,
1041        }
1042    }
1043
1044    /// Converts this specified side into an [`OrderSide`].
1045    #[must_use]
1046    pub fn as_order_side(&self) -> OrderSide {
1047        match &self {
1048            Self::Buy => OrderSide::Buy,
1049            Self::Sell => OrderSide::Sell,
1050        }
1051    }
1052}
1053
1054/// The status for a specific order.
1055///
1056/// An order is considered _open_ for the following status:
1057///  - `ACCEPTED`
1058///  - `TRIGGERED`
1059///  - `PENDING_UPDATE`
1060///  - `PENDING_CANCEL`
1061///  - `PARTIALLY_FILLED`
1062///
1063/// An order is considered _in-flight_ for the following status:
1064///  - `SUBMITTED`
1065///  - `PENDING_UPDATE`
1066///  - `PENDING_CANCEL`
1067///
1068/// An order is considered _closed_ for the following status:
1069///  - `DENIED`
1070///  - `REJECTED`
1071///  - `CANCELED`
1072///  - `EXPIRED`
1073///  - `FILLED`
1074#[repr(C)]
1075#[derive(
1076    Copy,
1077    Clone,
1078    Debug,
1079    Display,
1080    Hash,
1081    PartialEq,
1082    Eq,
1083    PartialOrd,
1084    Ord,
1085    AsRefStr,
1086    FromRepr,
1087    EnumIter,
1088    EnumString,
1089)]
1090#[strum(ascii_case_insensitive)]
1091#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1092#[cfg_attr(
1093    feature = "python",
1094    pyo3::pyclass(
1095        frozen,
1096        eq,
1097        eq_int,
1098        hash,
1099        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1100    )
1101)]
1102pub enum OrderStatus {
1103    /// The order is initialized (instantiated) within the Nautilus system.
1104    Initialized = 1,
1105    /// The order was denied by the Nautilus system, either for being invalid, unprocessable or exceeding a risk limit.
1106    Denied = 2,
1107    /// The order became emulated by the Nautilus system in the `OrderEmulator` component.
1108    Emulated = 3,
1109    /// The order was released by the Nautilus system from the `OrderEmulator` component.
1110    Released = 4,
1111    /// The order was submitted by the Nautilus system to the external service or trading venue (awaiting acknowledgement).
1112    Submitted = 5,
1113    /// The order was acknowledged by the trading venue as being received and valid (may now be working).
1114    Accepted = 6,
1115    /// The order was rejected by the trading venue.
1116    Rejected = 7,
1117    /// The order was canceled (closed/done).
1118    Canceled = 8,
1119    /// The order reached a GTD expiration (closed/done).
1120    Expired = 9,
1121    /// The order STOP price was triggered on a trading venue.
1122    Triggered = 10,
1123    /// The order is currently pending a request to modify on a trading venue.
1124    PendingUpdate = 11,
1125    /// The order is currently pending a request to cancel on a trading venue.
1126    PendingCancel = 12,
1127    /// The order has been partially filled on a trading venue.
1128    PartiallyFilled = 13,
1129    /// The order has been completely filled on a trading venue (closed/done).
1130    Filled = 14,
1131}
1132
1133impl OrderStatus {
1134    /// Returns a cached `AHashSet` of order statuses safe for cancellation queries.
1135    ///
1136    /// These are statuses where an order is working on the venue but not already
1137    /// in the process of being cancelled or updated. Including `PENDING_CANCEL`
1138    /// in cancellation filters can cause duplicate cancel attempts or incorrect open order counts.
1139    ///
1140    /// Returns:
1141    /// - `ACCEPTED`: Order is working on the venue.
1142    /// - `TRIGGERED`: Stop order has been triggered.
1143    /// - `PENDING_UPDATE`: Order being updated.
1144    /// - `PARTIALLY_FILLED`: Order is partially filled but still working.
1145    ///
1146    /// Excludes:
1147    /// - `PENDING_CANCEL`: Already being cancelled.
1148    #[must_use]
1149    pub fn cancellable_statuses_set() -> &'static AHashSet<Self> {
1150        static CANCELLABLE_SET: OnceLock<AHashSet<OrderStatus>> = OnceLock::new();
1151        CANCELLABLE_SET.get_or_init(|| {
1152            AHashSet::from_iter([
1153                Self::Accepted,
1154                Self::Triggered,
1155                Self::PendingUpdate,
1156                Self::PartiallyFilled,
1157            ])
1158        })
1159    }
1160}
1161
1162/// The type of order.
1163#[repr(C)]
1164#[derive(
1165    Copy,
1166    Clone,
1167    Debug,
1168    Display,
1169    Hash,
1170    PartialEq,
1171    Eq,
1172    PartialOrd,
1173    Ord,
1174    AsRefStr,
1175    FromRepr,
1176    EnumIter,
1177    EnumString,
1178)]
1179#[strum(ascii_case_insensitive)]
1180#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1181#[cfg_attr(
1182    feature = "python",
1183    pyo3::pyclass(
1184        frozen,
1185        eq,
1186        eq_int,
1187        hash,
1188        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1189    )
1190)]
1191pub enum OrderType {
1192    /// A market order to buy or sell at the best available price in the current market.
1193    Market = 1,
1194    /// A limit order to buy or sell at a specific price or better.
1195    Limit = 2,
1196    /// A stop market order to buy or sell once the price reaches the specified stop/trigger price. When the stop price is reached, the order effectively becomes a market order.
1197    StopMarket = 3,
1198    /// A stop limit order to buy or sell which combines the features of a stop order and a limit order. Once the stop/trigger price is reached, a stop-limit order effectively becomes a limit order.
1199    StopLimit = 4,
1200    /// A market-to-limit order is a market order that is to be executed as a limit order at the current best market price after reaching the market.
1201    MarketToLimit = 5,
1202    /// A market-if-touched order effectively becomes a market order when the specified trigger price is reached.
1203    MarketIfTouched = 6,
1204    /// A limit-if-touched order effectively becomes a limit order when the specified trigger price is reached.
1205    LimitIfTouched = 7,
1206    /// A trailing stop market order sets the stop/trigger price at a fixed "trailing offset" amount from the market.
1207    TrailingStopMarket = 8,
1208    /// A trailing stop limit order combines the features of a trailing stop order with those of a limit order.
1209    TrailingStopLimit = 9,
1210}
1211
1212/// The type of position adjustment.
1213#[repr(C)]
1214#[derive(
1215    Copy,
1216    Clone,
1217    Debug,
1218    Display,
1219    Hash,
1220    PartialEq,
1221    Eq,
1222    PartialOrd,
1223    Ord,
1224    AsRefStr,
1225    FromRepr,
1226    EnumIter,
1227    EnumString,
1228)]
1229#[strum(ascii_case_insensitive)]
1230#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1231#[cfg_attr(
1232    feature = "python",
1233    pyo3::pyclass(eq, eq_int, module = "nautilus_trader.core.nautilus_pyo3.model.enums")
1234)]
1235pub enum PositionAdjustmentType {
1236    /// Commission adjustment affecting position quantity.
1237    Commission = 1,
1238    /// Funding payment affecting position realized PnL.
1239    Funding = 2,
1240}
1241
1242impl FromU8 for PositionAdjustmentType {
1243    fn from_u8(value: u8) -> Option<Self> {
1244        match value {
1245            1 => Some(Self::Commission),
1246            2 => Some(Self::Funding),
1247            _ => None,
1248        }
1249    }
1250}
1251
1252/// The market side for a specific position, or action related to positions.
1253#[repr(C)]
1254#[derive(
1255    Copy,
1256    Clone,
1257    Debug,
1258    Default,
1259    Display,
1260    Hash,
1261    PartialEq,
1262    Eq,
1263    PartialOrd,
1264    Ord,
1265    AsRefStr,
1266    FromRepr,
1267    EnumIter,
1268    EnumString,
1269)]
1270#[strum(ascii_case_insensitive)]
1271#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1272#[allow(clippy::enum_variant_names)]
1273#[cfg_attr(
1274    feature = "python",
1275    pyo3::pyclass(
1276        frozen,
1277        eq,
1278        eq_int,
1279        hash,
1280        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1281    )
1282)]
1283pub enum PositionSide {
1284    /// No position side is specified (only valid in the context of a filter for actions involving positions).
1285    #[default]
1286    NoPositionSide = 0,
1287    /// A neural/flat position, where no position is currently held in the market.
1288    Flat = 1,
1289    /// A long position in the market, typically acquired through one or many BUY orders.
1290    Long = 2,
1291    /// A short position in the market, typically acquired through one or many SELL orders.
1292    Short = 3,
1293}
1294
1295impl PositionSide {
1296    /// Returns the specified [`PositionSideSpecified`] (`Long`, `Short`, or `Flat`) for this side.
1297    ///
1298    /// # Panics
1299    ///
1300    /// Panics if `self` is [`PositionSide::NoPositionSide`].
1301    #[must_use]
1302    pub fn as_specified(&self) -> PositionSideSpecified {
1303        match &self {
1304            Self::Long => PositionSideSpecified::Long,
1305            Self::Short => PositionSideSpecified::Short,
1306            Self::Flat => PositionSideSpecified::Flat,
1307            _ => panic!("Position invariant failed: side must be `Long`, `Short`, or `Flat`"),
1308        }
1309    }
1310}
1311
1312/// The market side for a specific position, or action related to positions.
1313#[repr(C)]
1314#[derive(
1315    Copy,
1316    Clone,
1317    Debug,
1318    Display,
1319    Hash,
1320    PartialEq,
1321    Eq,
1322    PartialOrd,
1323    Ord,
1324    AsRefStr,
1325    FromRepr,
1326    EnumIter,
1327    EnumString,
1328)]
1329#[strum(ascii_case_insensitive)]
1330#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1331#[allow(clippy::enum_variant_names)]
1332#[cfg_attr(
1333    feature = "python",
1334    pyo3::pyclass(
1335        frozen,
1336        eq,
1337        eq_int,
1338        hash,
1339        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1340    )
1341)]
1342pub enum PositionSideSpecified {
1343    /// A neural/flat position, where no position is currently held in the market.
1344    Flat = 1,
1345    /// A long position in the market, typically acquired through one or many BUY orders.
1346    Long = 2,
1347    /// A short position in the market, typically acquired through one or many SELL orders.
1348    Short = 3,
1349}
1350
1351impl PositionSideSpecified {
1352    /// Converts this specified side into a [`PositionSide`].
1353    #[must_use]
1354    pub fn as_position_side(&self) -> PositionSide {
1355        match &self {
1356            Self::Long => PositionSide::Long,
1357            Self::Short => PositionSide::Short,
1358            Self::Flat => PositionSide::Flat,
1359        }
1360    }
1361}
1362
1363/// The type of price for an instrument in a market.
1364#[repr(C)]
1365#[derive(
1366    Copy,
1367    Clone,
1368    Debug,
1369    Display,
1370    Hash,
1371    PartialEq,
1372    Eq,
1373    PartialOrd,
1374    Ord,
1375    AsRefStr,
1376    FromRepr,
1377    EnumIter,
1378    EnumString,
1379)]
1380#[strum(ascii_case_insensitive)]
1381#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1382#[cfg_attr(
1383    feature = "python",
1384    pyo3::pyclass(
1385        frozen,
1386        eq,
1387        eq_int,
1388        hash,
1389        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1390    )
1391)]
1392pub enum PriceType {
1393    /// The best quoted price at which buyers are willing to buy a quantity of an instrument.
1394    /// Often considered the best bid in the order book.
1395    Bid = 1,
1396    /// The best quoted price at which sellers are willing to sell a quantity of an instrument.
1397    /// Often considered the best ask in the order book.
1398    Ask = 2,
1399    /// The arithmetic midpoint between the best bid and ask quotes.
1400    Mid = 3,
1401    /// The price at which the last trade of an instrument was executed.
1402    Last = 4,
1403    /// A reference price reflecting an instrument's fair value, often used for portfolio
1404    /// calculations and risk management.
1405    Mark = 5,
1406}
1407
1408/// A record flag bit field, indicating event end and data information.
1409#[repr(C)]
1410#[derive(
1411    Copy,
1412    Clone,
1413    Debug,
1414    Display,
1415    Hash,
1416    PartialEq,
1417    Eq,
1418    PartialOrd,
1419    Ord,
1420    AsRefStr,
1421    FromRepr,
1422    EnumIter,
1423    EnumString,
1424)]
1425#[strum(ascii_case_insensitive)]
1426#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1427#[cfg_attr(
1428    feature = "python",
1429    pyo3::pyclass(
1430        frozen,
1431        eq,
1432        eq_int,
1433        hash,
1434        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1435    )
1436)]
1437#[allow(non_camel_case_types)]
1438pub enum RecordFlag {
1439    /// Last message in the book event or packet from the venue for a given `instrument_id`.
1440    F_LAST = 1 << 7, // 128
1441    /// Top-of-book message, not an individual order.
1442    F_TOB = 1 << 6, // 64
1443    /// Message sourced from a replay, such as a snapshot server.
1444    F_SNAPSHOT = 1 << 5, // 32
1445    /// Aggregated price level message, not an individual order.
1446    F_MBP = 1 << 4, // 16
1447    /// Reserved for future use.
1448    RESERVED_2 = 1 << 3, // 8
1449    /// Reserved for future use.
1450    RESERVED_1 = 1 << 2, // 4
1451}
1452
1453impl RecordFlag {
1454    /// Checks if the flag matches a given value.
1455    #[must_use]
1456    pub fn matches(self, value: u8) -> bool {
1457        (self as u8) & value != 0
1458    }
1459}
1460
1461/// The 'Time in Force' instruction for an order.
1462#[repr(C)]
1463#[derive(
1464    Copy,
1465    Clone,
1466    Debug,
1467    Display,
1468    Hash,
1469    PartialEq,
1470    Eq,
1471    PartialOrd,
1472    Ord,
1473    AsRefStr,
1474    FromRepr,
1475    EnumIter,
1476    EnumString,
1477)]
1478#[strum(ascii_case_insensitive)]
1479#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1480#[cfg_attr(
1481    feature = "python",
1482    pyo3::pyclass(
1483        frozen,
1484        eq,
1485        eq_int,
1486        hash,
1487        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1488    )
1489)]
1490pub enum TimeInForce {
1491    /// Good Till Cancel (GTC) - Remains active until canceled.
1492    Gtc = 1,
1493    /// Immediate or Cancel (IOC) - Executes immediately to the extent possible, with any unfilled portion canceled.
1494    Ioc = 2,
1495    /// Fill or Kill (FOK) - Executes in its entirety immediately or is canceled if full execution is not possible.
1496    Fok = 3,
1497    /// Good Till Date (GTD) - Remains active until the specified expiration date or time is reached.
1498    Gtd = 4,
1499    /// Day - Remains active until the close of the current trading session.
1500    Day = 5,
1501    /// At the Opening (ATO) - Executes at the market opening or expires if not filled.
1502    AtTheOpen = 6,
1503    /// At the Closing (ATC) - Executes at the market close or expires if not filled.
1504    AtTheClose = 7,
1505}
1506
1507/// The trading state for a node.
1508#[repr(C)]
1509#[derive(
1510    Copy,
1511    Clone,
1512    Debug,
1513    Display,
1514    Hash,
1515    PartialEq,
1516    Eq,
1517    PartialOrd,
1518    Ord,
1519    AsRefStr,
1520    FromRepr,
1521    EnumIter,
1522    EnumString,
1523)]
1524#[strum(ascii_case_insensitive)]
1525#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1526#[cfg_attr(
1527    feature = "python",
1528    pyo3::pyclass(
1529        frozen,
1530        eq,
1531        eq_int,
1532        hash,
1533        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1534    )
1535)]
1536pub enum TradingState {
1537    /// Normal trading operations.
1538    Active = 1,
1539    /// Trading is completely halted, no new order commands will be emitted.
1540    Halted = 2,
1541    /// Only order commands which would cancel order, or reduce position sizes are permitted.
1542    Reducing = 3,
1543}
1544
1545/// The trailing offset type for an order type which specifies a trailing stop/trigger or limit price.
1546#[repr(C)]
1547#[derive(
1548    Copy,
1549    Clone,
1550    Debug,
1551    Default,
1552    Display,
1553    Hash,
1554    PartialEq,
1555    Eq,
1556    PartialOrd,
1557    Ord,
1558    AsRefStr,
1559    FromRepr,
1560    EnumIter,
1561    EnumString,
1562)]
1563#[strum(ascii_case_insensitive)]
1564#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1565#[cfg_attr(
1566    feature = "python",
1567    pyo3::pyclass(
1568        frozen,
1569        eq,
1570        eq_int,
1571        hash,
1572        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1573    )
1574)]
1575pub enum TrailingOffsetType {
1576    /// No trailing offset type is specified (invalid for trailing type orders).
1577    #[default]
1578    NoTrailingOffset = 0,
1579    /// The trailing offset is based on a market price.
1580    Price = 1,
1581    /// The trailing offset is based on a percentage represented in basis points, of a market price.
1582    BasisPoints = 2,
1583    /// The trailing offset is based on the number of ticks from a market price.
1584    Ticks = 3,
1585    /// The trailing offset is based on a price tier set by a specific trading venue.
1586    PriceTier = 4,
1587}
1588
1589/// The trigger type for the stop/trigger price of an order.
1590#[repr(C)]
1591#[derive(
1592    Copy,
1593    Clone,
1594    Debug,
1595    Default,
1596    Display,
1597    Hash,
1598    PartialEq,
1599    Eq,
1600    PartialOrd,
1601    Ord,
1602    AsRefStr,
1603    FromRepr,
1604    EnumIter,
1605    EnumString,
1606)]
1607#[strum(ascii_case_insensitive)]
1608#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
1609#[cfg_attr(
1610    feature = "python",
1611    pyo3::pyclass(
1612        frozen,
1613        eq,
1614        eq_int,
1615        hash,
1616        module = "nautilus_trader.core.nautilus_pyo3.model.enums"
1617    )
1618)]
1619pub enum TriggerType {
1620    /// No trigger type is specified (invalid for orders with a trigger).
1621    #[default]
1622    NoTrigger = 0,
1623    /// The default trigger type set by the trading venue.
1624    Default = 1,
1625    /// Based on the last traded price for the instrument.
1626    LastPrice = 2,
1627    /// Based on the mark price for the instrument.
1628    MarkPrice = 3,
1629    /// Based on the index price for the instrument.
1630    IndexPrice = 4,
1631    /// Based on the top-of-book quoted prices for the instrument.
1632    BidAsk = 5,
1633    /// Based on a 'double match' of the last traded price for the instrument
1634    DoubleLast = 6,
1635    /// Based on a 'double match' of the bid/ask price for the instrument
1636    DoubleBidAsk = 7,
1637    /// Based on both the [`TriggerType::LastPrice`] and [`TriggerType::BidAsk`].
1638    LastOrBidAsk = 8,
1639    /// Based on the mid-point of the [`TriggerType::BidAsk`].
1640    MidPoint = 9,
1641}
1642
1643enum_strum_serde!(AccountType);
1644enum_strum_serde!(AggregationSource);
1645enum_strum_serde!(AggressorSide);
1646enum_strum_serde!(AssetClass);
1647enum_strum_serde!(BarAggregation);
1648enum_strum_serde!(BarIntervalType);
1649enum_strum_serde!(BookAction);
1650enum_strum_serde!(BookType);
1651enum_strum_serde!(ContingencyType);
1652enum_strum_serde!(CurrencyType);
1653enum_strum_serde!(InstrumentClass);
1654enum_strum_serde!(InstrumentCloseType);
1655enum_strum_serde!(LiquiditySide);
1656enum_strum_serde!(MarketStatus);
1657enum_strum_serde!(MarketStatusAction);
1658enum_strum_serde!(OmsType);
1659enum_strum_serde!(OptionKind);
1660enum_strum_serde!(OrderSide);
1661enum_strum_serde!(OrderSideSpecified);
1662enum_strum_serde!(OrderStatus);
1663enum_strum_serde!(OrderType);
1664enum_strum_serde!(PositionAdjustmentType);
1665enum_strum_serde!(PositionSide);
1666enum_strum_serde!(PositionSideSpecified);
1667enum_strum_serde!(PriceType);
1668enum_strum_serde!(RecordFlag);
1669enum_strum_serde!(TimeInForce);
1670enum_strum_serde!(TradingState);
1671enum_strum_serde!(TrailingOffsetType);
1672enum_strum_serde!(TriggerType);