Esempio n. 1
0
        /// <summary>
        /// Asigna estilos visuales a la interfaz grafica
        /// gruopbox, labels y graficas.
        /// </summary>
        private void lookAndFeel()
        {
            this.BackColor = Color.Black;

            #region GroupBox
            this.groupBox1.BackColor = Color.Black;
            this.groupBox1.ForeColor = Color.White;
            this.groupBox2.ForeColor = Color.White;
            this.groupBox3.ForeColor = Color.White;
            this.groupBox4.ForeColor = Color.White;
            this.groupBox5.ForeColor = Color.White;
            this.groupBox6.ForeColor = Color.White;
            this.groupBox7.ForeColor = Color.White;
            this.groupBox8.ForeColor = Color.White;
            #endregion

            #region Historial CPU
            ChartArea area   = this.chartCpuHistory.ChartAreas[0];
            Series    series = this.chartCpuHistory.Series[0];

            area.BackColor = Color.Black;
            area.AxisX.MajorGrid.LineColor = Color.DarkGreen;
            area.AxisY.MajorGrid.LineColor = Color.DarkGreen;
            this.chartCpuHistory.BackColor = Color.Black;
            series.Color     = Color.Green;
            series.ChartType = SeriesChartType.StackedArea;
            #endregion

            #region CPU bar chart
            area   = this.chartCpuActual.ChartAreas[0];
            series = this.chartCpuActual.Series[0];
            this.chartCpuActual.Series["CPU"].Points.Add(100);//iniciar en 0%

            area.BackColor = Color.Transparent;
            area.AxisX.MajorGrid.LineColor  = Color.Transparent;
            area.AxisY.MajorGrid.LineColor  = Color.Transparent;
            area.AxisX.LabelStyle.ForeColor = Color.Transparent;
            area.AxisX2.LineColor           = Color.Transparent;

            chartCpuActual.BackColor = Color.Transparent;
            series.ChartType         = SeriesChartType.Bar;
            #endregion

            #region pie RAM
            chartRamPie.Series[0].ChartType = SeriesChartType.Pie;
            area           = this.chartRamPie.ChartAreas[0];
            area.BackColor = Color.Transparent;
            area.AxisY.MajorGrid.LineColor = Color.Transparent;
            chartRamPie.BackColor          = Color.Transparent;
            #endregion

            #region Historial RAM
            barGreenStyle(this.chartRamHistory, false);
            #endregion

            #region Network & Disk Charts
            barGreenStyle(this.chartDiskReads, true);
            barGreenStyle(this.chartDiskWrites, true);
            barGreenStyle(this.chartNetIn, true);
            barGreenStyle(this.chartNetOut, true);
            #endregion
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // Payment scheme
            double initialNotional = Convert.ToDouble(tb_notional.Text);
            bool   isScopeSpread   = String.IsNullOrWhiteSpace(tb_spread.Text); // text for spread textbox
            bool   isScopeUpfront  = String.IsNullOrWhiteSpace(tb_quotedupfront.Text);
            double upfront         = 0.0;
            double spread          = 0.0;

            if (isScopeSpread == false)
            {
                spread = Convert.ToDouble(tb_spread.Text) / 10000;
            }
            if (isScopeUpfront == false)
            {
                upfront = Convert.ToDouble(tb_quotedupfront.Text) / 100;
            }
            //The trade level, if spread not equal coupon rate, then upfront fee is paid
            double coupon_rate = Convert.ToDouble(tb_fixrate.Text) / 10000; //The coupon paid by premium buyer
            string frequency   = cmb_frequency.Text;                        //   LB_frequency.Text;
            Int16  settle      = Convert.ToInt16(tb_cashsettle.Text);


            //Key dates
            DateTime Maturity     = Convert.ToDateTime(tb_maturity.Text);
            DateTime firstpayday  = Convert.ToDateTime(tb_firstpayday.Text);  //the first premium payment date
            DateTime formerpayday = Convert.ToDateTime(tb_formerpayday.Text); //the first premium payment date
            DateTime tradedate    = Convert.ToDateTime(tb_tradeDate.Text);    //the first premium payment date

            //Data to construct yield curve and credit curve
            double RecoveryRate = Convert.ToDouble(tb_recovery.Text);
            //Running spread of comparable products, assuming zero entry fee and same payment schema as the current product
            List <double> QuotedSpread = new List <double> {
                Convert.ToDouble(qs_6M.Text), Convert.ToDouble(qs_1Y.Text), Convert.ToDouble(qs_3Y.Text)
                , Convert.ToDouble(qs_5Y.Text), Convert.ToDouble(qs_7Y.Text), Convert.ToDouble(qs_10Y.Text)
            };
            //Benchmark interest rates, consisting of Libor, Deposit and SWAP
            List <double> QuotedSpot = new List <double> {
                Convert.ToDouble(ir_1M.Text), Convert.ToDouble(ir_2M.Text), Convert.ToDouble(ir_3M.Text),
                Convert.ToDouble(ir_6M.Text), Convert.ToDouble(tb_9M.Text), Convert.ToDouble(ir_1Y.Text),
                Convert.ToDouble(ir_2Y.Text), Convert.ToDouble(ir_3Y.Text), Convert.ToDouble(ir_4Y.Text), Convert.ToDouble(ir_5Y.Text), Convert.ToDouble(ir_6Y.Text),
                Convert.ToDouble(ir_7Y.Text), Convert.ToDouble(ir_8Y.Text), Convert.ToDouble(ir_9Y.Text), Convert.ToDouble(ir_10Y.Text), Convert.ToDouble(ir_11Y.Text), Convert.ToDouble(ir_12Y.Text),
                Convert.ToDouble(ir_15Y.Text), Convert.ToDouble(ir_20Y.Text), Convert.ToDouble(ir_25Y.Text), Convert.ToDouble(ir_30Y.Text)
            };

            // decide which scope we should use for computation

            String usecreditcurve = Convert.ToString(tb_usecreditcurve.Checked);

            switch (usecreditcurve)
            {
            case "True":
                //Use credit curve predefined
                break;

            case "False":
                QuotedSpread = null;
                break;

            default:
                break;
            }


            //Input & Output
            //Case 1: Input: coupon rate, credit curve, standard contract
            //      Output: upfront
            //Case 2: Input: coupon rate, upfront
            //      Output: spread, net amount paid
            //Case 2: Input: coupon rate, upfront
            //      Output: upfront, net amount paid
            CDS cds = new CDS(coupon_rate, initialNotional, Maturity, firstpayday, tradedate,
                              formerpayday, frequency, RecoveryRate, settle, 3);

            cds.Curve_Building(QuotedSpot, QuotedSpread, spread, upfront);
            cds.Pricing();

            dataGridView_fix.DataSource = cds.FixLeg;
            lb_zeroRates.DataSource     = cds.zero_rates;

            accrued.Text    = Convert.ToString(cds.accruedday);
            accruedamt.Text = Convert.ToString(cds.accruedamt);

            tb_upfront.Text   = Convert.ToString(cds.pv / initialNotional * 100);
            market_value.Text = Convert.ToString(cds.pv);
            clean_price.Text  = Convert.ToString((1 - cds.pv / initialNotional) * 100);
            //chart1.DataSource= cds.yield_series;
            this.chart2.Palette = ChartColorPalette.SeaGreen;
            // Set title.
            //this.chart1.Titles.Add("Pets");

            // Add series.
            for (int i = 1; i < cds.survival_prob.Count; i++)
            {
                // Add series.
                Series series = this.chart2.Series.Add(i.ToString());

                // Add point.
                series.Points.AddXY(i, cds.survival_prob[i]);
            }


            // Set palette.
            this.chart1.Palette = ChartColorPalette.SeaGreen;
            // Add series.
            for (int i = 1; i < cds.yield_series.Count; i++)
            {
                // Add series.
                Series series1 = this.chart1.Series.Add(i.ToString());

                // Add point.
                series1.Points.AddXY(i, cds.yield_series[i]);
            }
            //Form2 frm = new Form2();
        }