Struct MdApi

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

Implementations§

Source§

impl MdApi

Source

pub fn GetApiVersion(&self) -> String

Source§

impl MdApi

Source

pub fn Init(&self)

Examples found in repository?
examples/md_api.rs (line 19)
9fn main() {
10    let (tx, rx) = channel();
11    let api = Arc::new(MdApi::CreateMdApiAndSpi(
12        tx,
13        FLOW_PATH.to_string(),
14        false,
15        false,
16        true,
17    ));
18    api.RegisterFront(FRONT_ADDR.to_string());
19    api.Init();
20
21    loop {
22        let msg = rx.recv().unwrap();
23        match msg {
24            MdSpiMsg::OnFrontConnected => {
25                println!("front connected");
26                let mut req = ReqUserLoginField::default();
27                req.BrokerID = "".to_string();
28                req.UserID = "".to_string();
29                req.Password = "".to_string();
30                api.ReqUserLogin(req, 0);
31            }
32            MdSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
33                if rsp_info.ErrorID != 0 {
34                    println!("user login failed: {:?}", rsp_info);
35                    continue;
36                } else {
37                    println!("user login success: {:?}", rsp_info);
38                    let instruments: Vec<String> =
39                        INSTRUMENTS.iter().map(|&s| s.to_string()).collect();
40                    let len = instruments.len() as i32;
41                    api.SubscribeMarketData(instruments, len);
42                }
43            }
44            MdSpiMsg::OnRtnDepthMarketData(tick) => {
45                println!("{:?}", tick);
46            }
47            _ => {}
48        }
49    }
50}
Source§

impl MdApi

Source

pub fn Join(&self) -> i32

Source§

impl MdApi

Source

pub fn GetTradingDay(&self) -> String

Source§

impl MdApi

Source

pub fn RegisterFront(&self, pszFrontAddress: String)

Examples found in repository?
examples/md_api.rs (line 18)
9fn main() {
10    let (tx, rx) = channel();
11    let api = Arc::new(MdApi::CreateMdApiAndSpi(
12        tx,
13        FLOW_PATH.to_string(),
14        false,
15        false,
16        true,
17    ));
18    api.RegisterFront(FRONT_ADDR.to_string());
19    api.Init();
20
21    loop {
22        let msg = rx.recv().unwrap();
23        match msg {
24            MdSpiMsg::OnFrontConnected => {
25                println!("front connected");
26                let mut req = ReqUserLoginField::default();
27                req.BrokerID = "".to_string();
28                req.UserID = "".to_string();
29                req.Password = "".to_string();
30                api.ReqUserLogin(req, 0);
31            }
32            MdSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
33                if rsp_info.ErrorID != 0 {
34                    println!("user login failed: {:?}", rsp_info);
35                    continue;
36                } else {
37                    println!("user login success: {:?}", rsp_info);
38                    let instruments: Vec<String> =
39                        INSTRUMENTS.iter().map(|&s| s.to_string()).collect();
40                    let len = instruments.len() as i32;
41                    api.SubscribeMarketData(instruments, len);
42                }
43            }
44            MdSpiMsg::OnRtnDepthMarketData(tick) => {
45                println!("{:?}", tick);
46            }
47            _ => {}
48        }
49    }
50}
Source§

impl MdApi

Source

pub fn RegisterNameServer(&self, pszNsAddress: String)

Source§

impl MdApi

Source

pub fn RegisterFensUserInfo(&self, pFensUserInfo: FensUserInfoField)

Source§

impl MdApi

Source

pub fn SubscribeMarketData( &self, ppInstrumentID: Vec<String>, nCount: i32, ) -> i32

Examples found in repository?
examples/md_api.rs (line 41)
9fn main() {
10    let (tx, rx) = channel();
11    let api = Arc::new(MdApi::CreateMdApiAndSpi(
12        tx,
13        FLOW_PATH.to_string(),
14        false,
15        false,
16        true,
17    ));
18    api.RegisterFront(FRONT_ADDR.to_string());
19    api.Init();
20
21    loop {
22        let msg = rx.recv().unwrap();
23        match msg {
24            MdSpiMsg::OnFrontConnected => {
25                println!("front connected");
26                let mut req = ReqUserLoginField::default();
27                req.BrokerID = "".to_string();
28                req.UserID = "".to_string();
29                req.Password = "".to_string();
30                api.ReqUserLogin(req, 0);
31            }
32            MdSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
33                if rsp_info.ErrorID != 0 {
34                    println!("user login failed: {:?}", rsp_info);
35                    continue;
36                } else {
37                    println!("user login success: {:?}", rsp_info);
38                    let instruments: Vec<String> =
39                        INSTRUMENTS.iter().map(|&s| s.to_string()).collect();
40                    let len = instruments.len() as i32;
41                    api.SubscribeMarketData(instruments, len);
42                }
43            }
44            MdSpiMsg::OnRtnDepthMarketData(tick) => {
45                println!("{:?}", tick);
46            }
47            _ => {}
48        }
49    }
50}
Source§

