1use crate::constant::{Asset, Exchange, InstrumentType};
7
8#[derive(Debug, Clone, PartialEq)]
10#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
11pub struct ContractData {
12 pub gateway_name: String,
14 pub symbol: String,
16 pub exchange: Exchange,
18 pub name: String,
20 pub asset: Asset,
22 pub instrument_type: Option<InstrumentType>,
24 pub size: f64,
26 pub price_tick: f64,
28
29 pub product_id: Option<String>,
31
32 pub max_limit_order_volume: Option<f64>,
34 pub min_limit_order_volume: Option<f64>,
36 pub max_market_order_volume: Option<f64>,
38 pub min_market_order_volume: Option<f64>,
40
41 pub delivery_year: Option<i32>,
43 pub delivery_month: Option<i32>,
45
46 pub open_date: Option<String>,
49 pub pre_close: Option<f64>,
51 pub up_stop_price: Option<f64>,
53 pub down_stop_price: Option<f64>,
55 pub float_volume: Option<f64>,
57 pub total_volume: Option<f64>,
59 pub instrument_status: Option<i64>,
61 pub is_trading: Option<bool>,
63}
64
65impl Default for ContractData {
66 fn default() -> Self {
69 Self {
70 asset: Asset::EQUITY,
71 size: 1.0,
72 price_tick: 0.01,
73 ..Self::EMPTY
74 }
75 }
76}
77
78impl ContractData {
79 pub fn en_symbol(&self) -> String {
81 crate::symbol::vt_symbol(&self.symbol, self.exchange)
82 }
83}
84
85impl ContractData {
87 const EMPTY: Self = Self {
88 gateway_name: String::new(),
89 symbol: String::new(),
90 exchange: crate::constant::Exchange::LOCAL,
91 name: String::new(),
92 asset: Asset::EQUITY,
93 instrument_type: None,
94 size: 0.0,
95 price_tick: 0.0,
96 product_id: None,
97 max_limit_order_volume: None,
98 min_limit_order_volume: None,
99 max_market_order_volume: None,
100 min_market_order_volume: None,
101 delivery_year: None,
102 delivery_month: None,
103 open_date: None,
104 pre_close: None,
105 up_stop_price: None,
106 down_stop_price: None,
107 float_volume: None,
108 total_volume: None,
109 instrument_status: None,
110 is_trading: None,
111 };
112}