Example #1
0
        void SaveLongCodes()
        {
            Dictionary<String, String> stockBlgData = StockUtil.LoadBloombergStockDataFromDB();

            CPUTILLib.CpStockCode cpStockCode = new CPUTILLib.CpStockCode();

            DeleteLongCode();

            foreach (String code in stockBlgData.Keys)
            {
                String shortCode = BlgCodeToShortCode(code);
                String longCode = cpStockCode.CodeToFullCode(shortCode);
                String name = cpStockCode.CodeToName(shortCode);
                SaveLongCode_Raw(shortCode, longCode, name);
            }

            _lastLog.Add("Save long codes complete...");
        }
Example #2
0
        Dictionary<String, CP_LoadingDatum_Elw> GetElwInfoFromCP(DateTime maturity)
        {
            Dictionary<String, CP_LoadingDatum_Elw> elwInfos = new Dictionary<string, CP_LoadingDatum_Elw>();

            String kospi200 = "U180";

            CPSYSDIBLib.ElwAll elwAll = new CPSYSDIBLib.ElwAll();
            CPUTILLib.CpStockCode cpStockCode = new CPUTILLib.CpStockCode();

            // 1. ELW 종목 리스트를 얻어온다.
            // 2. Kospi200에 해당하는 리스트를 얻어온다.
            // 3. ELW를 등록한다.
            elwAll.SetInputValue(0, 1);

            while (true)
            {
                elwAll.BlockRequest();

                int count = Convert.ToInt32(elwAll.GetHeaderValue(0));

                for (int i = 0; i < count; ++i)
                {
                    String underlyingCode = Convert.ToString(elwAll.GetDataValue(36, i));
                    String underlyingName = Convert.ToString(elwAll.GetDataValue(37, i));

                    if (underlyingCode.CompareTo(kospi200) != 0)
                    {
                        continue;
                    }

                    String code = Convert.ToString(elwAll.GetDataValue(0, i));
                    String name = Convert.ToString(elwAll.GetDataValue(3, i));
                    String callPut = Convert.ToString(elwAll.GetDataValue(4, i));
                    long maturityCP = Convert.ToInt64(elwAll.GetDataValue(6, i));
                    double strike = Convert.ToDouble(elwAll.GetDataValue(10, i));
                    int changeRate = Convert.ToInt32(elwAll.GetDataValue(11, i));
                    double bidPrice = Convert.ToDouble(elwAll.GetDataValue(15, i));
                    double askPrice = Convert.ToDouble(elwAll.GetDataValue(14, i));
                    double curPrice = Convert.ToDouble(elwAll.GetDataValue(16, i));

                    double gearing = Convert.ToDouble(elwAll.GetDataValue(28, i));

                    long issuedCount = Convert.ToInt64(elwAll.GetDataValue(9, i));

                    long remainDays = Convert.ToInt32(elwAll.GetDataValue(13, i));

                    double kockoutPrice = Convert.ToDouble(elwAll.GetDataValue(43, i));

                    if (maturity.ToString("yyyyMMdd").CompareTo(maturityCP.ToString()) == 0)
                    {
                        if (kockoutPrice > 0)
                        {
                            // 조기종료 버린다.
                            logger.Debug("{0} is discarded in that it is KOBA.", name);
                            continue;
                        }

                        CP_LoadingDatum_Elw datum = new CP_LoadingDatum_Elw();
                        datum.UnderlyingCode = underlyingCode;
                        datum.UnderlyingName = underlyingName;

                        if (name.ToUpper().Contains("KB") ||
                          name.ToUpper().Contains("국민") ||
                          name.ToUpper().Contains("케이비") ||
                          name.ToUpper().Contains("kb"))
                        {
                            // KB투자증권 버린다.
                            logger.Debug("{0} is discarded in that it is KB.", name);
                            continue;
                        }

                        datum.Code = code;
                        datum.Name = name;
                        datum.Maturity = maturityCP;
                        datum.Strike = strike;
                        datum.ChangeRate = changeRate;
                        datum._CallPut = callPut;
                        datum.RemainDays = remainDays;
                        datum.Gearing = gearing;
                        datum.IssuedCount = issuedCount;
                        datum.LongCode = cpStockCode.CodeToFullCode(code);

                        datum.BidPrice = bidPrice;
                        datum.AskPrice = askPrice;
                        datum.CurPrice = curPrice;

                        elwInfos.Add(datum.Code, datum);
                    }
                }

                if (elwAll.Continue == 0)
                {
                    break;
                }
            }

            return elwInfos;
        }