impl MdApi

Source

pub fn UnSubscribeMarketData( &self, ppInstrumentID: Vec<String>, nCount: i32, ) -> i32

Source§

impl MdApi

Source

pub fn SubscribeForQuoteRsp( &self, ppInstrumentID: Vec<String>, nCount: i32, ) -> i32

Source§

impl MdApi

Source

pub fn UnSubscribeForQuoteRsp( &self, ppInstrumentID: Vec<String>, nCount: i32, ) -> i32

Source§

impl MdApi

Source

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

Examples found in repository?
examples/md_api.rs (line 30)
9fn main() {
10    let (tx, rx) = channel();
11    let api = Arc::new(MdApi::CreateMdApiAndSpi(
12        tx,
13        FLOW_PATH.to_string(),
14        false,
15        false,
16        true,
17    ));
18    api.RegisterFront(FRONT_ADDR.to_string());
19    api.Init();
20
21    loop {
22        let msg = rx.recv().unwrap();
23        match msg {
24            MdSpiMsg::OnFrontConnected => {
25                println!("front connected");
26                let mut req = ReqUserLoginField::default();
27                req.BrokerID = "".to_string();
28                req.UserID = "".to_string();
29                req.Password = "".to_string();
30                api.ReqUserLogin(req, 0);
31            }
32            MdSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
33                if rsp_info.ErrorID != 0 {
34                    println!("user login failed: {:?}", rsp_info);
35                    continue;
36                } else {
37                    println!("user login success: {:?}", rsp_info);
38                    let instruments: Vec<String> =
39                        INSTRUMENTS.iter().map(|&s| s.to_string()).collect();
40                    let len = instruments.len() as i32;
41                    api.SubscribeMarketData(instruments, len);
42                }
43            }
44            MdSpiMsg::OnRtnDepthMarketData(tick) => {
45                println!("{:?}", tick);
46            }
47            _ => {}
48        }
49    }
50}
Source§

impl MdApi

Source

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

Source§

impl MdApi

Source

pub fn ReqQryMulticastInstrument( &self, pQryMulticastInstrument: QryMulticastInstrumentField, nRequestID: i32, ) -> i32

Source§

impl MdApi

Source

pub fn CreateMdApiAndSpi( tx: Sender<MdSpiMsg>, flow_path: String, is_using_udp: bool, is_multicast: bool, is_production_mode: bool, ) -> UniquePtr<MdApi>

Examples found in repository?
examples/md_api.rs (lines 11-17)
9fn main() {
10    let (tx, rx) = channel();
11    let api = Arc::new(MdApi::CreateMdApiAndSpi(
12        tx,
13        FLOW_PATH.to_string(),
14        false,
15        false,
16        true,
17    ));
18    api.RegisterFront(FRONT_ADDR.to_string());
19    api.Init();
20
21    loop {
22        let msg = rx.recv().unwrap();
23        match msg {
24            MdSpiMsg::OnFrontConnected => {
25                println!("front connected");
26                let mut req = ReqUserLoginField::default();
27                req.BrokerID = "".to_string();
28                req.UserID = "".to_string();
29                req.Password = "".to_string();
30                api.ReqUserLogin(req, 0);
31            }
32            MdSpiMsg::OnRspUserLogin(_, rsp_info, _, _) => {
33                if rsp_info.ErrorID != 0 {
34                    println!("user login failed: {:?}", rsp_info);
35                    continue;
36                } else {
37                    println!("user login success: {:?}", rsp_info);
38                    let instruments: Vec<String> =
39                        INSTRUMENTS.iter().map(|&s| s.to_string()).collect();
40                    let len = instruments.len() as i32;
41                    api.SubscribeMarketData(instruments, len);
42                }
43            }
44            MdSpiMsg::OnRtnDepthMarketData(tick) => {
45                println!("{:?}", tick);
46            }
47            _ => {}
48        }
49    }
50}

Trait Implementations§

Source§

impl ExternType for MdApi

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 MdApi

Source§

impl Sync for MdApi

Source§

impl UniquePtrTarget for MdApi

Auto Trait Implementations§

§

impl !Freeze for MdApi

§

impl RefUnwindSafe for MdApi

§

impl !Unpin for MdApi

§

impl UnwindSafe for MdApi

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.