Beispiel #1
0
        public float verifyOrdersM(BuyOrder[] buyords, SellOrder[] sellords, StockMarket stock, int k)
        {
            RealtimeData stocky = (RealtimeData)stock;

            float lastprice   = 0;
            int   initializer = 0;

            if (stocky.companies[k].lastOrder.Equals("SellOrder"))
            {
                int determinant = 0;
                for (determinant = 0; determinant < sellords.Length; ++determinant)
                {
                    if (sellords[determinant] == null)
                    {
                        if (determinant > 0)
                        {
                            break;
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
                --determinant;
                for (int i = 0; i < buyords.Length; ++i)
                {
                    if (buyords[i] != null)
                    {
                        if (sellords[determinant].orderSize == buyords[i].orderSize && sellords[determinant].getPrice() == buyords[i].getPrice())
                        {
                            stocky.companies[k].setLastPrice(sellords[determinant].getPrice());
                            lastprice = sellords[determinant].getPrice();
                            ++initializer;
                        }
                    }
                }
                if (initializer > 0)
                {
                    stocky.companies[k].successfulO.Add(sellords[determinant].orderSize);
                }
            }
            else if (stocky.companies[k].lastOrder.Equals("BuyOrder"))
            {
                int determinant = 0; initializer = 0;
                for (determinant = 0; determinant < buyords.Length; ++determinant)
                {
                    if (buyords[determinant] == null)
                    {
                        if (determinant > 0)
                        {
                            break;
                        }
                        else
                        {
                            return(0);
                        }
                    }
                }
                --determinant;
                for (int i = 0; i < sellords.Length; ++i)
                {
                    if (sellords[i] != null)
                    {
                        if (buyords[determinant].orderSize == sellords[i].orderSize && buyords[determinant].getPrice() == sellords[i].getPrice())
                        {
                            stocky.companies[k].setLastPrice(buyords[determinant].getPrice());
                            lastprice = buyords[determinant].getPrice();
                            ++initializer;
                        }
                    }
                }

                if (initializer > 0)
                {
                    stocky.companies[k].successfulO.Add(buyords[determinant].orderSize);
                }
            }

            return(lastprice);
        }