Ejemplo n.º 1
0
 public Form1()
 {
     InitializeComponent();
     init();
     class1 = AppLib.getClass1Instance();
     class1.setAxKHOpenAPIInstance(this.axKHOpenAPI);
 }
Ejemplo n.º 2
0
 public static AppLib getClass1Instance() {
     if (_multiThread == false) {
         if (_class1 == null) {
             _class1 = new AppLib();
         }               
     }else{
         if (_class1 == null) {
             lock (_object1) {
                 _class1 = new AppLib();
             }
         }                
     }
     return _class1;
 }
Ejemplo n.º 3
0
        private void autoSale(OPT10085_Data opt10085_data)
        {
            FileLog.PrintF("autoSale loss_status=>" + loss_status + ",loss_rate=>" + loss_rate + ",종목코드=>" + opt10085_data.종목코드 + ",손익율=>" + opt10085_data.손익율 + ",주문상태=>" + opt10085_data.주문상태);
            //주식체결 정보가 들어와서 주식 현재가가 변동이 있을때 자동 판매로직이 실행됨
            /*손절매*/
            if (loss_status == true)
            {
                if (opt10085_data.손익율 <= this.loss_rate && opt10085_data.주문상태 == 1)//주문상태가 1 즉 보여상태이어야한다.
                {
                    if (MyOrder.getClass1Instance().ExistsOrder(opt10085_data.종목코드) == false)
                    {
                        //매도주문

                        int    nOrderType  = 2;//신규메도
                        String sCode       = opt10085_data.종목코드;
                        String sScreenNo   = ScreenNumber.getClass1Instance().GetAnyTimeScrNum();
                        int    nQty        = opt10085_data.보유수량;
                        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.주문상태 = 2;
                        dbUpdateOrderStatus(opt10085_data);
                    }
                }
            }
            /*이익실현*/
            if (profit_status == true)
            {
                if (opt10085_data.손익율 >= this.profit_rate && opt10085_data.주문상태 == 1)//주문상태가 1 즉 보여상태이어야한다.
                {
                    //매도주문
                    if (MyOrder.getClass1Instance().ExistsOrder(opt10085_data.종목코드) == false)
                    {
                        int    nOrderType  = 2;//신규메도
                        String sCode       = opt10085_data.종목코드;
                        int    nQty        = opt10085_data.보유수량;
                        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.주문상태 = 2;
                        dbUpdateOrderStatus(opt10085_data);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        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분이면 압축이 되겠지???
            }
        }