示例#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 irData(string name,
                    SquareRootProcess process,
                    double rand,
                    DateTime preDate,
                    DateTime nextDate)
        {
            DayCounter dc = new SimpleDayCounter();

            clsHDAT_MARKETDATA_TB clstb = new clsHDAT_MARKETDATA_TB();

            clstb.INDEX_CD = name;
            clstb.REF_DT = preDate.ToString("yyyyMMdd");
            clstb.SelectOwn();

            clstb.REF_DT = nextDate.ToString("yyyyMMdd");

            double x0 = clstb.LAST;

            double t0 = 0.0;
            double dt = dc.yearFraction(preDate, nextDate);

            double v = Math.Round(process.evolve(t0, x0, dt, rand), 8);

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

            clstb.Insert();

        }
示例#3
0
        public void buildTestData()
        {
            clsHDAT_MARKETDATA_TB clsTB = new clsHDAT_MARKETDATA_TB();
            string[] dateString = { "20130701","20130702","20130703","20130704","20130705","20130708","20130709","20130710","20130711","20130712","20130715","20130716",

                            #region data
	
                        "20130717","20130718","20130719","20130722","20130723","20130724","20130725","20130726","20130729","20130730","20130731","20130801",
                        "20130802","20130805","20130806","20130807","20130808","20130809","20130812","20130813","20130814","20130815","20130816","20130819",
                        "20130820","20130821","20130822","20130823","20130826","20130827","20130828","20130829","20130830","20130902","20130903","20130904",
                        "20130905","20130906","20130909","20130910","20130911","20130912","20130913","20130916","20130917","20130918","20130919","20130920",
                        "20130923","20130924","20130925","20130926","20130927","20130930","20131001","20131002","20131003","20131004","20131007","20131008",
                        "20131009","20131010","20131011","20131014","20131015","20131016","20131017","20131018","20131021","20131022","20131023","20131024",
                        "20131025","20131028","20131029","20131030","20131031","20131101","20131104","20131105","20131106","20131107","20131108","20131111",
                        "20131112","20131113","20131114","20131115","20131118","20131119","20131120","20131121","20131122","20131125","20131126","20131127",
                        "20131128","20131129","20131202","20131203","20131204","20131205","20131206","20131209","20131210","20131211","20131212","20131213",
                        "20131216","20131217","20131218","20131219","20131220","20131223","20131224","20131225","20131226","20131227","20131230","20131231",
                        "20140101","20140102","20140103","20140106","20140107","20140108","20140109","20140110","20140113","20140114","20140115","20140116",
                        "20140117","20140120","20140121","20140122","20140123","20140124","20140127","20140128","20140129","20140130","20140131","20140203",
                        "20140204","20140205","20140206","20140207","20140210","20140211","20140212","20140213","20140214","20140217","20140218","20140219",
                        "20140220","20140221","20140224","20140225","20140226","20140227","20140228","20140303","20140304","20140305","20140306","20140307",
                        "20140310","20140311","20140312","20140313","20140314","20140317","20140318","20140319","20140320","20140321","20140324","20140325",
                        "20140326","20140327","20140328","20140331","20140404","20140407","20140408","20140409","20140410","20140411","20140414","20140415",
                        "20140416","20140417","20140418","20140421","20140422","20140423","20140424","20140425","20140428","20140429","20140430","20140501",
                        "20140502","20140505","20140506","20140507","20140508","20140509","20140512","20140513","20140514","20140515","20140516","20140519",
                        "20140520","20140521","20140522","20140523","20140526","20140527","20140528","20140529","20140530","20140602","20140603","20140604",
                        "20140605","20140609","20140610","20140611","20140612","20140613","20140616","20140617","20140618","20140619","20140620","20140623",
                        "20140624","20140625","20140626","20140627","20140630","20140701","20140702","20140703","20140704","20140707","20140708","20140709",
                        "20140710","20140711","20140714","20140715","20140716","20140717","20140718","20140721","20140722","20140723","20140724","20140725",
                        "20140728","20140729","20140730","20140731","20140801","20140804","20140805","20140806","20140807","20140808","20140811","20140812",
                        "20140813","20140814","20140815","20140818","20140819","20140820","20140821","20140822","20140825","20140826","20140827","20140828",
                        "20140829","20140901","20140902","20140903","20140904","20140905","20140908","20140909","20140910","20140911","20140912","20140915",
                        "20140916","20140917","20140918","20140919","20140922","20140923","20140924","20140925","20140926","20140929","20140930","20141001",
                        "20141002","20141003","20141006","20141007","20141008","20141009","20141010","20141013","20141014","20141015","20141016","20141017",
                        "20141020","20141021","20141022","20141023","20141024","20141027","20141028","20141029","20141030","20141031","20141103","20141104",
                        "20141105","20141106","20141107","20141110","20141111","20141112","20141113","20141114","20141117","20141118","20141119","20141120",
                        "20141121","20141124","20141125","20141126","20141127","20141128","20141201","20141202","20141203","20141204","20141205","20141208",
                        "20141209","20141210","20141211","20141212","20141215","20141216","20141217","20141218","20141219","20141222","20141223","20141224",
                        "20141225","20141226","20141229","20141230","20141231","20150101","20150102","20150105","20150106","20150107","20150108","20150109",
                        "20150112","20150113","20150114","20150115","20150116","20150119","20150120","20150121","20150122","20150123","20150126","20150127",
                        "20150128","20150129","20150130","20150202","20150203","20150204","20150205","20150206","20150209","20150210","20150211","20150212",
                        "20150213","20150216","20150217","20150218","20150219","20150220","20150223","20150224","20150225","20150226","20150227","20150302",
                        "20150303","20150304","20150305","20150306","20150309","20150310","20150311","20150312","20150313","20150316","20150317","20150318",

                        #endregion

                        "20150319","20150320","20150323","20150324","20150325","20150326","20150327","20150330","20150604"
                        };

            double[] rateList = { 0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0269,0.0267,0.0267,0.0267,0.0267,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.026505,0.026503,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0266,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0265,0.0263,0.0262,0.0261,0.0246,0.0246,0.0243,0.0242,0.0242,0.0242,0.0241,0.0241,0.024,0.024,0.024,0.024,0.024,0.0236,0.0236,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0235,0.0231,0.023,0.023,0.0229,0.0228,0.0228,0.0218,0.0217,0.0217,0.0216,0.0215,0.0215,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0214,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0213,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.0212,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.021,0.0191,0.019,0.0189,0.0188,0.0187,0.0187,0.0186,0.0186,0.0186,0.0186,0.0186,0.0186,0.0185,0.0185 };
            double[] indexkospi200List = { 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47, 255.47 };

            int rateListLength = rateList.Length;
            int indexListLength = rateList.Length;
            int dateLength = dateString.Length;


            clsTB.INDEX_CD = "CD91";

            for (int i = 0; i < dateLength; i++)
            {
                clsTB.REF_DT = dateString[i];
                clsTB.LAST = rateList[i];
                clsTB.LOW= rateList[i];
                clsTB.HIGH= rateList[i];

                clsTB.Insert();

            }

            clsTB.INDEX_CD = "KOSPI200";

            for (int i = 0; i < dateLength; i++)
            {
                clsTB.REF_DT = dateString[i];
                clsTB.LAST = indexkospi200List[i];
                clsTB.LOW = indexkospi200List[i];
                clsTB.HIGH = indexkospi200List[i];

                clsTB.Insert();

            }

        }
示例#4
0
        public void build_irHistoryData(DateTime startDate, DateTime endDate, bool withClear)
        {
            CalendarManager cm = new CalendarManager(DateTime.Now, CalendarManager.CountryType.SOUTH_KOREA);

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

            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();

            foreach (VasicekParameter para in this.sampleIR_)
            {
                SquareRootProcess vasicek = new SquareRootProcess(para.LongTermRate_, para.Speed_, para.Vol_ , para.Initial_);

                clstb.INDEX_CD = para.Name_;

                if (withClear) 
                { 
                    clstb.DeleteIndex(); 

                    clstb.REF_DT = startDate.ToString("yyyyMMdd");

                    clstb.LAST = para.Initial_;
                    clstb.LOW = para.Initial_;
                    clstb.HIGH = para.Initial_;

                    clstb.Insert();
                }

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

                while (nextDate < endDate)
                {
                    clstb.REF_DT = roopDate.ToString("yyyyMMdd");
                    
                    nextDate = cm.adjust(roopDate, "1D");

                    this.irData(para.Name_, vasicek, sample.value[i], roopDate, nextDate);
                    
                    roopDate = nextDate;

                    i += 1;
                }

            }

        }