예제 #1
0
        public void IndexData(DateTime refDate)
        {
            string refDateStr = refDate.ToString("yyyyMMdd");
            //string fileName = @"D:\data_etl\INDEX_" + refDateStr + ".TXT";
            string fileName = @"C:\batch\INDEX_" + refDateStr + ".TXT";

            /* Download a File */
            this.FtpConnector_.download("/marketdata/index/INDEX_" + refDateStr + ".TXT", fileName);

            if (!File.Exists(fileName))
                throw new FileNotFoundException();

            DataSet ds = TextToDataSet.Convert(fileName, "testTB", "|");
            
            // db 에 올림.
            clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

            clstb.REF_DT = refDateStr;
            clstb.DeleteDate();

            foreach (DataRow dr in ds.Tables[0].Select())
            {
                if (dr[0].ToString() != "") 
                {
                    if ( dr[1].ToString().Trim().Substring(0,3) != "KRA")
                    {
                        clstb.REF_DT = dr[0].ToString().Trim();
                        clstb.INDEX_CD = dr[1].ToString().Trim();

                        if (dr[10].ToString().Trim() != "")
                        {
                            if (clstb.INDEX_CD == "KOSPI_029") { clstb.INDEX_CD = "KOSPI200"; }
                            clstb.LAST = Convert.ToDouble(dr[6].ToString().Trim()) / 100.0;
                            clstb.LOW = Convert.ToDouble(dr[7].ToString().Trim()) / 100.0;
                            clstb.HIGH = Convert.ToDouble(dr[8].ToString().Trim()) / 100.0;
                        }
                        else 
                        {
                            clstb.LAST = Convert.ToDouble(dr[6].ToString().Trim());
                            clstb.LOW = Convert.ToDouble(dr[7].ToString().Trim());
                            clstb.HIGH = Convert.ToDouble(dr[8].ToString().Trim());
                        }

                        clstb.Insert();
                    }

                }
            }

            clstb.INDEX_CD = "CD91";
            clstb.LAST = 0.0185;
            clstb.LOW = 0.0185;
            clstb.HIGH = 0.0185;

            clstb.Insert();

        }
예제 #2
0
        //public void historyIndexData(GBMParameter para, DateTime startDate, DateTime endDate)
        //{
        //    DayCounter dc = new SimpleDayCounter();
            
        //    CalendarManager cm = new CalendarManager(DateTime.Now,CalendarManager.CountryType.SOUTH_KOREA);

        //    double initialValue = para.Initial_;
        //    double preValue = initialValue;
        //    double drift = para.Drift_;
        //    double vol = para.Vol_;

        //    double t0 = 0.0;
        //    double dt = 0.0;
        //    double x0 = preValue;
        //    double dw = 0.0;

        //    DateTime roopDate = startDate;

        //    GeometricBrownianMotionProcess gbm = new GeometricBrownianMotionProcess(initialValue, drift, vol);

        //    PseudoRandom random = new PseudoRandom();
        //    //RandomSequenceGenerator<MersenneTwisterUniformRng> randGen = random.make_sequence_generator(1000, 1) as RandomSequenceGenerator<MersenneTwisterUniformRng>;
        //    int genNum = Convert.ToInt32((endDate - startDate).TotalDays);

        //    IRNG randGen = random.make_sequence_generator(genNum, Convert.ToUInt64( this.random_.Next())) as IRNG;

        //    int i = 0;
        //    Sample<List<double>> sample = randGen.nextSequence();
        //    //Sample<List<double>> sample = new Sample<List<double>>();

        //    clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

        //    clstb.INDEX_CD = para.Name_;

        //    while (roopDate < endDate)
        //    {
        //        clstb.REF_DT = roopDate.ToString("yyyyMMdd");

        //        DateTime nextDate = cm.adjust(roopDate,"1D");

        //        t0 = dc.yearFraction(startDate, roopDate);
        //        dt = dc.yearFraction(roopDate, nextDate);

        //        dw = sample.value[i];

        //        double v = Math.Round(gbm.evolve(t0, x0, dt, dw),2);
                
        //        clstb.LAST = v;
        //        clstb.LOW = v;
        //        clstb.HIGH = v;

        //        clstb.Insert();

        //        roopDate = nextDate;

        //        x0 = v;

        //        i += 1;
        //    }

        //}

        //public void historyIRData(VasicekParameter para, DateTime startDate, DateTime endDate)
        //{
        //    DayCounter dc = new SimpleDayCounter();

        //    CalendarManager cm = new CalendarManager(DateTime.Now, CalendarManager.CountryType.SOUTH_KOREA);

        //    double initialValue = para.Initial_;
        //    double preValue = initialValue;
        //    double longTermRate = para.LongTermRate_;
        //    double spreed = para.Speed_;
        //    double vol = para.Vol_;

        //    double t0 = 0.0;
        //    double dt = 0.0;
        //    double x0 = preValue;
        //    double dw = 0.0;

        //    DateTime roopDate = startDate;

        //    SquareRootProcess vasicek = new SquareRootProcess(longTermRate, spreed, vol, initialValue);

        //    PseudoRandom random = new PseudoRandom();
        //    int genNum = Convert.ToInt32((endDate - startDate).TotalDays);
        //    IRNG randGen
        //        = random.make_sequence_generator(genNum, Convert.ToUInt64(this.random_.Next())) as IRNG;

        //    int i = 0;
        //    Sample<List<double>> sample = randGen.nextSequence();

        //    clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

        //    clstb.INDEX_CD = para.Name_;

        //    while (roopDate < endDate)
        //    {
        //        clstb.REF_DT = roopDate.ToString("yyyyMMdd");

        //        DateTime nextDate = cm.adjust(roopDate, "1D");

        //        t0 = dc.yearFraction(startDate, roopDate);
        //        dt = dc.yearFraction(roopDate, nextDate);

        //        dw = sample.value[i];

        //        double v = Math.Round(vasicek.evolve(t0, x0, dt, dw));

        //        clstb.LAST = v;
        //        clstb.LOW = v;
        //        clstb.HIGH = v;

        //        clstb.Insert();
                
        //        roopDate = nextDate;

        //        x0 = v;

        //        i += 1;
        //    }

        //}


        public void getData(DateTime refDate)
        {
            // 전일자 구함.
            clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

            clstb.REF_DT = refDate.ToString("yyyyMMdd");
            clstb.DeleteDate();

            DateTime preDate = clstb.SelectMaxDate();

            // ㄱㄱ

            this.build_indexHistoryData(preDate,refDate,false);
            this.build_irHistoryData(preDate, refDate, false);
            this.build_curveHistoryData(preDate, refDate, false);




        }