public void closePriceQuote() { short istatus = quoteCom.RetriveClosePrice(); if (istatus < 0) { Console.WriteLine(quoteCom.GetSubQuoteMsg(istatus)); } }
public static void initial() { msg Quotemsg = new msg(); while (Login.kgiquote_test_mode == 2) Thread.Sleep(1000); if (Login.kgiquote_test_mode == 1)// 12 idx { int counter = 0; string line; string[] tradedata; Console.WriteLine("Study mode.\nDon't connect to Kgi server."); Console.WriteLine("Load r:\\taitest.txt"); System.IO.StreamReader file = new System.IO.StreamReader("r:\\taitest.txt"); while ((line = file.ReadLine()) != null) { tradedata = line.Split(' '); msg.kgitrademin_p[counter] = int.Parse(tradedata[1]); msg.kgitrademin_v[counter] = int.Parse(tradedata[2]); counter++; } msg.kgi_idx = counter; } if (Login.kgiquote_test_mode == 3)// all tick { Thread simticksrvinit = new Thread(msg.simtick_init); simticksrvinit.Start(); } else if (Login.kgiquote_test_mode == 0) // Real Trade { quoteCom = new Intelligence.QuoteCom(Login.Srv("Q"), Login.Port, "API", "b6eb"); // Host changed on Oct/01/2014 quoteCom.OnRcvMessage += Quotemsg.OnQuoteRcvMessage; quoteCom.OnGetStatus += Quotemsg.OnQuoteGetStatus; quoteCom.OnRecoverStatus += Quotemsg.OnRecoverStatus; quoteCom.OnRcvServerTime += Quotemsg.OnRcvServerTime; //接收主機時間 quoteCom.SourceId = "API"; while (true) { while (msg.kgiQuotesrv == false) { quoteCom.Connect2Quote(Login.Srv("Q"), Login.Port, Login.ID, Login.PW(), ' ', "TW."+ Login.tradeobj); Console.WriteLine("Register Trade Obj : " + "TW." + Login.tradeobj); Console.WriteLine("Kgi srv try con."); Thread.Sleep(3000); if (msg.kgiQuotesrv == true) { msg.kgisrv_wdg = true; Console.WriteLine("Kgi srv connected"); } } Thread.Sleep(1000); if (msg.kgi_idx >= 0) { while (msg.kgisrv_wdg) { msg.kgisrv_wdg = false; msg.kgiQuotesrv = false; Thread.Sleep(8000); } Console.WriteLine("Kgi srv WDG false"); short wdgtest = quoteCom.RetriveClosePrice(); } if (msg.kginowidx >= 1400) { Console.WriteLine("Trade Time is end !"); while (msg.kginowidx >= 1400) Thread.Sleep(10000); } Thread.Sleep(1000); } } }