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(); } }
public void orderSells(SellOrder[] sellorders) { SellOrder lowest = null; int mecase = 0; while (mecase < sellorders.Length) { int index = mecase; lowest = sellorders[mecase]; for (int i = mecase; i < sellorders.Length; ++i) { if (sellorders[i] != null) { if (lowest.getPrice() > sellorders[i].getPrice()) { lowest = sellorders[i]; index = i; } } } sellorders[index] = sellorders[mecase]; sellorders[mecase] = lowest; ++mecase; } }
public SellOrder(SellOrder j) { this.date = j.date; this.orderSize = j.orderSize; this.orderPrice = j.getPrice(); }