Exemple #1
0
        /// <summary>
        /// The log execution parameters to info log.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        private void LogExecutionParameters(ScheduledExecution execution, ISystemProcessOperationContext operationContext)
        {
            var executionJson        = JsonConvert.SerializeObject(execution);
            var operationContextJson = JsonConvert.SerializeObject(operationContext);

            this.logger.LogInformation($"analysis execute received json {executionJson} for opCtx {operationContextJson}");
        }
Exemple #2
0
        /// <summary>
        /// The subscribe to universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="highProfitParameters">
        /// The high profit parameters.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IReadOnlyCollection <IHighProfitsRuleFixedIncomeParameters> highProfitParameters,
            IJudgementService judgementService)
        {
            var subscriptions = new List <IUniverseRule>();

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (highProfitParameters != null && highProfitParameters.Any())
            {
                foreach (var param in highProfitParameters)
                {
                    var paramSubscriptions = this.SubscribeToParameters(
                        execution,
                        operationContext,
                        dataRequestSubscriber,
                        param,
                        judgementService);
                    subscriptions.Add(paramSubscriptions);
                }
            }
            else
            {
                var errorMessage =
                    $"tried to schedule a {nameof(FixedIncomeHighProfitsRule)} rule execution with no parameters set";
                this.logger.LogError(errorMessage);
                operationContext.EventError(errorMessage);
            }

            return(subscriptions);
        }
        /// <summary>
        /// The subscribe to universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <param name="highProfitParameters">
        /// The high profit parameters.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IJudgementService judgementService,
            IReadOnlyCollection <IHighProfitsRuleEquitiesParameters> highProfitParameters)
        {
            var subscriptions = new List <IUniverseRule>();

            if (highProfitParameters != null && highProfitParameters.Any())
            {
                foreach (var param in highProfitParameters)
                {
                    var cloneableRule = this.SubscribeParameters(
                        execution,
                        operationContext,
                        dataRequestSubscriber,
                        judgementService,
                        param);

                    subscriptions.Add(cloneableRule);
                }
            }
            else
            {
                const string ErrorMessage = "tried to schedule a high profit rule execution with no parameters set";
                this.logger.LogError(ErrorMessage);
                operationContext.EventError(ErrorMessage);
            }

            return(subscriptions);
        }
Exemple #4
0
        /// <summary>
        /// The build subscriptions.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="player">
        /// The player.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="ruleParameters">
        /// The rule parameters.
        /// </param>
        /// <param name="args">
        /// The args.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> BuildSubscriptions(
            ScheduledExecution execution,
            IUniversePlayer player,
            IUniverseAlertStream alertStream,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IJudgementService judgementService,
            ISystemProcessOperationContext operationContext,
            RuleParameterDto ruleParameters,
            params Func <ScheduledExecution,
                         RuleParameterDto,
                         ISystemProcessOperationContext,
                         IUniverseDataRequestsSubscriber,
                         IJudgementService,
                         IUniverseAlertStream,
                         IReadOnlyCollection <IUniverseRule> >[] args)
        {
            var universeRules = new List <IUniverseRule>();

            foreach (var func in args)
            {
                var result = func.Invoke(
                    execution,
                    ruleParameters,
                    operationContext,
                    dataRequestSubscriber,
                    judgementService,
                    alertStream);

                universeRules.AddRange(result);
            }

            return(universeRules);
        }
Exemple #5
0
        public MarkingTheCloseBreach(
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            TimeSpan window,
            FinancialInstrument security,
            MarketOpenClose marketClose,
            ITradePosition tradingPosition,
            IMarkingTheCloseEquitiesParameters equitiesParameters,
            VolumeBreach dailyBreach,
            VolumeBreach windowBreach,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue = factorValue;

            this.Window   = window;
            this.Security = security ?? throw new ArgumentNullException(nameof(security));

            this.MarketClose        = marketClose ?? throw new ArgumentNullException(nameof(marketClose));
            this.Trades             = tradingPosition ?? new TradePosition(new List <Order>());
            this.EquitiesParameters = equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));

            this.DailyBreach  = dailyBreach;
            this.WindowBreach = windowBreach;

            this.RuleParameterId   = equitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = equitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
        public WashTradeRuleBreach(
            TimeSpan windowSize,
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            IWashTradeRuleParameters equitiesParameters,
            ITradePosition tradePosition,
            FinancialInstrument security,
            WashTradeAveragePositionBreach averagePositionBreach,
            WashTradeClusteringPositionBreach clusteringPositionBreach,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue        = factorValue;
            this.EquitiesParameters = equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));

            this.Window   = windowSize;
            this.Trades   = tradePosition;
            this.Security = security;

            this.AveragePositionBreach =
                averagePositionBreach ?? throw new ArgumentNullException(nameof(averagePositionBreach));
            this.ClusteringPositionBreach = clusteringPositionBreach
                                            ?? throw new ArgumentNullException(nameof(clusteringPositionBreach));

            this.RuleParameterId   = equitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = equitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
Exemple #7
0
        public SpoofingRuleBreach(
            IFactorValue factorValue,
            ISystemProcessOperationContext operationContext,
            string correlationId,
            TimeSpan window,
            ITradePosition fulfilledTradePosition,
            ITradePosition cancelledTradePosition,
            FinancialInstrument security,
            Order mostRecentTrade,
            ISpoofingRuleEquitiesParameters spoofingEquitiesParameters,
            string description,
            string caseTitle,
            DateTime universeDateTime)
        {
            this.FactorValue = factorValue;

            this.Window          = window;
            this.Security        = security;
            this.MostRecentTrade = mostRecentTrade;

            var totalTrades = fulfilledTradePosition.Get().ToList();

            totalTrades.AddRange(cancelledTradePosition.Get());
            this.Trades = new TradePosition(totalTrades);
            this.TradesInFulfilledPosition = fulfilledTradePosition;
            this.CancelledTrades           = cancelledTradePosition;

            this.RuleParameterId   = spoofingEquitiesParameters?.Id ?? string.Empty;
            this.SystemOperationId = operationContext.Id.ToString();
            this.CorrelationId     = correlationId;
            this.RuleParameters    = spoofingEquitiesParameters;
            this.Description       = description ?? string.Empty;
            this.CaseTitle         = caseTitle ?? string.Empty;
            this.UniverseDateTime  = universeDateTime;
        }
Exemple #8
0
 public LayeringRuleBreach(
     IFactorValue factorValue,
     ISystemProcessOperationContext operationContext,
     string correlationId,
     ILayeringRuleEquitiesParameters equitiesParameters,
     TimeSpan window,
     ITradePosition trades,
     FinancialInstrument security,
     RuleBreachDescription bidirectionalTradeBreach,
     RuleBreachDescription dailyVolumeTradeBreach,
     RuleBreachDescription windowVolumeTradeBreach,
     RuleBreachDescription priceMovementBreach,
     string description,
     string caseTitle,
     DateTime universeDateTime)
 {
     this.FactorValue              = factorValue;
     this.EquitiesParameters       = equitiesParameters;
     this.Window                   = window;
     this.Trades                   = trades;
     this.Security                 = security;
     this.BidirectionalTradeBreach = bidirectionalTradeBreach;
     this.DailyVolumeTradeBreach   = dailyVolumeTradeBreach;
     this.WindowVolumeTradeBreach  = windowVolumeTradeBreach;
     this.PriceMovementBreach      = priceMovementBreach;
     this.RuleParameterId          = equitiesParameters?.Id ?? string.Empty;
     this.SystemOperationId        = operationContext.Id.ToString();
     this.CorrelationId            = correlationId;
     this.RuleParameters           = equitiesParameters;
     this.Description              = description ?? string.Empty;
     this.CaseTitle                = caseTitle ?? string.Empty;
     this.UniverseDateTime         = universeDateTime;
 }
Exemple #9
0
        /// <summary>
        /// The decorate with filters.
        /// </summary>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="washTrade">
        /// The wash trade.
        /// </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,
            IWashTradeRuleFixedIncomeParameters parameters,
            IUniverseRule washTrade,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            ISystemProcessOperationRunRuleContext processOperationRunRuleContext,
            RuleRunMode ruleRunMode)
        {
            if (parameters.HasInternalFilters())
            {
                this.logger.LogInformation($"parameters had filters. Inserting filtered universe in {operationContext.Id} OpCtx");

                var filteredUniverse = this.universeFilterFactory.Build(
                    washTrade,
                    parameters.Accounts,
                    parameters.Traders,
                    parameters.Markets,
                    parameters.Funds,
                    parameters.Strategies,
                    null,
                    null,
                    null,
                    null,
                    null,
                    ruleRunMode,
                    "Wash Trade Fixed Income",
                    universeDataRequestsSubscriber,
                    processOperationRunRuleContext);
                filteredUniverse.Subscribe(washTrade);

                return(filteredUniverse);
            }

            return(washTrade);
        }
Exemple #10
0
        public void Setup()
        {
            _alertStream        = A.Fake <IUniverseAlertStream>();
            _equitiesParameters = A.Fake <IHighVolumeRuleEquitiesParameters>();
            _ruleCtx            = A.Fake <ISystemProcessOperationRunRuleContext>();
            _opCtx = A.Fake <ISystemProcessOperationContext>();
            _dataRequestRepository     = A.Fake <IRuleRunDataRequestRepository>();
            _stubDataRequestRepository = A.Fake <IStubRuleRunDataRequestRepository>();

            _equityFactoryCache = A.Fake <ILogger <UniverseEquityMarketCacheFactory> >();
            _equityFactory      = new UniverseEquityMarketCacheFactory(_stubDataRequestRepository, _dataRequestRepository, _equityFactoryCache);

            _fixedIncomeFactoryCache = A.Fake <ILogger <UniverseFixedIncomeMarketCacheFactory> >();
            _fixedIncomeFactory      = new UniverseFixedIncomeMarketCacheFactory(_stubDataRequestRepository, _dataRequestRepository, _fixedIncomeFactoryCache);

            _tradingHoursService          = A.Fake <IMarketTradingHoursService>();
            _dataRequestSubscriber        = A.Fake <IUniverseDataRequestsSubscriber>();
            this.currencyConverterService = A.Fake <ICurrencyConverterService>();
            _logger        = A.Fake <ILogger <IHighVolumeRule> >();
            _tradingLogger = A.Fake <ILogger <TradingHistoryStack> >();

            _orderFilter = A.Fake <IUniverseOrderFilter>();
            A.CallTo(() => _orderFilter.Filter(A <IUniverseEvent> .Ignored)).ReturnsLazily(i => (IUniverseEvent)i.Arguments[0]);

            A.CallTo(() => _ruleCtx.EndEvent()).Returns(_opCtx);
        }
Exemple #11
0
        /// <summary>
        /// The subscribe to universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="layeringParameters">
        /// The layering parameters.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseAlertStream alertStream,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            IReadOnlyCollection <ILayeringRuleEquitiesParameters> layeringParameters)
        {
            var subscriptions = new List <IUniverseRule>();

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            if (layeringParameters != null && layeringParameters.Any())
            {
                foreach (var param in layeringParameters)
                {
                    var paramSubscriptions = this.SubscribeToParameters(
                        execution,
                        operationContext,
                        alertStream,
                        universeDataRequestsSubscriber,
                        param);
                    subscriptions.Add(paramSubscriptions);
                }
            }
            else
            {
                const string ErrorMessage = "tried to schedule a layering rule execution with no parameters set";
                this.logger.LogError(ErrorMessage);
                operationContext.EventError(ErrorMessage);
            }

            return(subscriptions);
        }
