private CalculationAmountViewModel calculationVM(string itemCode)
        {
            CalculationAmountViewModel calculationVM = new CalculationAmountViewModel();

            QueryStr queryStr = new QueryStr(this.masterInfo_);

            queryStr.VariableMap_.Add("KR_CODE", itemCode);

            conn_.clearQuery();
            conn_.addQuery("elsmaster", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["elsmaster"];

            string issue_amt = "0";
            string currency  = "KRW";

            foreach (DataRow item in tb.Rows)
            {
                issue_amt = item["ISSUE_AMT"].ToString();
            }

            calculationVM.Amount_   = issue_amt;
            calculationVM.Currency_ = currency;

            return(calculationVM);
        }
        private CorrelationInfo_paraViewModel makeCorrInfo(List <string> underCodeList)
        {
            QueryStr queryStr = new QueryStr(this.corrQueryInfo_);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < underCodeList.Count; i++)
            {
                sb.Append(QueryStr.wrapComma(underCodeList[i]));

                if (i != underCodeList.Count - 1)
                {
                    sb.Append(",");
                }
            }

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("UNDER_LIST", sb.ToString());

            conn_.addQuery("underCorrInfo", queryStr.getQuery());

            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["underCorrInfo"];

            List <string> first  = new List <string>();
            List <string> second = new List <string>();
            List <string> values = new List <string>();

            foreach (DataRow item in tb.Rows)
            {
                first.Add(item["STOCK_ID"].ToString());
                second.Add(item["OTHER_ID"].ToString());
                values.Add(item["CORR"].ToString());
            }

            CorrelationInfo_paraViewModel corrInfoVM = new CorrelationInfo_paraViewModel();

            corrInfoVM.Dimension_ = underCodeList.Count.ToString();

            //Int32 dimensionTrans = underCodeList.Count;
            //Int32 needCorrNum = dimensionTrans * (dimensionTrans + 1) / 2;

            for (int i = 0; i < values.Count; i++)
            {
                corrInfoVM.Correlation_paraViewModel_.Add(this.makeCorr(first[i], second[i], values[i]));
            }

            return(corrInfoVM);
        }
        private DiscountCurve_paraViewModel discount_paraVM(string itemCode)
        {
            DiscountCurve_paraViewModel discount_paraVM = new DiscountCurve_paraViewModel();
            YieldTermstructureViewModel yieldTSVM       = new YieldTermstructureViewModel();

            yieldTSVM.Type_                  = "ZEROYIELD";
            yieldTSVM.Interpolation_         = "BACKWARDFLAT";
            yieldTSVM.Daycounter_            = "ACT365FIX";
            yieldTSVM.Calendar_              = "NULLCALENDAR";
            yieldTSVM.BusinessDayConvention_ = "Following";

            QueryStr queryStr = new QueryStr(this.discountQueryInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("CURVE_CODE", "S");
            queryStr.VariableMap_.Add("BOND_CLASS_ID", "111001");

            conn_.clearQuery();
            conn_.addQuery("discountCurve", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["discountCurve"];

            foreach (DataRow item in tb.Rows)
            {
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("1", "D", (Convert.ToDouble(item["D001"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("3", "M", (Convert.ToDouble(item["M003"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("6", "M", (Convert.ToDouble(item["M006"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("9", "M", (Convert.ToDouble(item["M009"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("12", "M", (Convert.ToDouble(item["M012"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("18", "M", (Convert.ToDouble(item["M018"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("24", "M", (Convert.ToDouble(item["M024"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("30", "M", (Convert.ToDouble(item["M030"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("36", "M", (Convert.ToDouble(item["M036"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("48", "M", (Convert.ToDouble(item["M048"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("60", "M", (Convert.ToDouble(item["M060"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("84", "M", (Convert.ToDouble(item["M084"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("120", "M", (Convert.ToDouble(item["M120"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("180", "M", (Convert.ToDouble(item["M180"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("240", "M", (Convert.ToDouble(item["M240"].ToString()) / 100).ToString()));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("360", "M", (Convert.ToDouble(item["M360"].ToString()) / 100).ToString()));
            }

            discount_paraVM.YieldTermstructureViewModel_.Add(yieldTSVM);

            return(discount_paraVM);
        }
        private UnderlyingInfo_paraViewModel underInfo_paraVM(string itemCode)
        {
            UnderlyingInfo_paraViewModel underInfo_paraVM = new UnderlyingInfo_paraViewModel();

            QueryStr queryStr = new QueryStr(this.fileInfo_);

            queryStr.VariableMap_.Add("ITEM_CODE", itemCode);
            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));

            conn_.addQuery("underInfo", queryStr.getQuery());

            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["underInfo"];

            string krCode;
            string underName;
            string currentValue;
            string drift;
            string dividend;
            string volatility;

            List <string> underCode = new List <string>();

            foreach (DataRow item in tb.Rows)
            {
                krCode       = item["STOCK_ID"].ToString();
                underName    = item["STOCK_NAME"].ToString();
                currentValue = item["CURR_PRICE"].ToString();
                drift        = (Convert.ToDouble(item["RF"].ToString()) / 100).ToString();
                dividend     = (Convert.ToDouble(item["DIVIDEND_RATE"].ToString()) / 100).ToString();
                volatility   = (Convert.ToDouble(item["VOL"].ToString()) / 100).ToString();

                underCode.Add(krCode);

                GeometricBMViewModel gbmVM = this.makeGBM(krCode, underName, currentValue, drift, dividend, volatility);

                underInfo_paraVM.Underlying_paraViewModel_.Add(gbmVM);
            }

            underInfo_paraVM.CorrelationInfo_paraViewModel_ = this.makeCorrInfo(underCode);

            return(underInfo_paraVM);
        }
        private void positionLoad()
        {
            this.PositionList_ = new List<string>();

            QueryStr queryStr = new QueryStr(this.positionInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("FUND_CODE", "A27212','A27211','A27214");
            
            conn_.clearQuery();
            conn_.addQuery("position", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["position"];

            foreach (DataRow item in tb.Rows)
            {
                this.PositionList_.Add(item["KR_CODE"].ToString());
            }
        }
        private void positionLoad()
        {
            this.PositionList_ = new List <string>();

            QueryStr queryStr = new QueryStr(this.positionInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("FUND_CODE", "A27212','A27211','A27214");

            conn_.clearQuery();
            conn_.addQuery("position", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["position"];

            foreach (DataRow item in tb.Rows)
            {
                this.PositionList_.Add(item["KR_CODE"].ToString());
            }
        }
        public List <double> loadHistory(string itemCode, DateTime startDate, DateTime endDate)
        {
            OracleDataBaseConnect conn = OracleDataBaseConnect.CreateOracleDBConnet("Local");

            QueryStr query = new QueryStr(fileInfo1_);

            query.VariableMap_.Add("stockID", itemCode);
            query.VariableMap_.Add("startDate", startDate.ToString("yyyyMMdd"));
            query.VariableMap_.Add("endDate", endDate.ToString("yyyyMMdd"));

            conn.addQuery("Test", query.getQuery());
            conn.excute();

            List <double> valueList = new List <double>();
            List <string> datestr   = new List <string>();

            foreach (DataRow item in conn.ResultDataSet_.Tables["Test"].Rows)
            {
                valueList.Add(Convert.ToDouble(item["CURR_PRICE"].ToString()));
                datestr.Add(item["STD_DATE"].ToString());
            }

            return(Result_);
        }
        public List<double> loadHistory(string itemCode, DateTime startDate, DateTime endDate)
        {
            OracleDataBaseConnect conn = OracleDataBaseConnect.CreateOracleDBConnet("Local");

            QueryStr query = new QueryStr(fileInfo1_);

            query.VariableMap_.Add("stockID", itemCode);
            query.VariableMap_.Add("startDate", startDate.ToString("yyyyMMdd"));
            query.VariableMap_.Add("endDate", endDate.ToString("yyyyMMdd"));

            conn.addQuery("Test", query.getQuery());
            conn.excute();
            
            List<double> valueList = new List<double>();
            List<string> datestr = new List<string>();

            foreach (DataRow item in conn.ResultDataSet_.Tables["Test"].Rows)
            {
                valueList.Add(Convert.ToDouble(item["CURR_PRICE"].ToString()));
                datestr.Add(item["STD_DATE"].ToString());
            }

            return Result_;
        }
        private CorrelationInfo_paraViewModel makeCorrInfo(List<string> underCodeList)
        {

            QueryStr queryStr = new QueryStr(this.corrQueryInfo_);

            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < underCodeList.Count; i++)
            {
                sb.Append(QueryStr.wrapComma(underCodeList[i]));

                if (i != underCodeList.Count - 1)
                {
                    sb.Append(",");
                }

            }

            queryStr.VariableMap_.Add("STD_DATE",this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("UNDER_LIST", sb.ToString());

            conn_.addQuery("underCorrInfo", queryStr.getQuery());

            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["underCorrInfo"];

            List<string> first = new List<string>();
            List<string> second = new List<string>();
            List<string> values = new List<string>();

            foreach (DataRow item in tb.Rows)
            {
                first.Add(item["STOCK_ID"].ToString());
                second.Add(item["OTHER_ID"].ToString());
                values.Add(item["CORR"].ToString());
            }

            CorrelationInfo_paraViewModel corrInfoVM = new CorrelationInfo_paraViewModel();
            corrInfoVM.Dimension_ = underCodeList.Count.ToString();

            //Int32 dimensionTrans = underCodeList.Count;
            //Int32 needCorrNum = dimensionTrans * (dimensionTrans + 1) / 2;

            for (int i = 0; i < values.Count; i++)
            {
                corrInfoVM.Correlation_paraViewModel_.Add(this.makeCorr(first[i], second[i], values[i]));
            }

            return corrInfoVM;

        }
        private UnderlyingInfo_paraViewModel underInfo_paraVM(string itemCode)
        {
            UnderlyingInfo_paraViewModel underInfo_paraVM = new UnderlyingInfo_paraViewModel();

            QueryStr queryStr = new QueryStr(this.fileInfo_);

            queryStr.VariableMap_.Add("ITEM_CODE", itemCode);
            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));

            conn_.addQuery("underInfo", queryStr.getQuery());

            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["underInfo"];

            string krCode;
            string underName;
            string currentValue;
            string drift;
            string dividend;
            string volatility;

            List<string> underCode = new List<string>();

            foreach (DataRow item in tb.Rows)
            {
                krCode = item["STOCK_ID"].ToString();
                underName = item["STOCK_NAME"].ToString();
                currentValue = item["CURR_PRICE"].ToString();
                drift = ( Convert.ToDouble(item["RF"].ToString())/100 ).ToString();
                dividend = (Convert.ToDouble(item["DIVIDEND_RATE"].ToString()) / 100).ToString();
                volatility = (Convert.ToDouble(item["VOL"].ToString()) / 100).ToString();

                underCode.Add(krCode);

                GeometricBMViewModel gbmVM = this.makeGBM(krCode, underName, currentValue, drift, dividend, volatility);

                underInfo_paraVM.Underlying_paraViewModel_.Add(gbmVM);
            }

            underInfo_paraVM.CorrelationInfo_paraViewModel_ = this.makeCorrInfo(underCode);

            return underInfo_paraVM;
        }
        private DiscountCurve_paraViewModel discount_paraVM(string itemCode)
        {
            DiscountCurve_paraViewModel discount_paraVM = new DiscountCurve_paraViewModel();
            YieldTermstructureViewModel yieldTSVM = new YieldTermstructureViewModel();

            yieldTSVM.Type_ = "ZEROYIELD";
            yieldTSVM.Interpolation_ = "BACKWARDFLAT";
            yieldTSVM.Daycounter_ = "ACT365FIX";
            yieldTSVM.Calendar_ = "NULLCALENDAR";
            yieldTSVM.BusinessDayConvention_ = "Following";

            QueryStr queryStr = new QueryStr(this.discountQueryInfo_);

            queryStr.VariableMap_.Add("STD_DATE", this.ReferenceDate_.ToString("yyyyMMdd"));
            queryStr.VariableMap_.Add("CURVE_CODE", "S");
            queryStr.VariableMap_.Add("BOND_CLASS_ID","111001");
            
            conn_.clearQuery();
            conn_.addQuery("discountCurve", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["discountCurve"];

            foreach (DataRow item in tb.Rows)
	        {
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("1","D", ( Convert.ToDouble(item["D001"].ToString())/100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("3", "M", ( Convert.ToDouble(item["M003"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("6", "M", ( Convert.ToDouble(item["M006"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("9", "M", ( Convert.ToDouble(item["M009"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("12", "M", ( Convert.ToDouble(item["M012"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("18", "M", ( Convert.ToDouble(item["M018"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("24", "M", ( Convert.ToDouble(item["M024"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("30", "M", ( Convert.ToDouble(item["M030"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("36", "M", ( Convert.ToDouble(item["M036"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("48", "M", ( Convert.ToDouble(item["M048"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("60", "M", ( Convert.ToDouble(item["M060"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("84", "M", ( Convert.ToDouble(item["M084"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("120", "M", ( Convert.ToDouble(item["M120"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("180", "M", ( Convert.ToDouble(item["M180"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("240", "M", ( Convert.ToDouble(item["M240"].ToString()) / 100).ToString() ));
                yieldTSVM.RateDataViewModel_.Add(this.rateDataVM("360", "M", ( Convert.ToDouble(item["M360"].ToString()) / 100).ToString() ));

	        }

            discount_paraVM.YieldTermstructureViewModel_.Add(yieldTSVM);

            return discount_paraVM;
        }
        private CalculationAmountViewModel calculationVM(string itemCode)
        {
            CalculationAmountViewModel calculationVM = new CalculationAmountViewModel();

            QueryStr queryStr = new QueryStr(this.masterInfo_);

            queryStr.VariableMap_.Add("KR_CODE", itemCode);

            conn_.clearQuery();
            conn_.addQuery("elsmaster", queryStr.getQuery());
            conn_.excute();

            DataTable tb = conn_.ResultDataSet_.Tables["elsmaster"];

            string issue_amt = "0";
            string currency = "KRW";

            foreach (DataRow item in tb.Rows)
            {
                issue_amt = item["ISSUE_AMT"].ToString();

            }

            calculationVM.Amount_ = issue_amt;
            calculationVM.Currency_ = currency;

            return calculationVM;
        }