Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string        dbConnString   = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.48)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(sid=cp2)));User Id=cybosplus;Password=miji1212;";
            List <string> gStockCodeList = new List <string>();

            gStockCodeList.Add("A114090");

            Genius g = new Genius(dbConnString, gStockCodeList, LogWrite);

            g.Process();
        }
Exemple #2
0
        private void myTimer_OnTick(object state)
        {
            try
            {
                myTimer.Stop();

                if (DateTime.Now.Hour == 7 && DateTime.Now.Minute == 0 && DateTime.Now.Second == 0)
                {
                    SqlDal sd = new SqlDal(dbConnString);
                    gStockCodeList = sd.GetStockCode(StockGroup);
                }
                else if (DateTime.Now.Second == int.Parse(ExeSecond))
                {
                    DateTime sDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 0, 0);
                    DateTime eDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 15, 0);

                    DateTime EndMarketSDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 45, 0);
                    DateTime EndMarketEDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 55, 0);

                    DateTime DailyAllSellDate    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 15, 10, 0);
                    DateTime ResetOrderStockDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0);

                    DateTime Date0930 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 30, 0);

                    //if (DateTime.Now.Hour == sDate.Hour && DateTime.Now.Minute == sDate.Minute)
                    //    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") + " : " + "Simulator 시작");

                    //if (DateTime.Now.Hour == eDate.Hour && DateTime.Now.Minute == eDate.Minute)
                    //    Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") + " : " + "Simulator 종료");

                    if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday ||
                        DateTime.Now.DayOfWeek == DayOfWeek.Sunday ||
                        isHoliday
                        )
                    {
                        //Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") + " : " + "주말에는 쉽니다");
                        myTimer.Start();
                        return;
                    }

                    // DATA BASED TRADING
                    if (DateTime.Now.Hour == int.Parse(INSERTTODAYTRADESUMMARY.Substring(0, 2)) &&
                        DateTime.Now.Minute == int.Parse(INSERTTODAYTRADESUMMARY.Substring(2, 2))
                        )
                    {
                        if (StockGroup == "GROUP1")
                        {
                            SqlDal sd = new SqlDal(dbConnString);
                            sd.InsertTodayTradeSummary();
                            flog.write(LogType.INFORMATION, "TradeSummary");

                            sd.ResetBalance();
                            flog.write(LogType.INFORMATION, "ResetBalance");

                            sd.SaveScoreMstHistory();
                            flog.write(LogType.INFORMATION, "SaveScoreMstHistory");
                        }
                    }
                    else if (DateTime.Now.Hour == ResetOrderStockDate.Hour && DateTime.Now.Minute == ResetOrderStockDate.Minute)
                    {
                        if (StockGroup == "GROUP1")
                        {
                            SqlDal sd = new SqlDal(dbConnString);
                            sd.ResetOrderStock();
                            flog.write(LogType.INFORMATION, "ResetOrderStock");
                        }
                    }
                    else if (DateTime.Now >= sDate &&
                             DateTime.Now < eDate
                             )
                    {
                        // StockCur 기반 매수여부 확인
                        //BANG.CYBOSPLUS.Trader.gini_STOCKCUR giniStockCur = new BANG.CYBOSPLUS.Trader.gini_STOCKCUR(dbConnString, gStockCodeList);
                        //giniStockCur.Process();

                        //BANG.CYBOSPLUS.Trader.gini_STOCKMST giniStockMst = new BANG.CYBOSPLUS.Trader.gini_STOCKMST(dbConnString, gStockCodeList);
                        //giniStockMst.Process();

                        if (DateTime.Now.Hour == DailyAllSellDate.Hour && DateTime.Now.Minute >= DailyAllSellDate.Minute)
                        {
                            SqlDal sd = new SqlDal(dbConnString);

                            if (sd.GetisDailyTrading())
                            {
                                sd.SellActionOverDay();
                                sd.SellAction1440();
                                flog.write(LogType.INFORMATION, "당일청산");
                            }
                            else
                            {
                                flog.write(LogType.INFORMATION, "당일청산 Flag=N");
                            }
                        }
                        else if (DateTime.Now < Date0930)
                        {
                            SqlDal sd = new SqlDal(dbConnString);

                            if (sd.GetisStopMinusSellIn0930())
                            {
                                sd.SellActionOverDay();
                                sd.SellActionIn0930();
                            }
                            else
                            {
                                Genius g = new Genius(dbConnString, gStockCodeList, LogWrite);
                                g.Process();

                                //System.Threading.Thread t = new System.Threading.Thread(g.Process);
                                //t.Start();
                            }
                        }
                        else
                        {
                            Genius g = new Genius(dbConnString, gStockCodeList, LogWrite);
                            g.Process();

                            //System.Threading.Thread t = new System.Threading.Thread(g.Process);
                            //t.Start();
                        }
                    }
                    else if (DateTime.Now >= EndMarketSDate &&
                             DateTime.Now < EndMarketEDate)
                    {
                        SqlDal sd = new SqlDal(dbConnString);
                        if (sd.GetisDailyTrading())
                        {
                            sd.SellActionOverDay();
                            sd.SellAction1440();
                            flog.write(LogType.INFORMATION, "장종료후 당일청산 시도");
                        }
                    }
                    else
                    {
                        //Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss.fff") + " : " + "09:00 ~ 15:00 까지만 영업합니다");
                        myTimer.Start();
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("Simulator", e.ToString());
            }

            myTimer.Start();
        }