Пример #1
0
 private void button1_Click(object sender, EventArgs e)//update selected history price
 {
     try {
         int id = Convert.ToInt32(textBox_id.Text);
         container.Entity_Historyprice.Remove((from i in container.Entity_Historyprice
                                               where i.Id == id
                                               select i).First());
         container.SaveChanges();
         double   closeprice  = Convert.ToDouble(textBox_histprice.Text);
         string   ticker      = textBox_companyticker.Text;
         string   companyname = textBox_name.Text;
         DateTime pricedate   = Convert.ToDateTime(textBox_date.Text);
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             ClosePrice  = closeprice,
             Date        = pricedate,
             Ticker      = ticker,
             Id          = Convert.ToInt32(textBox_id.Text),
             CompanyName = textBox_name.Text
         });
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = id, CompanyName = companyname, Ticker = ticker, ClosePrice = closeprice, Date = pricedate,
         });
         container.SaveChanges();
         MessageBox.Show("You update a new history price!");
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)    //remove selected rate
        {
            int id = Convert.ToInt32(textBox_rateID.Text);

            container.Entity_rate.Remove((from i in container.Entity_rate
                                          where i.Id == id
                                          select i).First());
            container.SaveChanges();
            MessageBox.Show("Delete a Rate Successfully! ");
            Dispose();
        }
