private void _t_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { Log("登录成功"); foreach (var v in _t.DicPositionField.Values) { Log($"posi:{v.InstrumentID}\t{v.Direction}\t{v.Price}\t{v.Position}"); } // new Thread(() => //{ // // 需要另启线程,在onrsp中处理,会导致线程被阻塞,后续的查询无法返回. // Thread.Sleep(3000); // foreach (var v in _t.DicPositionField.Values) // { // Log($"posi:{v.InstrumentID}\t{v.Direction}\t{v.Price}\t{v.Position}"); // } //}).Start(); //_t.ReqOrderInsert(_inst, DirectionType.Buy, OffsetType.Open, _price, 1, 1000); } else { Log($"登录错误:{e.Value}"); } }
private void trade_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { LogWarn("登录成功."); _tradingDay = ((Trade)sender).TradingDay; if (!string.IsNullOrEmpty(fs[3])) { LoginQuote(fs[3].Split(','), fs[1], this.textBoxUser.Text, this.textBoxPwd.Text); } this.Invoke(new Action(() => { this.pictureBox1.Image = Properties.Resources.Open; this.toolTip1.SetToolTip(this.pictureBox1, "已连接"); //this.toolTip1.Show("已连接.", this.pictureBox1, 6000); this.toolTip1.SetToolTip(this.ComboBoxType, "策略文件(dll)放置在(./strategies)目录中."); this.toolTip1.Show("策略文件(dll)放置在(./strategies)目录中.", this.ComboBoxType, 6000); })); } else { LogError("login error:" + e.Value); _t.ReqUserLogout(); _t = null; _q = null; } }
//登录响应 private void RspLogin(object sender, IntEventArgs e) { var t = (Trade)sender; ShowMsg($"[{_investor}]登录:{e.Value}"); if (e.Value == 0) { this.Invoke(new Action(() => { foreach (var posi in _t.DicPositionField.Values) { _bsPosi.Add(posi); } })); FutureBroker svr = (this.comboBoxServer.DataSource as BindingSource).Current as FutureBroker; if (svr == null) { ShowMsg("前置配置为空无法登录行情"); return; } if (_q != null) { _q.ReqUserLogout(); _q = null; } if (svr.Type == ProxyType.Tdx) { _q = (Quote)Activator.CreateInstance(ass.GetType($"HaiFeng.{svr.Type}Quote"), _t); //this.Invoke(new Action(() => this.comboBoxInstrument.Items.Add("000001"))); } else { _q = (Quote)Activator.CreateInstance(ass.GetType($"HaiFeng.{svr.Type}Quote"), "./dll/ctp_quote.dll"); } _q.OnFrontConnected += (snd, ea) => { ShowMsg($"行情连接成功"); _q.ReqUserLogin(_investor, _password, svr.Broker); }; _q.OnRspUserLogin += (snd, ea) => { foreach (var v in _t.DicPositionField.Values) { ((Quote)snd).ReqSubscribeMarketData(v.InstrumentID); } ShowMsg($"行情登录成功"); LogSucceed(); }; _q.OnRtnTick += this.OnTick; _q.OnRspUserLogout += (snd, ea) => { ShowMsg($"[{_broker}]行情退出:{ea.Value}"); }; _q.ReqConnect(svr.QuoteAddr); } }
private void trade_OnRspUserLogout(object sender, IntEventArgs e) { LogError($"交易接口断开,{e.Value,4}"); this.Invoke(new Action(() => { this.pictureBox1.Image = Properties.Resources.Close; this.toolTip1.SetToolTip(this.pictureBox1, "停止"); this.toolTip1.Show("停止.", this.pictureBox1, 6000); })); }
private void _t_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { Log("登录成功"); _t.ReqOrderInsert("rb1705", DirectionType.Sell, OffsetType.Open, 3200, 1, 1000); } else { Log($"登录错误:{e.Value}"); } }
private void _q_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { Log($"登录成功:{_investor}"); _q.ReqSubscribeMarketData(_inst); } else { //_q.OnFrontConnected -= _q_OnFrontConnected; //解决登录错误后不断重连导致再不断登录的错误 Log($"登录错误:{e.Value}"); _q.ReqUserLogout(); } }
private void _t_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { Log("登录成功"); Log("显示结算:" + _t.SettleInfo);//显示结算信息 //_t.ReqOrderInsert(_sub1, DirectionType.Sell, OffsetType.Open, 3200, 1, 1000); //_t.ReqForQuoteInsert( ref CThostFtdcInputForQuoteField ss); } else { Log($"登录错误:{e.Value}"); } }
void quote_OnRspUserLogin(object sender, IntEventArgs e) { //隔夜处理,夜盘开始后需重新订阅. foreach (var stra in _dicStrategies.Values) { if (!stra.EnableTick) { continue; } foreach (var data in stra.Datas) { SubscribeInstrument(data.Instrument); SubscribeInstrument(data.InstrumentOrder); } } QuoteLogged(); }
private void quote_OnRspUserLogin(object sender, IntEventArgs e) { //交易日历,需每年更新 _dataProcess.UpdateInfo(); _tradingDate = _dataProcess.TradeDates; //隔夜处理,夜盘开始后需重新订阅. foreach (var stra in _dicStrategies.Values) { if (!stra.EnableTick) { continue; } foreach (var data in stra.Datas) { LogInfo($"订阅行情{data.Instrument}"); SubscribeInstrument(data.Instrument); SubscribeInstrument(data.InstrumentOrder); } } LogWarn("行情登录成功"); QuoteLogged(); }
private void _q_OnRspUserLogin(object sender, IntEventArgs e) { if (e.Value == 0) { Log($"登录成功:{_investor}"); _q.ReqSubscribeMarketData(_sub1); //"rb1705", "cu1705" "SR709", "m1709", "sr1709" Log("等待行情数据"); // _q.ReqSubscribeForQuoteRsp("SR1709", "M1709"); // _q.ReqDepthMarketData(_sub1); // String data = _q.ReqSubscribeMarketData(_sub1).ToString(); //Log($"Start:::::{data}"); } else { //_q.OnFrontConnected -= _q_OnFrontConnected; //解决登录错误后不断重连导致再不断登录的错误 Log($"登录错误:{e.Value}"); _q.ReqUserLogout(); } }
//登录响应 private void RspLogin(object sender, IntEventArgs e) { var t = (Trade)sender; ShowMsg($"[{_investor}]登录:{e.Value}"); if (e.Value == 0) { FutureBroker svr = (this.comboBoxServer.DataSource as BindingSource).Current as FutureBroker; if (svr == null) { ShowMsg("前置配置为空无法登录行情"); return; } _q = new CTPQuote(); _q.OnFrontConnected += (snd, ea) => { ShowMsg($"行情连接成功"); _q.ReqUserLogin(_investor, _password, svr.Broker); }; _q.OnRspUserLogin += (snd, ea) => { foreach (var v in _t.DicPositionField.Values) { ((Quote)snd).ReqSubscribeMarketData(v.InstrumentID); } ShowMsg($"行情登录成功"); LogSucceed(); }; _q.OnRtnTick += this.OnTick; _q.OnRspUserLogout += (snd, ea) => { ShowMsg($"[{_broker}]行情退出:{ea.Value}"); }; _q.ReqConnect($"tcp://{svr.QuoteIP}:{svr.QuotePort}"); } }
private void _t_OnRspUserLogout(object sender, IntEventArgs e) { Log("t: logout:" + e.Value); }
private void quote_OnRspUserLogout(object sender, IntEventArgs e) { _dicTick000.Clear(); LogError($"行情断开,{e.Value,4}"); }
private void _q_OnRtnForQuoteRsp(object sender, IntEventArgs e) { Log($"data::::::{e.Value}"); }
private void TradeExt_OnRspUserLogout(object sender, IntEventArgs e) { ShowInfo($"logout:{e.Value}"); }
private void _q_OnRspUserLogout(object sender, IntEventArgs e) { Log($"quote logout: {e.Value}"); }
private void _q_OnRspRtnDepthMarketData(object sender, IntEventArgs e) { Log($"data::::::{e.Value}"); }