public PlacingOrderWithNoIntentToExecuteRuleRuleBreach( TimeSpan window, ITradePosition trades, FinancialInstrument security, IFactorValue factorValue, decimal meanPrice, decimal sdPrice, IReadOnlyCollection <ProbabilityOfExecution> probabilityForOrders, IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameters, ISystemProcessOperationRunRuleContext ctx, string description, string caseTitle, DateTime universeDateTime) { this.Window = window; this.Trades = trades; this.Security = security; this.FactorValue = factorValue; this.Parameters = parameters; this.MeanPrice = meanPrice; this.StandardDeviationPrice = sdPrice; this.ProbabilityForOrders = probabilityForOrders ?? new List <ProbabilityOfExecution>(); this.RuleParameterId = parameters.Id; this.SystemOperationId = ctx.Id(); this.CorrelationId = ctx.CorrelationId(); this.RuleParameters = parameters; this.Description = description ?? string.Empty; this.CaseTitle = caseTitle ?? string.Empty; this.UniverseDateTime = universeDateTime; }
/// <summary> /// Initializes a new instance of the <see cref="PlacingOrdersWithNoIntentToExecuteRule"/> class. /// </summary> /// <param name="parameters"> /// The parameters. /// </param> /// <param name="orderFilter"> /// The order filter. /// </param> /// <param name="ruleContext"> /// The rule context. /// </param> /// <param name="equityMarketCacheFactory"> /// The market cache factory. /// </param> /// <param name="fixedIncomeMarketCacheFactory"> /// The market cache factory. /// </param> /// <param name="alertStream"> /// The alert stream. /// </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 PlacingOrdersWithNoIntentToExecuteRule( IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameters, IUniverseOrderFilter orderFilter, ISystemProcessOperationRunRuleContext ruleContext, IUniverseEquityMarketCacheFactory equityMarketCacheFactory, IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory, IUniverseAlertStream alertStream, IUniverseDataRequestsSubscriber dataRequestSubscriber, IMarketTradingHoursService tradingHoursService, RuleRunMode runMode, ILogger logger, ILogger <TradingHistoryStack> tradingStackLogger) : base( TimeSpan.FromHours(24), TimeSpan.FromHours(24), TimeSpan.Zero, Domain.Surveillance.Scheduling.Rules.PlacingOrderWithNoIntentToExecute, EquityRulePlacingOrdersWithoutIntentToExecuteFactory.Version, "Placing Orders With No Intent To Execute Rule", ruleContext, equityMarketCacheFactory, fixedIncomeMarketCacheFactory, runMode, logger, tradingStackLogger) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.ruleContext = ruleContext ?? throw new ArgumentNullException(nameof(ruleContext)); this.alertStream = alertStream ?? throw new ArgumentNullException(nameof(alertStream)); this.dataRequestSubscriber = dataRequestSubscriber ?? throw new ArgumentNullException(nameof(dataRequestSubscriber)); this.orderFilter = orderFilter ?? throw new ArgumentNullException(nameof(orderFilter)); this.parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); this.tradingHoursService = tradingHoursService ?? throw new ArgumentNullException(nameof(tradingHoursService)); }
/// <summary> /// The decorate with filters. /// </summary> /// <param name="operationContext"> /// The operation context. /// </param> /// <param name="parameter"> /// The parameter. /// </param> /// <param name="placingOrders"> /// The placing orders. /// </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, IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameter, IUniverseRule placingOrders, IUniverseDataRequestsSubscriber universeDataRequestsSubscriber, ISystemProcessOperationRunRuleContext processOperationRunRuleContext, RuleRunMode ruleRunMode) { if (parameter.HasInternalFilters() || parameter.HasReferenceDataFilters() || parameter.HasMarketCapFilters() || parameter.HasVenueVolumeFilters()) { this.logger.LogInformation($"parameters had filters. Inserting filtered universe in {operationContext.Id} OpCtx"); var filteredUniverse = this.universeFilterFactory.Build( placingOrders, parameter.Accounts, parameter.Traders, parameter.Markets, parameter.Funds, parameter.Strategies, parameter.Sectors, parameter.Industries, parameter.Regions, parameter.Countries, parameter.MarketCapFilter, ruleRunMode, "Placing Orders Equity", universeDataRequestsSubscriber, processOperationRunRuleContext); var decoratedFilter = filteredUniverse; if (parameter.HasVenueVolumeFilters()) { decoratedFilter = this.decoratorFilterFactory.Build( parameter.Windows, filteredUniverse, parameter.VenueVolumeFilter, processOperationRunRuleContext, universeDataRequestsSubscriber, DataSource.AnyIntraday, ruleRunMode); } decoratedFilter.Subscribe(placingOrders); return(decoratedFilter); } return(placingOrders); }
public IPlacingOrdersWithNoIntentToExecuteRule Build( IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameters, IUniverseAlertStream alertStream, ISystemProcessOperationRunRuleContext ruleCtx, IUniverseDataRequestsSubscriber dataRequestSubscriber, RuleRunMode runMode) { return(new PlacingOrdersWithNoIntentToExecuteRule( parameters, this._orderFilterService, ruleCtx, this._equityFactory, this._fixedIncomeFactory, alertStream, dataRequestSubscriber, this._tradingHoursService, runMode, this._logger, this._tradingHistoryLogger)); }
/// <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="parameter"> /// The parameter. /// </param> /// <param name="dataRequestSubscriber"> /// The data request subscriber. /// </param> /// <returns> /// The <see cref="IUniverseRule"/>. /// </returns> private IUniverseRule SubscribeToParameters( ScheduledExecution execution, ISystemProcessOperationContext operationContext, IUniverseAlertStream alertStream, IPlacingOrderWithNoIntentToExecuteRuleEquitiesParameters parameter, IUniverseDataRequestsSubscriber dataRequestSubscriber) { var ruleCtx = operationContext.CreateAndStartRuleRunContext( Rules.PlacingOrderWithNoIntentToExecute.GetDescription(), EquityRulePlacingOrdersWithoutIntentToExecuteFactory.Version, parameter.Id, (int)Rules.PlacingOrderWithNoIntentToExecute, execution.IsBackTest, execution.TimeSeriesInitiation.DateTime, execution.TimeSeriesTermination.DateTime, execution.CorrelationId, execution.IsForceRerun); var runMode = execution.IsForceRerun ? RuleRunMode.ForceRun : RuleRunMode.ValidationRun; var placingOrders = this.equityRulePlacingOrdersFactory.Build( parameter, alertStream, ruleCtx, dataRequestSubscriber, runMode); var placingOrdersOrgFactors = this.brokerServiceFactory.Build( placingOrders, parameter.Factors, parameter.AggregateNonFactorableIntoOwnCategory); var filteredPlacingOrders = this.DecorateWithFilters( operationContext, parameter, placingOrdersOrgFactors, dataRequestSubscriber, ruleCtx, runMode); return(filteredPlacingOrders); }