Ejemplo n.º 1
0
 private void add3_Click(object sender, EventArgs e)
 {
     try
     {
         if (companyname3.Text != "" && ticker3.Text != "" && exchange3.Text != "")
         {
             Instrument inst = new Instrument();
             string type; //mySave;
             inst.CompanyName = companyname3.Text;
             inst.Ticker = ticker3.Text;
             inst.Exchange = exchange3.Text;
             inst.Underlying = label.Text;
             inst.Strike = Convert.ToDouble(strike3.Value);
             inst.Tenor = Convert.ToDouble(tenor3.Value);
             if (call3.Checked == true)
                 inst.IsCall = 0;
             else if (put3.Checked == true)
                 inst.IsCall = 1;
             else
                 inst.IsCall = 2;
             type = insttype3.SelectedItem.ToString();
             IQueryable<InstType> temp = from p in portfolio.InstTypes
                                         where p.TypeName == type
                                         select p;//find out the intrument type id for new instrument
             foreach (InstType i in temp)
             {
                 if (i.TypeName == type)
                     inst.InstTypeId = i.Id;
             }
             portfolio.Instruments.Add(inst);
             portfolio.SaveChanges();
             MessageBox.Show("Data added successfully", "Notice");
             this.Close();
         }
         else
             MessageBox.Show("Please input the CompanyName, Ticker, Exchange", "Notice");
     }
     catch { MessageBox.Show("Something wrong, please check wheather the inputs are correct."); }
 }
Ejemplo n.º 2
0
        private void testdata2()
        {
            Instrument inst = new Instrument();
            inst.CompanyName = "MicroSoft";
            inst.Ticker = "MSFTC50Euro";
            inst.Underlying = "MSFT";
            inst.Strike = 50;
            inst.Tenor = 1;
            inst.IsCall = 0;
            var v = (from i in portfolio.InstTypes
                     where i.TypeName == "EuropeanOption"
                     select i.Id).First();
            inst.InstTypeId = v;
            portfolio.Instruments.Add(inst);
            portfolio.SaveChanges();

            Instrument inst2 = new Instrument();
            inst2.CompanyName = "Sina";
            inst2.Ticker = "SINAC50BARR";
            inst2.Underlying = "SINA";
            inst2.Strike = 50;
            inst2.Tenor = 1;
            inst2.IsCall = 0;
            var v2 = (from i in portfolio.InstTypes
                      where i.TypeName == "BarrierOption"
                      select i.Id).First();
            inst2.InstTypeId = v2;
            portfolio.Instruments.Add(inst2);
            portfolio.SaveChanges();

            Instrument inst3 = new Instrument();
            inst3.CompanyName = "MicroSoft";
            inst3.Ticker = "MSFT";
            inst3.Underlying = "MSFT";
            inst3.Strike = 50;
            inst3.Tenor = 1;
            inst3.IsCall = 0;
            var v3 = (from i in portfolio.InstTypes
                      where i.TypeName == "Stock"
                      select i.Id).First();
            inst3.InstTypeId = v3;
            portfolio.Instruments.Add(inst3);
            portfolio.SaveChanges();
        }