Exemple #1
0
        public string Process(string aOldRawid)
        {
            SqlDal sd = new SqlDal(cConnString);
            //List<string> lstStockCode = new List<string>();
            List <Thread> lstT = new List <Thread>();

            //lstStockCode = sd.GetAllStockCode();

            // 분봉 골드크로스/데드크로스 SIGNAL 발생처리//
            foreach (string sCode in gStockCodeList)
            {
                Thread tMaMin = new Thread(CheckSignal_MA_Minute);
                tMaMin.Start(sCode);
                lstT.Add(tMaMin);
            }

            foreach (Thread sT in lstT)
            {
                sT.Join();
            }
            ///////////////////////////////////////////////

            lstT.Clear();

            // 일봉 골드크로스/데드크로스 SIGNAL 발생처리//
            if (DateTime.Now.Hour == 9 && DateTime.Now.Minute == 20)
            {
                foreach (string sCode in gStockCodeList)
                {
                    Thread tMaMin = new Thread(CheckSignal_MA_Day);
                    tMaMin.Start(sCode);
                    lstT.Add(tMaMin);
                }

                foreach (Thread sT in lstT)
                {
                    sT.Join();
                }
            }
            ///////////////////////////////////////////////

            // 매수/매도 작업전에 현재 매수된 항목에 대한 매도이벤트 누락여부 검사 //

            DataSet dsCheckSellItem = sd.GetCheckSellItemBeforeBuy(gStockGroup);

            if (dsCheckSellItem != null && dsCheckSellItem.Tables.Count > 0 && dsCheckSellItem.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsCheckSellItem.Tables[0].Rows)
                {
                    string Rawid     = dr["RAWID"].ToString();
                    string DateChar  = dr["DateChar"].ToString();
                    string StockCode = dr["STOCKCODE"].ToString();
                    string BuyMethod = dr["buy_method"].ToString();

                    string TargetSellEvent = MakeSellWatchCode(BuyMethod);

                    if (sd.HasSellItem(DateChar, StockCode, TargetSellEvent))
                    {
                        sd.SellAction_OneByRawid(Rawid, StockCode);
                    }
                }
            }

            //////////////////////////////////////////////

            string retOldRawid = string.Empty;

            if (aOldRawid == null || aOldRawid.Length == 0)
            {
                this.oldRawid = "0";
            }
            else
            {
                this.oldRawid = aOldRawid;
            }

            DataSet dsCpWatch = sd.GetCpMarketWatch(oldRawid, gStockGroup);

            ChecknBuy(dsCpWatch);

            retOldRawid = getMaxRawid(dsCpWatch);
            return(retOldRawid);
        }