Ejemplo n.º 1
0
        static void UpdateStockPrices()
        {
            stockPrices = wallstreetClient.GetOverallMarketInformation();
            orders      = wallstreetClient.GetOverallOrders();

            for (int i = 0; i < stockPrices.Length; i++)
            {
                ShareInformation oldPrice          = stockPrices[i];
                long             pendingBuyOrders  = PendingOrders(oldPrice.FirmName, OrderType.BUY);
                long             pendingSellOrders = PendingOrders(oldPrice.FirmName, OrderType.SELL);
                double           x        = ComputeNewPrice(oldPrice.PricePerShare, pendingBuyOrders, pendingSellOrders);
                ShareInformation newPrice = new ShareInformation()
                {
                    ExchangeName  = oldPrice.ExchangeName,
                    FirmName      = oldPrice.FirmName,
                    NoOfShares    = oldPrice.NoOfShares,
                    IsFund        = oldPrice.IsFund,
                    PricePerShare = x
                };
                Console.WriteLine("Update {0} from {1} to {2}.", newPrice.FirmName, oldPrice.PricePerShare, newPrice.PricePerShare);

                stockPrices[i] = newPrice;
            }

            RandomlyUpdateASingleStock();

            for (int i = 0; i < stockPrices.Length; i++)
            {
                wallstreetClient.PutShareInformation(stockPrices[i], stockPrices[i].ExchangeName);
            }
        }