예제 #1
0
        public void SetYCSettingsFromGUI(int YcId)
        {
            YcSettings s = YcSettingsDic.GetYcSett(YcId);              // will return existing one (to overwrite here)

            // or create new default one with Id = YcId
            s.ycd.ZcBasisId  = -1;
            s.ycd.FrwBasisId = -1;
            foreach (var i in CachedData.CachedDayCounterDic.Values)
            {
                if (i.Name == (String)comboBox2.SelectedItem)
                {
                    s.ycd.ZcBasisId = i.Id;
                }
                if (i.Name == (String)comboBox4.SelectedItem)
                {
                    s.ycd.FrwBasisId = i.Id;
                }
            }

            s.ycd.ZcCompounding = (String)comboBox1.SelectedItem;
            //s.ycd.ZcBasisId = CachedData.CachedDayCounterDic[(String)comboBox2.SelectedItem];
            s.ycd.ZcFrequency    = (String)comboBox5.SelectedItem;
            s.ycd.FrwCompounding = (String)comboBox3.SelectedItem;
            //s.ycd.FrwBasisId = CachedData.CachedDayCounterDic[(String)comboBox4.SelectedItem];
            s.ycd.FrwFrequency = (String)comboBox6.SelectedItem;
            s.ycd.FrwTerm      = int.Parse(textBox1.Text);
            s.ycd.FrwTermBase  = (String)comboBox7.SelectedItem;
            s.ifZCCurve        = checkBox1.IsChecked.Value;
            s.ifForwardCurve   = checkBox2.IsChecked.Value;
            s.ZCColor          = this.colorPicker1.Color;
            s.FrwColor         = this.colorPicker2.Color;

            //YcSettingsDic.SetYcSett(CurrentElements.CurrentYCId, s);
        }
예제 #2
0
        public bool SetYCSettingsFromGUI(int YcId) //this function will return true if settings were changed otherwise false
        {
            bool       ifChanged = false;
            YcSettings s         = YcSettingsDic.GetYcSett(YcId); // will return existing one (to overwrite here)
            YcSettings s1        = new YcSettings();

            // or create new default one with Id = YcId
            //   s.ycd.ZcBasisId = -1;
            //   s.ycd.FrwBasisId = -1;
            foreach (var i in CachedData.CachedDayCounterDic.Values)
            {
                if (i.Name == (String)comboBox_ZCbas.SelectedItem)
                {
                    s1.ycd.settings.ZcBasisId = i.Id;
                }

                if (i.Name == (String)comboBox_FRWbas.SelectedItem)
                {
                    s1.ycd.settings.FrwBasisId = i.Id;
                }
            }


            s1.ycd.settings.ZcCompounding = (String)comboBox_ZCcomp.SelectedItem;
            //s.ycd.ZcBasisId = CachedData.CachedDayCounterDic[(String)comboBox2.SelectedItem];
            s1.ycd.settings.ZcFrequency    = (String)comboBox_ZCfre.SelectedItem;
            s1.ycd.settings.FrwCompounding = (String)comboBox_FRWcomp.SelectedItem;
            //s.ycd.FrwBasisId = CachedData.CachedDayCounterDic[(String)comboBox4.SelectedItem];
            s1.ycd.settings.FrwFrequency = (String)comboBox_FRWfre.SelectedItem;
            s1.ycd.settings.FrwTerm      = int.Parse(textBoxTerm.Text);
            s1.ycd.settings.FrwTermBase  = (String)comboBox_FRWterm.SelectedItem;
            s1.ifZCCurve             = checkBox1.IsChecked.Value;
            s1.ifForwardCurve        = checkBox2.IsChecked.Value;
            s1.ZCColor               = this.colorPicker_ZC.Color;
            s1.FrwColor              = this.colorPicker_FRW.Color;
            s1.ycd.settings.ZCColor  = this.colorPicker_ZC.Color.ToString();
            s1.ycd.settings.FrwColor = this.colorPicker_FRW.Color.ToString();



            if ((s1.ycd.settings.ZcBasisId != s.ycd.settings.ZcBasisId) || (s1.ycd.settings.FrwBasisId != s.ycd.settings.FrwBasisId) ||
                (s1.ycd.settings.ZcCompounding != s.ycd.settings.ZcCompounding) || (s1.ycd.settings.ZcBasisId != s.ycd.settings.ZcBasisId) ||
                (s1.ycd.settings.ZcFrequency != s.ycd.settings.ZcFrequency) || (s1.ycd.settings.FrwCompounding != s.ycd.settings.FrwCompounding) ||
                (s1.ycd.settings.FrwBasisId != s.ycd.settings.FrwBasisId) || (s1.ycd.settings.FrwFrequency != s.ycd.settings.FrwFrequency) ||
                (s1.ycd.settings.FrwTerm != s.ycd.settings.FrwTerm) || (s1.ycd.settings.FrwTermBase != s.ycd.settings.FrwTermBase) ||
                (s1.ifZCCurve != s.ifZCCurve) || (s1.ifForwardCurve != s.ifForwardCurve) ||
                (s1.ZCColor != s.ZCColor) || (s1.FrwColor != s.FrwColor))
            {
                ifChanged = true;
                s         = s1;
                s1.ycd.Id = CurrentElements.CurrentYCId;
                YcSettingsDic.SetYcSett(s1.ycd);
            }

            return(ifChanged);
        }
