Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

为什么on_rtn_depth_market_data收到不数据,但on_rtn_for_quote_rsp却不断收到数据? #19

Open
songroom2016 opened this issue Aug 7, 2020 · 2 comments

Comments

@songroom2016
Copy link

songroom2016 commented Aug 7, 2020

            let flow_path = ::std::ffi::CString::new("").unwrap();
            let mut md_api = MdApi::new(flow_path, false, false);
            md_api.register_spi(Box::new(_my_desk.clone()));
            md_api.register_front(std::ffi::CString::new(md_front).unwrap());
            md_api.init();
            std::thread::sleep(std::time::Duration::from_secs(1));
            let login_field = get_login_field(&acc);
            match md_api.req_user_login(&login_field, 1) {
                Ok(()) => println!("md req_user_login =>ok"),
                Err(err) => println!("md req_user_login =>err: {:?}", err),
            };
            let instrument_ids = vec![CString::new("IF2009").unwrap(),
                                      CString::new("au2012").unwrap(),
                                      CString::new("m2009").unwrap()];
            std::thread::sleep(std::time::Duration::from_secs(1));
            match md_api.subscribe_market_data(&instrument_ids.clone()) {
                Ok(()) => println!("subscribe_market_data =>ok instrs :{:?}",&instrument_ids.clone()),
                Err(err) => println!("subscribe_market_data err: {:?}", err),
            };

在impl MdSPI中,

fn on_rtn_depth_market_data(&mut self, depth_market_data: Option<&CThostFtdcDepthMarketDataField>) {
     println!("desk => depth_market_data:{:?}",depth_market_data);
     self.sender_to_manager.send(SpiData::DepthMarketData(MdSpiOnRtnDepthMarketData{ depth_market_data: *depth_market_data.expect("depth_market_data is none") })).expect("cannot send md spi")
 }

 fn on_rtn_for_quote_rsp(&mut self, for_quote_rsp: Option<&CThostFtdcForQuoteRspField>) {
     println!("desk => on_rtn_for_quote_rsp:{:?}",for_quote_rsp);
     self.sender_to_manager.send(SpiData::ForQuoteRsp(MdSpiOnRtnForQuoteRsp{ for_quote_rsp: *for_quote_rsp.expect("for_quote_rsp is none") })).expect("cannot send md spi");
 }

``
下面是我打印的:
desk=> on_rtn_for_quote_rsp:Some(CThostFtdcForQuoteRspField { TradingDay: "20200807", InstrumentID: "IF2009",
ForQuoteSysID: "", ForQuoteTime: "", ActionDay: "", ExchangeID: "" })
desk => on_rtn_for_quote_rsp:Some(CThostFtdcForQuoteRspField { TradingDay: "20200807", InstrumentID: "m2009", ForQuoteSysID: "", ForQuoteTime: "", ActionDay: "", ExchangeID: "" })
......

谢谢!

@WiSaGaN
Copy link
Owner

WiSaGaN commented Aug 7, 2020

你可以用其他客户端试试,看是数据源的问题还是ctp-rs的问题。

@songroom2016
Copy link
Author

songroom2016 commented Aug 7, 2020

我试了SIMNOW,还有另外一个期货公司的实盘,都是一样的。感觉非常奇怪。
下面接了一家期货实盘行情

md_front : "tcp://180.169.101.177:43213"
trade_front : "tcp://180.169.101.177:43205"
desk => on_front_connected
行情登陆成功!~~~~~~~
md req_user_login =>ok
desk => on_rsp_user_login
subscribe_market_data => ok instrs: ["IF2009", "au2012", "m2009"]
desk => on_rsp_un_sub_market_data
desk => on_rsp_un_sub_market_data
desk => on_rsp_un_sub_market_data
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp
desk => on_rtn_for_quote_rsp

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants