private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (this.DataContext != null)
            { 
                this.viewModel_ = this.DataContext as Excel_instrumentViewModel;

                //this.viewModel_.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.PropertyChanged +=
                //    this.viewModel_.Excel_parameterViewModel_.instrumentEventObserver;

                this.MasterInfoGrid_.Children.Clear();
                this.MasterInfoGrid_.Children.Add(this.viewModel_.MasterInformationViewModel_.view());

                this.ProductGrid_.Children.Clear();
                this.ProductGrid_.Children.Add(this.viewModel_.Excel_interfaceViewModel_.view());

                this.ParameterGrid_.Children.Clear();
                this.ParameterGrid_.Children.Add(this.viewModel_.Excel_parameterViewModel_.view());

                this.ResultGrid_.Children.Clear();
                this.ResultGrid_.Children.Add(this.viewModel_.Excel_parameterViewModel_.Excel_resultViewModel_.view());

                this.ProfitLossGrid_.Children.Clear();
                this.ProfitLossGrid_.Children.Add(this.viewModel_.Excel_profitLossViewModel_.view());

                this.EventGrid_.Children.Clear();
                this.EventGrid_.Children.Add(this.viewModel_.Excel_eventManagerViewModel_.view());
            }

        }
        public ParameterSettingManager(DateTime refDate, Excel_instrumentViewModel e_instVM)
        {
            this.ReferenceDate_ = refDate;
            this.Excel_InstrumentViewModel_ = e_instVM;
            e_instVM.Excel_parameterViewModel_.ParameterSettingManager_ = this;

            this.UnderlyingParaSetting_ = new UnderlyingParaSetting(this);
            this.DiscountCurveParaSetting_ = new DiscountCurveParaSetting(this);

        }
        public override bool removeInstrument(Excel_instrumentViewModel e_ivm)
        {
            // list 에서 삭제함.
            this.instrumentList_.Remove(e_ivm);

            // db 에서 삭제함.
            MasterInformationViewModel.removeMasterInfo(e_ivm.Item_code_);



            return true;
            
        }
        public override string value(DateTime dateTime, Excel_instrumentViewModel excel_instrumentViewModel, Excel_underlyingInfoViewModel excel_uivm)
        {
            TD_MRSTOCKFACTOR_Table_DAO dao = new TD_MRSTOCKFACTOR_Table_DAO();

            dao.STOCK_ID_ = excel_uivm.KrCode_;
            dao.STD_DATE_ = StringConverter.dbDateTimeToDateString(dateTime);

            dao.select_ID_Date(DataBaseConnectManager.ConnectionFactory("MRO"));

            string v = dao.DIVIDEND_RATE_;

            return v;
        }
        public static ParameterSettingManager makeParaSettingManager(string settingID,DateTime refDate,Excel_instrumentViewModel e_instVM)
        {
            ParameterSettingManager psm = new ParameterSettingManager(refDate, e_instVM);

            // simulation Number
            psm.SimulationNumber_ = 10000;

            // underlying
            {
                UnderlyingParaSetting ups = new UnderlyingParaSetting(psm);

                // stock

                GBMSetting gbmSetting = new GBMSetting();

                gbmSetting.GBMDriftSetting_ = new GBM_Const_DriftSetting("0.0289");
                gbmSetting.GBMDividendSetting_ = new GBM_Const_DividendSetting("0.019");
                gbmSetting.GBMVolatilitySetting_ = new GBM_Const_VolatilitySetting("0.3");

                ups.StockParaSetting_ = new GBMSetting();

                // ir

                HullWhiteSetting hwSetting = new HullWhiteSetting();

                hwSetting.HullWhite_AlphaSetting_ = new HullWhite_Const_AlphaSetting("");
                hwSetting.HullWhite_SigmaSetting_ = new HullWhite_Const_SigmaSetting("");
                hwSetting.HullWhite_FittingCurveSetting_ = new HullWhite_Const_FittingCurveSetting("");

                ups.InterestRateParaSetting_ = hwSetting;

                // fx


                // corr

                ups.CorrelationParaSetting_ = new Constant_CorrelationParaSetting(psm);
            }

            // discount
            {
                DiscountCurveParaSetting dcps = new DiscountCurveParaSetting(psm);

                psm.DiscountCurveParaSetting_ = dcps;
            }

            return psm;
        }
        public override Excel_yieldCurveViewModel value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
        {
            Excel_interestRateViewModel e_irvm = excel_uivm as Excel_interestRateViewModel;

            ObservableCollection<Excel_irCurveDataViewModel> e_ircdvmList = new ObservableCollection<Excel_irCurveDataViewModel>();

            Excel_yieldCurveViewModel e_ycvm = new Excel_yieldCurveViewModel();

            e_ycvm.Excel_interpolationViewModel_ = Excel_interpolationViewModel_;

            e_ycvm.Code_ = "constDefaultCurve";

            e_ycvm.loadCurve(constRate_);

            return e_ycvm;
        }
        private void ViewModelChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            this.viewModel_ = this.DataContext as Excel_instrumentViewModel;

            this.MasterInfoGrid_.Children.Clear();

            MasterInformationView masterInfoView = this.viewModel_.MasterInformationViewModel_.view();
            masterInfoView.bookingModeSetting(BookingMode.Booking);

            this.MasterInfoGrid_.Children.Add(masterInfoView);

            this.ProductGrid_.Children.Clear();
            this.ProductGrid_.Children.Add(this.viewModel_.Excel_interfaceViewModel_.view());

            this.ProfitLossGrid_.Children.Clear();
            this.ProfitLossGrid_.Children.Add(this.viewModel_.Excel_profitLossViewModel_.view());

        }
        public override string value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
        {
            OTC_TD_MRSTOCKFACTORVOL_Table_DAO dao = new OTC_TD_MRSTOCKFACTORVOL_Table_DAO();

            dao.STD_DATE_ = StringConverter.dbDateTimeToDateString(dateTime);
            dao.STOCK_ID_ = excel_uivm.KrCode_;
            dao.KR_CODE_ = e_instVM.MasterInformationViewModel_.Export_itemcode_;

            string sql = dao.select_date_code_id(DataBaseConnectManager.ConnectionFactory("MRO"));

            if (dao.STOCK_ID_ == "KR7060980000")
            {
                dao.VOL_ = "0.33";
            }

            //SQL_Logger.addLog(sql);

            return dao.VOL_;
        }
        public override Excel_underlyingModel_paraViewModel underModel(Excel_underlyingInfoViewModel excel_uivm,
                                                                       Excel_instrumentViewModel excel_instrumentViewModel, 
                                                                       DateTime dateTime)
        {
            Excel_geometricBMViewModel e_gbmvm = new Excel_geometricBMViewModel();

            //excel_upvm.loadMarketData(dateTime);

            string value = Excel_loaderViewModel.loadMarketData(dateTime, excel_uivm.Excel_type_, excel_uivm.KrCode_);

            e_gbmvm.CurrentValue_ = value;

            e_gbmvm.Drift_ = this.GBMDriftSetting_.value(dateTime, excel_instrumentViewModel, excel_uivm);
            e_gbmvm.Dividend_ = this.GBMDividendSetting_.value(dateTime, excel_instrumentViewModel, excel_uivm);
            e_gbmvm.Volatility_ = this.GBMVolatilitySetting_.value(dateTime, excel_instrumentViewModel, excel_uivm);

            return e_gbmvm;

        }
        public override string value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
        {
            // 국고 커브를 로드함

            DateTime maturity = e_instVM.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.MaturityDate_;

            Excel_yieldCurveViewModel e_ycvm =
                e_instVM.Excel_parameterViewModel_.ParameterSettingManager_.DiscountCurveParaSetting_.discountCurve(dateTime,"KRW");

            QLNet.YieldTermStructure q_y = e_ycvm.yieldCurve();

            TimeSpan timeSpan = maturity - dateTime;

            double t = timeSpan.TotalDays / 365;

            InterestRate rate = q_y.zeroRate(t, QLNet.Compounding.Compounded);
            
            double drift = rate.value();
            
            return drift.ToString();
        }
        public override Excel_yieldCurveViewModel value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
        {
            IRCurveMarketDataLoader curveLoader = IRCurveMarketDataLoader.CreateMarketDataLoader("MRO");

            Excel_interestRateViewModel e_irvm = excel_uivm as Excel_interestRateViewModel;

            ObservableCollection<Excel_irCurveDataViewModel> e_ircdvmList = new ObservableCollection<Excel_irCurveDataViewModel>();

            curveLoader.load(dateTime, e_irvm.LinkedCurveCode_, e_ircdvmList);
            //e_icsvm.Symbol_ = excel_uivm.KrCode_;

            //e_icsvm.dataLoad(dateTime, e_irvm.LinkedCurveCode_);

            Excel_yieldCurveViewModel e_ycvm = new Excel_yieldCurveViewModel();

            e_ycvm.Excel_interpolationViewModel_ = Excel_interpolationViewModel_;

            e_ycvm.Code_ = e_ircdvmList[0].Curve_code_;

            e_ycvm.Excel_rateDataViewModel_ = e_ircdvmList[0].Excel_rateDataViewModelList_;

            return e_ycvm;
        }
        public void enqueue_intrument(Excel_instrumentViewModel e_instVM)
        {
            BatchItemViewModel bvm = new BatchItemViewModel(e_instVM);

            this.BatchItemViewModelQueueList_.Add(bvm);
        }
        public virtual void calculate(Excel_instrumentViewModel e_inst)
        {
            string productXmlStr = e_inst.Excel_interfaceViewModel_.productXml(true);
            string parameterXmlStr = this.paraXml(false);
            
            //DateTime tradeDate = e_inst.MasterInformationViewModel_.Trade_date_;
            DateTime effectiveDate = e_inst.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;
            // < date , value > //
            //string underHistData = this.historyUnderData(effectiveDate, false);

            string underHistData = e_inst.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.historyUnderData(effectiveDate,this.referenceDate_, false);

            string calculationType = e_inst.MasterInformationViewModel_.Booking_type_.ToUpper();

            string result = "not calculated";

            try
            {
                result = CalculationModuleDLL.calculationLibCall(calculationType,
                                                               productXmlStr,
                                                               parameterXmlStr,
                                                               underHistData,
                                                               this.referenceDate_
                                                               );

                this.loadResult(e_inst,result);

            }
            catch (Exception e )
            {
                result = "dll error : " + e.Message;

                OutputLogViewModel.addResult(result);

                throw;
            }
            

            //string result = "empty";
            
            //try
            //{
            //    MessageManager messageManager = new MessageManager();

            //    messageManager.loadServerInformation();

            //    MessageViewModel mvm = new MessageViewModel();
                
            //    GridCalculationViewModel gcvm = MessageBodyViewModel.CreateMessageBody("gridCalculation") as GridCalculationViewModel;

            //    gcvm.mergeSetXml(productXmlStr, parameterXmlStr, underHistData);

            //    mvm.TargetCode_ = "gridCalculation";
            //    mvm.MessageBodyViewModel_ = gcvm;

            //    messageManager.send(mvm);

            //    //result = CalculationModuleDLL.calculationLibCall(calculationType,
            //    //                                                        productXmlStr,
            //    //                                                        parameterXmlStr,
            //    //                                                        underHistData
            //    //                                                        );
            //}
            //catch (Exception)
            //{
            //    result = "dll error";
            //}

        }
 public override string value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
 {
     return constVol_;
 }
        public static void SaveInstrument(Excel_instrumentViewModel e_instVM)
        {
            //positionDB.booking(this.viewModel_)
            string productXmlStr = e_instVM.Excel_interfaceViewModel_.productXml();

            //이놈은 나중에 다른 배치로 돌거임..
            //string parameterXmlStr = this.viewModel_.Excel_parameterViewModel_.paraXml();

            // < date , value > //
            //string underHistDataStr = this.viewModel_.Excel_parameterViewModel_.historyUnderData();

            // 현재 program foler로 저장됨

            //System.IO.File.WriteAllText("testProductInfo.xml", productXmlStr);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(productXmlStr);

            string itemCode = e_instVM.MasterInformationViewModel_.Item_code_;

            try
            {
                xmlDoc.Save(path_ + itemCode + ".xml");
            }
            catch (Exception)
            {
                OutputLogViewModel.addResult("Instrument Xml save fail!");
            }

        }
 public abstract Excel_underlyingModel_paraViewModel underModel(Excel_underlyingInfoViewModel excel_uivm,
                                                                Excel_instrumentViewModel excel_instrumentViewModel,
                                                                DateTime dateTime);
        public virtual void AddInstrument(Excel_instrumentViewModel e_instVM)
        {
            this.instrumentList_.Add(e_instVM);

            System.Xml.XmlElement xmlEle
                = this.node_.OwnerDocument.CreateElement("instrument");
            
            xmlEle.InnerText = e_instVM.Item_code_;

            this.node_["instrumentList"].AppendChild(xmlEle);
        }
 public abstract string value(DateTime dateTime, Excel_instrumentViewModel excel_instrumentViewModel, Excel_underlyingInfoViewModel excel_uivm);
