/// <summary>
        /// Initializes a new instance of the <see cref="JudgementServiceFactory"/> class.
        /// </summary>
        /// <param name="ruleViolationServiceFactory">
        /// The rule violation service factory.
        /// </param>
        /// <param name="judgementRepository">
        /// The judgement repository.
        /// </param>
        /// <param name="highProfitJudgementMapper">
        /// The high profit judgement mapper.
        /// </param>
        /// <param name="fixedIncomeHighProfitJudgementMapper">
        /// The fixed income high profit judgement mapper.
        /// </param>
        /// <param name="fixedIncomeHighVolumeJudgementMapper">
        /// The fixed income high volume judgement mapper.
        /// </param>
        /// <param name="logger">
        /// The logger.
        /// </param>
        public JudgementServiceFactory(
            IRuleViolationServiceFactory ruleViolationServiceFactory,
            IJudgementRepository judgementRepository,
            IHighProfitJudgementMapper highProfitJudgementMapper,
            IFixedIncomeHighProfitJudgementMapper fixedIncomeHighProfitJudgementMapper,
            IFixedIncomeHighVolumeJudgementMapper fixedIncomeHighVolumeJudgementMapper,
            ILogger <JudgementService> logger)
        {
            this.ruleViolationServiceFactory =
                ruleViolationServiceFactory ?? throw new ArgumentNullException(nameof(ruleViolationServiceFactory));

            this.judgementRepository =
                judgementRepository ?? throw new ArgumentNullException(nameof(judgementRepository));

            this.highProfitJudgementMapper =
                highProfitJudgementMapper ?? throw new ArgumentNullException(nameof(highProfitJudgementMapper));

            this.fixedIncomeHighProfitJudgementMapper =
                fixedIncomeHighProfitJudgementMapper ?? throw new ArgumentNullException(nameof(fixedIncomeHighProfitJudgementMapper));
            this.fixedIncomeHighVolumeJudgementMapper =
                fixedIncomeHighVolumeJudgementMapper ?? throw new ArgumentNullException(nameof(fixedIncomeHighVolumeJudgementMapper));

            this.logger =
                logger ?? throw new ArgumentNullException(nameof(logger));
        }
 public void Setup()
 {
     this.ruleViolationServiceFactory          = A.Fake <IRuleViolationServiceFactory>();
     this.fixedIncomeJudgementMapper           = A.Fake <IFixedIncomeHighProfitJudgementMapper>();
     this.judgementRepository                  = A.Fake <IJudgementRepository>();
     this.highProfitJudgementMapper            = A.Fake <IHighProfitJudgementMapper>();
     this.fixedIncomeHighVolumeJudgementMapper = A.Fake <IFixedIncomeHighVolumeJudgementMapper>();
     this.logger = A.Fake <ILogger <JudgementService> >();
 }
 public void Setup()
 {
     this.judgementRepository                       = A.Fake <IJudgementRepository>();
     this.highProfitJudgementContext                = A.Fake <IHighProfitJudgementContext>();
     this.cancelledOrderJudgementContext            = A.Fake <ICancelledOrderJudgement>();
     this.highVolumeJudgementContext                = A.Fake <IHighVolumeJudgement>();
     this.layeringJudgementContext                  = A.Fake <ILayeringJudgement>();
     this.placingOrdersWithNoIntentJudgementContext = A.Fake <IPlacingOrdersWithNoIntentToExecuteJudgement>();
     this.rampingJudgementContext                   = A.Fake <IRampingJudgement>();
     this.markingTheCloseJudgementContext           = A.Fake <IMarkingTheCloseJudgement>();
     this.spoofingJudgementContext                  = A.Fake <ISpoofingJudgement>();
     this.highProfitJudgementMapper                 = A.Fake <IHighProfitJudgementMapper>();
     this.fixedIncomeProfitJudgementMapper          = A.Fake <IFixedIncomeHighProfitJudgementMapper>();
     this.fixedIncomeProfitJudgementContext         = A.Fake <IFixedIncomeHighProfitJudgementContext>();
     this.fixedIncomeHighVolumeJudgementMapper      = A.Fake <IFixedIncomeHighVolumeJudgementMapper>();
     this.fixedIncomeHighVolumeJudgementContext     = A.Fake <IFixedIncomeHighVolumeJudgementContext>();
     this.ruleViolationService                      = A.Fake <IRuleViolationService>();
     this.logger = A.Fake <ILogger <JudgementService> >();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="JudgementService"/> class.
 /// </summary>
 /// <param name="judgementRepository">
 /// The judgement repository.
 /// </param>
 /// <param name="ruleViolationService">
 /// The rule violation service.
 /// </param>
 /// <param name="equityHighProfitJudgementMapper">
 /// The high profit judgement mapper.
 /// </param>
 /// <param name="fixedIncomeHighProfitJudgementMapper">
 /// The fixed income high profit judgement mapper
 /// </param>
 /// <param name="fixedIncomeHighVolumeJudgementMapper">
 /// The fixed income high volume judgement mapper for secondary market and percentage issuance
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 public JudgementService(
     IJudgementRepository judgementRepository,
     IRuleViolationService ruleViolationService,
     IHighProfitJudgementMapper equityHighProfitJudgementMapper,
     IFixedIncomeHighProfitJudgementMapper fixedIncomeHighProfitJudgementMapper,
     IFixedIncomeHighVolumeJudgementMapper fixedIncomeHighVolumeJudgementMapper,
     ILogger <JudgementService> logger)
 {
     this.judgementRepository =
         judgementRepository ?? throw new ArgumentNullException(nameof(judgementRepository));
     this.equityHighProfitJudgementMapper =
         equityHighProfitJudgementMapper ?? throw new ArgumentNullException(nameof(equityHighProfitJudgementMapper));
     this.fixedIncomeHighProfitJudgementMapper =
         fixedIncomeHighProfitJudgementMapper ?? throw new ArgumentNullException(nameof(fixedIncomeHighProfitJudgementMapper));
     this.fixedIncomeHighVolumeJudgementMapper =
         fixedIncomeHighVolumeJudgementMapper ?? throw new ArgumentNullException(nameof(fixedIncomeHighVolumeJudgementMapper));
     this.ruleViolationService =
         ruleViolationService ?? throw new ArgumentNullException(nameof(ruleViolationService));
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        /// <summary>
        /// The test setup.
        /// </summary>
        private void Setup()
        {
            this.tradingHoursService = A.Fake <IMarketTradingHoursService>();

            A.CallTo(() => this.tradingHoursService.GetTradingHoursForMic("XLON")).Returns(
                new TradingHours
            {
                CloseOffsetInUtc = TimeSpan.FromHours(16),
                IsValid          = true,
                Mic             = "XLON",
                OpenOffsetInUtc = TimeSpan.FromHours(8)
            });

            A.CallTo(() => this.tradingHoursService.GetTradingHoursForMic("NASDAQ")).Returns(
                new TradingHours
            {
                CloseOffsetInUtc = TimeSpan.FromHours(23),
                IsValid          = true,
                Mic             = "NASDAQ",
                OpenOffsetInUtc = TimeSpan.FromHours(15)
            });

            this.equityMarketCacheFactory = new UniverseEquityMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseEquityMarketCacheFactory>());

            this.fixedIncomeMarketCacheFactory = new UniverseFixedIncomeMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseFixedIncomeMarketCacheFactory>());

            this.universeOrderFilterService = A.Fake <IUniverseEquityOrderFilterService>();
            this.logger                = new NullLogger <HighProfitsRule>();
            this.tradingLogger         = new NullLogger <TradingHistoryStack>();
            this.ruleContext           = A.Fake <ISystemProcessOperationRunRuleContext>();
            this.dataRequestSubscriber = A.Fake <IUniverseDataRequestsSubscriber>();

            this.exchangeRateProfitCalculator   = A.Fake <IExchangeRateProfitCalculator>();
            this.marketDataCacheStrategyFactory = new EquityMarketDataCacheStrategyFactory();

            this.costCalculatorFactory = new CostCalculatorFactory(
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                new NullLogger <CostCalculator>(),
                new NullLogger <CostCurrencyConvertingCalculator>());

            this.revenueCalculatorFactory = new RevenueCalculatorFactory(
                this.tradingHoursService,
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                new NullLogger <RevenueCurrencyConvertingCalculator>(),
                new NullLogger <RevenueCalculator>());

            this.equityRuleHighProfitFactory = new EquityRuleHighProfitFactory(
                this.costCalculatorFactory,
                this.revenueCalculatorFactory,
                this.exchangeRateProfitCalculator,
                this.universeOrderFilterService,
                this.equityMarketCacheFactory,
                this.fixedIncomeMarketCacheFactory,
                this.marketDataCacheStrategyFactory,
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                this.logger,
                this.tradingLogger);

            this.judgementRepository  = A.Fake <IJudgementRepository>();
            this.ruleViolationService = A.Fake <IRuleViolationService>();

            this.judgementService = new JudgementService(
                this.judgementRepository,
                this.ruleViolationService,
                new HighProfitJudgementMapper(new NullLogger <HighProfitJudgementMapper>()),
                new FixedIncomeHighProfitJudgementMapper(new NullLogger <FixedIncomeHighProfitJudgementMapper>()),
                new FixedIncomeHighVolumeJudgementMapper(new NullLogger <FixedIncomeHighVolumeJudgementMapper>()),
                new NullLogger <JudgementService>());

            this.exchangeRateProfitCalculator   = A.Fake <IExchangeRateProfitCalculator>();
            this.marketDataCacheStrategyFactory = new EquityMarketDataCacheStrategyFactory();
        }
