Beispiel #1
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            ss.K        = Double.Parse(this.labelk.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Lambda_X = Double.Parse(this.labellambdax.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Sigma_x  = Double.Parse(this.labelsigma_x.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Mu_e     = Double.Parse(this.labelmu_e.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Sigma_e  = Double.Parse(this.labelsigma_e.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Lambda_e = Double.Parse(this.labellambdae.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.P_xe     = Double.Parse(this.labelpxe.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.e0       = Double.Parse(this.labele0.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.x0       = Double.Parse(this.labelx0.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.MaxIter  = Int32.Parse(this.labelMaxIter.Text);



            ParamCalibrationForm pcf = new ParamCalibrationForm()
            {
                ss = this.ss
            };

            if (pcf.ShowDialog() == DialogResult.OK)
            {
                ss                = pcf.ss;
                labelk.Text       = ss.K.ToString();
                labellambdax.Text = ss.Lambda_X.ToString();
                labellambdae.Text = ss.Lambda_e.ToString();
                labelsigma_e.Text = ss.Sigma_e.ToString();
                labelsigma_x.Text = ss.Sigma_x.ToString();
                labelpxe.Text     = ss.P_xe.ToString();
                labelmu_e.Text    = ss.Mu_e.ToString();
                labele0.Text      = ss.e0.ToString();
                labelx0.Text      = ss.x0.ToString();
                labelMaxIter.Text = ss.MaxIter.ToString();
            }
        }
        private void buttonCalibrate_Click(object sender, EventArgs e)
        {
            CalibrationForm cf = new CalibrationForm(ss);
            DialogResult r = cf.ShowDialog();
            if (r == DialogResult.OK) /** Calibration successful */
            {
                if(cf.generatedSpot!=null) curveViewer.AddCurve(new CurveViewer.Curve(cf.generatedSpot, Color.Red));
                ss = cf.ss;

                foreach (DataGridViewRow dgvr in dataGridViewFutures.Rows)
                {
                    DataGridViewCellCollection cells = dgvr.Cells;
                    double mat = (double)cells[0].Value;
                    cells[1].Value = PriceFuture(mat);
                }

                foreach (DataGridViewRow dgvr in dataGridViewOption.Rows)
                {
                    DataGridViewCellCollection cells = dgvr.Cells;
                    Option newOpt = new Option()
                    {
                        Value = (double)cells[0].Value,
                        StrikePrice = (double)cells[1].Value,
                        DaysTilExpiry = (int)cells[2].Value,
                        Type = (string)cells[3].Value,
                    };
                    cells[4].Value = PriceOption(newOpt);
                }

            }
        }
Beispiel #3
0
 private void buttonDefault_Click(object sender, EventArgs e)
 {
     ss                = new ParamSS();
     labelk.Text       = ss.K.ToString();
     labellambdax.Text = ss.Lambda_X.ToString();
     labellambdae.Text = ss.Lambda_e.ToString();
     labelsigma_e.Text = ss.Sigma_e.ToString();
     labelsigma_x.Text = ss.Sigma_x.ToString();
     labelpxe.Text     = ss.P_xe.ToString();
     labelmu_e.Text    = ss.Mu_e.ToString();
     labele0.Text      = ss.e0.ToString();
     labelx0.Text      = ss.x0.ToString();
     labelMaxIter.Text = ss.MaxIter.ToString();
 }
        public CalibrationForm(ParamSS s = null)
        {
            if (s != null)
                ss = s;
            else
                ss = new ParamSS();
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            InitializeComponent();

            labelk.Text = ss.K.ToString();
            labellambdax.Text = ss.Lambda_X.ToString();
            labellambdae.Text = ss.Lambda_e.ToString();
            labelsigma_e.Text = ss.Sigma_e.ToString();
            labelsigma_x.Text = ss.Sigma_x.ToString();
            labelpxe.Text = ss.P_xe.ToString();
            labelmu_e.Text = ss.Mu_e.ToString();
            labele0.Text = ss.e0.ToString();
            labelx0.Text = ss.x0.ToString();
            labelMaxIter.Text = ss.MaxIter.ToString();
        }
Beispiel #5
0
        public CalibrationForm(ParamSS s = null)
        {
            if (s != null)
            {
                ss = s;
            }
            else
            {
                ss = new ParamSS();
            }
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
            InitializeComponent();

            labelk.Text       = ss.K.ToString();
            labellambdax.Text = ss.Lambda_X.ToString();
            labellambdae.Text = ss.Lambda_e.ToString();
            labelsigma_e.Text = ss.Sigma_e.ToString();
            labelsigma_x.Text = ss.Sigma_x.ToString();
            labelpxe.Text     = ss.P_xe.ToString();
            labelmu_e.Text    = ss.Mu_e.ToString();
            labele0.Text      = ss.e0.ToString();
            labelx0.Text      = ss.x0.ToString();
            labelMaxIter.Text = ss.MaxIter.ToString();
        }
Beispiel #6
0
        private void buttonCalibrate_Click(object sender, EventArgs e)
        {
            CalibrationForm cf = new CalibrationForm(ss);
            DialogResult    r  = cf.ShowDialog();

            if (r == DialogResult.OK) /** Calibration successful */
            {
                if (cf.generatedSpot != null)
                {
                    curveViewer.AddCurve(new CurveViewer.Curve(cf.generatedSpot, Color.Red));
                }
                ss = cf.ss;


                foreach (DataGridViewRow dgvr in dataGridViewFutures.Rows)
                {
                    DataGridViewCellCollection cells = dgvr.Cells;
                    double mat = (double)cells[0].Value;
                    cells[1].Value = PriceFuture(mat);
                }


                foreach (DataGridViewRow dgvr in dataGridViewOption.Rows)
                {
                    DataGridViewCellCollection cells = dgvr.Cells;
                    Option newOpt = new Option()
                    {
                        Value         = (double)cells[0].Value,
                        StrikePrice   = (double)cells[1].Value,
                        DaysTilExpiry = (int)cells[2].Value,
                        Type          = (string)cells[3].Value,
                    };
                    cells[4].Value = PriceOption(newOpt);
                }
            }
        }
        private void buttonSet_Click(object sender, EventArgs e)
        {
            ss.K = Double.Parse(this.labelk.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Lambda_X = Double.Parse(this.labellambdax.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Sigma_x = Double.Parse(this.labelsigma_x.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Mu_e = Double.Parse(this.labelmu_e.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Sigma_e = Double.Parse(this.labelsigma_e.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.Lambda_e = Double.Parse(this.labellambdae.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.P_xe = Double.Parse(this.labelpxe.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.e0 = Double.Parse(this.labele0.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.x0 = Double.Parse(this.labelx0.Text, NumberStyles.AllowDecimalPoint | NumberStyles.Float);
            ss.MaxIter = Int32.Parse(this.labelMaxIter.Text);

            ParamCalibrationForm pcf = new ParamCalibrationForm()
            {
                ss = this.ss
            };
            if (pcf.ShowDialog() == DialogResult.OK)
            {
                ss = pcf.ss;
                labelk.Text = ss.K.ToString();
                labellambdax.Text = ss.Lambda_X.ToString();
                labellambdae.Text = ss.Lambda_e.ToString();
                labelsigma_e.Text = ss.Sigma_e.ToString();
                labelsigma_x.Text = ss.Sigma_x.ToString();
                labelpxe.Text = ss.P_xe.ToString();
                labelmu_e.Text = ss.Mu_e.ToString();
                labele0.Text = ss.e0.ToString();
                labelx0.Text = ss.x0.ToString();
                labelMaxIter.Text = ss.MaxIter.ToString();
            }
        }
 private void buttonDefault_Click(object sender, EventArgs e)
 {
     ss = new ParamSS();
     labelk.Text = ss.K.ToString();
     labellambdax.Text = ss.Lambda_X.ToString();
     labellambdae.Text = ss.Lambda_e.ToString();
     labelsigma_e.Text = ss.Sigma_e.ToString();
     labelsigma_x.Text = ss.Sigma_x.ToString();
     labelpxe.Text = ss.P_xe.ToString();
     labelmu_e.Text = ss.Mu_e.ToString();
     labele0.Text = ss.e0.ToString();
     labelx0.Text = ss.x0.ToString();
     labelMaxIter.Text = ss.MaxIter.ToString();
 }
 public MainForm()
 {
     InitializeComponent();
     ss = new ParamSS();
     curveViewer.MouseMoved += new CurveViewer.MouseMovedEvt(curveViewer_MouseMoved);
 }
Beispiel #10
0
 public MainForm()
 {
     InitializeComponent();
     ss = new ParamSS();
     curveViewer.MouseMoved += new CurveViewer.MouseMovedEvt(curveViewer_MouseMoved);
 }