public void DoIt() { string strErrorMsg; WindAPI w = new WindAPI(); //登录WFT int nRetCode = w.start(); if (0 != nRetCode)//登录失败 { strErrorMsg = w.getErrorMsg(nRetCode); Console.Write(strErrorMsg); return; } //登录账号 Console.Write("\r\ntlogon……"); WindData wd = w.tlogon("0000", "0", "w081496501", "******", "SHSZ"); string strLogonId = wd.GetLogonId(); wd = w.tquery("Trade"); return; //下单浦发银行 wd = w.torder("600000.SH", "Buy", "12.0", "200", "OrderType=LMT;LogonID=" + strLogonId);//单账户登录可以不指定LogonId=1 //获取下单ID string strRequestID1 = wd.GetOrderRequestID(); Console.WriteLine("RequestID=" + strRequestID1); //下单白云机场 wd = w.torder("600004.SH", "Buy", "12.00", "300", "OrderType=LMT;LogonID=" + strLogonId);//单账户登录可以不指定LogonId=1 //获取下单ID string strRequestID2 = wd.GetOrderRequestID(); //查询 Console.WriteLine("query……"); wd = w.tquery("Order", "RequestID=" + strRequestID1); //获取浦发银行OrderNumber string strOrderNumber = wd.GetOrderNumber(); //浦发银行撤单 Console.WriteLine("cancel……"); wd = w.tcancel(strOrderNumber); //再次查询 Console.WriteLine("query after cancel……"); wd = w.tquery("Order"); string strQueryInfoAfter = WindDataMethod.WindDataToString(wd, "tquery"); Console.Write(strQueryInfoAfter); //登出 Console.WriteLine("tlogout……"); w.tlogout(); //退出WindAPI w.stop(); }
private void button2_Click(object sender, EventArgs e) { string windCode = textBox4.Text; string svolume = textBox3.Text; if (!int.TryParse(svolume, out volume)) { volume = 100; } WindData wd = w.wsi(windCode, "open", DateTime.Today.AddHours(9.5), DateTime.Now, "BarSize=1"); if (wd.errorCode != 0) { richTextBox1.Text += "\r\n"; richTextBox1.Text += w.getErrorMsg(wd.errorCode); return; } open = (float)((double[])wd.data)[0]; Kmin = open; Kmax = 0; w.cancelRequest(rid); updateKLines(windCode); label4.Text = "当前价"; label7.Text = "K线最高价"; label7.ForeColor = Color.Red; label8.Text = "K线最低价"; label8.ForeColor = Color.Green; label13.Text = "开盘价"; label13.ForeColor = Color.SkyBlue; label14.Text = Convert.ToString(open); label14.ForeColor = Color.SkyBlue; //label11.Text = "5分钟K线图"; //label12.Text = "15分钟K线图"; //label11.ForeColor = myPens[0].Color; //label12.ForeColor = myPens[1].Color; label5.Text = windCode + " 最近15分钟价格走势图"; //for (int i = 1; i < allLabels.Count; i++) //{ // Controls.Add((Label)allLabels[i]); // ((Label)allLabels[i]).BringToFront(); //} }
public WDErrorException(WindAPI _w, int ErrorCode) { this.WDErrorCode = ErrorCode; if (ErrList == null) { ErrList = new Dictionary <int, string>(); } if (ErrList.ContainsKey(ErrorCode)) { this._Message = ErrList[ErrorCode]; } else { this._Message = _w.getErrorMsg(ErrorCode); ErrList.Add(ErrorCode, this._Message); } }
/// <summary> /// 获取WindAPI,三次登录失败返回null /// </summary> /// <returns></returns> public static WindAPI GetApi() { WindAPI w = new WindAPI(); for (int i = 0; i < 3; i++) { //登录WFT int nRetCode = w.start(); if (0 != nRetCode)//登录失败 { var strErrorMsg = w.getErrorMsg(nRetCode); Logger.Write("登录WFT失败", strErrorMsg, string.Empty, string.Empty, LogLevel.Error, 0); } else { return(w); } } return(null); }
public static WindAPI getAPI() { if (api == null || !api.isconnected()) { api = new WindAPI(); try { int result = (int)api.start(); if (result == 0) { Console.WriteLine(" Wind API 登录成功!"); } else { Console.WriteLine(" Wind API 登录失败: " + api.getErrorMsg(result)); } } catch (Exception e) { Console.WriteLine(e); } } return(api); }