Exemple #12
0
        /// <summary>
        /// The collate subscriptions.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="ruleParameters">
        /// The rule parameters.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseEvent"/>.
        /// </returns>
        public IReadOnlyCollection <IUniverseRule> CollateSubscriptions(
            ScheduledExecution execution,
            RuleParameterDto ruleParameters,
            ISystemProcessOperationContext operationContext,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IJudgementService judgementService,
            IUniverseAlertStream alertStream)
        {
            if (!execution.Rules?.Select(ru => ru.Rule).Contains(Rules.FixedIncomeWashTrades) ?? true)
            {
                return(new IUniverseRule[0]);
            }

            var filteredParameters = execution.Rules.SelectMany(ru => ru.Ids).Where(ru => ru != null).ToList();
            var dtos = ruleParameters.FixedIncomeWashTrades.Where(
                wt => filteredParameters.Contains(wt.Id, StringComparer.InvariantCultureIgnoreCase)).ToList();

            var fixedIncomeWashTradeParameters = this.ruleParameterMapper.Map(execution, dtos);
            var subscriptions = this.SubscribeToUniverse(
                execution,
                operationContext,
                alertStream,
                dataRequestSubscriber,
                fixedIncomeWashTradeParameters);

            return(subscriptions);
        }
Exemple #13
0
        /// <summary>
        /// The subscribe to universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="washTradeParameters">
        /// The wash trade parameters.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseAlertStream alertStream,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            IReadOnlyCollection <IWashTradeRuleFixedIncomeParameters> washTradeParameters)
        {
            var subscriptions = new List <IUniverseRule>();

            if (washTradeParameters != null && washTradeParameters.Any())
            {
                foreach (var param in washTradeParameters)
                {
                    var paramSubscriptions = this.SubscribeToParameters(
                        execution,
                        operationContext,
                        alertStream,
                        universeDataRequestsSubscriber,
                        param);
                    subscriptions.Add(paramSubscriptions);
                }
            }
            else
            {
                const string ErrorMessage = "tried to schedule a wash trade rule execution with no parameters set";
                this.logger.LogError(ErrorMessage);
                operationContext.EventError(ErrorMessage);
            }

            return(subscriptions);
        }
Exemple #14
0
        /// <summary>
        /// The collate subscriptions.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="ruleParameters">
        /// The rule parameters.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        public IReadOnlyCollection <IUniverseRule> CollateSubscriptions(
            ScheduledExecution execution,
            RuleParameterDto ruleParameters,
            ISystemProcessOperationContext operationContext,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IJudgementService judgementService,
            IUniverseAlertStream alertStream)
        {
            if (!execution.Rules?.Select(_ => _.Rule)?.Contains(Rules.PlacingOrderWithNoIntentToExecute) ?? true)
            {
                return(new IUniverseRule[0]);
            }

            var filteredParameters = execution.Rules.SelectMany(_ => _.Ids).Where(_ => _ != null).ToList();

            var dtos = ruleParameters.PlacingOrders
                       .Where(_ => filteredParameters.Contains(_.Id, StringComparer.InvariantCultureIgnoreCase)).ToList();

            var placingOrderParameters = this.ruleParameterMapper.Map(execution, dtos);
            var subscriptions          = this.SubscribeToUniverse(
                execution,
                operationContext,
                alertStream,
                placingOrderParameters,
                dataRequestSubscriber);

            return(subscriptions);
        }
Exemple #15
0
        /// <summary>
        /// The subscribe to parameters.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IUniverseRule SubscribeToParameters(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseAlertStream alertStream,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            IWashTradeRuleFixedIncomeParameters parameter)
        {
            var ctx = operationContext.CreateAndStartRuleRunContext(
                Rules.FixedIncomeWashTrades.GetDescription(),
                FixedIncomeWashTradeFactory.Version,
                parameter.Id,
                (int)Rules.FixedIncomeWashTrades,
                execution.IsBackTest,
                execution.TimeSeriesInitiation.DateTime,
                execution.TimeSeriesTermination.DateTime,
                execution.CorrelationId,
                execution.IsForceRerun);

            var runMode             = execution.IsForceRerun ? RuleRunMode.ForceRun : RuleRunMode.ValidationRun;
            var washTrade           = this.fixedIncomeRuleWashTradeFactory.BuildRule(parameter, ctx, alertStream, runMode);
            var washTradeOrgFactors = this.brokerServiceFactory.Build(
                washTrade,
                parameter.Factors,
                parameter.AggregateNonFactorableIntoOwnCategory);
            var washTradeFilters = this.DecorateWithFilters(
                operationContext,
                parameter,
                washTradeOrgFactors,
                universeDataRequestsSubscriber,
                ctx,
                runMode);

            return(washTradeFilters);
        }
