Skip to main content

fixer_fix/fix40/
quote_request.rs

1// Code generated by fixer-gen. DO NOT EDIT.
2#![allow(clippy::new_without_default)]
3#![allow(clippy::needless_pass_by_value)]
4#![allow(clippy::too_many_arguments)]
5#![allow(unused_imports)]
6
7use fixer::message::Message;
8use fixer::fix_string::FIXString;
9use fixer::errors::MessageRejectErrorEnum;
10use fixer::session::session_id::SessionID;
11
12use rust_decimal::Decimal;
13
14
15use crate::field;
16use crate::tag;
17
18/// `QuoteRequest` is the `fix40` `QuoteRequest` type, `MsgType` = R.
19pub struct QuoteRequest {
20    pub message: Message,
21}
22
23impl QuoteRequest {
24    /// Creates a new `QuoteRequest` with required fields.
25    pub fn new(quote_req_id: field::QuoteReqIDField, symbol: field::SymbolField) -> Self {
26        let mut msg = Message::new();
27        msg.header.set_field(tag::MSG_TYPE, FIXString::from("R".to_string()));
28
29        msg.body.set_field(tag::QUOTE_REQ_ID, quote_req_id.0);
30
31        msg.body.set_field(tag::SYMBOL, symbol.0);
32
33        Self { message: msg }
34    }
35
36    /// Creates a `QuoteRequest` from an existing `Message`.
37    pub fn from_message(msg: Message) -> Self {
38        Self { message: msg }
39    }
40
41    /// Returns the underlying `Message`.
42    pub fn to_message(self) -> Message {
43        self.message
44    }
45
46
47
48
49    /// Sets `IDSource`, Tag 22.
50    pub fn set_id_source(&mut self, v: String) {
51        self.message.body.set_field(tag::ID_SOURCE, FIXString::from(v));
52    }
53
54    /// Gets `IDSource`, Tag 22.
55    pub fn get_id_source(&self) -> Result<String, MessageRejectErrorEnum> {
56        let mut fld = field::IDSourceField::new(String::new());
57        self.message.body.get_field(tag::ID_SOURCE, &mut fld.0)?;
58        Ok(fld.value().to_string())
59    }
60
61
62    /// Returns true if `IDSource` is present, Tag 22.
63    pub fn has_id_source(&self) -> bool {
64        self.message.body.has(tag::ID_SOURCE)
65    }
66
67
68
69
70    /// Sets `Issuer`, Tag 106.
71    pub fn set_issuer(&mut self, v: String) {
72        self.message.body.set_field(tag::ISSUER, FIXString::from(v));
73    }
74
75    /// Gets `Issuer`, Tag 106.
76    pub fn get_issuer(&self) -> Result<String, MessageRejectErrorEnum> {
77        let mut fld = field::IssuerField::new(String::new());
78        self.message.body.get_field(tag::ISSUER, &mut fld.0)?;
79        Ok(fld.value().to_string())
80    }
81
82
83    /// Returns true if `Issuer` is present, Tag 106.
84    pub fn has_issuer(&self) -> bool {
85        self.message.body.has(tag::ISSUER)
86    }
87
88
89
90
91    /// Sets `OrderQty`, Tag 38.
92    pub fn set_order_qty(&mut self, val: Decimal, scale: i32) {
93        self.message.body.set_field(tag::ORDER_QTY, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
94    }
95
96    /// Gets `OrderQty`, Tag 38.
97    pub fn get_order_qty(&self) -> Result<Decimal, MessageRejectErrorEnum> {
98        let mut fld = field::OrderQtyField::new(Decimal::ZERO, 0);
99        self.message.body.get_field(tag::ORDER_QTY, &mut fld.0)?;
100        Ok(fld.value())
101    }
102
103
104    /// Returns true if `OrderQty` is present, Tag 38.
105    pub fn has_order_qty(&self) -> bool {
106        self.message.body.has(tag::ORDER_QTY)
107    }
108
109
110
111
112    /// Sets `PrevClosePx`, Tag 140.
113    pub fn set_prev_close_px(&mut self, val: Decimal, scale: i32) {
114        self.message.body.set_field(tag::PREV_CLOSE_PX, fixer::fix_decimal::FIXDecimal { decimal: val, scale });
115    }
116
117    /// Gets `PrevClosePx`, Tag 140.
118    pub fn get_prev_close_px(&self) -> Result<Decimal, MessageRejectErrorEnum> {
119        let mut fld = field::PrevClosePxField::new(Decimal::ZERO, 0);
120        self.message.body.get_field(tag::PREV_CLOSE_PX, &mut fld.0)?;
121        Ok(fld.value())
122    }
123
124
125    /// Returns true if `PrevClosePx` is present, Tag 140.
126    pub fn has_prev_close_px(&self) -> bool {
127        self.message.body.has(tag::PREV_CLOSE_PX)
128    }
129
130
131
132
133    /// Sets `QuoteReqID`, Tag 131.
134    pub fn set_quote_req_id(&mut self, v: String) {
135        self.message.body.set_field(tag::QUOTE_REQ_ID, FIXString::from(v));
136    }
137
138    /// Gets `QuoteReqID`, Tag 131.
139    pub fn get_quote_req_id(&self) -> Result<String, MessageRejectErrorEnum> {
140        let mut fld = field::QuoteReqIDField::new(String::new());
141        self.message.body.get_field(tag::QUOTE_REQ_ID, &mut fld.0)?;
142        Ok(fld.value().to_string())
143    }
144
145
146    /// Returns true if `QuoteReqID` is present, Tag 131.
147    pub fn has_quote_req_id(&self) -> bool {
148        self.message.body.has(tag::QUOTE_REQ_ID)
149    }
150
151
152
153
154    /// Sets `SecurityDesc`, Tag 107.
155    pub fn set_security_desc(&mut self, v: String) {
156        self.message.body.set_field(tag::SECURITY_DESC, FIXString::from(v));
157    }
158
159    /// Gets `SecurityDesc`, Tag 107.
160    pub fn get_security_desc(&self) -> Result<String, MessageRejectErrorEnum> {
161        let mut fld = field::SecurityDescField::new(String::new());
162        self.message.body.get_field(tag::SECURITY_DESC, &mut fld.0)?;
163        Ok(fld.value().to_string())
164    }
165
166
167    /// Returns true if `SecurityDesc` is present, Tag 107.
168    pub fn has_security_desc(&self) -> bool {
169        self.message.body.has(tag::SECURITY_DESC)
170    }
171
172
173
174
175    /// Sets `SecurityID`, Tag 48.
176    pub fn set_security_id(&mut self, v: String) {
177        self.message.body.set_field(tag::SECURITY_ID, FIXString::from(v));
178    }
179
180    /// Gets `SecurityID`, Tag 48.
181    pub fn get_security_id(&self) -> Result<String, MessageRejectErrorEnum> {
182        let mut fld = field::SecurityIDField::new(String::new());
183        self.message.body.get_field(tag::SECURITY_ID, &mut fld.0)?;
184        Ok(fld.value().to_string())
185    }
186
187
188    /// Returns true if `SecurityID` is present, Tag 48.
189    pub fn has_security_id(&self) -> bool {
190        self.message.body.has(tag::SECURITY_ID)
191    }
192
193
194
195
196    /// Sets `Side`, Tag 54.
197    pub fn set_side(&mut self, v: String) {
198        self.message.body.set_field(tag::SIDE, FIXString::from(v));
199    }
200
201    /// Gets `Side`, Tag 54.
202    pub fn get_side(&self) -> Result<String, MessageRejectErrorEnum> {
203        let mut fld = field::SideField::new(String::new());
204        self.message.body.get_field(tag::SIDE, &mut fld.0)?;
205        Ok(fld.value().to_string())
206    }
207
208
209    /// Returns true if `Side` is present, Tag 54.
210    pub fn has_side(&self) -> bool {
211        self.message.body.has(tag::SIDE)
212    }
213
214
215
216
217    /// Sets `Symbol`, Tag 55.
218    pub fn set_symbol(&mut self, v: String) {
219        self.message.body.set_field(tag::SYMBOL, FIXString::from(v));
220    }
221
222    /// Gets `Symbol`, Tag 55.
223    pub fn get_symbol(&self) -> Result<String, MessageRejectErrorEnum> {
224        let mut fld = field::SymbolField::new(String::new());
225        self.message.body.get_field(tag::SYMBOL, &mut fld.0)?;
226        Ok(fld.value().to_string())
227    }
228
229
230    /// Returns true if `Symbol` is present, Tag 55.
231    pub fn has_symbol(&self) -> bool {
232        self.message.body.has(tag::SYMBOL)
233    }
234
235
236
237
238    /// Sets `SymbolSfx`, Tag 65.
239    pub fn set_symbol_sfx(&mut self, v: String) {
240        self.message.body.set_field(tag::SYMBOL_SFX, FIXString::from(v));
241    }
242
243    /// Gets `SymbolSfx`, Tag 65.
244    pub fn get_symbol_sfx(&self) -> Result<String, MessageRejectErrorEnum> {
245        let mut fld = field::SymbolSfxField::new(String::new());
246        self.message.body.get_field(tag::SYMBOL_SFX, &mut fld.0)?;
247        Ok(fld.value().to_string())
248    }
249
250
251    /// Returns true if `SymbolSfx` is present, Tag 65.
252    pub fn has_symbol_sfx(&self) -> bool {
253        self.message.body.has(tag::SYMBOL_SFX)
254    }
255
256
257}
258
259/// `RouteOut` is the callback type for routing `QuoteRequest` messages.
260pub type RouteOut = fn(msg: QuoteRequest, session_id: SessionID) -> Result<(), MessageRejectErrorEnum>;
261
262/// Route type returned by the `route` function.
263pub type Route = (&'static str, &'static str, Box<dyn Fn(&Message, SessionID) -> Result<(), MessageRejectErrorEnum> + Send>);
264
265/// Returns the begin string, message type, and route function for `QuoteRequest`.
266pub fn route(router: RouteOut) -> Route {
267    let r = move |msg: &Message, session_id: SessionID| -> Result<(), MessageRejectErrorEnum> {
268        router(QuoteRequest::from_message(msg.clone()), session_id)
269    };
270    ("FIX.4.0", "R", Box::new(r))
271}