예제 #1
0
        protected virtual void OnQuote(FuturesQuote quote)
        {
            var handler = Quotes;

            if (handler != null)
            {
                handler(this, quote);
            }
        }
예제 #2
0
        public void MapFromFuturesQuote()
        {
            var quote = new FuturesQuote
            {
                Symbol = "CZ2013"
            };

            var commodityContract = NotifyOnBarrierEventsReactive.QuoteWithContract.ContractFromQuote(quote);

            commodityContract.ContractMonth.Should().Be(12);
            commodityContract.ContractYear.Should().Be(2013);
            commodityContract.ProductCode.Should().Be("C");
        }
예제 #3
0
        public void OnFuturesQuote_WithAnInvalidContract_StreamsNothing()
        {
            var invalidFuturesQuote = new FuturesQuote
            {
                Symbol = "invalidcontract"
            };
            var scheduler                = new TestScheduler();
            var futuresQuotes            = scheduler.CreateColdObservable(ReactiveTest.OnNext(0, invalidFuturesQuote));
            var quotesWithContractClient = new AntiCorruptionLayerObservableClient(futuresQuotes);

            var quotesWithContracts = scheduler.Start(() => quotesWithContractClient.Quotes);

            quotesWithContracts.Messages.Should().BeEmpty();
        }
예제 #4
0
        public void OnFuturesQuote_WithAValidContract_StreamsQuoteWithContract()
        {
            var validFuturesQuote = new FuturesQuote
            {
                Symbol = "CZ2013"
            };
            var scheduler                = new TestScheduler();
            var futuresQuotes            = scheduler.CreateColdObservable(ReactiveTest.OnNext(0, validFuturesQuote));
            var quotesWithContractClient = new AntiCorruptionLayerObservableClient(futuresQuotes);

            var quotesWithContracts = scheduler.Start(() => quotesWithContractClient.Quotes);

            quotesWithContracts.Messages.Should().HaveCount(1);
            var quoteWithContract = quotesWithContracts.Messages.Single().Value.Value;

            quoteWithContract.Quote.ShouldBeEquivalentTo(validFuturesQuote);
        }
        public void OnFuturesQuote_AValidContractOnAFuturesQuote_TriggersQuoteWithContract()
        {
            var validFuturesQuote = new FuturesQuote
            {
                Symbol = "CZ2013"
            };
            var futuresQuoteClient       = MockRepository.GenerateStub <IFuturesQuoteClient>();
            var quotesWithContractClient = new AntiCorruptionLayerEventClient(futuresQuoteClient);
            var quotes = new List <NotifyOnBarrierEventsReactive.QuoteWithContract>();

            quotesWithContractClient.Quotes += (sender, quote) => quotes.Add(quote);

            futuresQuoteClient.Raise(c => c.Quotes += null, null, validFuturesQuote);

            quotes.Should().HaveCount(1);
            var quoteWithContract = quotes.Single();

            quoteWithContract.Quote.ShouldBeEquivalentTo(validFuturesQuote);
        }
 private void TransformToQuoteWithContract(object sender, FuturesQuote quote)
 {
     OnQuotes(new NotifyOnBarrierEventsReactive.QuoteWithContract(quote));
 }