Exemple #16
0
 public void Setup()
 {
     _configuration       = TestHelpers.Config();
     _logger              = A.Fake <ILogger <ReddeerMarketRepository> >();
     _opCtx               = A.Fake <ISystemProcessOperationContext>();
     _cfiInstrumentMapper = new CfiInstrumentTypeMapper();
 }
 public ISystemProcessOperationDistributeRuleContext Build(ISystemProcessOperationContext operationContext)
 {
     return(new SystemProcessOperationDistributeRuleContext(
                operationContext,
                this._repository,
                this._operationLogging));
 }
 public void Setup()
 {
     this.apiRepository = A.Fake <IRuleParameterApi>();
     this.systemProcessOperationContext = A.Fake <ISystemProcessOperationContext>();
     this.distributedRulePublisher      = A.Fake <IQueueDistributedRulePublisher>();
     this.logger = A.Fake <ILogger <ScheduleDisassembler> >();
 }
Exemple #19
0
 public ISystemProcessOperationUploadFileContext Build(ISystemProcessOperationContext operationContext)
 {
     return(new SystemProcessOperationUploadFileContext(
                operationContext,
                this._operationLogging,
                this._repository));
 }
Exemple #20
0
        /// <summary>
        /// The subscribe to universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="rampingParameters">
        /// The ramping parameters.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IReadOnlyCollection <IUniverseRule> SubscribeToUniverse(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseAlertStream alertStream,
            IReadOnlyCollection <IRampingRuleEquitiesParameters> rampingParameters,
            IUniverseDataRequestsSubscriber dataRequestSubscriber)
        {
            var subscriptions = new List <IUniverseRule>();

            if (rampingParameters != null && rampingParameters.Any())
            {
                foreach (var param in rampingParameters)
                {
                    var baseSubscriber = this.SubscribeParameterToUniverse(
                        execution,
                        operationContext,
                        alertStream,
                        param,
                        dataRequestSubscriber);
                    subscriptions.Add(baseSubscriber);
                }
            }
            else
            {
                const string ErrorMessage = "tried to schedule a cancelled order rule execution with no parameters set";
                this.logger.LogError(ErrorMessage);
                operationContext.EventError(ErrorMessage);
            }

            return(subscriptions);
        }
Exemple #21
0
        /// <summary>
        /// The subscribe for parameters.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="alertStream">
        /// The alert stream.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="parameter">
        /// The parameter.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IUniverseRule SubscribeForParameters(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseAlertStream alertStream,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            ISpoofingRuleEquitiesParameters parameter)
        {
            var ruleCtx = operationContext.CreateAndStartRuleRunContext(
                Rules.Spoofing.GetDescription(),
                EquityRuleSpoofingFactory.Version,
                parameter.Id,
                (int)Rules.Spoofing,
                execution.IsBackTest,
                execution.TimeSeriesInitiation.DateTime,
                execution.TimeSeriesTermination.DateTime,
                execution.CorrelationId,
                execution.IsForceRerun);

            var runMode                = execution.IsForceRerun ? RuleRunMode.ForceRun : RuleRunMode.ValidationRun;
            var spoofingRule           = this.equityRuleSpoofingFactory.Build(parameter, ruleCtx, alertStream, runMode);
            var spoofingRuleOrgFactors = this.brokerServiceFactory.Build(
                spoofingRule,
                parameter.Factors,
                parameter.AggregateNonFactorableIntoOwnCategory);

            var filteredSpoofingRule = this.DecorateWithFilters(
                operationContext,
                parameter,
                spoofingRuleOrgFactors,
                universeDataRequestsSubscriber,
                ruleCtx,
                runMode);

            return(filteredSpoofingRule);
        }
 public ISystemProcessOperationThirdPartyDataRequestContext Build(
     ISystemProcessOperationContext operationContext)
 {
     return(new SystemProcessOperationThirdPartyDataRequestContext(
                operationContext,
                this._repository,
                this._operationLogging));
 }
        /// <summary>
        /// The build transient lazy universe.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="dataManifestInterpreter">
        /// The data Manifest Interpreter.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverse"/>.
        /// </returns>
        public IUniverse Build(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IDataManifestInterpreter dataManifestInterpreter)
        {
            var universeEvents = new LazyTransientUniverse(dataManifestInterpreter);

            return(new Universe(universeEvents));
        }