예제 #3
0
파일: CacheData.cs 프로젝트: vovus/curves
 public static YcSettings GetYcSett(int ycId)
 {
     try
     {
         return(ycdDic[ycId]);
     }
     catch (KeyNotFoundException)
     {
         // TODO: OR return NULL instead ?
         ycdDic[ycId]        = new YcSettings(); // create new one with default value
         ycdDic[ycId].ycd.Id = ycId;             // set Id instead of default -1
         return(ycdDic[ycId]);                   // put it into cache
     }
 }
예제 #4
0
        // this is a method to display GUI from SettingsList for corresponding YC
        public void SetControlsFromSettingsForYC(int YcId)
        {
            YcSettings s = YcSettingsDic.GetYcSett(CurrentElements.CurrentYCId);

            this.Title = "Settings: " + s.ycd.Name;
            this.checkBox1.IsChecked           = s.ifZCCurve;
            this.checkBox2.IsChecked           = s.ifForwardCurve;
            this.comboBox_ZCcomp.SelectedItem  = s.ycd.settings.ZcCompounding;
            this.comboBox_ZCbas.SelectedItem   = CachedData.CachedDayCounterDic[s.ycd.settings.ZcBasisId].Name;
            this.comboBox_ZCfre.SelectedItem   = s.ycd.settings.ZcFrequency;
            this.comboBox_FRWcomp.SelectedItem = s.ycd.settings.FrwCompounding;
            this.comboBox_FRWbas.SelectedItem  = CachedData.CachedDayCounterDic[s.ycd.settings.FrwBasisId].Name;
            this.comboBox_FRWfre.SelectedItem  = s.ycd.settings.FrwFrequency;
            this.comboBox_FRWterm.SelectedItem = s.ycd.settings.FrwTermBase;
            this.textBoxTerm.Text      = s.ycd.settings.FrwTerm.ToString();
            this.colorPicker_ZC.Color  = s.ZCColor;
            this.colorPicker_FRW.Color = s.FrwColor;
        }
예제 #5
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            Page1 p = my_parent;// this.Parent as Page1;

            if (p.EntryLine != null)
            {
                p.EntryLine.Clear();
            }

            ((LineSeries)p.chart1.Series[0]).ItemsSource = null;

            this.DialogResult = true;
            if ((((String)comboBox1.SelectedItem) == "") || (((String)comboBox5.SelectedItem) == ""))
            {
                MessageBox.Show("Two curves must be selected");
                return;
            }

            int CurveId1 = CachedData.GetYieldCurveIDbyName((String)comboBox1.SelectedItem);
            int CurveId2 = CachedData.GetYieldCurveIDbyName((String)comboBox5.SelectedItem);

            bool ifComputed1 = CachedData.CachedYieldCurvesDic.ContainsKey(CurveId1) &&                                         //everything is already cached
                               CachedData.CachedYieldCurvesDic[CurveId1].Points.Count != 0;
            bool ifComputed2 = CachedData.CachedYieldCurvesDic.ContainsKey(CurveId2) &&                                         //everything is already cached
                               CachedData.CachedYieldCurvesDic[CurveId2].Points.Count != 0;

            if (!ifComputed1)
            {
                YcSettings s = YcSettingsDic.GetYcSett(CurveId1);

                ObservableCollection <DateTime> dList = new ObservableCollection <DateTime>();

                foreach (YieldCurveEntryDataHistory y in CachedData.CachedEntryDataHistoryList)
                {
                    if (y.YieldCurveId != CurveId1)
                    {
                        continue;
                    }

                    dList.Add(CurrentElements.CurrentDate.AddDays(y.Duration));
                }
                //_service.CalculateDiscountedRateListAsync(YcSettingsDic.GetYcSett(CurveId1).ycd, settlementDate, dList);
            }
            else //everything is already cached
            {
                if (p.ZCLine != null)
                {
                    p.ZCLine.Clear();
                }

                //bool res = p.DrawZCandFrwCurveFromCache(CurveId1, true, false, true);
                bool res = p.DrawResultCurveFromCache(CurveId1, true, 1, this.colorPicker1.Color, 2);
            }

            if (!ifComputed2)
            {
                YcSettings s = YcSettingsDic.GetYcSett(CurveId2);

                ObservableCollection <DateTime> dList = new ObservableCollection <DateTime>();

                foreach (YieldCurveEntryDataHistory y in CachedData.CachedEntryDataHistoryList)
                {
                    if (y.YieldCurveId != CurveId2)
                    {
                        continue;
                    }

                    dList.Add(CurrentElements.CurrentDate.AddDays(y.Duration));
                }
                //_service.CalculateDiscountedRateListAsync(YcSettingsDic.GetYcSett(CurveId2).ycd, settlementDate, dList);
            }
            else //everything is already cached
            {
                if (p.frwLine != null)
                {
                    p.frwLine.Clear();
                }

                //bool res = p.DrawZCandFrwCurveFromCache(CurveId2, true, false, false);
                bool res = p.DrawResultCurveFromCache(CurveId2, true, 2, this.colorPicker2.Color, 2);
            }


            bool res1;

            if (ifComputed1 & ifComputed2)
            {
                res1 = p.DrawCompareDiffCurves(CurveId1, CurveId2);
            }
        }