Пример #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         double   closeprice  = Convert.ToDouble(textBox_histprice.Text);//Input element to database
         string   ticker      = textBox_companyticker.Text;
         int      id          = Convert.ToInt32(textBox_id.Text);
         string   companyname = textBox_name.Text;
         DateTime pricedate   = Convert.ToDateTime(textBox_date.Text);
         container.Entity_Historyprice.Add(new Entity_Historyprice() //add to database
         {
             ClosePrice  = closeprice,
             Date        = pricedate,
             Ticker      = ticker,
             Id          = Convert.ToInt32(textBox_id.Text),
             CompanyName = textBox_name.Text
         });
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = id, CompanyName = companyname, Ticker = ticker, ClosePrice = closeprice, Date = pricedate,
         });
         container.SaveChanges();
         MessageBox.Show("You add a new history price!"); //finish adding
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int    id         = Convert.ToInt32(textBox_tradeID.Text);
         short  direction  = Convert.ToInt16(comboBox_direction.SelectedIndex == 0 ? 1 : 0);
         int    quantity   = Convert.ToInt32(textBox_quantity.Text);
         double tradeprice = Convert.ToDouble(textBox_tradeprice.Text);
         // string insttype =Convert.ToString(comboBox_instType.SelectedItem);
         //string type = Convert.ToString(comboBox_Type.SelectedItem);
         container.Entity_Trade.Add(new Entity_Trade()
         {
             Id                  = id,
             Direction           = direction,
             Quantity            = quantity,
             Tradeprice          = tradeprice,
             Entity_instrumentId = Convert.ToInt32(textBox_instid.Text)
         });
         container.SaveChanges();
         MessageBox.Show("You add a new trade!");
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #5
0
 private void button1_Click(object sender, EventArgs e) //add interest rate
 {
     try
     {
         container.Entity_rate.Add(new Entity_rate()
         {
             Id = Convert.ToInt32(textBox_id.Text), Tenor = Convert.ToDouble(textBox_tenor.Text), Interest_rate = Convert.ToDouble(textBox_rate.Text)
         });
         container.SaveChanges();
         MessageBox.Show("You add a new interest rate!");
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #6
0
 private void button1_Click(object sender, EventArgs e)
 {
     try {
         int    id = Convert.ToInt32(textBox_id.Text);
         string companyname = textBox_companyname.Text;
         string ticker = textBox_Ticker.Text;
         string exchange = textBox_exchange.Text;
         string instype = comboBox_istype.SelectedItem.ToString();
         double underlying = Convert.ToDouble(textBox_Underlying.Text);
         double barrier; double rebate; string type; double tenor;
         if (comboBox_istype.SelectedIndex == 0) //if stock selected
         {
             type = "Neither call nor put";
             container.Entity_instrument.Add(new Entity_instrument()
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Type          = type,
                 Instype       = instype,
                 Entity_rateId = 1
             });
         }
         else if (comboBox_istype.SelectedIndex == 1 || comboBox_istype.SelectedIndex == 3 || comboBox_istype.SelectedIndex == 4)
         //european option or aisan or lookback option selected
         {
             tenor = Convert.ToDouble(textBox_tenor.Text);
             type  = Convert.ToString(comboBox_type.SelectedItem);
             string strike = textBox_strike.Text;
             container.Entity_instrument.Add(new Entity_instrument
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Strike        = strike,
                 Type          = type,
                 Instype       = instype,
                 Tenor         = tenor,
                 Entity_rateId = Convert.ToInt32(textBox_rateid.Text)
             });
         }
         //if range option selected
         else if (comboBox_istype.SelectedIndex == 2)
         {
             tenor = Convert.ToDouble(textBox_tenor.Text);
             container.Entity_instrument.Add(new Entity_instrument
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Instype       = instype,
                 Tenor         = tenor,
                 Entity_rateId = Convert.ToInt32(textBox_rateid.Text)
             });
         }
         //if digital option selected
         else if (comboBox_istype.SelectedIndex == 9)
         {
             rebate = Convert.ToDouble(textBox_rebate.Text);
             tenor  = Convert.ToDouble(textBox_tenor.Text);
             type   = Convert.ToString(comboBox_type.SelectedItem);
             string strike = textBox_strike.Text;
             container.Entity_instrument.Add(new Entity_instrument
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Strike        = strike,
                 Rebate        = rebate,
                 Type          = type,
                 Instype       = instype,
                 Tenor         = tenor,
                 Entity_rateId = Convert.ToInt32(textBox_rateid.Text)
             });
         }
         //if barrier option selected
         else   //(comboBox_istype.SelectedIndex == 5 || comboBox_istype.SelectedIndex == 6 || comboBox_istype.SelectedIndex == 7 || comboBox_istype.SelectedIndex == 8)
         {
             barrier = Convert.ToDouble(textBox_barrier.Text);
             tenor   = Convert.ToDouble(textBox_tenor.Text);
             type    = Convert.ToString(comboBox_type.SelectedItem);
             string strike = textBox_strike.Text;
             container.Entity_instrument.Add(new Entity_instrument
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Strike        = strike,
                 Barrier       = barrier,
                 Type          = type,
                 Instype       = instype,
                 Tenor         = tenor,
                 Entity_rateId = Convert.ToInt32(textBox_rateid.Text)
             });
         }
         container.SaveChanges();
         MessageBox.Show("You add a new instrument!");
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #7
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         int id = Convert.ToInt32(textBox_id.Text);
         container.Entity_instrument.Remove((from i in container.Entity_instrument
                                             where i.Id == id
                                             select i).First());
         container.SaveChanges();
         string companyname = textBox_companyname.Text;
         string ticker = textBox_Ticker.Text;
         string exchange = textBox_exchange.Text;
         string instype = Convert.ToString(comboBox_istype.SelectedItem);
         double underlying = Convert.ToDouble(textBox_Underlying.Text);
         double strike; double barrier; double rebate; string type; double tenor;
         if (comboBox_istype.SelectedIndex == 0) //if stock selected
         {
             type = "Neither call nor put";
             container.Entity_instrument.Add(new Entity_instrument()
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Strike        = Convert.ToString(0),
                 Barrier       = 0,
                 Rebate        = 0,
                 Type          = type,
                 Instype       = instype,
                 Tenor         = 0,
                 Entity_rateId = 1
             });
         }
         else
         {
             tenor = Convert.ToDouble(textBox_tenor.Text);
             type  = Convert.ToString(comboBox_type.SelectedItem);
             if (comboBox_istype.SelectedIndex == 2)
             {
                 strike = 0;
             }
             else
             {
                 strike = Convert.ToDouble(textBox_strike.Text);
             }
             if (comboBox_istype.SelectedIndex == 9)
             {
                 rebate = Convert.ToDouble(textBox_rebate);
             }
             else
             {
                 rebate = 0;
             }
             //if barrier option selected
             if (comboBox_istype.SelectedIndex == 5 || comboBox_istype.SelectedIndex == 6 || comboBox_istype.SelectedIndex == 7 || comboBox_istype.SelectedIndex == 8)
             {
                 barrier = Convert.ToDouble(textBox_barrier.Text);
             }
             else
             {
                 barrier = 0;
             }
             container.Entity_instrument.Add(new Entity_instrument
             {
                 Id            = id,
                 CompanyName   = companyname,
                 Ticker        = ticker,
                 Exchange      = exchange,
                 Underlying    = underlying,
                 Strike        = Convert.ToString(strike),
                 Barrier       = barrier,
                 Rebate        = rebate,
                 Type          = type,
                 Instype       = instype,
                 Tenor         = tenor,
                 Entity_rateId = Convert.ToInt32(textBox_rateid.Text)
             });
         }
         container.SaveChanges();
         MessageBox.Show("You update a new instrument!");
         Dispose();
     }
     catch (Exception x)
     {
         MessageBox.Show("Error:" + x);
     }
 }
