Ejemplo n.º 1
0
        private void StockCheckProcess()
        {
            while (cIsRunning)
            {

                if (DateTime.Now.DayOfWeek == DayOfWeek.Friday || DateTime.Now.DayOfWeek == DayOfWeek.Saturday)
                {
                    Write("금요일 저녁, 토요일 저녁은 검색안함.");
                    Thread.Sleep(1000 * 60 * 5);
                    continue;
                }

                if(DateTime.Now.Day != cProcDay && (19 <= DateTime.Now.Hour && DateTime.Now.Hour < 23))
                {
                    cProcDay = DateTime.Now.Day;

                    //매수하라고 등록되어있지만 그날 매수하지 않은 종목은 DB에서 삭제한다.
                    StockDB mSD2 = new StockDB();
                    mSD2.DelBuyList();
                    mSD2 = null;

                    StockDB mSD = new StockDB();

                    if (true)
                    {
                        #region 매수/매도 목록 검색후 XmlDB 업데이트==========================================================================================

                        if (true)
                        {
                            #region 초기화
                            ProcStockCheck.InitStockTrend();
                            #endregion

                            #region 다음증권 사이트에서 패턴을 분석할 주식종목을 테마별로 검색

                            #region 코스피 /코스닥 전종목 검색

                            Write("코스피 전종목 코드검색..");
                            string[] mStocks_P = GetAllStockPageP_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }


                            Write("코스닥 전종목 코드검색..");
                            string[] mStocks_Q = GetAllStockPageQ_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            #endregion

                            #region 코스피 /코스닥 상승종목 검색

                            Write("코스피 상승종목 코드검색..");
                            string[] mStocksUP_P = GetUpStockPageP_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            Write("코스닥 상승종목 코드검색..");
                            string[] mStocksUP_Q = GetUpStockPageQ_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            #endregion

                            #region 코스피 /코스닥 거래량탑종목 검색

                            Write("코스피 거래량탑종목 코드검색..");
                            string[] mStocksTOP_P = GetTopStockPageP_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            Write("코스닥 거래량탑종목 코드검색..");
                            string[] mStocksTOP_Q = GetTopStockPageQ_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            #endregion

                            #region 코스피 /코스닥 상한가종목 검색

                            Write("코스피 전날상한가종목 코드검색..");
                            string[] mStocksTTOP_P = GetTTopStockPageP_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            Write("코스닥 전날상한가종목 코드검색..");
                            string[] mStocksTTOP_Q = GetTTopStockPageQ_StockCode();
                            Thread.Sleep(cThreadSleepTime);
                            if (!cIsRunning) { break; }

                            #endregion

                            #endregion

                            #region 검색된 주식목록에 매수패턴과 매도패턴을 대입하여 일치하는 데이타를 찾아낸다.

                            #region 코스피 전날상한가종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksTTOP_P.Length; k++)
                            {
                                Write("코스피 전날상한가종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksTTOP_P[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTTOP_P[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksTTOP_P[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTTOP_P[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksTTOP_P[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion

                            #region 코스닥 전날상한가종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksTTOP_Q.Length; k++)
                            {
                                Write("코스닥 전날상한가종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksTTOP_Q[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTTOP_Q[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksTTOP_Q[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTTOP_Q[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksTTOP_Q[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion


                            #region 코스피 전종목을 검색하여 패턴대입

                            for (int k = 0; k < mStocks_P.Length; k++)
                            {
                                Write("코스피 전종목을 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocks_P[k] == null) { break; }
                                mStocks_P[k] = "046120";
                                for (int i = 1; i <= 5; i++)
                                {

                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocks_P[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocks_P[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocks_P[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocks_P[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion

                            #region 코스닥 전종목을 검색하여 패턴대입

                            for (int k = 0; k < mStocks_Q.Length; k++)
                            {
                                Write("코스닥 전종목을 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocks_Q[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocks_Q[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocks_Q[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocks_Q[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocks_Q[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion


                            #region 코스피 전일상승종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksUP_P.Length; k++)
                            {
                                Write("코스피 전일상승종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksUP_P[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksUP_P[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksUP_P[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksUP_P[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksUP_P[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion

                            #region 코스닥 전일상승종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksUP_Q.Length; k++)
                            {
                                Write("코스닥 전일상승종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksUP_Q[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksUP_Q[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksUP_Q[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksUP_Q[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksUP_Q[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion


                            #region 코스피 거래량탑종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksTOP_P.Length; k++)
                            {
                                Write("코스피 거래량탑종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksTOP_P[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTOP_P[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksTOP_P[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTOP_P[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksTOP_P[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion

                            #region 코스닥 거래량탑종목 검색하여 패턴대입

                            for (int k = 0; k < mStocksTOP_Q.Length; k++)
                            {
                                Write("코스닥 거래량탑종목 검색하여 패턴대입");
                                if (!cIsRunning) { break; }
                                bool mIsError = true;
                                if (mStocksTOP_Q[k] == null) { break; }
                                for (int i = 1; i <= 5; i++)
                                {
                                    Thread.Sleep(cThreadSleepTime);
                                    mIsError = ProcStockCheck.SetStockTrend("http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTOP_Q[k] + "&modify=1");

                                    if (!mIsError) { Write(mStocksTOP_Q[k] + " 검색 도중 에러 : " + "http://stock.daum.net/item/quote_yyyymmdd_sub.daum?page=" + i.ToString() + "&code=" + mStocksTOP_Q[k] + "&modify=1"); break; }
                                }
                                if (!mIsError) { ProcStockCheck.ClearStockTrend(); continue; }

                                ProcStockCheck.SetStorkMake5Line();
                                ProcStockCheck.SetStorkMake10Line();
                                ProcStockCheck.SetStorkMake20Line();

                                BuyReservStock(mStocksTOP_Q[k]);

                                ProcStockCheck.ClearStockTrend();

                                SetBuyList();
                            }

                            #endregion


                            #endregion
                        }

                        SelReservStock();

                        #endregion
                        Thread.Sleep(cThreadSleepTime);
                    }

                    if (true)
                    {
                        #region HTS 프로그램 매수/매도 실행=================================================================================================

                        KeyEnter();
                        Thread.Sleep(10000);

                        Thread.Sleep(cThreadSleepTime);
                        SetCursorPos(cCursorX, cCursorY);

                        //거래비밀번호 입력처리
                        MoveMouse(cPasswordX, cPasswordY);
                        MouseLeftClick();
                        KeyWrite("0809");

                        #region 매도할 종목
                        Write("매도 종목 검색");
                        cSellTb = mSD.SelListMustSell();
                        for (int i = 0; i < cSellTb.Rows.Count; i++)
                        {
                            int mIdx = Convert.ToInt32(cSellTb.Rows[i]["Index"].ToString());
                            string mStockCode = cSellTb.Rows[i]["Code"].ToString();
                            string mStockCost = "0";
                            try
                            {
                                mStockCost = cSellTb.Rows[i]["SellCost"].ToString();
                            }
                            catch
                            {
                            }
                            string mCount = cSellTb.Rows[i]["Count"].ToString();
                            string mStockBuyPatternCode = cSellTb.Rows[i]["BuyPatternCode"].ToString();

                            string mBuyPC = mStockBuyPatternCode.Substring(0, 1);

                            //종목코드 입력
                            MoveMouse(cStockCodeX, cStockCodeY);
                            MouseLeftClick();
                            KeyWrite(mStockCode);

                            //라디오 매도 체크
                            MoveMouse(cRdoSellX, cRdoSellY);
                            MouseLeftClick();

                            //if (mBuyPC == "3")
                            //{
                            //    //시장가 선택
                            //    MoveMouse(cPriceTypeX, cPriceTypeY);
                            //    MouseLeftClick();
                            //    MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                            //    MouseLeftClick();
                            //}
                            //else
                            //{
                            //    MoveMouse(cPriceTypeX, cPriceTypeY);
                            //    MouseLeftClick();
                            //    MoveMouse(cPriceTypeX, cPriceTypeY + 15);
                            //    MouseLeftClick();

                            //    //매도가격 입력
                            //    MoveMouse(cBuyCostX, cBuyCostY);
                            //    MouseLeftClick();
                            //    KeyWrite(mStockCost);
                            //}

                            //시장가 선택 (무조건 시장가로)
                            MoveMouse(cPriceTypeX, cPriceTypeY);
                            MouseLeftClick();
                            MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                            MouseLeftClick();

                            //매도수량 입력
                            MoveMouse(cBuyCountX, cBuyCountY);
                            MouseLeftClick();
                            KeyWrite(mCount);



                            //버튼클릭
                            MoveMouse(cBuyBtnX, cBuyBtnY);
                            MouseLeftClick();
                            Thread.Sleep(3000);

                            KeyEnter();
                            Thread.Sleep(7000);

                            mSD.UpdSellComplete(mIdx);
                            SetMyList();
                        }
                        #endregion

                        #region 매수할 종목
                        Write("매수 종목 검색");
                        //하루에 3개종목까지만 매수하고 총 10개 이하 종목으로 유지한다.
                        int mTodayBuyCnt = 1;
                        DataTable mProfitOrder = mSD.SelListBuyPatternReport();
                        for (int m = 0; m < mProfitOrder.Rows.Count; m++)
                        {
                            cBuyTb = mSD.SelListMustBuy(mProfitOrder.Rows[m]["KEY"].ToString());
                            for (int i = 0; i < cBuyTb.Rows.Count; i++)
                            {
                                if (mSD.GetMyStock() >= 10) { break; } //내가 보유한종목이 10개 이상이면 매수 중단.
                                if (mTodayBuyCnt >= 3) { break; } else { mTodayBuyCnt++; } //오늘 매수종목이 3개 이상이면 매수 중단.
                                int mIdx = Convert.ToInt32(cBuyTb.Rows[i]["Index"].ToString());
                                string mStockCode = cBuyTb.Rows[i]["Code"].ToString();
                                string mStockCost = cBuyTb.Rows[i]["BuyCost"].ToString();
                                string mCount = cBuyTb.Rows[i]["Count"].ToString();
                                string mStockBuyPatternCode = cBuyTb.Rows[i]["BuyPatternCode"].ToString();

                                string mBuyPC = mStockBuyPatternCode.Substring(0, 1);

                                //종목코드 입력
                                MoveMouse(cStockCodeX, cStockCodeY);
                                MouseLeftClick();
                                KeyWrite(mStockCode);

                                //라디오 매수 체크
                                MoveMouse(cRdoBuyX, cRdoBuyY);
                                MouseLeftClick();

                                //if (mBuyPC == "3")
                                //{
                                //    //시장가 선택
                                //    MoveMouse(cPriceTypeX, cPriceTypeY);
                                //    MouseLeftClick();
                                //    MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                                //    MouseLeftClick();
                                //}
                                //else
                                //{
                                //    //시장가 선택
                                //    MoveMouse(cPriceTypeX, cPriceTypeY);
                                //    MouseLeftClick();
                                //    MoveMouse(cPriceTypeX, cPriceTypeY + 15);
                                //    MouseLeftClick();

                                //    //구매가격 입력
                                //    MoveMouse(cBuyCostX, cBuyCostY);
                                //    MouseLeftClick();
                                //    KeyWrite(mStockCost);
                                //}


                                //시장가 선택(무조건 시장가로)
                                MoveMouse(cPriceTypeX, cPriceTypeY);
                                MouseLeftClick();
                                MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                                MouseLeftClick();

                                //구매수량 입력
                                MoveMouse(cBuyCountX, cBuyCountY);
                                MouseLeftClick();
                                KeyWrite(mCount);

                                //버튼클릭
                                MoveMouse(cBuyBtnX, cBuyBtnY);
                                MouseLeftClick();
                                Thread.Sleep(2000);

                                KeyEnter();
                                Thread.Sleep(3000);

                                mSD.UpdBuyComplete(mIdx);
                                SetMyList();
                            }
                        }
                        mProfitOrder = null;
                        mTodayBuyCnt = 1;
                        cBuyTb = mSD.SelListMustBuy();                        
                        for (int i = 0; i < cBuyTb.Rows.Count; i++)
                        {
                            if (mSD.GetMyStock() >= 10) { break; } //내가 보유한종목이 10개 이상이면 매수 중단.
                            if (mTodayBuyCnt >= 3) { break; } else { mTodayBuyCnt++; } //오늘 매수종목이 3개 이상이면 매수 중단.
                            int mIdx = Convert.ToInt32(cBuyTb.Rows[i]["Index"].ToString());
                            string mStockCode = cBuyTb.Rows[i]["Code"].ToString();
                            string mStockCost = cBuyTb.Rows[i]["BuyCost"].ToString();
                            string mCount = cBuyTb.Rows[i]["Count"].ToString();
                            string mStockBuyPatternCode = cBuyTb.Rows[i]["BuyPatternCode"].ToString();

                            string mBuyPC = mStockBuyPatternCode.Substring(0, 1);

                            //종목코드 입력
                            MoveMouse(cStockCodeX, cStockCodeY);
                            MouseLeftClick();
                            KeyWrite(mStockCode);

                            //라디오 매수 체크
                            MoveMouse(cRdoBuyX, cRdoBuyY);
                            MouseLeftClick();

                            //if (mBuyPC == "3")
                            //{
                            //    //시장가 선택
                            //    MoveMouse(cPriceTypeX, cPriceTypeY);
                            //    MouseLeftClick();
                            //    MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                            //    MouseLeftClick();
                            //}
                            //else
                            //{
                            //    //시장가 선택
                            //    MoveMouse(cPriceTypeX, cPriceTypeY);
                            //    MouseLeftClick();
                            //    MoveMouse(cPriceTypeX, cPriceTypeY + 15);
                            //    MouseLeftClick();

                            //    //구매가격 입력
                            //    MoveMouse(cBuyCostX, cBuyCostY);
                            //    MouseLeftClick();
                            //    KeyWrite(mStockCost);
                            //}


                            //시장가 선택(무조건 시장가로)
                            MoveMouse(cPriceTypeX, cPriceTypeY);
                            MouseLeftClick();
                            MoveMouse(cPriceTypeX, cPriceTypeY + 30);
                            MouseLeftClick();

                            //구매수량 입력
                            MoveMouse(cBuyCountX, cBuyCountY);
                            MouseLeftClick();
                            KeyWrite(mCount);

                            //버튼클릭
                            MoveMouse(cBuyBtnX, cBuyBtnY);
                            MouseLeftClick();
                            Thread.Sleep(2000);

                            KeyEnter();
                            Thread.Sleep(3000);

                            mSD.UpdBuyComplete(mIdx);
                            SetMyList();
                        }
                        #endregion


                        
                        #endregion
                        Thread.Sleep(cThreadSleepTime);
                    }

                    SetReport();
                    SetSelReport();
                    SetSuik();

                    mSD = null;
                }
                else
                {
                    Write("19:00~23:00시가 될때까지 대기중");
                    Thread.Sleep(1000*60*30);
                }

            }
        }
Ejemplo n.º 2
0
        void ProcSupping()
        {
            while (C_IsRunning)
            {
                if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
                {
                    Write("토요일,일요일 작업중지");
                    Thread.Sleep(C_ThreadSleepTime);
                    continue;
                }

                if (DateTime.Now.Day != C_ProcDay && (2 <= DateTime.Now.Hour && DateTime.Now.Hour <= 6))
                {
                    C_ProcDay = DateTime.Now.Day;
                    return;//테스트용

                    KeyEnter();
                    Thread.Sleep(1000);

                    Thread.Sleep(C_ThreadSleepTime);
                    SetCursorPos(C_CursorX, C_CursorY);

                    //거래비밀번호 입력처리
                    MoveMouse(POINT_PASSWORD_X, POINT_PASSWORD_Y);
                    MouseLeftClick();
                    KeyWrite("0809");

                    StockDB mSD = new StockDB();

                    #region 매수할 종목
                    Write("매수 종목 검색");
                    C_BuyTb = mSD.SelListMustBuy();
                    for (int i = 0; i < C_BuyTb.Rows.Count; i++)
                    {
                        if (mSD.GetMyStock() >= 10) { break; } //내가 보유한종목이 10개 이상이면 매수 중단.
                        int mIdx = Convert.ToInt32(C_BuyTb.Rows[i]["Index"].ToString());
                        string mStockCode = C_BuyTb.Rows[i]["Code"].ToString();
                        string mStockCost = C_BuyTb.Rows[i]["BuyCost"].ToString();
                        string mCount = C_BuyTb.Rows[i]["Count"].ToString();

                        //종목코드 입력
                        MoveMouse(POINT_STOCKCODE_X, POINT_STOCKCODDE_Y);
                        MouseLeftClick();
                        KeyWrite(mStockCode);

                        //라디오 매수 체크
                        MoveMouse(POINT_RDOBUY_X, POINT_RDOBUY_Y);
                        MouseLeftClick();

                        //구매수량 입력
                        MoveMouse(POINT_BUYCOUNT_X, POINT_BUYCOUNT_Y);
                        MouseLeftClick();
                        KeyWrite(mCount);

                        //구매수량 입력
                        MoveMouse(POINT_BUYCOST_X, POINT_BUYCOST_Y);
                        MouseLeftClick();
                        KeyWrite(mStockCost);

                        //버튼클릭
                        MoveMouse(POINT_BUYBTN_X, POINT_BUYBTN_Y);
                        MouseLeftClick();
                        Thread.Sleep(2000);

                        KeyEnter();
                        Thread.Sleep(3000);

                        mSD.UpdBuyComplete(mIdx);
                    }
                    #endregion

                    #region 매도할 종목
                    Write("매도 종목 검색");
                    C_SellTb = mSD.SelListMustSell();
                    for (int i = 0; i < C_SellTb.Rows.Count; i++)
                    {
                        int mIdx = Convert.ToInt32(C_SellTb.Rows[i]["Index"].ToString());
                        string mStockCode = C_SellTb.Rows[i]["Code"].ToString();
                        string mStockCost = C_SellTb.Rows[i]["SellCost"].ToString();
                        string mCount = C_SellTb.Rows[i]["Count"].ToString();

                        //종목코드 입력
                        MoveMouse(POINT_STOCKCODE_X, POINT_STOCKCODDE_Y);
                        MouseLeftClick();
                        KeyWrite(mStockCode);

                        //라디오 매수 체크
                        MoveMouse(POINT_RDOSELL_X, POINT_RDOSELL_Y);
                        MouseLeftClick();

                        //매도수량 입력
                        MoveMouse(POINT_BUYCOUNT_X, POINT_BUYCOUNT_Y);
                        MouseLeftClick();
                        KeyWrite(mCount);

                        //매도가격 입력
                        MoveMouse(POINT_BUYCOST_X, POINT_BUYCOST_Y);
                        MouseLeftClick();
                        KeyWrite(mStockCost);

                        //버튼클릭
                        MoveMouse(POINT_BUYBTN_X, POINT_BUYBTN_Y);
                        MouseLeftClick();
                        Thread.Sleep(3000);

                        KeyEnter();
                        Thread.Sleep(7000);

                        mSD.UpdSellComplete(mIdx);
                    }
                    #endregion

                    mSD = null;
                }
                else
                {
                    Write("02시까지 대기중 : " + DateTime.Now.ToString());
                    KeyEnter();
                    Thread.Sleep(10000);


                    //테스트용
                    SetCursorPos(C_CursorX, C_CursorY);

                    Random random = new Random();
                    int mUp = random.Next(100, 1000);
                    int mDn = random.Next(100, 1000);
                    MoveMouse(mUp, mDn);
                    mUp = random.Next(100, 1000);
                    mDn = random.Next(100, 1000);
                    MoveMouse(mUp, mDn);
                }


            }
        }