public async Task Summon_InsertsUniverseBeginningAndEndEventData() { var timeSeriesInitiation = new DateTime(2018, 01, 01); var timeSeriesTermination = new DateTime(2018, 01, 02); var builder = new UniverseBuilder( this._auroraOrdersRepository, this._orderAllocationProjector, this._auroraMarketRepository, this._marketService, this._sortComparer, this._logger); var schedule = new ScheduledExecution { Rules = new List <RuleIdentifier>(), TimeSeriesInitiation = timeSeriesInitiation, TimeSeriesTermination = timeSeriesTermination }; var result = await builder.Summon(schedule, this._opCtx); Assert.IsNotNull(result); Assert.AreEqual(result.UniverseEvents.FirstOrDefault().StateChange, UniverseStateEvent.Genesis); Assert.AreEqual( result.UniverseEvents.Skip(1).FirstOrDefault().StateChange, UniverseStateEvent.EpochPrimordialUniverse); Assert.AreEqual( result.UniverseEvents.Skip(2).FirstOrDefault().StateChange, UniverseStateEvent.EpochRealUniverse); Assert.AreEqual( result.UniverseEvents.Skip(3).FirstOrDefault().StateChange, UniverseStateEvent.EpochFutureUniverse); Assert.AreEqual(result.UniverseEvents.Skip(4).FirstOrDefault().StateChange, UniverseStateEvent.Eschaton); }
public void WhenIRunTheFixedIncomeHighProfitRule() { var scheduledExecution = new ScheduledExecution { IsForceRerun = true }; this.Setup(); var rule = new FixedIncomeWashTradeRule( this._parameters, this._orderFilterService, this._ruleCtx, this._equityMarketCacheFactory, this._fixedIncomeMarketCacheFactory, RuleRunMode.ForceRun, this._alertStream, this._clusteringService, this._portfolioFactory, new NullLogger <FixedIncomeWashTradeRule>(), new NullLogger <TradingHistoryStack>()); foreach (var universeEvent in this._universeSelectionState.SelectedUniverse.UniverseEvents) { rule.OnNext(universeEvent); } }
/// <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}"); }
/// <summary> /// The rule run update message send /// This is for relaying updates to the client service. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <param name="ids"> /// The ids. /// </param> private void RuleRunUpdateMessageSend(ScheduledExecution execution, IReadOnlyCollection <string> ids) { if (execution == null) { this.logger.LogInformation("execution was null not sending rule run update message"); return; } if (!execution.IsBackTest) { this.logger.LogInformation($"execution with correlation id {execution.CorrelationId} was not a back test not sending rule run update message"); return; } if (ids == null) { this.logger.LogInformation($"no ids for rule run with correlation id {execution.CorrelationId} not submitting update message"); return; } foreach (var id in ids) { this.logger.LogInformation($"submitting rule update message for correlation id {execution.CorrelationId} and test parameter id {id}"); this.queueRuleUpdatePublisher.Send(id).Wait(); } if (!ids.Any()) { this.logger.LogError($"could not submit rule update message for correlation id {execution.CorrelationId} as there were no ids"); } }
/// <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); }
/// <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); }
public IReadOnlyCollection <ICancelledOrderRuleEquitiesParameters> Map( ScheduledExecution execution, List <CancelledOrderRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation("asked to map null or empty cancelled order dtos"); return(null); } return(dtos.Select( _ => new CancelledOrderRuleEquitiesParameters( _.Id, _.WindowSize, _.CancelledOrderPercentagePositionThreshold, _.CancelledOrderCountPercentageThreshold, _.MinimumNumberOfTradesToApplyRuleTo, _.MaximumNumberOfTradesToApplyRuleTo, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public HealthMonitoringExpression ScheduledExecution(ScheduledExecution scheduledExecution) { _parent.AlterSettings<PollingJobSettings>(x => { x.JobFor<HealthMonitorPollingJob>().ScheduledExecution = scheduledExecution; }); return this; }
public IReadOnlyCollection <IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters> Map( ScheduledExecution execution, List <PlacingOrdersWithNoIntentToExecuteRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation( $"asked to map null or empty {nameof(PlacingOrderWithNoIntentToExecuteRuleEquitiesParameters)}"); return(null); } return(dtos.Select( _ => new PlacingOrderWithNoIntentToExecuteRuleEquitiesParameters( _.Id, _.Sigma, _.WindowSize, this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), _.PerformTuning)).ToList()); }
public IReadOnlyCollection <ISpoofingRuleEquitiesParameters> Map( ScheduledExecution execution, List <SpoofingRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation("asked to map null or empty spoofing dtos"); return(null); } return(dtos.Select( _ => new SpoofingRuleEquitiesParameters( _.Id, _.WindowSize, _.CancellationThreshold, _.RelativeSizeMultipleForSpoofExceedingReal, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public IReadOnlyCollection <IHighVolumeIssuanceRuleFixedIncomeParameters> Map( ScheduledExecution execution, List <FixedIncomeHighVolumeRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation( $"asked to map null or empty {nameof(FixedIncomeHighVolumeRuleParameterDto)}"); return(null); } return(dtos.Select( _ => new HighVolumeIssuanceRuleFixedIncomeParameters( _.Id, _.WindowSize, _.PerformDailyAnalysis ? _.HighVolumePercentageDaily : null, _.PerformWindowAnalysis ? _.HighVolumePercentageWindow : null, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public IReadOnlyCollection <IWashTradeRuleFixedIncomeParameters> Map( ScheduledExecution execution, List <FixedIncomeWashTradeRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation( $"asked to map null or empty {nameof(FixedIncomeWashTradeRuleParameterDto)}"); return(null); } return(dtos.Select( _ => new WashTradeRuleFixedIncomeParameters( _.Id, _.WindowSize, _.PerformAveragePositionAnalysis, _.PerformClusteringPositionAnalysis, _.AveragePositionMinimumNumberOfTrades, _.AveragePositionMaximumPositionValueChange, _.AveragePositionMaximumAbsoluteValueChangeAmount, _.AveragePositionMaximumAbsoluteValueChangeCurrency, _.ClusteringPositionMinimumNumberOfTrades, _.ClusteringPercentageValueDifferenceThreshold, this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public IReadOnlyCollection <IRampingRuleEquitiesParameters> Map( ScheduledExecution execution, List <RampingRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation("asked to map null or empty ramping dtos"); return(null); } return(dtos.Select( _ => new RampingRuleEquitiesParameters( _.Id, _.WindowSize, _.AutoCorrelationCoefficient, _.ThresholdOrdersExecutedInWindow, _.ThresholdVolumePercentageWindow, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public HealthMonitoringExpression ScheduledExecution(ScheduledExecution scheduledExecution) { _parent.AlterSettings <PollingJobSettings>(x => { x.JobFor <HealthMonitorPollingJob>().ScheduledExecution = scheduledExecution; }); return(this); }
public PollingJobChain(Type jobType, Type settingType, Expression intervalSource) { if (jobType == null) { throw new ArgumentNullException("jobType"); } if (settingType == null) { throw new ArgumentNullException("settingType"); } if (intervalSource == null) { throw new ArgumentNullException("intervalSource"); } ScheduledExecution = ScheduledExecution.WaitUntilInterval; JobType = jobType; SettingType = settingType; IntervalSource = intervalSource; Tags.Add(NoTracing); var handlerType = typeof(JobRunner <>).MakeGenericType(JobType); var method = handlerType.GetMethod("Run"); AddToEnd(new HandlerCall(handlerType, method)); }
public IReadOnlyCollection <ILayeringRuleEquitiesParameters> Map( ScheduledExecution execution, List <LayeringRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation("asked to map null or empty layering dtos"); return(null); } return(dtos.Select( _ => new LayeringRuleEquitiesParameters( _.Id, _.WindowSize, _.PercentageOfMarketDailyVolume, _.PercentageOfMarketWindowVolume, _.CheckForCorrespondingPriceMovement, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
public async Task InitiateRuleRunForTwoWeeksButNullParamsDoesNotDoAnything() { A.CallTo(() => this.apiRepository.GetAsync()).Returns(new RuleParameterDto { HighProfits = null }); var serialiser = new ScheduledExecutionMessageBusSerialiser(new ScheduleExecutionDtoMapper(null)); var scheduler = this.Build(); var execution = new ScheduledExecution { Rules = new List <RuleIdentifier> { new RuleIdentifier { Rule = Rules.HighProfits, Ids = new string[0] } }, TimeSeriesInitiation = new DateTime(2018, 01, 01), TimeSeriesTermination = new DateTime(2018, 01, 15) }; var messageBody = serialiser.SerialiseScheduledExecution(execution); await scheduler.Disassemble(this.systemProcessOperationContext, execution, "any-id", messageBody); A.CallTo(() => this.distributedRulePublisher.ScheduleExecution(A <ScheduledExecution> .Ignored)) .MustNotHaveHappened(); }
public void WhenIRunTheFixedIncomeHighProfitRule() { var scheduledExecution = new ScheduledExecution { IsForceRerun = true }; this.Setup(); var rule = new FixedIncomeHighVolumeRule( this.parameters, this.orderFilterService, this.ruleContext, this.equityMarketCacheFactory, this.fixedIncomeMarketCacheFactory, this.judgementService, this.dataRequestSubscriber, this.marketTradingHoursService, RuleRunMode.ForceRun, new NullLogger <FixedIncomeHighVolumeRule>(), new NullLogger <TradingHistoryStack>()); foreach (var universeEvent in this.universeSelectionState.SelectedUniverse.UniverseEvents) { rule.OnNext(universeEvent); } }
/// <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 IReadOnlyCollection <IMarkingTheCloseEquitiesParameters> Map( ScheduledExecution execution, List <MarkingTheCloseRuleParameterDto> dtos) { if (dtos == null || !dtos.Any()) { this._logger.LogInformation("asked to map null or empty marking the close dtos"); return(null); } return(dtos.Select( _ => new MarkingTheCloseEquitiesParameters( _.Id, _.WindowSize, _.PercentageThresholdDailyVolume, _.PercentageThresholdWindowVolume, _.PercentThresholdOffTouch, this._decimalRangeRuleFilterProjector.Project(_.MarketCap), this._decimalRangeRuleFilterProjector.Project(_.Turnover), this._ruleFilterProjector.Project(_.Accounts), this._ruleFilterProjector.Project(_.Traders), this._ruleFilterProjector.Project(_.Markets), this._ruleFilterProjector.Project(_.Funds), this._ruleFilterProjector.Project(_.Strategies), this._ruleFilterProjector.Project(_.Sectors), this._ruleFilterProjector.Project(_.Industries), this._ruleFilterProjector.Project(_.Regions), this._ruleFilterProjector.Project(_.Countries), this._organisationalFactorMapper.Map(_.OrganisationalFactors), _.AggregateNonFactorableIntoOwnCategory, _.PerformTuning)).ToList()); }
/// <summary> /// The send. /// </summary> /// <param name="message"> /// The message. /// </param> /// <returns> /// The <see cref="Task"/>. /// </returns> public async Task Send(ScheduledExecution message) { if (message == null) { this.logger.LogWarning("was asked to send a null message. Will not be sending anything."); return; } var messageBusCts = new CancellationTokenSource(); var serialisedMessage = this.serialiser.SerialiseScheduledExecution(message); try { this.logger.LogInformation($"dispatching to {this.awsConfiguration.ScheduledRuleQueueName}"); await this .awsQueueClient .SendToQueue(this.awsConfiguration.ScheduledRuleQueueName, serialisedMessage, messageBusCts.Token) ; this.logger.LogInformation($"finished dispatching to {this.awsConfiguration.ScheduledRuleQueueName}"); } catch (Exception e) { this.logger.LogError(e, $"Exception sending message '{message}' to queue {this.awsConfiguration.ScheduledRuleQueueName}."); } }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <summary> /// The validate schedule rule. /// </summary> /// <param name="execution"> /// The execution. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> protected bool ValidateScheduleRule(ScheduledExecution execution) { if (execution == null) { this.logger?.LogError("had a null scheduled execution. Returning."); return(false); } if (execution.TimeSeriesInitiation.DateTime.Year < 2015) { this.logger?.LogError("had a time series initiation before 2015. Returning."); return(false); } if (execution.TimeSeriesTermination.DateTime.Year < 2015) { this.logger?.LogError("had a time series termination before 2015. Returning."); return(false); } if (execution.TimeSeriesInitiation > execution.TimeSeriesTermination) { this.logger?.LogError("had a time series initiation that exceeded the time series termination."); return(false); } return(true); }
/// <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); }
public void Run(string command) { if (!command.Contains("run schedule rule")) { return; } var removedCommand = command.Replace("run schedule rule", string.Empty).Trim(); var dates = removedCommand.Split(' '); if (dates.Length != 2) { // write out error to screen this._console.WriteToUserFeedbackLine( $"Malformed command format at schedule rule command {command}. Expected 'run schedule rule 01/01/2018 12/01/2018'"); return; } if (!DateTime.TryParse(dates[0], out var initialDate)) { this._console.WriteToUserFeedbackLine($"{initialDate} could not be parsed as a date"); return; } if (!DateTime.TryParse(dates[1], out var terminationDate)) { this._console.WriteToUserFeedbackLine($"{terminationDate} could not be parsed as a date"); return; } terminationDate = this.OffsetTerminationDate(terminationDate); if (initialDate > terminationDate) { this._console.WriteToUserFeedbackLine("Initiation precedes Termination date. Invalid input."); return; } initialDate = DateTime.SpecifyKind(initialDate, DateTimeKind.Utc); terminationDate = DateTime.SpecifyKind(terminationDate, DateTimeKind.Utc); var allRulesList = this.GetAllRules(); var scheduledExecution = new ScheduledExecution { Rules = allRulesList, TimeSeriesInitiation = initialDate, TimeSeriesTermination = terminationDate }; var message = this._serialiser.SerialiseScheduledExecution(scheduledExecution); var cts = new CancellationTokenSource(TimeSpan.FromMinutes(1)); this._awsQueueClient.SendToQueue(this._configuration.ScheduledRuleQueueName, message, cts.Token); }
public HealthMonitoringExpression ScheduledExecution(ScheduledExecution scheduledExecution) { _parent.AlterSettings<PollingJobSettings>(x => { x.AddJob<HealthMonitorPollingJob, HealthMonitoringSettings>(settings => settings.Interval) .ScheduledExecution = scheduledExecution; }); return this; }
/// <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)); }