Dictionary<String, BondSpotInfo> GetBondDic_Raw(MySqlConnection con)
        {
            Dictionary<String, BondSpotInfo> dic = new Dictionary<string, BondSpotInfo>();

            try
            {
                String calDate = DateTime.Now.ToString("yyyy-MM-dd");

                String query = String.Format("select * from bond_daily_avg_price where cal_date = '{0}'", calDate);
                MySqlCommand cmd = new MySqlCommand(query, con);
                MySqlDataAdapter dataAdapter = new MySqlDataAdapter(cmd);

                DataSet ds = new DataSet("bond_daily_avg_price");

                dataAdapter.Fill(ds, "bond_daily_avg_price");
                DataRowCollection drc = ds.Tables["bond_daily_avg_price"].Rows;

                if (drc.Count <= 0)
                {
                    logger.Warn("count of bond dic is 0, do you insert yesterday avg price of bond?");
                    return dic;
                }

                for (int i = 0; i < drc.Count; ++i)
                {
                    DataRow dr = drc[i];
                    String code = dr["code"].ToString();
                    String name = dr["name"].ToString();
                    String issudDate = dr["issue_date"].ToString();
                    String maturityDate = dr["maturity_date"].ToString();
                    double avgPrice = Convert.ToDouble(dr["avg_price"]);

                    BondSpotInfo bi = new BondSpotInfo();
                    bi.Code = code;
                    bi.Name = name;
                    bi.IssueDate = issudDate;
                    bi.MaturiytDate = maturityDate;
                    bi.CalDate = calDate;
                    bi.AvgYesPrice = avgPrice;

                    if (5000 <= bi.AvgYesPrice && bi.AvgYesPrice <= 20000)
                    {
                        dic.Add(bi.Code, bi);
                    }
                    else if (1 <= bi.AvgYesPrice && bi.AvgYesPrice < 5000)
                    {
                        logger.Warn("Strange BondData is excluded from dict. ({0}, {1:n0})", bi.ToString(), bi.AvgYesPrice);
                    }

                    BondCodeNameMap.Ins().AddIfNotExist(bi.Code, bi.Name);
                }

                ds.Clear();
            }
            catch (System.Exception ex)
            {
                logger.Error(ex.ToString());
                Util.KillWithNotice(ex.ToString());
            }

            return dic;
        }
Esempio n. 2
0
        Boolean IsValidLongPrice(BondSpotInfo bi, double longPrice)
        {
            if (bi.AvgYesPrice >= longPrice)
            {
                return true;
            }

            if (BondPairManager.Ins().IsRiskTakeCountRemain())
            {
                return true;
            }

            return false;
        }
Esempio n. 3
0
 static void ValidateHouseBondName(BondSpotInfo bondInfo)
 {
     int month = DateTime.Now.Month;
     int bondMonth = Convert.ToInt32(bondInfo.Name.Substring(
         bondInfo.Name.IndexOf("-") + 1));
     if (month == bondMonth)
     {
         logger.Info("{0} {1}이 국민주택 OnTheRun으로 선정", bondInfo.Name, bondInfo.Code);
     }
     else
     {
         logger.Error("국민주택 읽어오기 실패");
         Util.KillWithNotice("국민주택 읽어오기 실패");
     }
 }