Exemplo n.º 1
0
        public void Filter_WhenUniverseEventAndTradingHoursIsNotValid_MustBeFiltered()
        {
            var fundOne  = ((Order)null).Random();
            var eventOne = new UniverseEvent(UniverseStateEvent.Order, DateTime.UtcNow, fundOne);

            A.CallTo(() => _tradingHoursService.GetTradingHoursForMic(fundOne.Market.MarketIdentifierCode))
            .Returns(new TradingHours()
            {
                IsValid = false
            });

            var marketCapRangeRuleFilter = new DecimalRangeRuleFilter
            {
                Type = RuleFilterType.Include
            };

            var highMarketCapFilter = new HighMarketCapFilter(
                _universeMarketCacheFactory,
                Engine.Rules.Rules.RuleRunMode.ValidationRun,
                marketCapRangeRuleFilter,
                _tradingHoursService,
                _operationRunRuleContext,
                _universeDataRequestsSubscriber,
                this.currencyConverterService,
                "test",
                _logger);

            var result = highMarketCapFilter.Filter(eventOne);

            Assert.IsTrue(result);
        }
Exemplo n.º 2
0
        public void Filter_WhenUniverseEventExcludeMarketCapFilter_MustNotBeFiltered()
        {
            var marketCapRangeRuleFilter = new DecimalRangeRuleFilter
            {
                Type = RuleFilterType.Exclude
            };

            var highMarketCapFilter = new HighMarketCapFilter(
                _universeMarketCacheFactory,
                Engine.Rules.Rules.RuleRunMode.ValidationRun,
                marketCapRangeRuleFilter,
                _tradingHoursService,
                _operationRunRuleContext,
                _universeDataRequestsSubscriber,
                this.currencyConverterService,
                "test",
                _logger);


            var eventOne = new UniverseEvent(UniverseStateEvent.Order, DateTime.UtcNow, new { });

            var result = highMarketCapFilter.Filter(eventOne);

            Assert.IsFalse(result);
        }
Exemplo n.º 3
0
        public void Filter_WhenUniverseEventAndMarketCapFilter_MustFilterCorrectly(
            decimal?marketCap,
            decimal?min,
            decimal?max,
            bool mustBeFiltered)
        {
            A.CallTo(
                () => this.currencyConverterService.Convert(
                    A <IReadOnlyCollection <Money> > .Ignored,
                    A <Currency> .Ignored,
                    A <DateTime> .Ignored,
                    A <ISystemProcessOperationRunRuleContext> .Ignored)).Returns(new Money(marketCap.Value, "GBP"));

            var fundOne  = ((Order)null).Random();
            var eventOne = new UniverseEvent(UniverseStateEvent.Order, DateTime.UtcNow, fundOne);

            A.CallTo(() => _tradingHoursService.GetTradingHoursForMic(fundOne.Market.MarketIdentifierCode))
            .Returns(new TradingHours()
            {
                IsValid = true
            });

            //decimal? marketCap = 150;
            var marketDataResponse = new MarketDataResponse <EquityInstrumentInterDayTimeBar>(
                new EquityInstrumentInterDayTimeBar(null, new DailySummaryTimeBar(marketCap, "GBP", null, null, new Volume(), DateTime.UtcNow), DateTime.UtcNow, null), false, false);

            A.CallTo(() => _universeEquityInterDayCache.Get(
                         A <MarketDataRequest> .That.Matches(
                             m => m.MarketIdentifierCode == fundOne.Market.MarketIdentifierCode &&
                             m.Cfi == fundOne.Instrument.Cfi
                             )))
            .Returns(marketDataResponse);

            var marketCapRangeRuleFilter = new DecimalRangeRuleFilter
            {
                Type = RuleFilterType.Include,
                Min  = min,
                Max  = max
            };

            var highMarketCapFilter = new HighMarketCapFilter(
                _universeMarketCacheFactory,
                Engine.Rules.Rules.RuleRunMode.ValidationRun,
                marketCapRangeRuleFilter,
                _tradingHoursService,
                _operationRunRuleContext,
                _universeDataRequestsSubscriber,
                this.currencyConverterService,
                "test",
                _logger);

            var result = highMarketCapFilter.Filter(eventOne);

            Assert.AreEqual(result, mustBeFiltered);
        }
Exemplo n.º 4
0
        public void Filter_WhenUniverseEventNull_MustNotBeFiltered()
        {
            var marketCapRangeRuleFilter = DecimalRangeRuleFilter.None();

            var highMarketCapFilter = new HighMarketCapFilter(
                _universeMarketCacheFactory,
                Engine.Rules.Rules.RuleRunMode.ValidationRun,
                marketCapRangeRuleFilter,
                _tradingHoursService,
                _operationRunRuleContext,
                _universeDataRequestsSubscriber,
                this.currencyConverterService,
                "test",
                _logger);

            var result = highMarketCapFilter.Filter(null);

            Assert.IsFalse(result);
        }
Exemplo n.º 5
0
        public void Filter_WhenUniverseEventAndHadMissingDataInUniverseEquityInterdayCache_MustBeFiltered()
        {
            var fundOne  = ((Order)null).Random();
            var eventOne = new UniverseEvent(UniverseStateEvent.Order, DateTime.UtcNow, fundOne);

            A.CallTo(() => _tradingHoursService.GetTradingHoursForMic(fundOne.Market.MarketIdentifierCode))
            .Returns(new TradingHours()
            {
                IsValid = true
            });

            A.CallTo(() => _universeEquityInterDayCache.Get(
                         A <MarketDataRequest> .That.Matches(
                             m => m.MarketIdentifierCode == fundOne.Market.MarketIdentifierCode &&
                             m.Cfi == fundOne.Instrument.Cfi
                             )))
            .Returns(MarketDataResponse <EquityInstrumentInterDayTimeBar> .MissingData());

            var marketCapRangeRuleFilter = new DecimalRangeRuleFilter
            {
                Type = RuleFilterType.Include
            };

            var highMarketCapFilter = new HighMarketCapFilter(
                _universeMarketCacheFactory,
                Engine.Rules.Rules.RuleRunMode.ValidationRun,
                marketCapRangeRuleFilter,
                _tradingHoursService,
                _operationRunRuleContext,
                _universeDataRequestsSubscriber,
                this.currencyConverterService,
                "test",
                _logger);

            var result = highMarketCapFilter.Filter(eventOne);

            Assert.IsTrue(result);
        }