kiteconnect_async_wasm/models/common/enums/
trading.rs

1/*!
2Trading products and order-related enums.
3*/
4
5use serde::{Deserialize, Serialize};
6
7/// Product types for orders
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub enum Product {
10    #[serde(rename = "CNC")]
11    CNC, // Cash & Carry for equity
12    #[serde(rename = "NRML")]
13    NRML, // Normal for futures and options
14    #[serde(rename = "MIS")]
15    MIS, // Margin Intraday Squareoff for futures and options
16    #[serde(rename = "MTF")]
17    MTF, // Margin Trading Facility
18}
19
20impl std::fmt::Display for Product {
21    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        match self {
23            Product::CNC => write!(f, "CNC"),
24            Product::MIS => write!(f, "MIS"),
25            Product::NRML => write!(f, "NRML"),
26            Product::MTF => write!(f, "MTF"),
27        }
28    }
29}
30
31/// Order validity types
32#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
33pub enum Validity {
34    #[serde(rename = "DAY")]
35    DAY, // Day order
36    #[serde(rename = "IOC")]
37    IOC, // Immediate or Cancel
38    #[serde(rename = "TTL")]
39    TTL, // Time to Live (for GTT orders)
40}
41
42impl std::fmt::Display for Validity {
43    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
44        match self {
45            Validity::DAY => write!(f, "DAY"),
46            Validity::IOC => write!(f, "IOC"),
47            Validity::TTL => write!(f, "TTL"),
48        }
49    }
50}
51
52/// Transaction types
53#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
54pub enum TransactionType {
55    #[serde(rename = "BUY")]
56    BUY,
57    #[serde(rename = "SELL")]
58    SELL,
59}
60
61impl std::fmt::Display for TransactionType {
62    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
63        match self {
64            TransactionType::BUY => write!(f, "BUY"),
65            TransactionType::SELL => write!(f, "SELL"),
66        }
67    }
68}
69
70/// Order types
71#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
72pub enum OrderType {
73    #[serde(rename = "MARKET")]
74    MARKET,
75    #[serde(rename = "LIMIT")]
76    LIMIT,
77    #[serde(rename = "SL")]
78    SL, // Stop Loss
79    #[serde(rename = "SL-M")]
80    SLM, // Stop Loss Market
81}
82
83impl std::fmt::Display for OrderType {
84    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
85        match self {
86            OrderType::MARKET => write!(f, "MARKET"),
87            OrderType::LIMIT => write!(f, "LIMIT"),
88            OrderType::SL => write!(f, "SL"),
89            OrderType::SLM => write!(f, "SL-M"),
90        }
91    }
92}
93
94/// Order varieties
95#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
96pub enum Variety {
97    #[serde(rename = "regular")]
98    Regular,
99    #[serde(rename = "co")]
100    CO, // Cover Order
101    #[serde(rename = "amo")]
102    AMO, // After Market Order
103    #[serde(rename = "iceberg")]
104    Iceberg,
105    #[serde(rename = "auction")]
106    Auction,
107}
108
109impl std::fmt::Display for Variety {
110    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
111        match self {
112            Variety::Regular => write!(f, "regular"),
113            Variety::CO => write!(f, "co"),
114            Variety::AMO => write!(f, "amo"),
115            Variety::Iceberg => write!(f, "iceberg"),
116            Variety::Auction => write!(f, "auction"),
117        }
118    }
119}