Пример #1
0
        private void UpdateQuote(TickPriceMessage tickPriceMessage)
        {
            switch (tickPriceMessage.TickType)
            {
                case TickType.Bid:
                    this.quote.BidPrice = tickPriceMessage.Price;
                    this.quote.BidSize = tickPriceMessage.Size;
                    return;

                case TickType.Ask:
                    this.quote.AskPrice = tickPriceMessage.Price;
                    this.quote.AskSize = tickPriceMessage.Size;
                    return;

                case TickType.Last:
                    this.quote.TradePrice = tickPriceMessage.Price;
                    this.quote.TradeSize = tickPriceMessage.Size;
                    return;
            }
        }
Пример #2
0
        public void EnsureThatSubscriptionWorks()
        {
            var quoteSucription = this.CreateQuoteSubscription();

            {
                var message = new TickPriceMessage
                {
                    RequestId = ConnectionHelper.RequestId,
                    Price = 1.05,
                    Size = 1,
                    TickType = TickType.Ask
                };

                this.connectionHelper.SendMessage(message);

                var expectedQuote = new Quote {AskPrice = 1.05, AskSize = 1};
                this.observerMock.Verify(observer => observer.OnQuote(expectedQuote), Times.Once);
            }

            {
                var message = new TickPriceMessage
                {
                    RequestId = ConnectionHelper.RequestId,
                    Price = 2.05,
                    Size = 2,
                    TickType = TickType.Bid
                };

                this.connectionHelper.SendMessage(message);

                var expectedQuote = new Quote {AskPrice = 1.05, AskSize = 1, BidPrice = 2.05, BidSize = 2};
                this.observerMock.Verify(observer => observer.OnQuote(expectedQuote), Times.Once);
            }

            {
                var message = new TickPriceMessage
                {
                    RequestId = ConnectionHelper.RequestId,
                    Price = 3.05,
                    Size = 3,
                    TickType = TickType.Last
                };

                this.connectionHelper.SendMessage(message);

                var expectedQuote = new Quote
                {
                    AskPrice = 1.05,
                    AskSize = 1,
                    BidPrice = 2.05,
                    BidSize = 2,
                    TradePrice = 3.05,
                    TradeSize = 3
                };

                this.observerMock.Verify(observer => observer.OnQuote(expectedQuote), Times.Once);
            }

            this.observerMock.Verify(observer => observer.OnError(It.IsAny<Error>()), Times.Never);
            quoteSucription.Dispose();
        }
Пример #3
0
 private void OnTickPrice(TickPriceMessage message)
 {
     this.UpdateQuote(message);
     this.observer.OnQuote(this.quote);
 }