Exemple #1
0
        public void OrderBookContext_update_test()
        {
            OrderBookContext obContext = new OrderBookContext(10);

            obContext.Update(0, "RTS-12.13_FT", 140000, 100, 140010, 50);
            Assert.AreEqual(140010, obContext.GetOfferPrice("RTS-12.13_FT", 0));
            Assert.AreEqual(140000, obContext.GetBidPrice("RTS-12.13_FT", 0));
            Assert.AreEqual(50, obContext.GetOfferVolume("RTS-12.13_FT", 0));
            Assert.AreEqual(100, obContext.GetBidVolume("RTS-12.13_FT", 0));
        }
        public static double GetOfferVolumeSum(this OrderBookContext orderBook, string symbol, int depth = 50)
        {
            double sum = 0;

            if (depth > orderBook.Depth)
            {
                depth = orderBook.Depth;
            }

            for (int i = 0; i < depth; i++)
            {
                sum += orderBook.GetOfferVolume(symbol, i);
            }

            return(sum);
        }
Exemple #3
0
        public void UpdateQuotesOnBidAsk_handle_add_records_for_registered_symbol()
        {
            BidAsk bidAskOne = new BidAsk {
                Id = SerialIntegerFactory.Make(), Symbol = "RTS-9.13_FT", DateTime = BrokerDateTime.Make(DateTime.Now), Row = 0, NRows = 10, Ask = 150010, AskSize = 300, Bid = 150000, BidSize = 100
            };

            this.tradingData.Get <ObservableCollection <BidAsk> >().Add(bidAskOne);

            double resultBidPrice  = storage.GetBidPrice(bidAskOne.Symbol, 0);
            double resultBidVolume = storage.GetBidVolume(bidAskOne.Symbol, 0);

            double resultOfferPrice  = storage.GetOfferPrice(bidAskOne.Symbol, 0);
            double resultOfferVolume = storage.GetOfferVolume(bidAskOne.Symbol, 0);

            Assert.AreEqual(bidAskOne.Bid, resultBidPrice);
            Assert.AreEqual(bidAskOne.BidSize, resultBidVolume);

            Assert.AreEqual(bidAskOne.Ask, resultOfferPrice);
            Assert.AreEqual(bidAskOne.AskSize, resultOfferVolume);
        }