Struct TraderApi

Source
#[repr(C)]
pub struct TraderApi { /* private fields */ }

Implementations§

Source§

impl TraderApi

Source§

impl TraderApi

Source

pub fn GetApiVersion(&self) -> String

Source§

impl TraderApi

Source

pub fn Init(&self)

Examples found in repository?
examples/td_api.rs (line 25)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn Join(&self) -> i32

Source§

impl TraderApi

Source

pub fn GetTradingDay(&self) -> String

Source§

impl TraderApi

Source

pub fn RegisterFront(&self, pszFrontAddress: String)

Examples found in repository?
examples/td_api.rs (line 22)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn RegisterNameServer(&self, pszNsAddress: String)

Source§

impl TraderApi

Source

pub fn RegisterFensUserInfo(&self, pFensUserInfo: FensUserInfoField)

Source§

impl TraderApi

Source

pub fn SubscribePrivateTopic(&self, nResumeType: i32)

Examples found in repository?
examples/td_api.rs (line 24)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn SubscribePublicTopic(&self, nResumeType: i32)

Examples found in repository?
examples/td_api.rs (line 23)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn ReqAuthenticate( &self, pReqAuthenticateField: ReqAuthenticateField, nRequestID: i32, ) -> i32

Examples found in repository?
examples/td_api.rs (line 39)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn RegisterUserSystemInfo( &self, pUserSystemInfo: UserSystemInfoField, ) -> i32

Source§

impl TraderApi

Source

pub fn SubmitUserSystemInfo(&self, pUserSystemInfo: UserSystemInfoField) -> i32

Source§

impl TraderApi

Source§

impl TraderApi

Source