Esempio n. 19
0
 public override void AddInstrument(Excel_instrumentViewModel e_instVM)
 {
     //base.AddInstrument(e_instVM);
 }
 public Excel_underlyingModel_paraViewModel underModel(Excel_underlyingInfoViewModel excel_uivm, Excel_instrumentViewModel excel_instrumentViewModel, DateTime dateTime)
 {
     throw new NotImplementedException();
 }
        public void booking(Excel_instrumentViewModel e_instVM)
        {
            ////w.Content = e_instVM.view(true);

            //e_instVM.linkEventPass();

            //    // master db에 박고
            //    // file 저장하고
            //e_instVM.bookingInstrument(); // db에 박음.

            //XMLFileLoader.SaveInstrument(e_instVM);

            //MasterInformationViewModel.WholeMasterPosition_.Add(e_instVM);
            //// 우선은 미분류로 보냄
            //// favoriteViewModel에 instrument List 에 더하고
            //this.rootFavoriteViewModel_.UnClassifiedFavoriteViewModel_.AddInstrument(e_instVM);

            //////이놈은 상품 xml 저장이 아니고 favor xml 저장
            //this.rootFavoriteViewModel_.saveXml();

            ////unclassified_fvm.InstrumentList_.Add(e_instVM);

            //// menu booking의 경우 refDate기준으로 임시 파라메터를 만들어줌.

            //e_instVM.buildParameterFromInstrument(ProgramVariable.ReferenceDate_);

            //XMLFileLoader.SaveParameter(e_instVM.Excel_parameterViewModel_);
            //XMLFileLoader.SaveHistoryData(e_instVM);
        }
