예제 #1
0
        private void InitializeMarket(double basePrice)
        {
            market = new Market();

            // Calculate the Bid series
            int    bids     = random.Next(10, 20);
            double bidPrice = basePrice - 0.01 - Math.Round(random.NextDouble() * 0.02, 2);

            for (int bid = 0; bid < bids; bid++)
            {
                int    largeBlock = random.Next(0, 3);
                double quantity   = Convert.ToDouble(random.Next(1, largeBlock == 0 ? 20 : 5) * 100);
                bidPrice -= 0.01 + Math.Round(random.NextDouble() * 0.02, 2);
                market.Bid.AddBidRow(0, Convert.ToDouble(bidPrice), quantity, DateTime.Now);
            }

            // Calculate the Ask series
            int    asks     = random.Next(10, 20);
            double askPrice = basePrice + 0.01 + Math.Round(random.NextDouble() * 0.02, 2);

            for (int ask = 0; ask < asks; ask++)
            {
                int    largeBlock = random.Next(0, 3);
                double quantity   = Convert.ToDouble(random.Next(1, largeBlock == 0 ? 20 : 5) * 100);
                askPrice += 0.01 + Math.Round(random.NextDouble() * 0.02, 2);
                market.Ask.AddAskRow(0, Convert.ToDouble(askPrice), quantity, DateTime.Now);
            }

            // Accept the initial market conditions.
            market.AcceptChanges();
        }