示例#1
0
        public void SMACrossProbe_OHLCFeed_DoesNotTriggerAnEvent()
        {
            //Arrange

            var forexPair = MockObjectFactory.MockTickerSymbol(MockObjectFactory.EURUSD);
            var timeFrame = new TimeframeUnit(TimeframeOption.M1);

            var feedService = MockObjectFactory.MockManualPriceFeedService();
            var ticker      = feedService.Setup(forexPair.Object, timeFrame, OHLCPriceOption.All);

            var isTriggered = false;

            var smaCross = new SMACrossProbe(ticker, 3, 5, () => isTriggered = true);

            smaCross.Subscribe(feedService);

            var priceSwing = MockDataFactory.ExtractOHLCPrices(MockDataFactory.PriceSwingBeginMarker, MockDataFactory.PriceSwingEndMarker, -1);

            //Act
            priceSwing.ForEach((s) => feedService.OHLC.PriceAction(ticker, s));

            //Assert
            Assert.IsFalse(isTriggered);
            Assert.AreEqual(0, smaCross.Length);
        }
示例#2
0
        public void SMACrossProbe_PriceBarOptionFeedTriggersAnEvent()
        {
            //Arrange

            var forexPair = MockObjectFactory.MockTickerSymbol(MockObjectFactory.EURUSD);
            var timeFrame = new TimeframeUnit(TimeframeOption.M1);

            var feedService = MockObjectFactory.MockManualPriceFeedService();
            var ticker      = feedService.Setup(forexPair.Object, timeFrame, PriceBarOption.Close);

            var isTriggered = false;

            var smaCross = new SMACrossProbe(ticker, 2, 5, () => isTriggered = true);

            smaCross.Subscribe(feedService);

            feedService.Start();

            var priceSwing = MockDataFactory.ExtractPrices(MockDataFactory.PriceSwingBeginMarker, MockDataFactory.PriceSwingEndMarker);

            //Act
            priceSwing.ForEach((s) => feedService.PriceBar.PriceAction(ticker, s.TimeStamp, PriceBarOption.Close, s.Close));

            //Assert
            Assert.IsTrue(isTriggered);
            Assert.IsTrue(smaCross.Current.Status == EventStateOption.On);
        }
示例#3
0
        public void EMAProbe_ReactsToPriceFeed()
        {
            var forexPair = MockObjectFactory.MockTickerSymbol(MockObjectFactory.EURUSD);
            var timeFrame = new TimeframeUnit(TimeframeOption.M1);

            var feedService = MockObjectFactory.MockManualPriceFeedService();
            var ticker      = feedService.Setup(forexPair, timeFrame, OHLCPriceOption.All);

            var probe = new EMAProbe(ticker, 3);

            probe.Subscribe(feedService);

            var priceSwing = MockDataFactory.ExtractOHLCPrices(MockDataFactory.PriceSwingBeginMarker, MockDataFactory.PriceSwingEndMarker);

            //Act
            priceSwing.ForEach((s) => feedService.OHLC.PriceAction(ticker, s));

            //Assert
            Assert.IsTrue(probe.Length > 0);
        }