1#![allow(dead_code)]
2#![allow(non_camel_case_types)]
3#![allow(non_snake_case)]
4#![allow(non_upper_case_globals)]
5#![allow(clippy::unreadable_literal)]
6include!("generated/struct.rs.in");
7include!("generated/error.rs.in");
8
9pub const THOST_FTDC_BOOL_True: TThostFtdcBoolType = 1;
10pub const THOST_FTDC_BOOL_False: TThostFtdcBoolType = 0;
11
12pub const THOST_FTDC_COMB_FLAG_LENGTH: usize = 5;
13
14use std::fmt;
15
16use serde::{Deserialize, Serialize};
17
18use super::{gb18030_cstr_to_str, maybe_char, normalize_double, reduce_comb_flags};
19
20impl fmt::Debug for CThostFtdcRspAuthenticateField {
21 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
22 fmt.debug_struct("CThostFtdcRspAuthenticateField")
23 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
24 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
25 .field(
26 "UserProductInfo",
27 &gb18030_cstr_to_str(&self.UserProductInfo),
28 )
29 .field("AppID", &gb18030_cstr_to_str(&self.AppID))
30 .field("AppType", &maybe_char(self.AppType))
31 .finish()
32 }
33}
34
35impl fmt::Debug for CThostFtdcReqUserLoginField {
36 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
37 fmt.debug_struct("CThostFtdcReqUserLoginField")
38 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
39 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
40 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
41 .field("Password", &gb18030_cstr_to_str(&self.Password))
42 .field(
43 "UserProductInfo",
44 &gb18030_cstr_to_str(&self.UserProductInfo),
45 )
46 .field(
47 "InterfaceProductInfo",
48 &gb18030_cstr_to_str(&self.InterfaceProductInfo),
49 )
50 .field("ProtocolInfo", &gb18030_cstr_to_str(&self.ProtocolInfo))
51 .field("MacAddress", &gb18030_cstr_to_str(&self.MacAddress))
52 .field(
53 "OneTimePassword",
54 &gb18030_cstr_to_str(&self.OneTimePassword),
55 )
56 .field(
57 "ClientIPAddress",
58 &gb18030_cstr_to_str(&self.ClientIPAddress),
59 )
60 .finish()
61 }
62}
63
64impl fmt::Debug for CThostFtdcRspUserLoginField {
65 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
66 fmt.debug_struct("CThostFtdcRspUserLoginField")
67 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
68 .field("LoginTime", &gb18030_cstr_to_str(&self.LoginTime))
69 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
70 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
71 .field("SystemName", &gb18030_cstr_to_str(&self.SystemName))
72 .field("FrontID", &self.FrontID)
73 .field("SessionID", &self.SessionID)
74 .field("MaxOrderRef", &gb18030_cstr_to_str(&self.MaxOrderRef))
75 .field("SHFETime", &gb18030_cstr_to_str(&self.SHFETime))
76 .field("DCETime", &gb18030_cstr_to_str(&self.DCETime))
77 .field("CZCETime", &gb18030_cstr_to_str(&self.CZCETime))
78 .field("FFEXTime", &gb18030_cstr_to_str(&self.FFEXTime))
79 .field("INETime", &gb18030_cstr_to_str(&self.INETime))
80 .finish()
81 }
82}
83
84impl fmt::Debug for CThostFtdcUserLogoutField {
85 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
86 fmt.debug_struct("CThostFtdcUserLogoutField")
87 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
88 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
89 .finish()
90 }
91}
92
93impl fmt::Debug for CThostFtdcUserPasswordUpdateField {
94 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
95 fmt.debug_struct("CThostFtdcUserPasswordUpdateField")
96 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
97 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
98 .field("OldPassword", &gb18030_cstr_to_str(&self.OldPassword))
99 .field("NewPassword", &gb18030_cstr_to_str(&self.NewPassword))
100 .finish()
101 }
102}
103
104impl fmt::Debug for CThostFtdcSpecificInstrumentField {
105 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
106 fmt.debug_struct("CThostFtdcSpecificInstrumentField")
107 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
108 .finish()
109 }
110}
111
112impl fmt::Debug for CThostFtdcInstrumentField {
113 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
114 fmt.debug_struct("CThostFtdcInstrumentField")
115 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
116 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
117 .field("InstrumentName", &gb18030_cstr_to_str(&self.InstrumentName))
118 .field("ExchangeInstID", &gb18030_cstr_to_str(&self.ExchangeInstID))
119 .field("ProductID", &gb18030_cstr_to_str(&self.ProductID))
120 .field("ProductClass", &char::from(self.ProductClass))
121 .field("DeliveryYear", &self.DeliveryYear)
122 .field("DeliveryMonth", &self.DeliveryMonth)
123 .field("MaxMarketOrderVolume", &self.MaxMarketOrderVolume)
124 .field("MinMarketOrderVolume", &self.MinMarketOrderVolume)
125 .field("MaxLimitOrderVolume", &self.MaxLimitOrderVolume)
126 .field("MinLimitOrderVolume", &self.MinLimitOrderVolume)
127 .field("VolumeMultiple", &self.VolumeMultiple)
128 .field("PriceTick", &self.PriceTick)
129 .field("CreateDate", &gb18030_cstr_to_str(&self.CreateDate))
130 .field("OpenDate", &gb18030_cstr_to_str(&self.OpenDate))
131 .field("ExpireDate", &gb18030_cstr_to_str(&self.ExpireDate))
132 .field("StartDelivDate", &gb18030_cstr_to_str(&self.StartDelivDate))
133 .field("EndDelivDate", &gb18030_cstr_to_str(&self.EndDelivDate))
134 .field("InstLifePhase", &char::from(self.InstLifePhase))
135 .field("IsTrading", &self.IsTrading)
136 .field("PositionType", &char::from(self.PositionType))
137 .field("PositionDateType", &char::from(self.PositionDateType))
138 .field("LongMarginRatio", &normalize_double(self.LongMarginRatio))
139 .field("ShortMarginRatio", &normalize_double(self.ShortMarginRatio))
140 .field(
141 "MaxMarginSideAlgorithm",
142 &char::from(self.MaxMarginSideAlgorithm),
143 )
144 .field(
145 "UnderlyingInstrID",
146 &gb18030_cstr_to_str(&self.UnderlyingInstrID),
147 )
148 .field("StrikePrice", &normalize_double(self.StrikePrice))
149 .field("OptionsType", &maybe_char(self.OptionsType))
150 .field(
151 "UnderlyingMultiple",
152 &normalize_double(self.UnderlyingMultiple),
153 )
154 .field("CombinationType", &maybe_char(self.CombinationType))
155 .finish()
156 }
157}
158
159impl fmt::Debug for CThostFtdcInstrumentStatusField {
160 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
161 fmt.debug_struct("CThostFtdcInstrumentStatusField ")
162 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
163 .field("ExchangeInstID", &gb18030_cstr_to_str(&self.ExchangeInstID))
164 .field(
165 "SettlementGroupID",
166 &gb18030_cstr_to_str(&self.SettlementGroupID),
167 )
168 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
169 .field("InstrumentStatus", &char::from(self.InstrumentStatus))
170 .field("TradingSegmentSN", &self.TradingSegmentSN)
171 .field("EnterTime", &gb18030_cstr_to_str(&self.EnterTime))
172 .field("EnterReason", &char::from(self.EnterReason))
173 .finish()
174 }
175}
176
177impl fmt::Debug for CThostFtdcOrderField {
178 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
179 fmt.debug_struct("CThostFtdcOrderField")
180 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
181 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
182 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
183 .field("OrderRef", &gb18030_cstr_to_str(&self.OrderRef))
184 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
185 .field("OrderPriceType", &char::from(self.OrderPriceType))
186 .field("Direction", &char::from(self.Direction))
187 .field("CombOffsetFlag", &reduce_comb_flags(&self.CombOffsetFlag))
188 .field("CombHedgeFlag", &reduce_comb_flags(&self.CombHedgeFlag))
189 .field("LimitPrice", &self.LimitPrice)
190 .field("VolumeTotalOriginal", &self.VolumeTotalOriginal)
191 .field("TimeCondition", &char::from(self.TimeCondition))
192 .field("GTDDate", &gb18030_cstr_to_str(&self.GTDDate))
193 .field("VolumeCondition", &char::from(self.VolumeCondition))
194 .field("MinVolume", &self.MinVolume)
195 .field("ContingentCondition", &char::from(self.ContingentCondition))
196 .field("StopPrice", &self.StopPrice)
197 .field("ForceCloseReason", &char::from(self.ForceCloseReason))
198 .field("IsAutoSuspend", &self.IsAutoSuspend)
199 .field("BusinessUnit", &gb18030_cstr_to_str(&self.BusinessUnit))
200 .field("RequestID", &self.RequestID)
201 .field("OrderLocalID", &gb18030_cstr_to_str(&self.OrderLocalID))
202 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
203 .field("ParticipantID", &gb18030_cstr_to_str(&self.ParticipantID))
204 .field("ClientID", &gb18030_cstr_to_str(&self.ClientID))
205 .field("ExchangeInstID", &gb18030_cstr_to_str(&self.ExchangeInstID))
206 .field("TraderID", &gb18030_cstr_to_str(&self.TraderID))
207 .field("InstallID", &self.InstallID)
208 .field("OrderSubmitStatus", &char::from(self.OrderSubmitStatus))
209 .field("NotifySequence", &self.NotifySequence)
210 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
211 .field("SettlementID", &self.SettlementID)
212 .field("OrderSysID", &gb18030_cstr_to_str(&self.OrderSysID))
213 .field("OrderSource", &maybe_char(self.OrderSource))
214 .field("OrderStatus", &char::from(self.OrderStatus))
215 .field("OrderType", &maybe_char(self.OrderType))
216 .field("VolumeTraded", &self.VolumeTraded)
217 .field("VolumeTotal", &self.VolumeTotal)
218 .field("InsertDate", &gb18030_cstr_to_str(&self.InsertDate))
219 .field("InsertTime", &gb18030_cstr_to_str(&self.InsertTime))
220 .field("ActiveTime", &gb18030_cstr_to_str(&self.ActiveTime))
221 .field("SuspendTime", &gb18030_cstr_to_str(&self.SuspendTime))
222 .field("UpdateTime", &gb18030_cstr_to_str(&self.UpdateTime))
223 .field("CancelTime", &gb18030_cstr_to_str(&self.CancelTime))
224 .field("ActiveTraderID", &gb18030_cstr_to_str(&self.ActiveTraderID))
225 .field("ClearingPartID", &gb18030_cstr_to_str(&self.ClearingPartID))
226 .field("SequenceNo", &self.SequenceNo)
227 .field("FrontID", &self.FrontID)
228 .field("SessionID", &self.SessionID)
229 .field(
230 "UserProductInfo",
231 &gb18030_cstr_to_str(&self.UserProductInfo),
232 )
233 .field("StatusMsg", &gb18030_cstr_to_str(&self.StatusMsg))
234 .field("UserForceClose", &self.UserForceClose)
235 .field("ActiveUserID", &gb18030_cstr_to_str(&self.ActiveUserID))
236 .field("BrokerOrderSeq", &self.BrokerOrderSeq)
237 .field(
238 "RelativeOrderSysID",
239 &gb18030_cstr_to_str(&self.RelativeOrderSysID),
240 )
241 .field("ZCETotalTradedVolume", &self.ZCETotalTradedVolume)
242 .field("IsSwapOrder", &self.IsSwapOrder)
243 .finish()
244 }
245}
246
247impl fmt::Debug for CThostFtdcTradeField {
248 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
249 fmt.debug_struct("CThostFtdcTradeField")
250 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
251 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
252 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
253 .field("OrderRef", &gb18030_cstr_to_str(&self.OrderRef))
254 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
255 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
256 .field("TradeID", &gb18030_cstr_to_str(&self.TradeID))
257 .field("Direction", &char::from(self.Direction))
258 .field("OrderSysID", &gb18030_cstr_to_str(&self.OrderSysID))
259 .field("ParticipantID", &gb18030_cstr_to_str(&self.ParticipantID))
260 .field("ClientID", &gb18030_cstr_to_str(&self.ClientID))
261 .field("TradingRole", &self.TradingRole)
262 .field("ExchangeInstID", &gb18030_cstr_to_str(&self.ExchangeInstID))
263 .field("OffsetFlag", &char::from(self.OffsetFlag))
264 .field("HedgeFlag", &char::from(self.HedgeFlag))
265 .field("Price", &self.Price)
266 .field("Volume", &self.Volume)
267 .field("TradeDate", &gb18030_cstr_to_str(&self.TradeDate))
268 .field("TradeTime", &gb18030_cstr_to_str(&self.TradeTime))
269 .field("TradeType", &maybe_char(self.TradeType))
270 .field("PriceSource", &maybe_char(self.PriceSource))
271 .field("TraderID", &gb18030_cstr_to_str(&self.TraderID))
272 .field("OrderLocalID", &gb18030_cstr_to_str(&self.OrderLocalID))
273 .field("ClearingPartID", &gb18030_cstr_to_str(&self.ClearingPartID))
274 .field("BusinessUnit", &gb18030_cstr_to_str(&self.BusinessUnit))
275 .field("SequenceNo", &self.SequenceNo)
276 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
277 .field("SettlementID", &self.SettlementID)
278 .field("BrokerOrderSeq", &self.BrokerOrderSeq)
279 .field("TradeSource", &char::from(self.TradeSource))
280 .finish()
281 }
282}
283
284impl fmt::Debug for CThostFtdcSettlementInfoField {
285 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
286 fmt.debug_struct("CThostFtdcSettlementInfoField")
287 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
288 .field("SettlementID", &self.SettlementID)
289 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
290 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
291 .field("SequenceNo", &self.SequenceNo)
292 .field("Content", &gb18030_cstr_to_str(&self.Content))
293 .finish()
294 }
295}
296
297impl fmt::Debug for CThostFtdcExchangeMarginRateField {
298 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
299 fmt.debug_struct("CThostFtdcExchangeMarginRateField")
300 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
301 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
302 .field("HedgeFlag", &char::from(self.HedgeFlag))
303 .field(
304 "LongMarginRatioByMoney",
305 &normalize_double(self.LongMarginRatioByMoney),
306 )
307 .field(
308 "LongMarginRatioByVolume",
309 &normalize_double(self.LongMarginRatioByVolume),
310 )
311 .field(
312 "ShortMarginRatioByMoney",
313 &normalize_double(self.ShortMarginRatioByMoney),
314 )
315 .field(
316 "ShortMarginRatioByVolume",
317 &normalize_double(self.ShortMarginRatioByVolume),
318 )
319 .finish()
320 }
321}
322
323impl fmt::Debug for CThostFtdcExchangeMarginRateAdjustField {
324 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
325 fmt.debug_struct("CThostFtdcExchangeMarginRateAdjustField")
326 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
327 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
328 .field("HedgeFlag", &char::from(self.HedgeFlag))
329 .field(
330 "LongMarginRatioByMoney",
331 &normalize_double(self.LongMarginRatioByMoney),
332 )
333 .field(
334 "LongMarginRatioByVolume",
335 &normalize_double(self.LongMarginRatioByVolume),
336 )
337 .field(
338 "ShortMarginRatioByMoney",
339 &normalize_double(self.ShortMarginRatioByMoney),
340 )
341 .field(
342 "ShortMarginRatioByVolume",
343 &normalize_double(self.ShortMarginRatioByVolume),
344 )
345 .field(
346 "ExchLongMarginRatioByMoney",
347 &normalize_double(self.ExchLongMarginRatioByMoney),
348 )
349 .field(
350 "ExchLongMarginRatioByVolume",
351 &normalize_double(self.ExchLongMarginRatioByVolume),
352 )
353 .field(
354 "ExchShortMarginRatioByMoney",
355 &normalize_double(self.ExchShortMarginRatioByMoney),
356 )
357 .field(
358 "ExchShortMarginRatioByVolume",
359 &normalize_double(self.ExchShortMarginRatioByVolume),
360 )
361 .field(
362 "NoLongMarginRatioByMoney",
363 &normalize_double(self.NoLongMarginRatioByMoney),
364 )
365 .field(
366 "NoLongMarginRatioByVolume",
367 &normalize_double(self.NoLongMarginRatioByVolume),
368 )
369 .field(
370 "NoShortMarginRatioByMoney",
371 &normalize_double(self.NoShortMarginRatioByMoney),
372 )
373 .field(
374 "NoShortMarginRatioByVolume",
375 &normalize_double(self.NoShortMarginRatioByVolume),
376 )
377 .finish()
378 }
379}
380
381impl fmt::Debug for CThostFtdcExchangeRateField {
382 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
383 fmt.debug_struct("CThostFtdcExchangeRateField")
384 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
385 .field("FromCurrencyID", &gb18030_cstr_to_str(&self.FromCurrencyID))
386 .field("FromCurrencyUnit", &self.FromCurrencyUnit)
387 .field("ToCurrencyID", &gb18030_cstr_to_str(&self.ToCurrencyID))
388 .field("ExchangeRate", &self.ExchangeRate)
389 .finish()
390 }
391}
392
393impl fmt::Debug for CThostFtdcSettlementInfoConfirmField {
394 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
395 fmt.debug_struct("CThostFtdcSettlementInfoConfirmField")
396 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
397 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
398 .field("ConfirmDate", &gb18030_cstr_to_str(&self.ConfirmDate))
399 .field("ConfirmTime", &gb18030_cstr_to_str(&self.ConfirmTime))
400 .finish()
401 }
402}
403
404impl fmt::Debug for CThostFtdcInputOrderField {
405 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
406 fmt.debug_struct("CThostFtdcInputOrderField")
407 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
408 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
409 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
410 .field("OrderRef", &gb18030_cstr_to_str(&self.OrderRef))
411 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
412 .field("OrderPriceType", &char::from(self.OrderPriceType))
413 .field("Direction", &char::from(self.Direction))
414 .field("CombOffsetFlag", &reduce_comb_flags(&self.CombOffsetFlag))
415 .field("CombHedgeFlag", &reduce_comb_flags(&self.CombHedgeFlag))
416 .field("LimitPrice", &self.LimitPrice)
417 .field("VolumeTotalOriginal", &self.VolumeTotalOriginal)
418 .field("TimeCondition", &char::from(self.TimeCondition))
419 .field("GTDDate", &gb18030_cstr_to_str(&self.GTDDate))
420 .field("VolumeCondition", &char::from(self.VolumeCondition))
421 .field("MinVolume", &self.MinVolume)
422 .field("ContingentCondition", &char::from(self.ContingentCondition))
423 .field("StopPrice", &self.StopPrice)
424 .field("ForceCloseReason", &char::from(self.ForceCloseReason))
425 .field("IsAutoSuspend", &self.IsAutoSuspend)
426 .field("BusinessUnit", &gb18030_cstr_to_str(&self.BusinessUnit))
427 .field("RequestID", &self.RequestID)
428 .field("UserForceClose", &self.UserForceClose)
429 .field("IsSwapOrder", &self.IsSwapOrder)
430 .finish()
431 }
432}
433
434impl fmt::Debug for CThostFtdcOrderActionField {
435 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
436 fmt.debug_struct("CThostFtdcOrderActionField")
437 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
438 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
439 .field("OrderActionRef", &self.OrderActionRef)
440 .field("OrderRef", &gb18030_cstr_to_str(&self.OrderRef))
441 .field("RequestID", &self.RequestID)
442 .field("FrontID", &self.FrontID)
443 .field("SessionID", &self.SessionID)
444 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
445 .field("OrderSysID", &gb18030_cstr_to_str(&self.OrderSysID))
446 .field("ActionFlag", &char::from(self.ActionFlag))
447 .field("LimitPrice", &self.LimitPrice)
448 .field("VolumeChange", &self.VolumeChange)
449 .field("ActionDate", &gb18030_cstr_to_str(&self.ActionDate))
450 .field("ActionTime", &gb18030_cstr_to_str(&self.ActionTime))
451 .field("TraderID", &gb18030_cstr_to_str(&self.TraderID))
452 .field("InstallID", &self.InstallID)
453 .field("OrderLocalID", &gb18030_cstr_to_str(&self.OrderLocalID))
454 .field("ActionLocalID", &gb18030_cstr_to_str(&self.ActionLocalID))
455 .field("ParticipantID", &gb18030_cstr_to_str(&self.ParticipantID))
456 .field("ClientID", &gb18030_cstr_to_str(&self.ClientID))
457 .field("BusinessUnit", &gb18030_cstr_to_str(&self.BusinessUnit))
458 .field("OrderActionStatus", &self.OrderActionStatus)
459 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
460 .field("StatusMsg", &gb18030_cstr_to_str(&self.StatusMsg))
461 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
462 .finish()
463 }
464}
465
466impl fmt::Debug for CThostFtdcInputOrderActionField {
467 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
468 fmt.debug_struct("CThostFtdcInputOrderActionField")
469 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
470 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
471 .field("OrderActionRef", &self.OrderActionRef)
472 .field("OrderRef", &gb18030_cstr_to_str(&self.OrderRef))
473 .field("RequestID", &self.RequestID)
474 .field("FrontID", &self.FrontID)
475 .field("SessionID", &self.SessionID)
476 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
477 .field("OrderSysID", &gb18030_cstr_to_str(&self.OrderSysID))
478 .field("ActionFlag", &char::from(self.ActionFlag))
479 .field("LimitPrice", &self.LimitPrice)
480 .field("VolumeChange", &self.VolumeChange)
481 .field("UserID", &gb18030_cstr_to_str(&self.UserID))
482 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
483 .finish()
484 }
485}
486
487impl fmt::Debug for CThostFtdcTradingNoticeInfoField {
488 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
489 fmt.debug_struct("CThostFtdcTradingNoticeInfoField")
490 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
491 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
492 .field("SendTime", &gb18030_cstr_to_str(&self.SendTime))
493 .field("FieldContent", &gb18030_cstr_to_str(&self.FieldContent))
494 .field("SequenceSeries", &self.SequenceSeries)
495 .field("SequenceNo", &self.SequenceNo)
496 .finish()
497 }
498}
499
500impl fmt::Debug for CThostFtdcInvestorField {
501 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
502 fmt.debug_struct("CThostFtdcInvestorField")
503 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
504 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
505 .field(
506 "InvestorGroupID",
507 &gb18030_cstr_to_str(&self.InvestorGroupID),
508 )
509 .field("InvestorName", &gb18030_cstr_to_str(&self.InvestorName))
510 .field("IdentifiedCardType", &char::from(self.IdentifiedCardType))
511 .field(
512 "IdentifiedCardNo",
513 &gb18030_cstr_to_str(&self.IdentifiedCardNo),
514 )
515 .field("IsActive", &self.IsActive)
516 .field("Telephone", &gb18030_cstr_to_str(&self.Telephone))
517 .field("Address", &gb18030_cstr_to_str(&self.Address))
518 .field("OpenDate", &gb18030_cstr_to_str(&self.OpenDate))
519 .field("Mobile", &gb18030_cstr_to_str(&self.Mobile))
520 .field("CommModelID", &gb18030_cstr_to_str(&self.CommModelID))
521 .field("MarginModelID", &gb18030_cstr_to_str(&self.MarginModelID))
522 .finish()
523 }
524}
525
526impl fmt::Debug for CThostFtdcTradingCodeField {
527 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
528 fmt.debug_struct("CThostFtdcTradingCodeField")
529 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
530 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
531 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
532 .field("ClientID", &gb18030_cstr_to_str(&self.ClientID))
533 .field("IsActive", &self.IsActive)
534 .field("ClientIDType", &char::from(self.ClientIDType))
535 .finish()
536 }
537}
538
539impl fmt::Debug for CThostFtdcTradingAccountField {
540 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
541 fmt.debug_struct("CThostFtdcTradingAccountField")
542 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
543 .field("AccountID", &gb18030_cstr_to_str(&self.AccountID))
544 .field("PreMortgage", &self.PreMortgage)
545 .field("PreCredit", &self.PreCredit)
546 .field("PreDeposit", &self.PreDeposit)
547 .field("PreBalance", &self.PreBalance)
548 .field("PreMargin", &self.PreMargin)
549 .field("InterestBase", &self.InterestBase)
550 .field("Interest", &self.Interest)
551 .field("Deposit", &self.Deposit)
552 .field("Withdraw", &self.Withdraw)
553 .field("FrozenMargin", &self.FrozenMargin)
554 .field("FrozenCash", &self.FrozenCash)
555 .field("FrozenCommission", &self.FrozenCommission)
556 .field("CurrMargin", &self.CurrMargin)
557 .field("CashIn", &self.CashIn)
558 .field("Commission", &self.Commission)
559 .field("CloseProfit", &self.CloseProfit)
560 .field("PositionProfit", &self.PositionProfit)
561 .field("Balance", &self.Balance)
562 .field("Available", &self.Available)
563 .field("WithdrawQuota", &self.WithdrawQuota)
564 .field("Reserve", &self.Reserve)
565 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
566 .field("SettlementID", &self.SettlementID)
567 .field("Credit", &self.Credit)
568 .field("Mortgage", &self.Mortgage)
569 .field("ExchangeMargin", &self.ExchangeMargin)
570 .field("DeliveryMargin", &self.DeliveryMargin)
571 .field("ExchangeDeliveryMargin", &self.ExchangeDeliveryMargin)
572 .field("ReserveBalance", &self.ReserveBalance)
573 .field("CurrencyID", &gb18030_cstr_to_str(&self.CurrencyID))
574 .field("PreFundMortgageIn", &self.PreFundMortgageIn)
575 .field("PreFundMortgageOut", &self.PreFundMortgageOut)
576 .field("FundMortgageIn", &self.FundMortgageIn)
577 .field("FundMortgageOut", &self.FundMortgageOut)
578 .field("FundMortgageAvailable", &self.FundMortgageAvailable)
579 .field("MortgageableFund", &self.MortgageableFund)
580 .field("SpecProductMargin", &self.SpecProductMargin)
581 .field("SpecProductFrozenMargin", &self.SpecProductFrozenMargin)
582 .field("SpecProductCommission", &self.SpecProductCommission)
583 .field(
584 "SpecProductFrozenCommission",
585 &self.SpecProductFrozenCommission,
586 )
587 .field("SpecProductPositionProfit", &self.SpecProductPositionProfit)
588 .field("SpecProductCloseProfit", &self.SpecProductCloseProfit)
589 .field(
590 "SpecProductPositionProfitByAlg",
591 &self.SpecProductPositionProfitByAlg,
592 )
593 .field("SpecProductExchangeMargin", &self.SpecProductExchangeMargin)
594 .finish()
595 }
596}
597
598impl fmt::Debug for CThostFtdcInvestorPositionField {
599 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
600 fmt.debug_struct("CThostFtdcInvestorPositionField")
601 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
602 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
603 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
604 .field("PosiDirection", &char::from(self.PosiDirection))
605 .field("HedgeFlag", &char::from(self.HedgeFlag))
606 .field("PositionDate", &char::from(self.PositionDate))
607 .field("YdPosition", &self.YdPosition)
608 .field("Position", &self.Position)
609 .field("LongFrozen", &self.LongFrozen)
610 .field("ShortFrozen", &self.ShortFrozen)
611 .field("LongFrozenAmount", &self.LongFrozenAmount)
612 .field("ShortFrozenAmount", &self.ShortFrozenAmount)
613 .field("OpenVolume", &self.OpenVolume)
614 .field("CloseVolume", &self.CloseVolume)
615 .field("OpenAmount", &self.OpenAmount)
616 .field("CloseAmount", &self.CloseAmount)
617 .field("PositionCost", &self.PositionCost)
618 .field("PreMargin", &self.PreMargin)
619 .field("UseMargin", &self.UseMargin)
620 .field("FrozenMargin", &self.FrozenMargin)
621 .field("FrozenCash", &self.FrozenCash)
622 .field("FrozenCommission", &self.FrozenCommission)
623 .field("CashIn", &self.CashIn)
624 .field("Commission", &self.Commission)
625 .field("CloseProfit", &self.CloseProfit)
626 .field("PositionProfit", &self.PositionProfit)
627 .field("PreSettlementPrice", &self.PreSettlementPrice)
628 .field("SettlementPrice", &self.SettlementPrice)
629 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
630 .field("SettlementID", &self.SettlementID)
631 .field("OpenCost", &self.OpenCost)
632 .field("ExchangeMargin", &self.ExchangeMargin)
633 .field("CombPosition", &self.CombPosition)
634 .field("CombLongFrozen", &self.CombLongFrozen)
635 .field("CombShortFrozen", &self.CombShortFrozen)
636 .field("CloseProfitByDate", &self.CloseProfitByDate)
637 .field("CloseProfitByTrade", &self.CloseProfitByTrade)
638 .field("TodayPosition", &self.TodayPosition)
639 .field("MarginRateByMoney", &self.MarginRateByMoney)
640 .field("MarginRateByVolume", &self.MarginRateByVolume)
641 .field("StrikeFrozen", &self.StrikeFrozen)
642 .field("StrikeFrozenAmount", &self.StrikeFrozenAmount)
643 .field("AbandonFrozen", &self.AbandonFrozen)
644 .finish()
645 }
646}
647
648impl fmt::Debug for CThostFtdcInstrumentMarginRateField {
649 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
650 fmt.debug_struct("CThostFtdcInstrumentMarginRateField")
651 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
652 .field("InvestorRange", &self.InvestorRange)
653 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
654 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
655 .field("HedgeFlag", &char::from(self.HedgeFlag))
656 .field(
657 "LongMarginRatioByMoney",
658 &normalize_double(self.LongMarginRatioByMoney),
659 )
660 .field(
661 "LongMarginRatioByVolume",
662 &normalize_double(self.LongMarginRatioByVolume),
663 )
664 .field(
665 "ShortMarginRatioByMoney",
666 &normalize_double(self.ShortMarginRatioByMoney),
667 )
668 .field(
669 "ShortMarginRatioByVolume",
670 &normalize_double(self.ShortMarginRatioByVolume),
671 )
672 .field("IsRelative", &self.IsRelative)
673 .finish()
674 }
675}
676
677impl fmt::Debug for CThostFtdcInstrumentCommissionRateField {
678 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
679 fmt.debug_struct("CThostFtdcInstrumentCommissionRateField")
680 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
681 .field("InvestorRange", &self.InvestorRange)
682 .field("BrokerID", &gb18030_cstr_to_str(&self.BrokerID))
683 .field("InvestorID", &gb18030_cstr_to_str(&self.InvestorID))
684 .field("OpenRatioByMoney", &self.OpenRatioByMoney)
685 .field("OpenRatioByVolume", &self.OpenRatioByVolume)
686 .field("CloseRatioByMoney", &self.CloseRatioByMoney)
687 .field("CloseRatioByVolume", &self.CloseRatioByVolume)
688 .field("CloseTodayRatioByMoney", &self.CloseTodayRatioByMoney)
689 .field("CloseTodayRatioByVolume", &self.CloseTodayRatioByVolume)
690 .finish()
691 }
692}
693
694impl fmt::Debug for CThostFtdcDepthMarketDataField {
695 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
696 let mut debug = fmt.debug_struct("CThostFtdcDepthMarketDataField");
697 debug
698 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
699 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
700 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
701 .field("ExchangeInstID", &gb18030_cstr_to_str(&self.ExchangeInstID))
702 .field("LastPrice", &normalize_double(self.LastPrice))
703 .field(
704 "PreSettlementPrice",
705 &normalize_double(self.PreSettlementPrice),
706 )
707 .field("PreClosePrice", &normalize_double(self.PreClosePrice))
708 .field("PreOpenInterest", &self.PreOpenInterest)
709 .field("OpenPrice", &normalize_double(self.OpenPrice))
710 .field("HighestPrice", &normalize_double(self.HighestPrice))
711 .field("LowestPrice", &normalize_double(self.LowestPrice))
712 .field("Volume", &self.Volume)
713 .field("Turnover", &self.Turnover)
714 .field("OpenInterest", &self.OpenInterest)
715 .field("ClosePrice", &normalize_double(self.ClosePrice))
716 .field("SettlementPrice", &normalize_double(self.SettlementPrice))
717 .field("UpperLimitPrice", &normalize_double(self.UpperLimitPrice))
718 .field("LowerLimitPrice", &normalize_double(self.LowerLimitPrice))
719 .field("PreDelta", &normalize_double(self.PreDelta))
720 .field("CurrDelta", &normalize_double(self.CurrDelta))
721 .field("UpdateTime", &gb18030_cstr_to_str(&self.UpdateTime))
722 .field("UpdateMillisec", &self.UpdateMillisec)
723 .field("BidPrice1", &normalize_double(self.BidPrice1))
724 .field("BidVolume1", &self.BidVolume1)
725 .field("AskPrice1", &normalize_double(self.AskPrice1))
726 .field("AskVolume1", &self.AskVolume1);
727 if !(self.BidVolume2 == 0
728 && self.AskVolume2 == 0
729 && self.BidVolume3 == 0
730 && self.AskVolume3 == 0
731 && self.BidVolume4 == 0
732 && self.AskVolume4 == 0
733 && self.BidVolume5 == 0
734 && self.AskVolume5 == 0)
735 {
736 debug
737 .field("BidPrice2", &normalize_double(self.BidPrice2))
738 .field("BidVolume2", &self.BidVolume2)
739 .field("AskPrice2", &normalize_double(self.AskPrice2))
740 .field("AskVolume2", &self.AskVolume2)
741 .field("BidPrice3", &normalize_double(self.BidPrice3))
742 .field("BidVolume3", &self.BidVolume3)
743 .field("AskPrice3", &normalize_double(self.AskPrice3))
744 .field("AskVolume3", &self.AskVolume3)
745 .field("BidPrice4", &normalize_double(self.BidPrice4))
746 .field("BidVolume4", &self.BidVolume4)
747 .field("AskPrice4", &normalize_double(self.AskPrice4))
748 .field("AskVolume4", &self.AskVolume4)
749 .field("BidPrice5", &normalize_double(self.BidPrice5))
750 .field("BidVolume5", &self.BidVolume5)
751 .field("AskPrice5", &normalize_double(self.AskPrice5))
752 .field("AskVolume5", &self.AskVolume5);
753 }
754 debug
755 .field("AveragePrice", &normalize_double(self.AveragePrice))
756 .field("ActionDay", &gb18030_cstr_to_str(&self.ActionDay))
757 .finish()
758 }
759}
760
761#[derive(Debug, Clone, Serialize, Deserialize)]
762pub struct DepthMarketData {
763 pub TradingDay: String,
764 pub InstrumentID: String,
765 pub ExchangeID: String,
766 pub ExchangeInstID: String,
767 pub LastPrice: f64,
768 pub PreSettlementPrice: f64,
769 pub PreClosePrice: f64,
770 pub PreOpenInterest: f64,
771 pub OpenPrice: f64,
772 pub HighestPrice: f64,
773 pub LowestPrice: f64,
774 pub Volume: i32,
775 pub Turnover: f64,
776 pub OpenInterest: f64,
777 pub UpperLimitPrice: f64,
778 pub LowerLimitPrice: f64,
779 pub UpdateTime: String,
780 pub UpdateMillisec: i32,
781 pub BidPrice1: f64,
782 pub BidVolume1: i32,
783 pub AskPrice1: f64,
784 pub AskVolume1: i32,
785}
786
787impl CThostFtdcDepthMarketDataField {
788 pub fn to_struct(self) -> DepthMarketData {
789 DepthMarketData {
790 TradingDay: gb18030_cstr_to_str(&self.TradingDay).to_string(),
791 InstrumentID: gb18030_cstr_to_str(&self.InstrumentID).to_string(),
792 ExchangeID: gb18030_cstr_to_str(&self.ExchangeID).to_string(),
793 ExchangeInstID: gb18030_cstr_to_str(&self.ExchangeInstID).to_string(),
794 LastPrice: normalize_double(self.LastPrice)
795 .or_else(|| Some(0.0))
796 .unwrap(),
797 PreSettlementPrice: normalize_double(self.PreSettlementPrice)
798 .or_else(|| Some(0.0))
799 .unwrap(),
800 PreClosePrice: normalize_double(self.PreClosePrice)
801 .or_else(|| Some(0.0))
802 .unwrap(),
803 PreOpenInterest: self.PreOpenInterest,
804 OpenPrice: normalize_double(self.OpenPrice)
805 .or_else(|| Some(0.0))
806 .unwrap(),
807 HighestPrice: normalize_double(self.HighestPrice)
808 .or_else(|| Some(0.0))
809 .unwrap(),
810 LowestPrice: normalize_double(self.LowestPrice)
811 .or_else(|| Some(0.0))
812 .unwrap(),
813 Volume: self.Volume,
814 Turnover: self.Turnover,
815 OpenInterest: self.OpenInterest,
816 UpperLimitPrice: normalize_double(self.UpperLimitPrice)
817 .or_else(|| Some(0.0))
818 .unwrap(),
819 LowerLimitPrice: normalize_double(self.LowerLimitPrice)
820 .or_else(|| Some(0.0))
821 .unwrap(),
822 UpdateTime: gb18030_cstr_to_str(&self.UpdateTime).to_string(),
823 UpdateMillisec: self.UpdateMillisec,
824 BidPrice1: normalize_double(self.BidPrice1)
825 .or_else(|| Some(0.0))
826 .unwrap(),
827 BidVolume1: self.BidVolume1,
828 AskPrice1: normalize_double(self.AskPrice1)
829 .or_else(|| Some(0.0))
830 .unwrap(),
831 AskVolume1: self.AskVolume1,
832 }
833 }
834}
835
836impl fmt::Debug for CThostFtdcExchangeField {
837 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
838 fmt.debug_struct("CThostFtdcExchangeField")
839 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
840 .field("ExchangeName", &gb18030_cstr_to_str(&self.ExchangeName))
841 .field("ExchangeProperty", &char::from(self.ExchangeProperty))
842 .finish()
843 }
844}
845
846impl fmt::Debug for CThostFtdcProductField {
847 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
848 fmt.debug_struct("CThostFtdcProductField")
849 .field("ProductID", &gb18030_cstr_to_str(&self.ProductID))
850 .field("ProductName", &gb18030_cstr_to_str(&self.ProductName))
851 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
852 .field("ProductClass", &char::from(self.ProductClass))
853 .field("VolumeMultiple", &self.VolumeMultiple)
854 .field("PriceTick", &self.PriceTick)
855 .field("MaxMarketOrderVolume", &self.MaxMarketOrderVolume)
856 .field("MinMarketOrderVolume", &self.MinMarketOrderVolume)
857 .field("MaxLimitOrderVolume", &self.MaxLimitOrderVolume)
858 .field("MinLimitOrderVolume", &self.MinLimitOrderVolume)
859 .field("PositionType", &char::from(self.PositionType))
860 .field("PositionDateType", &char::from(self.PositionDateType))
861 .field("CloseDealType", &char::from(self.CloseDealType))
862 .field(
863 "TradeCurrencyID",
864 &gb18030_cstr_to_str(&self.TradeCurrencyID),
865 )
866 .field(
867 "MortgageFundUseRange",
868 &char::from(self.MortgageFundUseRange),
869 )
870 .field(
871 "ExchangeProductID",
872 &gb18030_cstr_to_str(&self.ExchangeProductID),
873 )
874 .field(
875 "UnderlyingMultiple",
876 &normalize_double(self.UnderlyingMultiple),
877 )
878 .finish()
879 }
880}
881
882impl fmt::Debug for CThostFtdcForQuoteRspField {
883 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
884 fmt.debug_struct("CThostFtdcForQuoteRspField")
885 .field("TradingDay", &gb18030_cstr_to_str(&self.TradingDay))
886 .field("InstrumentID", &gb18030_cstr_to_str(&self.InstrumentID))
887 .field("ForQuoteSysID", &gb18030_cstr_to_str(&self.ForQuoteSysID))
888 .field("ForQuoteTime", &gb18030_cstr_to_str(&self.ForQuoteTime))
889 .field("ActionDay", &gb18030_cstr_to_str(&self.ActionDay))
890 .field("ExchangeID", &gb18030_cstr_to_str(&self.ExchangeID))
891 .finish()
892 }
893}