Esempio n. 22
0
 public override string value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm)
 {
     return(this.constDrift_);
 }
        private void loadInstrumentList(Excel_instrumentViewModel e_inst)
        {
            //bold로 표시한거 푸는것
            this.rootBookViewModel_.clearSelection();

            if (e_inst != null)
            {
                try
                {
                    e_inst.loadDetailContext();

                    //this.rootBookViewModel_.clearSelection();
                    this.rootBookViewModel_.hasTradeInstrument(e_inst.Trade_id_);

                    this.detailContentsGrid_.Children.Clear();
                    //e_inst.View_.UpdateLayout();
                    e_inst.dataContextRefesh();
                    this.detailContentsGrid_.Children.Add(e_inst.view(false));

                    this.bookFolderTreeView_.Items.Refresh();

                }
                catch (Exception e)
                {
                    OutputLogViewModel.addResult(e.Message);
                    //throw;
                }
                


            }
        }
        //private void fixedBondButton_Click(object sender, RoutedEventArgs e)
        //{
        //    Excel_instrumentViewModel e_instVM = new Excel_instrument_fixedBondViewModel(true);
        //    this.menuBooking(e_instVM);
            
        //}

        //private void elsStepDownKIButton_Click(object sender, RoutedEventArgs e)
        //{
        //    Excel_instrumentViewModel e_instVM = new Excel_instrument_hifiveViewModel(true);

        //    this.menuBooking(e_instVM);
        //}

        //private void elsStepDownKICustomButton_Click(object sender, RoutedEventArgs e)
        //{
        //    Excel_instrumentViewModel e_instVM = new Excel_instrument_stepDownKICustomViewModel(true);

        //    this.menuBooking(e_instVM);
        //}

        //private void compositeOptionButton_Click(object sender, RoutedEventArgs e)
        //{
        //    Excel_instrumentViewModel e_instVM = new Excel_instrument_compositeOptionViewModel(true);

        //    this.menuBooking(e_instVM);
        //}

        //private void makeInstButton_Click(object sender, RoutedEventArgs e)
        //{
        //    Excel_instrumentViewModel e_instVM = new Excel_instrument_generalViewModel(true);

        //    this.menuBooking(e_instVM);

        //}


        //private void vanillaFloatingBondButton_Click(object sender, RoutedEventArgs e)
        //{

        //}

        //private void etcFloatingBondButton_Click(object sender, RoutedEventArgs e)
        //{

        //}

        private void menuBooking(Excel_instrumentViewModel e_instVM)
        {
            Window w = new Window();
            w.Width = 400;
            w.Height = 400;
            w.Content = e_instVM.view(true);

            e_instVM.linkEventPass();

            w.Visibility = 0;

            // booking button 눌리면
            if (w.ShowDialog() == true)
            {
                // master db에 박고
                // file 저장하고
                e_instVM.bookingInstrument(); // db에 박음.
                
                XMLFileLoader.SaveInstrument(e_instVM);

                MasterInformationViewModel.WholeMasterPosition_.Add(e_instVM);
                // 우선은 미분류로 보냄
                // favoriteViewModel에 instrument List 에 더하고
                this.rootFavoriteViewModel_.UnClassifiedFavoriteViewModel_.AddInstrument(e_instVM);

                ////이놈은 상품 xml 저장이 아니고 favor xml 저장
                this.rootFavoriteViewModel_.saveXml();

                //unclassified_fvm.InstrumentList_.Add(e_instVM);

                // menu booking의 경우 refDate기준으로 임시 파라메터를 만들어줌.

                e_instVM.buildParameterFromInstrument(ProgramVariable.ReferenceDate_);

                XMLFileLoader.SaveParameter(e_instVM.Excel_parameterViewModel_);
                XMLFileLoader.SaveHistoryData(e_instVM);
            }
            else
            {

            }
            
        }
 public override void AddInstrument(Excel_instrumentViewModel e_instVM)
 {
     //base.AddInstrument(e_instVM);
 }
        public void loadResult(Excel_instrumentViewModel e_inst,string result)
        {
            this.excel_resultViewModel_.Notional_ =
                e_inst.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.Notional_;

            this.excel_resultViewModel_.loadResultXml(result);
        }
 public BatchItemViewModel(Excel_instrumentViewModel e_inst)
 {
     this.excel_instrumentViewModel_ = e_inst;
 }
        public void setFromXml(System.Xml.XmlNode InstNode)
        {
            this.node_ = InstNode;
            //InstNode["book"]["bookInfo"];

            System.Xml.XmlNode bookInfoNode
                = InstNode["favoriteInfo"];

            this.favoriteName_ = bookInfoNode["favoriteName"].InnerText;
            this.favoriteCode_ = bookInfoNode["favoriteCode"].InnerText;

                System.Xml.XmlNodeList instrumentListNodeList
                    = InstNode["instrumentList"].SelectNodes("instrument");

            foreach (System.Xml.XmlNode item in instrumentListNodeList)
            {
                string instCode = item.InnerText;

                Excel_instrumentViewModel instrument = new Excel_instrumentViewModel();
                instrument.Item_code_ = instCode;

                this.instrumentList_.Add(instrument);

            }
            
            
        }
 public override string value(DateTime dateTime, Excel_instrumentViewModel excel_instrumentViewModel, Excel_underlyingInfoViewModel excel_uivm)
 {
     return this.constDiv_;
 }
 public BatchItemViewModel(Excel_instrumentViewModel e_inst)
 {
     this.excel_instrumentViewModel_ = e_inst;
 }
