コード例 #1
0
 public void update(RealTimeData sub)
 {
     this.sub = sub;
     foreach (Company company in sub.companies)
     {
         if (companyName == company.companyName)
         {
             //Clear previous entries from the dataGridView and reset heads?? Not sure how/why, but it prevents crashes...
             dataGridView1.Rows.Clear();
             dataGridView1.ColumnCount = 2;
             dataGridView1.ColumnHeadersVisible = true;
             //Sort the buy orders according to its implementation of CompareTo
             company.buyOrders.Sort();
             foreach (BuyOrder buyOrder in company.buyOrders.Take(10)) //only take top 10
             {
                 this.dataGridView1.Rows.Add(buyOrder.orderSize,buyOrder.orderPrice);
             }
             dataGridView2.Rows.Clear();
             dataGridView1.ColumnCount = 2;
             dataGridView1.ColumnHeadersVisible = true;
             //Sort the sell orders according to its implementation of CompareTo
             company.sellOrders.Sort();
             foreach (SellOrder sellOrder in company.sellOrders.Take(10)) //only take top 10
             {
                 this.dataGridView2.Rows.Add(sellOrder.orderPrice, sellOrder.orderSize);
             }
         }
     }
 }
コード例 #2
0
 public placeBidOrderForm(RealTimeData data)
 {
     this.data = data;
     InitializeComponent();
     //Add companies to the drop down list
     foreach (Company company in data.companies)
     {
         comboBox1.Items.Add(company.companyName);
     }
 }
コード例 #3
0
        RealTimeData data; //used to modify the subject

        #endregion Fields

        #region Constructors

        public placeAskOrderForm(RealTimeData data)
        {
            this.data = data;
            InitializeComponent();
            //populate the dropdown company list from the companies in the subject
            foreach (Company company in data.companies)
            {
                comboBox1.Items.Add(company.companyName);
            }
        }
コード例 #4
0
 //Will fill all applicable columns of stock state summary for all companies in the subject
 public void update(RealTimeData sub)
 {
     this.sub = sub;
     dataGridView1.Rows.Clear();
     // Create an unbound DataGridView by declaring a column count, prevents mising header after clear
     dataGridView1.ColumnCount = 8;
     dataGridView1.ColumnHeadersVisible = true;
     foreach (Company company in sub.companies)
         this.dataGridView1.Rows.Add(company.companyName, company.symbol, company.openPrice, company.getLastPrice(), company.priceChange,company.picture, company.percentChange, company.getVolume());
 }
コード例 #5
0
 //This is called upon notifying the subject that the data has changed
 public void update(RealTimeData sub)
 {
     this.sub = sub;
     foreach (Company company in sub.companies)
     {
         if (companyName == company.companyName)
         {
             //BUY ORDERS
             //Clear existing entries from the datagridview for bids
             dataGridView1.Rows.Clear();
             foreach (BuyOrder order in company.buyOrders)
             {
                 int numOccurs = 0;
                 if (!usedPrices.Contains(order.orderPrice))
                 {
                     //For each order, traverse the rest of the list and see if there are any others with the same price,
                     //If there are, increment numOccurs, add volume together
                     usedPrices.Add(order.orderPrice);
                     int totalVolume = 0;
                     foreach (BuyOrder CompressedOrder in company.buyOrders.Skip(0))
                     {
                         if (CompressedOrder.orderPrice == order.orderPrice) //if current iterated order has the same price as exterior order
                         {
                             numOccurs++; //increase the occurances of an order with this price
                             totalVolume += (int)CompressedOrder.orderSize; //add the volume of orders with this price
                         }
                     }
                     //create a new instance of helper class listItem with the number of occurances, the price and the volume
                     entries.Add(new listItem(numOccurs, order.orderPrice, totalVolume));
                     numOccurs = 0; //reset
                     totalVolume = 0; //reset
                 }
             }
             //Add each list item to the datagrid view, should already be properly sorted
             foreach (listItem entry in entries.Take(10)) //only take top 10
             {
                 this.dataGridView1.Rows.Add(entry.numOccurs, entry.orderSize, entry.orderPrice);
             }
             entries.Clear(); //Clear entries so that the same list can be used for sell orders now
             usedPrices.Clear(); //clear list, same reasoning
             //SELL ORDERS
             //Clear existing entries from the datagridview for bids
             dataGridView2.Rows.Clear();
             foreach (SellOrder order in company.sellOrders)
             {
                 int numOccurs = 0;
                 if (!usedPrices.Contains(order.orderPrice))
                 {
                     //For each order, traverse the rest of the list and see if there are any others with the same price,
                     //If there are, increment numOccurs, add volume together
                     usedPrices.Add(order.orderPrice);
                     int totalVolume = 0;
                     foreach (SellOrder CompressedOrder in company.sellOrders.Skip(0))
                     {
                         if (CompressedOrder.orderPrice == order.orderPrice) //if current iterated order has the same price as exterior order
                         {
                             numOccurs++;
                             totalVolume += (int)CompressedOrder.orderSize;
                         }
                     }
                     entries.Add(new listItem(numOccurs, order.orderPrice, totalVolume));
                     numOccurs = 0;
                     totalVolume = 0;
                 }
             }
             //add all sell orderst that have been grouped, should already be sorted
             foreach (listItem entry in entries.Take(10)) //take top 10
             {
                 this.dataGridView2.Rows.Add(entry.orderPrice, entry.orderSize, entry.numOccurs);
             }
             entries.Clear();
             usedPrices.Clear();
         }
     }
 }