public void orderBuys(BuyOrder[] buyorders)
        {
            BuyOrder highest = null;
            int      mecase  = 0;

            while (mecase < buyorders.Length)
            {
                int index = mecase;
                highest = buyorders[mecase];
                for (int i = mecase; i < buyorders.Length; ++i)
                {
                    if (buyorders[i] != null)
                    {
                        if (highest.getPrice() < buyorders[i].getPrice())
                        {
                            highest = buyorders[i]; index = i;
                        }
                    }
                }

                buyorders[index]  = buyorders[mecase];
                buyorders[mecase] = highest;
                ++mecase;
            }
        }
        public void Update(StockMarket data)
        {
            RealtimeData stock = (RealtimeData)data;

            SellOrder[] sellorderz = stock.companies[1].sellorders;
            BuyOrder[]  buyorderz  = stock.companies[1].buyorders;


            int secret = 0;

            if (stock.companies[1].lastOrder.Equals("BuyOrder"))
            {
                BuyOrder mybuy = stock.companies[1].getLastBuyOrder();
                for (int k = 0; k < dataGridView1.Rows.Count; ++k)
                {
                    if (dataGridView1.Rows[k].Cells[2].Value != null && mybuy != null)
                    {
                        if ((float)dataGridView1.Rows[k].Cells[2].Value == (float)mybuy.getPrice())
                        {
                            ++secret;
                            dataGridView1.Rows[k].Cells[0].Value = (int)dataGridView1.Rows[k].Cells[0].Value + 1;
                            dataGridView1.Rows[k].Cells[1].Value = (double)dataGridView1.Rows[k].Cells[1].Value + (float)mybuy.orderSize;
                        }
                    }
                }
                if (secret == 0 && mybuy != null)
                {
                    addToViewBuy(mybuy.getPrice(), mybuy.orderSize);
                }
                secret = 0;
                orderBuyView();
            }

            else
            {
                secret = 0;
                SellOrder mysell = stock.companies[1].getLastSellOrder();
                for (int k = 0; k < dataGridView1.Rows.Count; ++k)
                {
                    if (dataGridView1.Rows[k].Cells[4].Value != null && mysell != null)
                    {
                        if ((float)dataGridView1.Rows[k].Cells[4].Value == mysell.getPrice())
                        {
                            ++secret;
                            dataGridView1.Rows[k].Cells[5].Value = (int)dataGridView1.Rows[k].Cells[5].Value + 1;
                            dataGridView1.Rows[k].Cells[3].Value = (double)dataGridView1.Rows[k].Cells[3].Value + mysell.orderSize;
                        }
                    }
                }
                if (secret == 0 && mysell != null)
                {
                    addToViewSell(mysell.getPrice(), mysell.orderSize);
                }
                secret = 0;
                orderSellView();
            }
        }
Example #3
0
        private void bidToolStripMenuItem_Click(object sender, EventArgs e)
        {
            BuyOrder newMDIChild = new BuyOrder();

            // Set the parent form of the child window.
            newMDIChild.MdiParent = this;
            // Display the new form.
            newMDIChild.Show();

            // newMDIChild = this.ActiveMdiChild;
        }
Example #4
0
        public void addBuyOrder(BuyOrder s)
        {
            int i = 0;

            for (i = 0; i < buyorders.Length; i++)
            {
                if (buyorders[i] == null)
                {
                    break;
                }
            }

            buyorders[i] = new BuyOrder(s);
        }
Example #5
0
        public BuyOrder[] getCopyBuy()
        {
            BuyOrder[] newbuyords = new BuyOrder[20];

            for (int i = 0; i < buyorders.Length; ++i)
            {
                if (buyorders[i] != null)
                {
                    newbuyords[i] = new BuyOrder();
                    newbuyords[i].setPrice(buyorders[i].getPrice());
                    newbuyords[i].orderSize = buyorders[i].orderSize;
                }
            }

            return(newbuyords);
        }
Example #6
0
 public BuyOrder(BuyOrder j)
 {
     this.date       = j.date;
     this.orderSize  = j.orderSize;
     this.orderPrice = j.getPrice();
 }