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 doBreakThrough() { if (maxCount == 2 && !doBTUp) { richTextBox1.Text += "\r\n 最高价突破,执行买入。"; w.torder(rwCode, "Buy", ((double[])wsqData.data)[0], volume, ""); maxCount = 0; doBTUp = true; } else if (minCount == 2 && !doBTDown) { richTextBox1.Text += "\r\n 最低价突破,执行卖出。"; w.torder(rwCode, "Sell", ((double[])wsqData.data)[0], volume, ""); minCount = 0; } }