Example #6
0
        /// <summary>
        /// The test setup.
        /// </summary>
        private void Setup()
        {
            this.orderFilterService        = A.Fake <IUniverseFixedIncomeOrderFilterService>();
            this.ruleContext               = A.Fake <ISystemProcessOperationRunRuleContext>();
            this.dataRequestSubscriber     = A.Fake <IUniverseDataRequestsSubscriber>();
            this.marketTradingHoursService = A.Fake <IMarketTradingHoursService>();

            this.judgementRepository  = A.Fake <IJudgementRepository>();
            this.ruleViolationService = A.Fake <IRuleViolationService>();

            this.judgementService = new JudgementService(
                this.judgementRepository,
                this.ruleViolationService,
                new HighProfitJudgementMapper(new NullLogger <HighProfitJudgementMapper>()),
                new FixedIncomeHighProfitJudgementMapper(new NullLogger <FixedIncomeHighProfitJudgementMapper>()),
                new FixedIncomeHighVolumeJudgementMapper(new NullLogger <FixedIncomeHighVolumeJudgementMapper>()),
                new NullLogger <JudgementService>());

            var repository = A.Fake <IMarketOpenCloseApiCachingDecorator>();

            A
            .CallTo(() => repository.GetAsync()).
            Returns(new ExchangeDto[]
            {
                new ExchangeDto
                {
                    Code              = "XLON",
                    MarketOpenTime    = TimeSpan.FromHours(8),
                    MarketCloseTime   = TimeSpan.FromHours(16),
                    IsOpenOnMonday    = true,
                    IsOpenOnTuesday   = true,
                    IsOpenOnWednesday = true,
                    IsOpenOnThursday  = true,
                    IsOpenOnFriday    = true,
                    IsOpenOnSaturday  = true,
                    IsOpenOnSunday    = true,
                },

                new ExchangeDto
                {
                    Code              = "Diversity",
                    MarketOpenTime    = TimeSpan.FromHours(8),
                    MarketCloseTime   = TimeSpan.FromHours(16),
                    IsOpenOnMonday    = true,
                    IsOpenOnTuesday   = true,
                    IsOpenOnWednesday = true,
                    IsOpenOnThursday  = true,
                    IsOpenOnFriday    = true,
                    IsOpenOnSaturday  = true,
                    IsOpenOnSunday    = true,
                },

                new ExchangeDto
                {
                    Code              = "NASDAQ",
                    MarketOpenTime    = TimeSpan.FromHours(15),
                    MarketCloseTime   = TimeSpan.FromHours(23),
                    IsOpenOnMonday    = true,
                    IsOpenOnTuesday   = true,
                    IsOpenOnWednesday = true,
                    IsOpenOnThursday  = true,
                    IsOpenOnFriday    = true,
                    IsOpenOnSaturday  = true,
                    IsOpenOnSunday    = true,
                }
            });

            this.marketTradingHoursService = new MarketTradingHoursService(repository, new NullLogger <MarketTradingHoursService>());

            this.equityMarketCacheFactory = new UniverseEquityMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseEquityMarketCacheFactory>());

            this.fixedIncomeMarketCacheFactory = new UniverseFixedIncomeMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseFixedIncomeMarketCacheFactory>());
        }