1use crate::encoding::GbkConverter;
6use crate::error::CtpResult;
7
8pub type TraderIdType = [u8; 21];
10
11pub type InvestorIdType = [u8; 13];
13
14pub type BrokerIdType = [u8; 11];
16
17pub type BrokerAbbrType = [u8; 9];
19
20pub type BrokerNameType = [u8; 81];
22
23pub type InstrumentIdType = [u8; 31];
25
26pub type PasswordType = [u8; 41];
28
29pub type UserIdType = [u8; 16];
31
32pub type ProductInfoType = [u8; 11];
34
35pub type CurrencyIdType = [u8; 4];
37
38pub type BizTypeType = [u8; 1];
40
41pub type AccountIdType = [u8; 13];
43
44pub type ExchangeIdType = [u8; 9];
46
47pub type InvestUnitIdType = [u8; 17];
49
50pub type ProtocolInfoType = [u8; 11];
52
53pub type MacAddressType = [u8; 21];
55
56pub type AuthCodeType = [u8; 17];
58
59pub type AppIdType = [u8; 21];
61
62pub type IpAddressType = [u8; 16];
64
65pub type IpPortType = [u8; 6];
67
68pub type OrderSysIdType = [u8; 21];
72
73pub type TimeType = [u8; 9];
75
76pub type TradeIdType = [u8; 21];
78
79pub type ExchangeInstIdType = [u8; 31];
81
82pub type OrderActionRefType = [u8; 13];
84
85pub type ActionFlagType = u8;
87
88pub type IPAddressType = [u8; 16];
90
91pub type OrderRefType = [u8; 13];
93
94pub type RequestIdType = i32;
96
97pub type FrontIdType = i32;
99
100pub type SessionIdType = i32;
102
103pub type BusinessUnitType = [u8; 21];
105pub type ClientIdType = [u8; 11];
107pub type ParkedOrderIdType = [u8; 13];
109pub type TradingDayType = [u8; 9];
111pub type BankIdType = [u8; 4];
113pub type BankBrchIdType = [u8; 5];
115pub type BankNameType = [u8; 101];
117
118pub type PriceType = f64;
120
121pub type DateType = [u8; 9];
123
124pub type InstallIdType = i32;
126
127pub type OrderLocalIdType = [u8; 13];
129
130pub type ParticipantIdType = [u8; 11];
132
133pub type OrderActionStatusType = u8;
135
136pub type ErrorMsgType = [u8; 81];
138
139pub type BranchIdType = [u8; 9];
141
142pub type VolumeType = i32;
144
145#[repr(C)]
147#[derive(Debug, Clone, Copy, PartialEq, Eq)]
148pub enum ResumeType {
149 Restart = 0,
151 Resume = 1,
153 Quick = 2,
155 None = 3,
157}
158
159impl Default for ResumeType {
160 fn default() -> Self {
161 ResumeType::Restart
162 }
163}
164
165pub trait StringConvert {
169 fn to_utf8_string(&self) -> CtpResult<String>;
171
172 fn from_utf8_string(s: &str) -> CtpResult<Self>
174 where
175 Self: Sized;
176}
177
178macro_rules! impl_string_convert {
179 ($type:ty, $size:expr) => {
180 impl StringConvert for $type {
181 fn to_utf8_string(&self) -> CtpResult<String> {
182 GbkConverter::fixed_bytes_to_utf8(self)
183 }
184
185 fn from_utf8_string(s: &str) -> CtpResult<Self> {
186 GbkConverter::utf8_to_fixed_bytes::<$size>(s)
187 }
188 }
189 };
190}
191
192impl_string_convert!([u8; 21], 21); impl_string_convert!([u8; 13], 13); impl_string_convert!([u8; 11], 11); impl_string_convert!([u8; 9], 9); impl_string_convert!([u8; 81], 81); impl_string_convert!([u8; 31], 31); impl_string_convert!([u8; 41], 41); impl_string_convert!([u8; 17], 17); impl_string_convert!([u8; 16], 16); impl_string_convert!([u8; 6], 6); impl_string_convert!([u8; 4], 4); impl_string_convert!([u8; 1], 1); #[repr(C)]
208#[derive(Debug, Clone)]
209pub struct ReqUserLoginField {
210 pub trading_day: [u8; 9],
212 pub broker_id: BrokerIdType,
214 pub user_id: UserIdType,
216 pub password: PasswordType,
218 pub user_product_info: ProductInfoType,
220 pub interface_product_info: ProductInfoType,
222 pub protocol_info: ProtocolInfoType,
224 pub mac_address: MacAddressType,
226 pub one_time_password: PasswordType,
228 pub client_ip_address: IpAddressType,
230 pub client_ip_port: IpPortType,
232 pub login_remark: [u8; 36],
234}
235
236impl Default for ReqUserLoginField {
237 fn default() -> Self {
238 Self {
239 trading_day: [0; 9],
240 broker_id: [0; 11],
241 user_id: [0; 16],
242 password: [0; 41],
243 user_product_info: [0; 11],
244 interface_product_info: [0; 11],
245 protocol_info: [0; 11],
246 mac_address: [0; 21],
247 one_time_password: [0; 41],
248 client_ip_address: [0; 16],
249 client_ip_port: [0; 6],
250 login_remark: [0; 36],
251 }
252 }
253}
254
255impl ReqUserLoginField {
256 pub fn new(broker_id: &str, user_id: &str, password: &str) -> CtpResult<Self> {
258 let mut req = Self::default();
259
260 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
261 req.user_id = UserIdType::from_utf8_string(user_id)?;
262 req.password = PasswordType::from_utf8_string(password)?;
263
264 Ok(req)
265 }
266
267 pub fn with_product_info(mut self, product_info: &str) -> CtpResult<Self> {
269 self.user_product_info = ProductInfoType::from_utf8_string(product_info)?;
270 self.interface_product_info = ProductInfoType::from_utf8_string(product_info)?;
271 Ok(self)
272 }
273
274 pub fn with_auth_code(mut self, auth_code: &str) -> CtpResult<Self> {
276 self.one_time_password = PasswordType::from_utf8_string(auth_code)?;
277 Ok(self)
278 }
279
280 pub fn with_mac_address(mut self, mac_address: &str) -> CtpResult<Self> {
282 self.mac_address = MacAddressType::from_utf8_string(mac_address)?;
283 Ok(self)
284 }
285
286 pub fn with_client_ip(mut self, ip: &str, port: &str) -> CtpResult<Self> {
288 self.client_ip_address = IpAddressType::from_utf8_string(ip)?;
289 self.client_ip_port = IpPortType::from_utf8_string(port)?;
290 Ok(self)
291 }
292}
293
294#[repr(C)]
296#[derive(Debug, Clone)]
297pub struct RspUserLoginField {
298 pub trading_day: [u8; 9],
300 pub login_time: [u8; 9],
302 pub broker_id: BrokerIdType,
304 pub user_id: UserIdType,
306 pub system_name: [u8; 41],
308 pub front_id: i32,
310 pub session_id: i32,
312 pub max_order_ref: [u8; 13],
314 pub shfe_time: [u8; 9],
316 pub dce_time: [u8; 9],
318 pub czce_time: [u8; 9],
320 pub ffex_time: [u8; 9],
322 pub ine_time: [u8; 9],
324}
325
326impl Default for RspUserLoginField {
327 fn default() -> Self {
328 Self {
329 trading_day: [0; 9],
330 login_time: [0; 9],
331 broker_id: [0; 11],
332 user_id: [0; 16],
333 system_name: [0; 41],
334 front_id: 0,
335 session_id: 0,
336 max_order_ref: [0; 13],
337 shfe_time: [0; 9],
338 dce_time: [0; 9],
339 czce_time: [0; 9],
340 ffex_time: [0; 9],
341 ine_time: [0; 9],
342 }
343 }
344}
345
346#[repr(C)]
348#[derive(Debug, Clone)]
349pub struct RspInfoField {
350 pub error_id: i32,
352 pub error_msg: [u8; 81],
354}
355
356impl Default for RspInfoField {
357 fn default() -> Self {
358 Self {
359 error_id: 0,
360 error_msg: [0; 81],
361 }
362 }
363}
364
365impl RspInfoField {
366 pub fn get_error_msg(&self) -> CtpResult<String> {
368 GbkConverter::fixed_bytes_to_utf8(&self.error_msg)
369 }
370
371 pub fn is_success(&self) -> bool {
373 self.error_id == 0
374 }
375}
376
377#[cfg(test)]
378mod tests {
379 use super::*;
380
381 #[test]
382 fn test_string_convert() {
383 let test_str = "测试用户";
384 let user_id = UserIdType::from_utf8_string(test_str).unwrap();
385 let converted = user_id.to_utf8_string().unwrap();
386 assert_eq!(converted.trim_end_matches('\0'), test_str);
387 }
388
389 #[test]
390 fn test_login_request_creation() {
391 let req = ReqUserLoginField::new("9999", "investor1", "123456").unwrap();
392
393 assert_eq!(
394 req.broker_id
395 .to_utf8_string()
396 .unwrap()
397 .trim_end_matches('\0'),
398 "9999"
399 );
400 assert_eq!(
401 req.user_id.to_utf8_string().unwrap().trim_end_matches('\0'),
402 "investor1"
403 );
404 assert_eq!(
405 req.password
406 .to_utf8_string()
407 .unwrap()
408 .trim_end_matches('\0'),
409 "123456"
410 );
411 }
412
413 #[test]
414 fn test_rsp_info_success() {
415 let mut rsp = RspInfoField::default();
416 assert!(rsp.is_success());
417
418 rsp.error_id = -1;
419 assert!(!rsp.is_success());
420 }
421}
422
423#[repr(C)]
425#[derive(Debug, Clone)]
426pub struct QryTradingAccountField {
427 pub broker_id: BrokerIdType,
429 pub investor_id: InvestorIdType,
431 pub currency_id: CurrencyIdType,
433 pub biz_type: BizTypeType,
435 pub account_id: AccountIdType,
437}
438
439impl Default for QryTradingAccountField {
440 fn default() -> Self {
441 unsafe { std::mem::zeroed() }
442 }
443}
444
445impl QryTradingAccountField {
446 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
447 let mut req = Self::default();
448 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
449 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
450 Ok(req)
452 }
453
454 pub fn with_currency(mut self, currency_id: &str) -> CtpResult<Self> {
455 self.currency_id = CurrencyIdType::from_utf8_string(currency_id)?;
456 Ok(self)
457 }
458}
459
460#[repr(C)]
462#[derive(Debug, Clone)]
463pub struct QryInvestorPositionField {
464 pub broker_id: BrokerIdType,
466 pub investor_id: InvestorIdType,
468 pub instrument_id: InstrumentIdType,
470 pub exchange_id: ExchangeIdType,
472 pub invest_unit_id: InvestUnitIdType,
474}
475
476impl Default for QryInvestorPositionField {
477 fn default() -> Self {
478 unsafe { std::mem::zeroed() }
479 }
480}
481
482impl QryInvestorPositionField {
483 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
484 let mut req = Self::default();
485 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
486 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
487 Ok(req)
488 }
489
490 pub fn with_instrument_id(mut self, instrument_id: &str) -> CtpResult<Self> {
491 self.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
492 Ok(self)
493 }
494}
495
496#[repr(C)]
500#[derive(Debug, Clone)]
501pub struct QryOrderField {
502 pub broker_id: BrokerIdType,
504 pub investor_id: InvestorIdType,
506 pub instrument_id: InstrumentIdType,
508 pub exchange_id: ExchangeIdType,
510 pub order_sys_id: OrderSysIdType,
512 pub insert_time_start: TimeType,
514 pub insert_time_end: TimeType,
516 pub invest_unit_id: InvestUnitIdType,
518}
519
520impl Default for QryOrderField {
521 fn default() -> Self {
522 unsafe { std::mem::zeroed() }
523 }
524}
525
526impl QryOrderField {
527 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
528 let mut req = Self::default();
529 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
530 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
531 Ok(req)
532 }
533
534 pub fn with_instrument_id(mut self, instrument_id: &str) -> CtpResult<Self> {
535 self.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
536 Ok(self)
537 }
538}
539
540#[repr(C)]
542#[derive(Debug, Clone)]
543pub struct QryTradeField {
544 pub broker_id: BrokerIdType,
546 pub investor_id: InvestorIdType,
548 pub instrument_id: InstrumentIdType,
550 pub exchange_id: ExchangeIdType,
552 pub trade_id: TradeIdType,
554 pub trade_time_start: TimeType,
556 pub trade_time_end: TimeType,
558 pub invest_unit_id: InvestUnitIdType,
560}
561
562impl Default for QryTradeField {
563 fn default() -> Self {
564 unsafe { std::mem::zeroed() }
565 }
566}
567
568impl QryTradeField {
569 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
570 let mut req = Self::default();
571 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
572 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
573 Ok(req)
574 }
575
576 pub fn with_instrument_id(mut self, instrument_id: &str) -> CtpResult<Self> {
577 self.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
578 Ok(self)
579 }
580}
581
582#[repr(C)]
584#[derive(Debug, Clone)]
585pub struct QryInstrumentField {
586 pub instrument_id: InstrumentIdType,
588 pub exchange_id: ExchangeIdType,
590 pub exchange_inst_id: ExchangeInstIdType,
592 pub product_id: InstrumentIdType,
594}
595
596impl Default for QryInstrumentField {
597 fn default() -> Self {
598 unsafe { std::mem::zeroed() }
599 }
600}
601
602impl QryInstrumentField {
603 pub fn new() -> Self {
604 Self::default()
605 }
606
607 pub fn with_instrument_id(mut self, instrument_id: &str) -> CtpResult<Self> {
608 self.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
609 Ok(self)
610 }
611
612 pub fn with_exchange_id(mut self, exchange_id: &str) -> CtpResult<Self> {
613 self.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
614 Ok(self)
615 }
616}
617
618#[repr(C)]
620#[derive(Debug, Clone)]
621pub struct InputOrderActionField {
622 pub broker_id: BrokerIdType,
624 pub investor_id: InvestorIdType,
626 pub order_action_ref: OrderActionRefType,
628 pub order_ref: OrderRefType,
630 pub request_id: RequestIdType,
632 pub front_id: FrontIdType,
634 pub session_id: SessionIdType,
636 pub exchange_id: ExchangeIdType,
638 pub order_sys_id: OrderSysIdType,
640 pub action_flag: ActionFlagType,
642 pub limit_price: PriceType,
644 pub volume_change: VolumeType,
646 pub user_id: UserIdType,
648 pub instrument_id: InstrumentIdType,
650 pub invest_unit_id: InvestUnitIdType,
652 pub ip_address: IPAddressType,
654 pub mac_address: MacAddressType,
656}
657
658impl Default for InputOrderActionField {
659 fn default() -> Self {
660 unsafe { std::mem::zeroed() }
661 }
662}
663
664impl InputOrderActionField {
665 pub fn new(
666 broker_id: &str,
667 investor_id: &str,
668 action_flag: u8,
669 order_ref: &str,
670 front_id: i32,
671 session_id: i32,
672 exchange_id: &str,
673 order_sys_id: &str,
674 ) -> CtpResult<Self> {
675 let mut req = Self::default();
676 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
677 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
678 req.action_flag = action_flag;
679 req.order_ref = OrderRefType::from_utf8_string(order_ref)?;
680 req.front_id = front_id;
681 req.session_id = session_id;
682 req.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
683 req.order_sys_id = OrderSysIdType::from_utf8_string(order_sys_id)?;
684 Ok(req)
685 }
686}
687
688#[repr(C)]
690#[derive(Debug, Clone)]
691pub struct OrderActionField {
692 pub broker_id: BrokerIdType,
694 pub investor_id: InvestorIdType,
696 pub order_action_ref: OrderActionRefType,
698 pub order_ref: OrderRefType,
700 pub request_id: RequestIdType,
702 pub front_id: FrontIdType,
704 pub session_id: SessionIdType,
706 pub exchange_id: ExchangeIdType,
708 pub order_sys_id: OrderSysIdType,
710 pub action_flag: ActionFlagType,
712 pub limit_price: PriceType,
714 pub volume_change: VolumeType,
716 pub action_date: DateType,
718 pub action_time: TimeType,
720 pub trader_id: TraderIdType,
722 pub install_id: InstallIdType,
724 pub order_local_id: OrderLocalIdType,
726 pub action_local_id: OrderLocalIdType,
728 pub participant_id: ParticipantIdType,
730 pub client_id: ClientIdType,
732 pub business_unit: BusinessUnitType,
734 pub order_action_status: OrderActionStatusType,
736 pub user_id: UserIdType,
738 pub status_msg: ErrorMsgType,
740 pub instrument_id: InstrumentIdType,
742 pub branch_id: BranchIdType,
744 pub invest_unit_id: InvestUnitIdType,
746 pub ip_address: IPAddressType,
748 pub mac_address: MacAddressType,
750}
751
752impl Default for OrderActionField {
753 fn default() -> Self {
754 unsafe { std::mem::zeroed() }
755 }
756}
757
758#[repr(C)]
762#[derive(Debug, Clone)]
763pub struct QryInstrumentMarginRateField {
764 pub broker_id: BrokerIdType,
766 pub investor_id: InvestorIdType,
768 pub instrument_id: InstrumentIdType,
770 pub hedge_flag: u8,
772 pub exchange_id: ExchangeIdType,
774 pub invest_unit_id: InvestUnitIdType,
776}
777
778impl Default for QryInstrumentMarginRateField {
779 fn default() -> Self {
780 unsafe { std::mem::zeroed() }
781 }
782}
783
784impl QryInstrumentMarginRateField {
785 pub fn new(broker_id: &str, investor_id: &str, instrument_id: &str) -> CtpResult<Self> {
786 let mut req = Self::default();
787 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
788 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
789 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
790 Ok(req)
791 }
792
793 pub fn with_hedge_flag(mut self, hedge_flag: u8) -> Self {
794 self.hedge_flag = hedge_flag;
795 self
796 }
797
798 pub fn with_exchange_id(mut self, exchange_id: &str) -> CtpResult<Self> {
799 self.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
800 Ok(self)
801 }
802}
803
804#[repr(C)]
806#[derive(Debug, Clone)]
807pub struct QryInstrumentCommissionRateField {
808 pub broker_id: BrokerIdType,
810 pub investor_id: InvestorIdType,
812 pub instrument_id: InstrumentIdType,
814 pub exchange_id: ExchangeIdType,
816 pub invest_unit_id: InvestUnitIdType,
818}
819
820impl Default for QryInstrumentCommissionRateField {
821 fn default() -> Self {
822 unsafe { std::mem::zeroed() }
823 }
824}
825
826impl QryInstrumentCommissionRateField {
827 pub fn new(broker_id: &str, investor_id: &str, instrument_id: &str) -> CtpResult<Self> {
828 let mut req = Self::default();
829 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
830 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
831 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
832 Ok(req)
833 }
834
835 pub fn with_exchange_id(mut self, exchange_id: &str) -> CtpResult<Self> {
836 self.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
837 Ok(self)
838 }
839}
840
841#[repr(C)]
843#[derive(Debug, Clone)]
844pub struct QryExchangeField {
845 pub exchange_id: ExchangeIdType,
847}
848
849impl Default for QryExchangeField {
850 fn default() -> Self {
851 unsafe { std::mem::zeroed() }
852 }
853}
854
855impl QryExchangeField {
856 pub fn new() -> Self {
857 Self::default()
858 }
859
860 pub fn with_exchange_id(mut self, exchange_id: &str) -> CtpResult<Self> {
861 self.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
862 Ok(self)
863 }
864}
865
866#[repr(C)]
868#[derive(Debug, Clone)]
869pub struct QryProductField {
870 pub product_id: InstrumentIdType,
872 pub product_class: u8,
874 pub exchange_id: ExchangeIdType,
876}
877
878impl Default for QryProductField {
879 fn default() -> Self {
880 unsafe { std::mem::zeroed() }
881 }
882}
883
884impl QryProductField {
885 pub fn new() -> Self {
886 Self::default()
887 }
888
889 pub fn with_product_id(mut self, product_id: &str) -> CtpResult<Self> {
890 self.product_id = InstrumentIdType::from_utf8_string(product_id)?;
891 Ok(self)
892 }
893
894 pub fn with_exchange_id(mut self, exchange_id: &str) -> CtpResult<Self> {
895 self.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
896 Ok(self)
897 }
898
899 pub fn with_product_class(mut self, product_class: u8) -> Self {
900 self.product_class = product_class;
901 self
902 }
903}
904
905#[repr(C)]
907#[derive(Debug, Clone)]
908pub struct SettlementInfoConfirmField {
909 pub broker_id: BrokerIdType,
911 pub investor_id: InvestorIdType,
913 pub confirm_date: [u8; 9],
915 pub confirm_time: [u8; 9],
917 pub settlement_id: i32,
919 pub account_id: AccountIdType,
921 pub currency_id: CurrencyIdType,
923}
924
925impl Default for SettlementInfoConfirmField {
926 fn default() -> Self {
927 unsafe { std::mem::zeroed() }
928 }
929}
930
931impl SettlementInfoConfirmField {
932 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
933 let mut req = Self::default();
934 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
935 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
936 Ok(req)
937 }
938
939 pub fn with_account_id(mut self, account_id: &str) -> CtpResult<Self> {
940 self.account_id = AccountIdType::from_utf8_string(account_id)?;
941 Ok(self)
942 }
943}
944
945#[repr(C)]
947#[derive(Debug, Clone)]
948pub struct ParkedOrderField {
949 pub broker_id: BrokerIdType,
951 pub investor_id: InvestorIdType,
953 pub instrument_id: InstrumentIdType,
955 pub order_ref: OrderRefType,
957 pub user_id: UserIdType,
959 pub order_price_type: u8,
961 pub direction: u8,
963 pub comb_offset_flag: [u8; 5],
965 pub comb_hedge_flag: [u8; 5],
967 pub limit_price: PriceType,
969 pub volume_total_original: VolumeType,
971 pub time_condition: u8,
973 pub gtd_date: [u8; 9],
975 pub volume_condition: u8,
977 pub min_volume: VolumeType,
979 pub contingent_condition: u8,
981 pub stop_price: PriceType,
983 pub force_close_reason: u8,
985 pub is_auto_suspend: i32,
987 pub business_unit: [u8; 21],
989 pub request_id: RequestIdType,
991 pub user_force_close: i32,
993 pub exchange_id: ExchangeIdType,
995 pub parked_order_id: [u8; 13],
997 pub user_type: u8,
999 pub status: u8,
1001 pub error_id: i32,
1003 pub error_msg: [u8; 81],
1005 pub is_swap_order: i32,
1007 pub invest_unit_id: InvestUnitIdType,
1009 pub account_id: AccountIdType,
1011 pub currency_id: CurrencyIdType,
1013 pub client_id: [u8; 11],
1015 pub ip_address: IPAddressType,
1017 pub mac_address: MacAddressType,
1019}
1020
1021impl Default for ParkedOrderField {
1022 fn default() -> Self {
1023 unsafe { std::mem::zeroed() }
1024 }
1025}
1026
1027impl ParkedOrderField {
1028 pub fn new(
1029 broker_id: &str,
1030 investor_id: &str,
1031 instrument_id: &str,
1032 order_ref: &str,
1033 direction: u8,
1034 limit_price: f64,
1035 volume: i32,
1036 ) -> CtpResult<Self> {
1037 let mut req = Self::default();
1038 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1039 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1040 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1041 req.order_ref = OrderRefType::from_utf8_string(order_ref)?;
1042 req.direction = direction;
1043 req.limit_price = limit_price;
1044 req.volume_total_original = volume;
1045 Ok(req)
1046 }
1047}
1048
1049#[repr(C)]
1051#[derive(Debug, Clone)]
1052pub struct ParkedOrderActionField {
1053 pub broker_id: BrokerIdType,
1055 pub investor_id: InvestorIdType,
1057 pub order_action_ref: OrderActionRefType,
1059 pub order_ref: OrderRefType,
1061 pub request_id: RequestIdType,
1063 pub front_id: FrontIdType,
1065 pub session_id: SessionIdType,
1067 pub exchange_id: ExchangeIdType,
1069 pub order_sys_id: OrderSysIdType,
1071 pub action_flag: ActionFlagType,
1073 pub limit_price: PriceType,
1075 pub volume_change: VolumeType,
1077 pub user_id: UserIdType,
1079 pub instrument_id: InstrumentIdType,
1081 pub parked_order_action_id: [u8; 13],
1083 pub user_type: u8,
1085 pub status: u8,
1087 pub error_id: i32,
1089 pub error_msg: [u8; 81],
1091 pub invest_unit_id: InvestUnitIdType,
1093 pub ip_address: IPAddressType,
1095 pub mac_address: MacAddressType,
1097}
1098
1099impl Default for ParkedOrderActionField {
1100 fn default() -> Self {
1101 unsafe { std::mem::zeroed() }
1102 }
1103}
1104
1105impl ParkedOrderActionField {
1106 pub fn new(
1107 broker_id: &str,
1108 investor_id: &str,
1109 action_flag: u8,
1110 order_ref: &str,
1111 front_id: i32,
1112 session_id: i32,
1113 exchange_id: &str,
1114 order_sys_id: &str,
1115 ) -> CtpResult<Self> {
1116 let mut req = Self::default();
1117 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1118 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1119 req.action_flag = action_flag;
1120 req.order_ref = OrderRefType::from_utf8_string(order_ref)?;
1121 req.front_id = front_id;
1122 req.session_id = session_id;
1123 req.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
1124 req.order_sys_id = OrderSysIdType::from_utf8_string(order_sys_id)?;
1125 Ok(req)
1126 }
1127}
1128
1129#[repr(C)]
1133#[derive(Debug, Clone)]
1134pub struct InstrumentMarginRateField {
1135 pub instrument_id: InstrumentIdType,
1137 pub investor_range: u8,
1139 pub broker_id: BrokerIdType,
1141 pub investor_id: InvestorIdType,
1143 pub hedge_flag: u8,
1145 pub long_margin_ratio_by_money: f64,
1147 pub long_margin_ratio_by_volume: f64,
1149 pub short_margin_ratio_by_money: f64,
1151 pub short_margin_ratio_by_volume: f64,
1153 pub is_relative: i32,
1155 pub exchange_id: ExchangeIdType,
1157 pub invest_unit_id: InvestUnitIdType,
1159}
1160
1161impl Default for InstrumentMarginRateField {
1162 fn default() -> Self {
1163 unsafe { std::mem::zeroed() }
1164 }
1165}
1166
1167#[repr(C)]
1169#[derive(Debug, Clone)]
1170pub struct InstrumentCommissionRateField {
1171 pub instrument_id: InstrumentIdType,
1173 pub investor_range: u8,
1175 pub broker_id: BrokerIdType,
1177 pub investor_id: InvestorIdType,
1179 pub open_ratio_by_money: f64,
1181 pub open_ratio_by_volume: f64,
1183 pub close_ratio_by_money: f64,
1185 pub close_ratio_by_volume: f64,
1187 pub close_today_ratio_by_money: f64,
1189 pub close_today_ratio_by_volume: f64,
1191 pub exchange_id: ExchangeIdType,
1193 pub biz_type: u8,
1195 pub invest_unit_id: InvestUnitIdType,
1197}
1198
1199impl Default for InstrumentCommissionRateField {
1200 fn default() -> Self {
1201 unsafe { std::mem::zeroed() }
1202 }
1203}
1204
1205#[repr(C)]
1207#[derive(Debug, Clone)]
1208pub struct ExchangeField {
1209 pub exchange_id: ExchangeIdType,
1211 pub exchange_name: [u8; 61],
1213 pub exchange_property: u8,
1215}
1216
1217impl Default for ExchangeField {
1218 fn default() -> Self {
1219 unsafe { std::mem::zeroed() }
1220 }
1221}
1222
1223#[repr(C)]
1225#[derive(Debug, Clone)]
1226pub struct ProductField {
1227 pub product_id: InstrumentIdType,
1229 pub product_name: [u8; 21],
1231 pub exchange_id: ExchangeIdType,
1233 pub product_class: u8,
1235 pub volume_multiple: i32,
1237 pub price_tick: f64,
1239 pub max_market_order_volume: i32,
1241 pub min_market_order_volume: i32,
1243 pub max_limit_order_volume: i32,
1245 pub min_limit_order_volume: i32,
1247 pub position_type: u8,
1249 pub position_date_type: u8,
1251 pub close_deal_type: u8,
1253 pub trade_currency_id: CurrencyIdType,
1255 pub margin_currency_id: CurrencyIdType,
1257}
1258
1259impl Default for ProductField {
1260 fn default() -> Self {
1261 unsafe { std::mem::zeroed() }
1262 }
1263}
1264
1265#[repr(C)]
1269#[derive(Debug, Clone)]
1270pub struct InputExecOrderField {
1271 pub broker_id: BrokerIdType,
1272 pub investor_id: InvestorIdType,
1273 pub instrument_id: InstrumentIdType,
1274 pub exec_order_ref: OrderRefType,
1275 pub user_id: UserIdType,
1276 pub volume: i32,
1277 pub request_id: i32,
1278 pub business_unit: BusinessUnitType,
1279 pub offset_flag: u8,
1280 pub hedge_flag: u8,
1281 pub action_type: u8,
1282 pub posidir: u8,
1283 pub reserve_position_flag: u8,
1284 pub close_flag: u8,
1285 pub exchange_id: ExchangeIdType,
1286 pub invest_unit_id: InvestUnitIdType,
1287 pub account_id: AccountIdType,
1288 pub currency_id: CurrencyIdType,
1289 pub client_id: ClientIdType,
1290 pub ip_address: [u8; 16],
1291 pub mac_address: [u8; 21],
1292}
1293
1294impl Default for InputExecOrderField {
1295 fn default() -> Self {
1296 unsafe { std::mem::zeroed() }
1297 }
1298}
1299
1300impl InputExecOrderField {
1301 pub fn new(
1302 broker_id: &str,
1303 investor_id: &str,
1304 instrument_id: &str,
1305 exec_order_ref: &str,
1306 user_id: &str,
1307 volume: i32,
1308 action_type: u8,
1309 ) -> CtpResult<Self> {
1310 let mut req = Self::default();
1311 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1312 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1313 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1314 req.exec_order_ref = OrderRefType::from_utf8_string(exec_order_ref)?;
1315 req.user_id = UserIdType::from_utf8_string(user_id)?;
1316 req.volume = volume;
1317 req.action_type = action_type;
1318 Ok(req)
1319 }
1320}
1321
1322#[repr(C)]
1324#[derive(Debug, Clone)]
1325pub struct InputExecOrderActionField {
1326 pub broker_id: BrokerIdType,
1327 pub investor_id: InvestorIdType,
1328 pub exec_order_action_ref: OrderRefType,
1329 pub exec_order_ref: OrderRefType,
1330 pub request_id: i32,
1331 pub front_id: i32,
1332 pub session_id: i32,
1333 pub exchange_id: ExchangeIdType,
1334 pub exec_order_sys_id: OrderSysIdType,
1335 pub action_flag: u8,
1336 pub user_id: UserIdType,
1337 pub instrument_id: InstrumentIdType,
1338 pub invest_unit_id: InvestUnitIdType,
1339 pub ip_address: [u8; 16],
1340 pub mac_address: [u8; 21],
1341}
1342
1343impl Default for InputExecOrderActionField {
1344 fn default() -> Self {
1345 unsafe { std::mem::zeroed() }
1346 }
1347}
1348
1349impl InputExecOrderActionField {
1350 pub fn new(
1351 broker_id: &str,
1352 investor_id: &str,
1353 exec_order_action_ref: &str,
1354 exec_order_ref: &str,
1355 user_id: &str,
1356 action_flag: u8,
1357 ) -> CtpResult<Self> {
1358 let mut req = Self::default();
1359 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1360 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1361 req.exec_order_action_ref = OrderRefType::from_utf8_string(exec_order_action_ref)?;
1362 req.exec_order_ref = OrderRefType::from_utf8_string(exec_order_ref)?;
1363 req.user_id = UserIdType::from_utf8_string(user_id)?;
1364 req.action_flag = action_flag;
1365 Ok(req)
1366 }
1367}
1368
1369#[repr(C)]
1371#[derive(Debug, Clone)]
1372pub struct InputForQuoteField {
1373 pub broker_id: BrokerIdType,
1374 pub investor_id: InvestorIdType,
1375 pub instrument_id: InstrumentIdType,
1376 pub for_quote_ref: OrderRefType,
1377 pub user_id: UserIdType,
1378 pub exchange_id: ExchangeIdType,
1379 pub invest_unit_id: InvestUnitIdType,
1380 pub ip_address: [u8; 16],
1381 pub mac_address: [u8; 21],
1382}
1383
1384impl Default for InputForQuoteField {
1385 fn default() -> Self {
1386 unsafe { std::mem::zeroed() }
1387 }
1388}
1389
1390impl InputForQuoteField {
1391 pub fn new(
1392 broker_id: &str,
1393 investor_id: &str,
1394 instrument_id: &str,
1395 for_quote_ref: &str,
1396 user_id: &str,
1397 ) -> CtpResult<Self> {
1398 let mut req = Self::default();
1399 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1400 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1401 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1402 req.for_quote_ref = OrderRefType::from_utf8_string(for_quote_ref)?;
1403 req.user_id = UserIdType::from_utf8_string(user_id)?;
1404 Ok(req)
1405 }
1406}
1407
1408#[repr(C)]
1410#[derive(Debug, Clone)]
1411pub struct InputQuoteField {
1412 pub broker_id: BrokerIdType,
1413 pub investor_id: InvestorIdType,
1414 pub instrument_id: InstrumentIdType,
1415 pub quote_ref: OrderRefType,
1416 pub user_id: UserIdType,
1417 pub ask_price: f64,
1418 pub bid_price: f64,
1419 pub ask_volume: i32,
1420 pub bid_volume: i32,
1421 pub request_id: i32,
1422 pub business_unit: BusinessUnitType,
1423 pub ask_offset_flag: u8,
1424 pub bid_offset_flag: u8,
1425 pub ask_hedge_flag: u8,
1426 pub bid_hedge_flag: u8,
1427 pub ask_order_ref: OrderRefType,
1428 pub bid_order_ref: OrderRefType,
1429 pub for_quote_sys_id: OrderSysIdType,
1430 pub exchange_id: ExchangeIdType,
1431 pub invest_unit_id: InvestUnitIdType,
1432 pub account_id: AccountIdType,
1433 pub currency_id: CurrencyIdType,
1434 pub client_id: ClientIdType,
1435 pub ip_address: [u8; 16],
1436 pub mac_address: [u8; 21],
1437}
1438
1439impl Default for InputQuoteField {
1440 fn default() -> Self {
1441 unsafe { std::mem::zeroed() }
1442 }
1443}
1444
1445impl InputQuoteField {
1446 pub fn new(
1447 broker_id: &str,
1448 investor_id: &str,
1449 instrument_id: &str,
1450 quote_ref: &str,
1451 user_id: &str,
1452 ask_price: f64,
1453 bid_price: f64,
1454 ask_volume: i32,
1455 bid_volume: i32,
1456 ) -> CtpResult<Self> {
1457 let mut req = Self::default();
1458 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1459 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1460 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1461 req.quote_ref = OrderRefType::from_utf8_string(quote_ref)?;
1462 req.user_id = UserIdType::from_utf8_string(user_id)?;
1463 req.ask_price = ask_price;
1464 req.bid_price = bid_price;
1465 req.ask_volume = ask_volume;
1466 req.bid_volume = bid_volume;
1467 Ok(req)
1468 }
1469}
1470
1471#[repr(C)]
1473#[derive(Debug, Clone)]
1474pub struct InputQuoteActionField {
1475 pub broker_id: BrokerIdType,
1476 pub investor_id: InvestorIdType,
1477 pub quote_action_ref: OrderRefType,
1478 pub quote_ref: OrderRefType,
1479 pub request_id: i32,
1480 pub front_id: i32,
1481 pub session_id: i32,
1482 pub exchange_id: ExchangeIdType,
1483 pub quote_sys_id: OrderSysIdType,
1484 pub action_flag: u8,
1485 pub user_id: UserIdType,
1486 pub instrument_id: InstrumentIdType,
1487 pub invest_unit_id: InvestUnitIdType,
1488 pub client_id: ClientIdType,
1489 pub ip_address: [u8; 16],
1490 pub mac_address: [u8; 21],
1491}
1492
1493impl Default for InputQuoteActionField {
1494 fn default() -> Self {
1495 unsafe { std::mem::zeroed() }
1496 }
1497}
1498
1499impl InputQuoteActionField {
1500 pub fn new(
1501 broker_id: &str,
1502 investor_id: &str,
1503 quote_action_ref: &str,
1504 quote_ref: &str,
1505 user_id: &str,
1506 action_flag: u8,
1507 ) -> CtpResult<Self> {
1508 let mut req = Self::default();
1509 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1510 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1511 req.quote_action_ref = OrderRefType::from_utf8_string(quote_action_ref)?;
1512 req.quote_ref = OrderRefType::from_utf8_string(quote_ref)?;
1513 req.user_id = UserIdType::from_utf8_string(user_id)?;
1514 req.action_flag = action_flag;
1515 Ok(req)
1516 }
1517}
1518
1519#[repr(C)]
1521#[derive(Debug, Clone)]
1522pub struct InputBatchOrderActionField {
1523 pub broker_id: BrokerIdType,
1524 pub investor_id: InvestorIdType,
1525 pub order_action_ref: OrderRefType,
1526 pub request_id: i32,
1527 pub front_id: i32,
1528 pub session_id: i32,
1529 pub exchange_id: ExchangeIdType,
1530 pub user_id: UserIdType,
1531 pub invest_unit_id: InvestUnitIdType,
1532 pub ip_address: [u8; 16],
1533 pub mac_address: [u8; 21],
1534}
1535
1536impl Default for InputBatchOrderActionField {
1537 fn default() -> Self {
1538 unsafe { std::mem::zeroed() }
1539 }
1540}
1541
1542impl InputBatchOrderActionField {
1543 pub fn new(
1544 broker_id: &str,
1545 investor_id: &str,
1546 order_action_ref: &str,
1547 user_id: &str,
1548 exchange_id: &str,
1549 ) -> CtpResult<Self> {
1550 let mut req = Self::default();
1551 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1552 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1553 req.order_action_ref = OrderRefType::from_utf8_string(order_action_ref)?;
1554 req.user_id = UserIdType::from_utf8_string(user_id)?;
1555 req.exchange_id = ExchangeIdType::from_utf8_string(exchange_id)?;
1556 Ok(req)
1557 }
1558}
1559
1560#[repr(C)]
1562#[derive(Debug, Clone)]
1563pub struct RemoveParkedOrderField {
1564 pub broker_id: BrokerIdType,
1565 pub investor_id: InvestorIdType,
1566 pub parked_order_id: ParkedOrderIdType,
1567 pub invest_unit_id: InvestUnitIdType,
1568}
1569
1570impl Default for RemoveParkedOrderField {
1571 fn default() -> Self {
1572 unsafe { std::mem::zeroed() }
1573 }
1574}
1575
1576impl RemoveParkedOrderField {
1577 pub fn new(broker_id: &str, investor_id: &str, parked_order_id: &str) -> CtpResult<Self> {
1578 let mut req = Self::default();
1579 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1580 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1581 req.parked_order_id = ParkedOrderIdType::from_utf8_string(parked_order_id)?;
1582 Ok(req)
1583 }
1584}
1585
1586#[repr(C)]
1588#[derive(Debug, Clone)]
1589pub struct RemoveParkedOrderActionField {
1590 pub broker_id: BrokerIdType,
1591 pub investor_id: InvestorIdType,
1592 pub parked_order_action_id: ParkedOrderIdType,
1593 pub invest_unit_id: InvestUnitIdType,
1594}
1595
1596impl Default for RemoveParkedOrderActionField {
1597 fn default() -> Self {
1598 unsafe { std::mem::zeroed() }
1599 }
1600}
1601
1602impl RemoveParkedOrderActionField {
1603 pub fn new(
1604 broker_id: &str,
1605 investor_id: &str,
1606 parked_order_action_id: &str,
1607 ) -> CtpResult<Self> {
1608 let mut req = Self::default();
1609 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1610 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1611 req.parked_order_action_id = ParkedOrderIdType::from_utf8_string(parked_order_action_id)?;
1612 Ok(req)
1613 }
1614}
1615
1616#[repr(C)]
1618#[derive(Debug, Clone)]
1619pub struct QryMaxOrderVolumeField {
1620 pub broker_id: BrokerIdType,
1621 pub investor_id: InvestorIdType,
1622 pub instrument_id: InstrumentIdType,
1623 pub direction: u8,
1624 pub offset_flag: u8,
1625 pub hedge_flag: u8,
1626 pub max_volume: i32,
1627 pub exchange_id: ExchangeIdType,
1628 pub invest_unit_id: InvestUnitIdType,
1629}
1630
1631impl Default for QryMaxOrderVolumeField {
1632 fn default() -> Self {
1633 unsafe { std::mem::zeroed() }
1634 }
1635}
1636
1637impl QryMaxOrderVolumeField {
1638 pub fn new(
1639 broker_id: &str,
1640 investor_id: &str,
1641 instrument_id: &str,
1642 direction: u8,
1643 ) -> CtpResult<Self> {
1644 let mut req = Self::default();
1645 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1646 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1647 req.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1648 req.direction = direction;
1649 Ok(req)
1650 }
1651}
1652
1653#[repr(C)]
1655#[derive(Debug, Clone)]
1656pub struct QryDepthMarketDataField {
1657 pub instrument_id: InstrumentIdType,
1658 pub exchange_id: ExchangeIdType,
1659}
1660
1661impl Default for QryDepthMarketDataField {
1662 fn default() -> Self {
1663 unsafe { std::mem::zeroed() }
1664 }
1665}
1666
1667impl QryDepthMarketDataField {
1668 pub fn new() -> Self {
1669 Self::default()
1670 }
1671
1672 pub fn with_instrument_id(mut self, instrument_id: &str) -> CtpResult<Self> {
1673 self.instrument_id = InstrumentIdType::from_utf8_string(instrument_id)?;
1674 Ok(self)
1675 }
1676}
1677
1678#[repr(C)]
1680#[derive(Debug, Clone)]
1681pub struct QrySettlementInfoField {
1682 pub broker_id: BrokerIdType,
1683 pub investor_id: InvestorIdType,
1684 pub trading_day: TradingDayType,
1685 pub account_id: AccountIdType,
1686 pub currency_id: CurrencyIdType,
1687}
1688
1689impl Default for QrySettlementInfoField {
1690 fn default() -> Self {
1691 unsafe { std::mem::zeroed() }
1692 }
1693}
1694
1695impl QrySettlementInfoField {
1696 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
1697 let mut req = Self::default();
1698 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1699 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1700 Ok(req)
1701 }
1702}
1703
1704#[repr(C)]
1706#[derive(Debug, Clone)]
1707pub struct QryTransferBankField {
1708 pub bank_id: BankIdType,
1709 pub bank_brch_id: BankBrchIdType,
1710}
1711
1712impl Default for QryTransferBankField {
1713 fn default() -> Self {
1714 unsafe { std::mem::zeroed() }
1715 }
1716}
1717
1718impl QryTransferBankField {
1719 pub fn new() -> Self {
1720 Self::default()
1721 }
1722}
1723
1724#[repr(C)]
1726#[derive(Debug, Clone)]
1727pub struct QryInvestorPositionDetailField {
1728 pub broker_id: BrokerIdType,
1729 pub investor_id: InvestorIdType,
1730 pub instrument_id: InstrumentIdType,
1731 pub exchange_id: ExchangeIdType,
1732 pub invest_unit_id: InvestUnitIdType,
1733}
1734
1735impl Default for QryInvestorPositionDetailField {
1736 fn default() -> Self {
1737 unsafe { std::mem::zeroed() }
1738 }
1739}
1740
1741impl QryInvestorPositionDetailField {
1742 pub fn new(broker_id: &str, investor_id: &str) -> CtpResult<Self> {
1743 let mut req = Self::default();
1744 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1745 req.investor_id = InvestorIdType::from_utf8_string(investor_id)?;
1746 Ok(req)
1747 }
1748}
1749
1750#[repr(C)]
1752#[derive(Debug, Clone)]
1753pub struct QryNoticeField {
1754 pub broker_id: BrokerIdType,
1755}
1756
1757impl Default for QryNoticeField {
1758 fn default() -> Self {
1759 unsafe { std::mem::zeroed() }
1760 }
1761}
1762
1763impl QryNoticeField {
1764 pub fn new(broker_id: &str) -> CtpResult<Self> {
1765 let mut req = Self::default();
1766 req.broker_id = BrokerIdType::from_utf8_string(broker_id)?;
1767 Ok(req)
1768 }
1769}
1770
1771#[repr(C)]
1775#[derive(Debug, Clone)]
1776pub struct SettlementInfoField {
1777 pub trading_day: TradingDayType,
1778 pub settlement_id: i32,
1779 pub broker_id: BrokerIdType,
1780 pub investor_id: InvestorIdType,
1781 pub sequence_no: i32,
1782 pub content: [u8; 1001],
1783 pub account_id: AccountIdType,
1784 pub currency_id: CurrencyIdType,
1785}
1786
1787impl Default for SettlementInfoField {
1788 fn default() -> Self {
1789 unsafe { std::mem::zeroed() }
1790 }
1791}
1792
1793#[repr(C)]
1795#[derive(Debug, Clone)]
1796pub struct TransferBankField {
1797 pub bank_id: BankIdType,
1798 pub bank_brch_id: BankBrchIdType,
1799 pub bank_name: BankNameType,
1800 pub is_active: i32,
1801}
1802
1803impl Default for TransferBankField {
1804 fn default() -> Self {
1805 unsafe { std::mem::zeroed() }
1806 }
1807}
1808
1809#[repr(C)]
1811#[derive(Debug, Clone)]
1812pub struct InvestorPositionDetailField {
1813 pub instrument_id: InstrumentIdType,
1814 pub broker_id: BrokerIdType,
1815 pub investor_id: InvestorIdType,
1816 pub hedge_flag: u8,
1817 pub direction: u8,
1818 pub open_date: TradingDayType,
1819 pub trade_id: TradeIdType,
1820 pub volume: i32,
1821 pub open_price: f64,
1822 pub trading_day: TradingDayType,
1823 pub settlement_id: i32,
1824 pub trade_type: u8,
1825 pub comb_instrument_id: InstrumentIdType,
1826 pub exchange_id: ExchangeIdType,
1827 pub close_profit_by_date: f64,
1828 pub close_profit_by_trade: f64,
1829 pub position_profit_by_date: f64,
1830 pub position_profit_by_trade: f64,
1831 pub margin: f64,
1832 pub exch_margin: f64,
1833 pub margin_rate_by_money: f64,
1834 pub margin_rate_by_volume: f64,
1835 pub last_settlement_price: f64,
1836 pub settlement_price: f64,
1837 pub close_volume: i32,
1838 pub close_amount: f64,
1839 pub time_first_volume: i32,
1840 pub invest_unit_id: InvestUnitIdType,
1841 pub spec_posidir: u8,
1842}
1843
1844impl Default for InvestorPositionDetailField {
1845 fn default() -> Self {
1846 unsafe { std::mem::zeroed() }
1847 }
1848}
1849
1850#[repr(C)]
1852#[derive(Debug, Clone)]
1853pub struct NoticeField {
1854 pub broker_id: BrokerIdType,
1855 pub content: [u8; 501],
1856 pub url_link: [u8; 201],
1857}
1858
1859impl Default for NoticeField {
1860 fn default() -> Self {
1861 unsafe { std::mem::zeroed() }
1862 }
1863}