void UpdatePools(List <BidPriceLevel> BidsPool, List <OfferPriceLevel> OffersPool)
 {
     foreach (BidPriceLevel BPL in BidsPool)
     {
         MarketMakerManager.AddJob(BPL.bids.Where((Bids b) => b.TurnsInPool >= 10 && b.Quanity > 0).ToList());
         BPL.bids.RemoveAll((Bids b) => b.TurnsInPool >= 10 || b.Quanity == 0);
     }
     foreach (OfferPriceLevel OPL in OffersPool)
     {
         MarketMakerManager.AddJob(OPL.offers.Where((Offers o) => o.TurnsInPool >= 10 && o.quanity > 0).ToList());
         OPL.offers.RemoveAll((Offers o) => o.TurnsInPool >= 10 || o.Quanity == 0);
     }
     BidsPool.RemoveAll((BidPriceLevel PBL) => PBL.bids.Count == 0);
     OffersPool.RemoveAll((OfferPriceLevel OPL) => OPL.offers.Count == 0);
     //DisplayDetails(BidsPool, OffersPool);
     Pool.SetBidPool(BidsPool);
     Pool.SetOfferPool(OffersPool);
 }
Пример #2
0
        static void Main(string[] args)
        {
            Stopwatch mainTime = new Stopwatch();
            int       TotalStocksInCirculation = 10000;

            mainTime.Start();
            int i = 0;

            while (1 == 1)
            {
                if (mainTime.Elapsed.TotalSeconds > 0.2f)
                {
                    i++;
                    if (i == 5)
                    {
                        algoTrader.RunTurn(TradesThisTurn);
                        TradesThisTurn.Clear();
                        MarketMakerManager.RunMarketMakers();
                        i = 0;
                    }
                    Random r           = new Random((int)DateTime.Now.Ticks);
                    int    NumOfBuyers = r.Next(10);
                    int    NumOfOffers = r.Next(10);
                    for (int j = 0; j < NumOfBuyers; j++)
                    {
                        Pool.AddBid(new Bids(Math.Round(CurrentPrice, 2), r.Next(100), new Client(j)));
                    }
                    for (int j = 0; j < NumOfOffers; j++)
                    {
                        Pool.AddOffer(new Offers(Math.Round(CurrentPrice, 2), r.Next(100), new Client(j)));
                    }
                    UpdateStockPrice(ref CurrentPrice, Pool.NumberOfBuyer, Pool.NumberOfOffers, TotalStocksInCirculation);
                    mainTime.Stop();
                    Pool.RunMatchMaker();
                    mainTime.Reset();
                    mainTime.Start();
                }
            }
        }