private static void CompressZip(string zipPath, string startsWith, string endsWith) { DirectoryInfo directorySelected = new DirectoryInfo(Config.GetPath()); //Directory.GetFiles(path,"*.txt",SearchOption.TopDirectoryOnly).Where(s=>s.StartsWith(startsWith)); FileInfo[] fileList = directorySelected.GetFiles(startsWith + "*" + endsWith + ".txt"); if (fileList.Count() > 0 && AppLib.getClass1Instance().getStockCodeList().Count() <= fileList.Count()) { //카운트가 맞을때만 압축하는것도 좋은 예지만 이것만으로는 TEXT파일에 끝까지데이터가 있다는걸 보장을 할수 없다. FileLog.PrintF("CompressZip zipPath=" + zipPath); FileLog.PrintF("CompressZip startsWith=" + startsWith); FileLog.PrintF("CompressZip endsWith=" + endsWith); using (FileStream zipToCreate = new FileStream(zipPath, FileMode.Create)) { using (ZipArchive archive = new ZipArchive(zipToCreate, ZipArchiveMode.Create)) { foreach (FileInfo fileToCompress in fileList) { archive.CreateEntryFromFile(fileToCompress.FullName, fileToCompress.Name); } } } } }
public static void threadJob(OpenApi.Spell.SpellOpt spellOpt) { List <String> stockCodeList = AppLib.getClass1Instance().getStockCodeList(); for (int i = 0; i < stockCodeList.Count; i++) { OpenApi.Spell.SpellOpt tmp = spellOpt.ShallowCopy(); String stockCode = stockCodeList[i]; String sScrNo = ScreenNumber.getClass1Instance().GetEosScrNum(); String keyStockCodeLayout = "sRQName:{0}|sTrCode:{1}|sScreenNo:{2}"; String keyStockCode = String.Format(keyStockCodeLayout , tmp.sRQNAME , tmp.sTrCode , sScrNo ); String keyLayout = "sRQName:{0}|sTrCode:{1}|sScreenNo:{2}|stockCode:{3}"; String key = String.Format(keyLayout , tmp.sRQNAME , tmp.sTrCode , sScrNo , stockCode ); tmp.sScreenNo = sScrNo; tmp.stockCode = stockCode; tmp.key = key; tmp.reportGubun = "FILE"; // FileLog.PrintF("threadJob keyStockCode="+ keyStockCode); // FileLog.PrintF("threadJob key=" + key); //String logDate = DateTime.Today.ToString("yyyyMMdd"); if (!(System.IO.File.Exists(Config.GetPath() + tmp.GetZipFileName()) || System.IO.File.Exists(Config.GetBackUpPath() + tmp.GetZipFileName()))) { // FileLog.PrintF("threadJob zipPath=" + zipPath); if (!System.IO.File.Exists(Config.GetPath() + tmp.GetFileName())) { // FileLog.PrintF("threadJob path=" + path); AppLib.getClass1Instance().EnqueueByOrderQueue(tmp); AppLib.getClass1Instance().AddSpellDictionary(key, tmp); AppLib.getClass1Instance().AddStockCodeDictionary(keyStockCode, stockCode); AppLib.getClass1Instance().InCraeteOrderedCodeCount(); } } } }
private void autoSale(TB_OPT10085 opt10085_data) { FileLog.PrintF("autoSale loss_status=>" + loss_status + ",loss_rate=>" + loss_rate + ",종목코드=>" + opt10085_data.stock_cd + ",손익율=>" + opt10085_data.profit_loss_rt + ",주문상태=>" + opt10085_data.order_status); //주식체결 정보가 들어와서 주식 현재가가 변동이 있을때 자동 판매로직이 실행됨 /*손절매*/ if (loss_status == true) { if (opt10085_data.profit_loss_rt <= this.loss_rate && opt10085_data.order_status == 1)//주문상태가 1 즉 보여상태이어야한다. { if (MyOrder.getClass1Instance().ExistsOrder(opt10085_data.stock_cd) == false) { //매도주문 int nOrderType = 2;//신규메도 String sCode = opt10085_data.stock_cd; String sScreenNo = ScreenNumber.getClass1Instance().GetAnyTimeScrNum(); int nQty = opt10085_data.possession_qty; int nPrice = 0; //일단 시장가매도하자. String sHogaGb = "03"; //시장가 매도 String sOrgOrderNo = ""; //원주문번호는 공백 FileLog.PrintF("autoSale sScreenNo=>" + sScreenNo); FileLog.PrintF("autoSale accountNumber=>" + accountNumber); FileLog.PrintF("autoSale nOrderType=>" + nOrderType); FileLog.PrintF("autoSale sCode=>" + sCode); FileLog.PrintF("autoSale nQty=>" + nQty); FileLog.PrintF("autoSale nPrice=>" + nPrice); FileLog.PrintF("autoSale sHogaGb=>" + sHogaGb); FileLog.PrintF("autoSale sOrgOrderNo=>" + sOrgOrderNo); //아 이거 1초에 5번 즉 0.2초 제한이 여기도 있다. ㅠㅠ이렇게 바로 보내면 안된다... int ret = AppLib.getClass1Instance().getAxKHOpenAPIInstance().SendOrder("손절매_매도주문", sScreenNo, accountNumber, nOrderType, sCode, nQty, nPrice, sHogaGb, sOrgOrderNo); FileLog.PrintF("MyStock AutoSale ret=>" + ret); //상태가 하나더 있어야겠다 주문접수를 한상태인거는 다시 매도를 시도하면 안되므로 opt10085_data.order_status = 2; dbUpdateOrderStatus(opt10085_data); } } } /*이익실현*/ if (profit_status == true) { if (opt10085_data.profit_loss_rt >= this.profit_rate && opt10085_data.order_status == 1) //주문상태가 1 즉 보여상태이어야한다. { //매도주문 if (MyOrder.getClass1Instance().ExistsOrder(opt10085_data.stock_cd) == false) { int nOrderType = 2;//신규메도 String sCode = opt10085_data.stock_cd; int nQty = opt10085_data.possession_qty; int nPrice = 0; //일단 시장가매도하자. String sHogaGb = "03"; //시장가 매도 String sOrgOrderNo = ""; //원주문번호는 공백 String sScreenNo = ScreenNumber.getClass1Instance().GetAnyTimeScrNum(); FileLog.PrintF("autoSale sScreenNo=>" + sScreenNo); FileLog.PrintF("autoSale accountNumber=>" + accountNumber); FileLog.PrintF("autoSale nOrderType=>" + nOrderType); FileLog.PrintF("autoSale sCode=>" + sCode); FileLog.PrintF("autoSale nQty=>" + nQty); FileLog.PrintF("autoSale nPrice=>" + nPrice); FileLog.PrintF("autoSale sHogaGb=>" + sHogaGb); FileLog.PrintF("autoSale sOrgOrderNo=>" + sOrgOrderNo); int ret = AppLib.getClass1Instance().getAxKHOpenAPIInstance().SendOrder("이익매_매도주문", sScreenNo, accountNumber, nOrderType, sCode, nQty, nPrice, sHogaGb, sOrgOrderNo); FileLog.PrintF("MyStock AutoSale ret=>" + ret); opt10085_data.order_status = 2; dbUpdateOrderStatus(opt10085_data); } } } }
public static void EOS_CompressZip() { while (true) { FileLog.PrintF("EOS_CompressZip"); //1. 주식일봉차트조회 string zipPath = Config.GetPath() + "OPT10081_" + AppLib.getClass1Instance().endDateEos + ".zip"; string zipCheckPath = Config.GetPath() + "OPT10081.dat"; string ftpCheckPath = Config.GetPath() + "OPT10081_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10081 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10081 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10081_", ""); DeleteFile(zipPath, "OPT10081_", ""); File.Move(zipCheckPath, ftpCheckPath); } } //2. 일별거래상세요청 zipPath = Config.GetPath() + "OPT10015_" + AppLib.getClass1Instance().endDateEos + ".zip"; zipCheckPath = Config.GetPath() + "OPT10015.dat"; ftpCheckPath = Config.GetPath() + "OPT10015_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10015 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10015 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10015_", ""); DeleteFile(zipPath, "OPT10015_", ""); File.Move(zipCheckPath, ftpCheckPath); } } //3. 종목별투자자기관별차트 zipPath = Config.GetPath() + "OPT10059_" + AppLib.getClass1Instance().endDateEos + "_1_1.zip"; zipCheckPath = Config.GetPath() + "OPT10059_1_1.dat"; ftpCheckPath = Config.GetPath() + "OPT10059_1_1_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10059_1_1 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10059_1_1 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10059_", "_1_1"); DeleteFile(zipPath, "OPT10059_", "_1_1"); File.Move(zipCheckPath, ftpCheckPath); } } zipPath = Config.GetPath() + "OPT10059_" + AppLib.getClass1Instance().endDateEos + "_1_2.zip"; zipCheckPath = Config.GetPath() + "OPT10059_1_2.dat"; ftpCheckPath = Config.GetPath() + "OPT10059_1_2_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10059_1_2 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10059_1_2 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10059_", "_1_2"); DeleteFile(zipPath, "OPT10059_", "_1_2"); File.Move(zipCheckPath, ftpCheckPath); } } zipPath = Config.GetPath() + "OPT10059_" + AppLib.getClass1Instance().endDateEos + "_2_1.zip"; zipCheckPath = Config.GetPath() + "OPT10059_2_1.dat"; ftpCheckPath = Config.GetPath() + "OPT10059_2_1_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10059_2_1 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10059_2_1 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10059_", "_2_1"); DeleteFile(zipPath, "OPT10059_", "_2_1"); File.Move(zipCheckPath, ftpCheckPath); } } zipPath = Config.GetPath() + "OPT10059_" + AppLib.getClass1Instance().endDateEos + "_2_2.zip"; zipCheckPath = Config.GetPath() + "OPT10059_2_2.dat"; ftpCheckPath = Config.GetPath() + "OPT10059_2_2_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10059_2_2 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10059_2_2 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10059_", "_2_2"); DeleteFile(zipPath, "OPT10059_", "_2_2"); File.Move(zipCheckPath, ftpCheckPath); } } //4. 공매도추이요청 zipPath = Config.GetPath() + "OPT10014_" + AppLib.getClass1Instance().endDateEos + ".zip"; zipCheckPath = Config.GetPath() + "OPT10014.dat"; ftpCheckPath = Config.GetPath() + "OPT10014_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10014 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10014 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10014_", ""); DeleteFile(zipPath, "OPT10014_", ""); File.Move(zipCheckPath, ftpCheckPath); } } //5. 주식일봉차트조회요청 zipPath = Config.GetPath() + "OPT10080_" + AppLib.getClass1Instance().endDateEos + ".zip"; zipCheckPath = Config.GetPath() + "OPT10080.dat"; ftpCheckPath = Config.GetPath() + "OPT10080_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10080 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10080 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10080_", ""); DeleteFile(zipPath, "OPT10080_", ""); File.Move(zipCheckPath, ftpCheckPath); } } //5. 주식일봉차트조회요청 zipPath = Config.GetPath() + "OPT10001_" + AppLib.getClass1Instance().endDateEos + ".zip"; zipCheckPath = Config.GetPath() + "OPT10001.dat"; ftpCheckPath = Config.GetPath() + "OPT10001_FTP.dat"; if (File.Exists(zipPath) == false) { if (File.Exists(zipCheckPath)) { FileLog.PrintF("EOS_CompressZip OPT10001 zipPath=" + zipPath); FileLog.PrintF("EOS_CompressZip OPT10001 zipCheckPath=" + zipCheckPath); CompressZip(zipPath, "OPT10001_", ""); DeleteFile(zipPath, "OPT10001_", ""); File.Move(zipCheckPath, ftpCheckPath); } } Thread.Sleep(300000);//5분이면 압축이 되겠지??? } }