Exemple #24
0
 public void Setup()
 {
     this._configuration           = TestHelpers.Config();
     this._logger                  = A.Fake <ILogger <OrdersRepository> >();
     this._opCtx                   = A.Fake <ISystemProcessOperationContext>();
     this._marketRepository        = A.Fake <IReddeerMarketRepository>();
     this._orderBrokerRepository   = A.Fake <IOrderBrokerRepository>();
     this._connectionStringFactory = A.Fake <IConnectionStringFactory>();
 }
 public SystemProcessOperationThirdPartyDataRequestContext(
     ISystemProcessOperationContext processOperationContext,
     ISystemProcessOperationThirdPartyDataRequestRepository requestRepository,
     IOperationLogging operationLogging)
 {
     this._processOperationContext = processOperationContext
                                     ?? throw new ArgumentNullException(nameof(processOperationContext));
     this._requestRepository = requestRepository ?? throw new ArgumentNullException(nameof(requestRepository));
     this._operationLogging  = operationLogging ?? throw new ArgumentNullException(nameof(operationLogging));
 }
 public void Setup()
 {
     this._auroraOrdersRepository   = A.Fake <IOrdersRepository>();
     this._orderAllocationProjector = A.Fake <IOrdersToAllocatedOrdersProjector>();
     this._auroraMarketRepository   = A.Fake <IReddeerMarketRepository>();
     this._marketService            = A.Fake <IMarketOpenCloseEventService>();
     this._opCtx        = A.Fake <ISystemProcessOperationContext>();
     this._sortComparer = A.Fake <IUniverseSortComparer>();
     this._logger       = A.Fake <ILogger <UniverseBuilder> >();
 }
Exemple #27
0
 /// <summary>
 /// Crack the cosmic egg and unscramble your reality
 /// </summary>
 /// <param name="execution">
 /// The execution.
 /// </param>
 /// <param name="operationContext">
 /// The operation Context.
 /// </param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 public async Task <IUniverse> Summon(ScheduledExecution execution, ISystemProcessOperationContext operationContext)
 {
     return(await this.Summon(
                execution,
                operationContext,
                true,
                true,
                execution.TimeSeriesInitiation,
                execution.TimeSeriesTermination));
 }
Exemple #28
0
 public UniverseDataRequestsSubscriber(
     ISystemProcessOperationContext operationContext,
     IQueueDataSynchroniserRequestPublisher queueDataSynchroniserRequestPublisher,
     ILogger <UniverseDataRequestsSubscriber> logger)
 {
     this._operationContext = operationContext ?? throw new ArgumentNullException(nameof(operationContext));
     this._queueDataSynchroniserRequestPublisher = queueDataSynchroniserRequestPublisher
                                                   ?? throw new ArgumentNullException(
                                                             nameof(queueDataSynchroniserRequestPublisher));
     this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #29
0
        /// <summary>
        /// The trade data fetch aurora.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        private async Task <IReadOnlyCollection <Order> > TradeDataFetchAurora(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext)
        {
            var trades = await this.ordersRepository.Get(
                execution.TimeSeriesInitiation.Date,
                execution.TimeSeriesTermination.Date,
                operationContext);

            return(trades ?? new List <Order>());
        }
Exemple #30
0
        public SystemProcessOperationDistributeRuleContext(
            ISystemProcessOperationContext processOperationContext,
            ISystemProcessOperationDistributeRuleRepository repository,
            IOperationLogging operationLogging)
        {
            this._processOperationContext = processOperationContext
                                            ?? throw new ArgumentNullException(nameof(processOperationContext));

            this._repository = repository ?? throw new ArgumentNullException(nameof(repository));

            this._operationLogging = operationLogging ?? throw new ArgumentNullException(nameof(operationLogging));
        }