/// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighVolumeRule"/> class.
 /// </summary>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <param name="orderFilterService">
 /// The order filter service.
 /// </param>
 /// <param name="ruleContext">
 /// The rule context.
 /// </param>
 /// <param name="equityFactory">
 /// The factory.
 /// </param>
 /// <param name="fixedIncomeFactory">
 /// The factory.
 /// </param>
 /// <param name="judgementService">
 /// The judgement service.
 /// </param>
 /// <param name="dataRequestSubscriber">
 /// The data request subscriber
 /// </param>
 /// <param name="tradingHoursService">
 /// The trading hours service
 /// </param>
 /// <param name="runMode">
 /// The run mode.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingStackLogger">
 /// The trading stack logger.
 /// </param>
 public FixedIncomeHighVolumeRule(
     IHighVolumeIssuanceRuleFixedIncomeParameters parameters,
     IUniverseFixedIncomeOrderFilterService orderFilterService,
     ISystemProcessOperationRunRuleContext ruleContext,
     IUniverseEquityMarketCacheFactory equityFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeFactory,
     IFixedIncomeHighVolumeJudgementService judgementService,
     IUniverseDataRequestsSubscriber dataRequestSubscriber,
     IMarketTradingHoursService tradingHoursService,
     RuleRunMode runMode,
     ILogger <FixedIncomeHighVolumeRule> logger,
     ILogger <TradingHistoryStack> tradingStackLogger)
     : base(
         parameters.Windows.BackwardWindowSize,
         parameters.Windows.BackwardWindowSize,
         parameters.Windows.FutureWindowSize,
         Rules.FixedIncomeHighVolumeIssuance,
         FixedIncomeHighVolumeFactory.Version,
         $"{nameof(FixedIncomeHighVolumeRule)}",
         ruleContext,
         equityFactory,
         fixedIncomeFactory,
         runMode,
         logger,
         tradingStackLogger)
 {
     this.parameters            = parameters ?? throw new ArgumentNullException(nameof(parameters));
     this.orderFilterService    = orderFilterService ?? throw new ArgumentNullException(nameof(orderFilterService));
     this.judgementService      = judgementService ?? throw new ArgumentNullException(nameof(judgementService));
     this.dataRequestSubscriber = dataRequestSubscriber ?? throw new ArgumentNullException(nameof(dataRequestSubscriber));
     this.tradingHoursService   = tradingHoursService ?? throw new ArgumentNullException(nameof(tradingHoursService));
     this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
예제 #2
0
 public void Setup()
 {
     this.parameters                    = A.Fake <IHighVolumeIssuanceRuleFixedIncomeParameters>();
     this.fixedIncomeOrderFile          = A.Fake <IUniverseFixedIncomeOrderFilterService>();
     this.ruleContext                   = A.Fake <ISystemProcessOperationRunRuleContext>();
     this.equityMarketCacheFactory      = A.Fake <IUniverseEquityMarketCacheFactory>();
     this.fixedIncomeMarketCacheFactory = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
     this.marketTradingHoursService     = A.Fake <IMarketTradingHoursService>();
     this.tradingStackLogger            = new NullLogger <TradingHistoryStack>();
 }
 /// <summary>
 /// The build rule method to return a new high volume issuance rule with each call.
 /// </summary>
 /// <param name="parameters">
 /// The parameters.
 /// </param>
 /// <param name="operationContext">
 /// The operation context.
 /// </param>
 /// <param name="judgementService">
 /// The judgement service/
 /// </param>
 /// <param name="dataRequestSubscriber">
 /// The data request subscriber.
 /// </param>
 /// <param name="runMode">
 /// The run mode.
 /// </param>
 /// <returns>
 /// The <see cref="IFixedIncomeHighVolumeRule"/>.
 /// </returns>
 public IFixedIncomeHighVolumeRule BuildRule(
     IHighVolumeIssuanceRuleFixedIncomeParameters parameters,
     ISystemProcessOperationRunRuleContext operationContext,
     IFixedIncomeHighVolumeJudgementService judgementService,
     IUniverseDataRequestsSubscriber dataRequestSubscriber,
     RuleRunMode runMode)
 {
     return(new FixedIncomeHighVolumeRule(
                parameters,
                this.filterService,
                operationContext,
                this.equityMarketCacheFactory,
                this.fixedIncomeMarketCacheFactory,
                judgementService,
                dataRequestSubscriber,
                this.marketTradingHoursService,
                runMode,
                this.logger,
                this.tradingLogger));
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighVolumeJudgementContext"/> class.
 /// </summary>
 /// <param name="judgement">
 /// The judgement.
 /// </param>
 /// <param name="raiseRuleViolation">
 /// The raise rule violation.
 /// </param>
 /// <param name="ruleBreachContext">
 /// The rule breach context.
 /// </param>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="totalOrdersTradedInWindow">
 /// The total orders traded in window.
 /// </param>
 /// <param name="security">
 /// The security.
 /// </param>
 /// <param name="isIssuanceBreach">
 /// The is issuance breach.
 /// </param>
 /// <param name="tradePosition">
 /// The trade Position.
 /// </param>
 /// <param name="venue">
 /// The venue.
 /// </param>
 public FixedIncomeHighVolumeJudgementContext(
     IFixedIncomeHighVolumeJudgement judgement,
     bool raiseRuleViolation,
     IRuleBreachContext ruleBreachContext,
     IHighVolumeIssuanceRuleFixedIncomeParameters fixedIncomeParameters,
     decimal totalOrdersTradedInWindow,
     FinancialInstrument security,
     bool isIssuanceBreach,
     TradePosition tradePosition,
     Market venue)
 {
     this.Judgement                 = judgement;
     this.RaiseRuleViolation        = raiseRuleViolation;
     this.RuleBreachContext         = ruleBreachContext;
     this.FixedIncomeParameters     = fixedIncomeParameters;
     this.TotalOrdersTradedInWindow = totalOrdersTradedInWindow;
     this.Security         = security;
     this.IsIssuanceBreach = isIssuanceBreach;
     this.TradePosition    = tradePosition;
     this.Venue            = venue;
 }
예제 #5
0
        /// <summary>
        /// The subscribe to parameters.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="judgementService">
        /// The judgement Service.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IUniverseRule SubscribeToParameters(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IJudgementService judgementService,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IHighVolumeIssuanceRuleFixedIncomeParameters parameters)
        {
            var ruleContext = operationContext.CreateAndStartRuleRunContext(
                Rules.FixedIncomeHighVolumeIssuance.GetDescription(),
                FixedIncomeHighVolumeFactory.Version,
                parameters.Id,
                (int)Rules.FixedIncomeHighVolumeIssuance,
                execution.IsBackTest,
                execution.TimeSeriesInitiation.DateTime,
                execution.TimeSeriesTermination.DateTime,
                execution.CorrelationId,
                execution.IsForceRerun);

            var runMode    = execution.IsForceRerun ? RuleRunMode.ForceRun : RuleRunMode.ValidationRun;
            var highVolume = this.fixedIncomeRuleHighVolumeFactory.BuildRule(
                parameters,
                ruleContext,
                judgementService,
                dataRequestSubscriber,
                runMode);
            var highVolumeOrgFactors = this.brokerServiceFactory.Build(
                highVolume,
                parameters.Factors,
                parameters.AggregateNonFactorableIntoOwnCategory);
            var highVolumeFilters = this.DecorateWithFilters(
                operationContext,
                parameters,
                highVolumeOrgFactors,
                dataRequestSubscriber,
                ruleContext,
                runMode);

            return(highVolumeFilters);
        }
예제 #6
0
        /// <summary>
        /// The decorate with filters.
        /// </summary>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="highVolume">
        /// The high volume.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="processOperationRunRuleContext">
        /// The process operation run rule context.
        /// </param>
        /// <param name="ruleRunMode">
        /// The rule run mode.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IUniverseRule DecorateWithFilters(
            ISystemProcessOperationContext operationContext,
            IHighVolumeIssuanceRuleFixedIncomeParameters parameters,
            IUniverseRule highVolume,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            ISystemProcessOperationRunRuleContext processOperationRunRuleContext,
            RuleRunMode ruleRunMode)
        {
            if (parameters.HasInternalFilters())
            {
                this.logger.LogInformation($"parameters had filters. Inserting filtered universe in {operationContext.Id} operation context");

                var filteredUniverse = this.universeFilterFactory.Build(
                    highVolume,
                    parameters.Accounts,
                    parameters.Traders,
                    parameters.Markets,
                    parameters.Funds,
                    parameters.Strategies,
                    null,
                    null,
                    null,
                    null,
                    null,
                    ruleRunMode,
                    "High Volume Fixed Income",
                    universeDataRequestsSubscriber,
                    processOperationRunRuleContext);

                filteredUniverse.Subscribe(highVolume);

                return(filteredUniverse);
            }

            return(highVolume);
        }