Esempio n. 31
0
 public override string value(DateTime dateTime, Excel_instrumentViewModel excel_instrumentViewModel, Excel_underlyingInfoViewModel excel_uivm)
 {
     return(constSigma_);
 }
 public abstract Excel_yieldCurveViewModel value(DateTime dateTime, Excel_instrumentViewModel e_instVM, Excel_underlyingInfoViewModel excel_uivm);
        public virtual bool removeInstrument(Excel_instrumentViewModel e_ivm)
        {
            System.Xml.XmlNodeList instrumentListNodeList
                = this.node_["instrumentList"].SelectNodes("instrument");

            foreach (System.Xml.XmlNode item in instrumentListNodeList)
            {
                string code = item.InnerText;

                if (code == e_ivm.Item_code_) 
                {
                    this.instrumentList_.Remove(e_ivm);
                    this.node_["instrumentList"].RemoveChild(item);

                    return true;
                }
            }

            return false;
        }
        public void mergeSetXml(Excel_instrumentViewModel e_inst,DateTime refDate)
        {
            this.inst_code_ = e_inst.Item_code_;
            this.inst_type_ = e_inst.MasterInformationViewModel_.Booking_type_;
            this.inst_name_ = e_inst.MasterInformationViewModel_.Item_name_;
            this.para_refDate_ = refDate;

            this.InnerXml_ = e_inst.mergedXml(this.para_refDate_);
        }
 public abstract Excel_underlyingModel_paraViewModel underModel(Excel_underlyingInfoViewModel excel_uivm,
                                                                Excel_instrumentViewModel excel_instrumentViewModel,
                                                                DateTime dateTime);
        public static void SaveHistoryData(Excel_instrumentViewModel e_inst)
        {
            Excel_parameterViewModel e_paraVM = e_inst.Excel_parameterViewModel_;

            //DateTime tradeDate = e_inst.MasterInformationViewModel_.Trade_date_;

            DateTime effectiveDate = e_inst.Excel_interfaceViewModel_.Excel_issueInfoViewModel_.EffectiveDate_;

            //string historyUnderStr = e_paraVM.historyUnderData(effectiveDate);
            string historyUnderStr = e_inst.Excel_interfaceViewModel_.Excel_underlyingCalcInfoViewModel_.historyUnderData(effectiveDate, e_paraVM.ReferenceDate_);

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(historyUnderStr);

            string itemCode = e_paraVM.ItemCode_;
            string refDateStr = e_paraVM.ReferenceDate_.ToString("yyyyMMdd");

            bool exists = System.IO.Directory.Exists(path_ + refDateStr);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(path_ + refDateStr);
            }


            try
            {
                xmlDoc.Save(path_ + refDateStr + "\\" + itemCode + "_" + refDateStr + "_historyData.xml");
            }
            catch (Exception )
            {
                OutputLogViewModel.addResult("history Xml save fail!");
            }

        }
 public abstract string value(DateTime dateTime, Excel_instrumentViewModel excel_instrumentViewModel, Excel_underlyingInfoViewModel excel_uivm);
Esempio n. 38
0
        public void enqueue_intrument(Excel_instrumentViewModel e_instVM)
        {
            BatchItemViewModel bvm = new BatchItemViewModel(e_instVM);

            this.BatchItemViewModelQueueList_.Add(bvm);
        }