pub fn SubmitWechatUserSystemInfo( &self, pUserSystemInfo: WechatUserSystemInfoField, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserLogin( &self, pReqUserLoginField: ReqUserLoginField, nRequestID: i32, ) -> i32

Examples found in repository?
examples/td_api.rs (line 54)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn ReqUserLogout( &self, pUserLogout: UserLogoutField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserPasswordUpdate( &self, pUserPasswordUpdate: UserPasswordUpdateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqTradingAccountPasswordUpdate( &self, pTradingAccountPasswordUpdate: TradingAccountPasswordUpdateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserAuthMethod( &self, pReqUserAuthMethod: ReqUserAuthMethodField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqGenUserCaptcha( &self, pReqGenUserCaptcha: ReqGenUserCaptchaField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqGenUserText( &self, pReqGenUserText: ReqGenUserTextField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserLoginWithCaptcha( &self, pReqUserLoginWithCaptcha: ReqUserLoginWithCaptchaField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserLoginWithText( &self, pReqUserLoginWithText: ReqUserLoginWithTextField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqUserLoginWithOTP( &self, pReqUserLoginWithOTP: ReqUserLoginWithOTPField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqOrderInsert( &self, pInputOrder: InputOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqParkedOrderInsert( &self, pParkedOrder: ParkedOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqParkedOrderAction( &self, pParkedOrderAction: ParkedOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqOrderAction( &self, pInputOrderAction: InputOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryMaxOrderVolume( &self, pQryMaxOrderVolume: QryMaxOrderVolumeField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqSettlementInfoConfirm( &self, pSettlementInfoConfirm: SettlementInfoConfirmField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqRemoveParkedOrder( &self, pRemoveParkedOrder: RemoveParkedOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqRemoveParkedOrderAction( &self, pRemoveParkedOrderAction: RemoveParkedOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqExecOrderInsert( &self, pInputExecOrder: InputExecOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqExecOrderAction( &self, pInputExecOrderAction: InputExecOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqForQuoteInsert( &self, pInputForQuote: InputForQuoteField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQuoteInsert( &self, pInputQuote: InputQuoteField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQuoteAction( &self, pInputQuoteAction: InputQuoteActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqBatchOrderAction( &self, pInputBatchOrderAction: InputBatchOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqOptionSelfCloseInsert( &self, pInputOptionSelfClose: InputOptionSelfCloseField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqOptionSelfCloseAction( &self, pInputOptionSelfCloseAction: InputOptionSelfCloseActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqCombActionInsert( &self, pInputCombAction: InputCombActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryOrder(&self, pQryOrder: QryOrderField, nRequestID: i32) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTrade(&self, pQryTrade: QryTradeField, nRequestID: i32) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorPosition( &self, pQryInvestorPosition: QryInvestorPositionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTradingAccount( &self, pQryTradingAccount: QryTradingAccountField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestor( &self, pQryInvestor: QryInvestorField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTradingCode( &self, pQryTradingCode: QryTradingCodeField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInstrumentMarginRate( &self, pQryInstrumentMarginRate: QryInstrumentMarginRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInstrumentCommissionRate( &self, pQryInstrumentCommissionRate: QryInstrumentCommissionRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryUserSession( &self, pQryUserSession: QryUserSessionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryExchange( &self, pQryExchange: QryExchangeField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryProduct( &self, pQryProduct: QryProductField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInstrument( &self, pQryInstrument: QryInstrumentField, nRequestID: i32, ) -> i32

Examples found in repository?
examples/td_api.rs (line 64)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}
Source§

impl TraderApi

Source

pub fn ReqQryDepthMarketData( &self, pQryDepthMarketData: QryDepthMarketDataField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTraderOffer( &self, pQryTraderOffer: QryTraderOfferField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySettlementInfo( &self, pQrySettlementInfo: QrySettlementInfoField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTransferBank( &self, pQryTransferBank: QryTransferBankField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorPositionDetail( &self, pQryInvestorPositionDetail: QryInvestorPositionDetailField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryNotice(&self, pQryNotice: QryNoticeField, nRequestID: i32) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySettlementInfoConfirm( &self, pQrySettlementInfoConfirm: QrySettlementInfoConfirmField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorPositionCombineDetail( &self, pQryInvestorPositionCombineDetail: QryInvestorPositionCombineDetailField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryCFMMCTradingAccountKey( &self, pQryCFMMCTradingAccountKey: QryCFMMCTradingAccountKeyField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryEWarrantOffset( &self, pQryEWarrantOffset: QryEWarrantOffsetField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorProductGroupMargin( &self, pQryInvestorProductGroupMargin: QryInvestorProductGroupMarginField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryExchangeMarginRate( &self, pQryExchangeMarginRate: QryExchangeMarginRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryExchangeMarginRateAdjust( &self, pQryExchangeMarginRateAdjust: QryExchangeMarginRateAdjustField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryExchangeRate( &self, pQryExchangeRate: QryExchangeRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySecAgentACIDMap( &self, pQrySecAgentACIDMap: QrySecAgentACIDMapField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryProductExchRate( &self, pQryProductExchRate: QryProductExchRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryProductGroup( &self, pQryProductGroup: QryProductGroupField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryMMInstrumentCommissionRate( &self, pQryMMInstrumentCommissionRate: QryMMInstrumentCommissionRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryMMOptionInstrCommRate( &self, pQryMMOptionInstrCommRate: QryMMOptionInstrCommRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInstrumentOrderCommRate( &self, pQryInstrumentOrderCommRate: QryInstrumentOrderCommRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySecAgentTradingAccount( &self, pQryTradingAccount: QryTradingAccountField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySecAgentCheckMode( &self, pQrySecAgentCheckMode: QrySecAgentCheckModeField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySecAgentTradeInfo( &self, pQrySecAgentTradeInfo: QrySecAgentTradeInfoField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryOptionInstrTradeCost( &self, pQryOptionInstrTradeCost: QryOptionInstrTradeCostField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryOptionInstrCommRate( &self, pQryOptionInstrCommRate: QryOptionInstrCommRateField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryExecOrder( &self, pQryExecOrder: QryExecOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryForQuote( &self, pQryForQuote: QryForQuoteField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryQuote(&self, pQryQuote: QryQuoteField, nRequestID: i32) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryOptionSelfClose( &self, pQryOptionSelfClose: QryOptionSelfCloseField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestUnit( &self, pQryInvestUnit: QryInvestUnitField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryCombInstrumentGuard( &self, pQryCombInstrumentGuard: QryCombInstrumentGuardField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryCombAction( &self, pQryCombAction: QryCombActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTransferSerial( &self, pQryTransferSerial: QryTransferSerialField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryAccountregister( &self, pQryAccountregister: QryAccountregisterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryContractBank( &self, pQryContractBank: QryContractBankField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryParkedOrder( &self, pQryParkedOrder: QryParkedOrderField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryParkedOrderAction( &self, pQryParkedOrderAction: QryParkedOrderActionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryTradingNotice( &self, pQryTradingNotice: QryTradingNoticeField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryBrokerTradingParams( &self, pQryBrokerTradingParams: QryBrokerTradingParamsField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryBrokerTradingAlgos( &self, pQryBrokerTradingAlgos: QryBrokerTradingAlgosField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQueryCFMMCTradingAccountToken( &self, pQueryCFMMCTradingAccountToken: QueryCFMMCTradingAccountTokenField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqFromBankToFutureByFuture( &self, pReqTransfer: ReqTransferField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqFromFutureToBankByFuture( &self, pReqTransfer: ReqTransferField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQueryBankAccountMoneyByFuture( &self, pReqQueryAccount: ReqQueryAccountField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryClassifiedInstrument( &self, pQryClassifiedInstrument: QryClassifiedInstrumentField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryCombPromotionParam( &self, pQryCombPromotionParam: QryCombPromotionParamField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRiskSettleInvstPosition( &self, pQryRiskSettleInvstPosition: QryRiskSettleInvstPositionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRiskSettleProductStatus( &self, pQryRiskSettleProductStatus: QryRiskSettleProductStatusField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMFutureParameter( &self, pQrySPBMFutureParameter: QrySPBMFutureParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMOptionParameter( &self, pQrySPBMOptionParameter: QrySPBMOptionParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMIntraParameter( &self, pQrySPBMIntraParameter: QrySPBMIntraParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMInterParameter( &self, pQrySPBMInterParameter: QrySPBMInterParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMPortfDefinition( &self, pQrySPBMPortfDefinition: QrySPBMPortfDefinitionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMInvestorPortfDef( &self, pQrySPBMInvestorPortfDef: QrySPBMInvestorPortfDefField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorPortfMarginRatio( &self, pQryInvestorPortfMarginRatio: QryInvestorPortfMarginRatioField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorProdSPBMDetail( &self, pQryInvestorProdSPBMDetail: QryInvestorProdSPBMDetailField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorCommoditySPMMMargin( &self, pQryInvestorCommoditySPMMMargin: QryInvestorCommoditySPMMMarginField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorCommodityGroupSPMMMargin( &self, pQryInvestorCommodityGroupSPMMMargin: QryInvestorCommodityGroupSPMMMarginField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPMMInstParam( &self, pQrySPMMInstParam: QrySPMMInstParamField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPMMProductParam( &self, pQrySPMMProductParam: QrySPMMProductParamField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQrySPBMAddOnInterParameter( &self, pQrySPBMAddOnInterParameter: QrySPBMAddOnInterParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSCombProductInfo( &self, pQryRCAMSCombProductInfo: QryRCAMSCombProductInfoField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSInstrParameter( &self, pQryRCAMSInstrParameter: QryRCAMSInstrParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSIntraParameter( &self, pQryRCAMSIntraParameter: QryRCAMSIntraParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSInterParameter( &self, pQryRCAMSInterParameter: QryRCAMSInterParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSShortOptAdjustParam( &self, pQryRCAMSShortOptAdjustParam: QryRCAMSShortOptAdjustParamField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRCAMSInvestorCombPosition( &self, pQryRCAMSInvestorCombPosition: QryRCAMSInvestorCombPositionField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorProdRCAMSMargin( &self, pQryInvestorProdRCAMSMargin: QryInvestorProdRCAMSMarginField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRULEInstrParameter( &self, pQryRULEInstrParameter: QryRULEInstrParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRULEIntraParameter( &self, pQryRULEIntraParameter: QryRULEIntraParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryRULEInterParameter( &self, pQryRULEInterParameter: QryRULEInterParameterField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorProdRULEMargin( &self, pQryInvestorProdRULEMargin: QryInvestorProdRULEMarginField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorPortfSetting( &self, pQryInvestorPortfSetting: QryInvestorPortfSettingField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryInvestorInfoCommRec( &self, pQryInvestorInfoCommRec: QryInvestorInfoCommRecField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryCombLeg( &self, pQryCombLeg: QryCombLegField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqOffsetSetting( &self, pInputOffsetSetting: InputOffsetSettingField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqCancelOffsetSetting( &self, pInputOffsetSetting: InputOffsetSettingField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn ReqQryOffsetSetting( &self, pQryOffsetSetting: QryOffsetSettingField, nRequestID: i32, ) -> i32

Source§

impl TraderApi

Source

pub fn CreateTraderApiAndSpi( tx: Sender<TraderSpiMsg>, flow_path: String, is_production_mode: bool, ) -> UniquePtr<TraderApi>

Examples found in repository?
examples/td_api.rs (lines 17-21)
15fn main() {
16    let (tx, rx) = channel();
17    let api = Arc::new(TraderApi::CreateTraderApiAndSpi(
18        tx,
19        FLOW_PATH.to_string(),
20        true,
21    ));
22    api.RegisterFront(FRONT_ADDR.to_string());
23    api.SubscribePublicTopic(THOST_TE_RESUME_TYPE::THOST_TERT_QUICK as i32);
24    api.SubscribePrivateTopic(THOST_TE_RESUME_TYPE::THOST_TERT_RESTART as i32);
25    api.Init();
26
27    loop {
28        let msg = rx.recv().unwrap();
29        match msg {
30            TraderSpiMsg::OnFrontConnected => {
31                println!("front connected");
32                let req = ReqAuthenticateField {
33                    BrokerID: BROKER_ID.to_string(),
34                    UserID: USER_ID.to_string(),
35                    AuthCode: AUTH_CODE.to_string(),
36                    AppID: APP_ID.to_string(),
37                    ..Default::default()
38                };
39                api.ReqAuthenticate(req, 0);
40            }
41            TraderSpiMsg::OnRspAuthenticate(_, rsp_info, _, _) => {
42                if rsp_info.ErrorID != 0 {
43                    println!("auth failed: {:?}", rsp_info);
44                    std::process::exit(1);
45                } else {
46                    println!("auth success: {:?}", rsp_info);
47
48                    let req = ReqUserLoginField {
49                        BrokerID: BROKER_ID.to_string(),
50                        UserID: USER_ID.to_string(),
51                        Password: PASSWORD.to_string(),
52                        ..Default::default()
53                    };
54                    api.ReqUserLogin(req, 0);
55                }
56            }
57            TraderSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
58                if rsp_info.ErrorID != 0 {
59                    println!("user login failed: {:?}", rsp_info);
60                    std::process::exit(1);
61                } else {
62                    println!("user login success: {:?}", rsp_info);
63
64                    api.ReqQryInstrument(QryInstrumentField::default(), 0);
65                }
66            }
67            TraderSpiMsg::OnRspQryInstrument(instrument, rsp_info, _, _) => {
68                if instrument.is_null {
69                    eprintln!("qry instrument: {:?}", rsp_info);
70                    std::process::exit(1);
71                }
72
73                println!("{:?}", instrument);
74            }
75            _ => {}
76        }
77    }
78}

Trait Implementations§

Source§

impl ExternType for TraderApi

Source§

type Kind = Opaque

Source§

type Id

A type-level representation of the type’s C++ namespace and type name. Read more
Source§

impl Send for TraderApi

Source§

impl Sync for TraderApi

Source§

impl UniquePtrTarget for TraderApi

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.