Пример #8
0
 private void addSampleToolStripMenuItem_Click(object sender, EventArgs e) //add sample data to database
 {
     if (!container.Entity_Historyprice.Any())                             //if there is no data in database
     {                                                                     //insert basic element to database before users using
         container.Entity_rate.Add(new Entity_rate()
         {
             Id = 1, Tenor = 1, Interest_rate = 0.05
         });
         container.Entity_rate.Add(new Entity_rate()
         {
             Id = 2, Tenor = 2, Interest_rate = 0.08
         });
         container.Entity_rate.Add(new Entity_rate()
         {
             Id = 3, Tenor = 0.5, Interest_rate = 0.03
         });
         DateTime date = new DateTime(2020, 05, 08);
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = 1, Ticker = "MSFT", CompanyName = "Microsoft", ClosePrice = 184, Date = date
         });
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = 2, Ticker = "AAPL", CompanyName = "APPLE.Inc", ClosePrice = 310.13, Date = date
         });
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = 3, Ticker = "HPQ", CompanyName = "HP.Inc", ClosePrice = 15.66, Date = date
         });
         container.Entity_Historyprice.Add(new Entity_Historyprice()
         {
             Id = 4, Ticker = "AMZN", CompanyName = "Amazon", ClosePrice = 2379.61, Date = date
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 1, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Stock", Exchange = "NASDAQ", Underlying = 184
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 2, Tenor = 1, Entity_rateId = 1, CompanyName = "Apple", Ticker = "AAPL", Instype = "Stock", Exchange = "NASDAQ", Underlying = 310.13
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 3, Tenor = 1, Entity_rateId = 1, CompanyName = "HP.Inc", Ticker = "HPQ", Instype = "Stock", Exchange = "NASDAQ", Underlying = 15.66
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 4, Tenor = 1, Entity_rateId = 1, CompanyName = "Amazon", Ticker = "AMZN", Instype = "Stock", Exchange = "NASDAQ", Underlying = 2379.61
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 5, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "European", Exchange = "NASDAQ", Underlying = 184, Strike = 180.ToString(), Type = "Call"
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 6, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Asian", Exchange = "NASDAQ", Underlying = 184, Strike = 180.ToString(), Type = "Call"
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 7, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Lookback", Exchange = "NASDAQ", Underlying = 184, Strike = 180.ToString(), Type = "Call"
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 8, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Digital", Exchange = "NASDAQ", Underlying = 184, Strike = 180.ToString(), Type = "Call", Rebate = 10
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 9, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Barrier", Exchange = "NASDAQ", Underlying = 184, Strike = 180.ToString(), Type = "Call", Barrier = 190
         });
         container.Entity_instrument.Add(new Entity_instrument()
         {
             Id = 10, Tenor = 1, Entity_rateId = 1, CompanyName = "Microsoft", Ticker = "MSFT", Instype = "Range", Exchange = "NASDAQ", Underlying = 184
         });
         container.Entity_Trade.Add(new Entity_Trade()
         {
             Id = 1, Quantity = 100, Direction = 0, Entity_instrumentId = 1, Tradeprice = 178
         });
         container.Entity_Trade.Add(new Entity_Trade()
         {
             Id = 2, Quantity = 100, Direction = 1, Entity_instrumentId = 5, Tradeprice = 20
         });
         container.Entity_Trade.Add(new Entity_Trade()
         {
             Id = 3, Quantity = 100, Direction = 1, Entity_instrumentId = 6, Tradeprice = 15
         });
         container.Entity_Trade.Add(new Entity_Trade()
         {
             Id = 4, Quantity = 100, Direction = 0, Entity_instrumentId = 7, Tradeprice = 30
         });
         container.SaveChanges();
         MessageBox.Show("You add sample successfully!");
     }
     else
     {
         MessageBox.Show("Add sample failed: Sample already exists!");
     }
 }