/// <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 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); }
/// <summary> /// Initializes a new instance of the <see cref="FixedIncomeWashTradeRule"/> 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="runMode"> /// The run mode. /// </param> /// <param name="alertStream"> /// The alert stream. /// </param> /// <param name="clusteringService"> /// The clustering service. /// </param> /// <param name="portfolioFactory"> /// The portfolio factory. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="tradingStackLogger"> /// The trading stack logger. /// </param> public FixedIncomeWashTradeRule( IWashTradeRuleFixedIncomeParameters parameters, IUniverseFixedIncomeOrderFilterService orderFilterService, ISystemProcessOperationRunRuleContext ruleContext, IUniverseEquityMarketCacheFactory equityFactory, IUniverseFixedIncomeMarketCacheFactory fixedIncomeFactory, RuleRunMode runMode, IUniverseAlertStream alertStream, IClusteringService clusteringService, IPortfolioFactory portfolioFactory, ILogger <FixedIncomeWashTradeRule> logger, ILogger <TradingHistoryStack> tradingStackLogger) : base( parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1), parameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1), parameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero, Rules.FixedIncomeWashTrades, Versioner.Version(1, 0), $"{nameof(FixedIncomeWashTradeRule)}", ruleContext, equityFactory, fixedIncomeFactory, runMode, logger, tradingStackLogger) { this.parameters = parameters ?? throw new ArgumentNullException(nameof(parameters)); this.orderFilterService = orderFilterService ?? throw new ArgumentNullException(nameof(orderFilterService)); this.alertStream = alertStream ?? throw new ArgumentNullException(nameof(alertStream)); this.clusteringService = clusteringService ?? throw new ArgumentNullException(nameof(clusteringService)); this.portfolioFactory = portfolioFactory ?? throw new ArgumentNullException(nameof(portfolioFactory)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public void Setup() { this._parameters = A.Fake <IWashTradeRuleFixedIncomeParameters>(); this._fixedIncomeOrderFile = A.Fake <IUniverseFixedIncomeOrderFilterService>(); this._ruleCtx = A.Fake <ISystemProcessOperationRunRuleContext>(); this._equityMarketCacheFactory = A.Fake <IUniverseEquityMarketCacheFactory>(); this._fixedIncomeMarketCacheFactory = A.Fake <IUniverseFixedIncomeMarketCacheFactory>(); this._alertStream = A.Fake <IUniverseAlertStream>(); this._clusteringService = A.Fake <IClusteringService>(); this._portfolioFactory = A.Fake <IPortfolioFactory>(); this._logger = new NullLogger <FixedIncomeHighProfitsRule>(); this._tradingStackLogger = new NullLogger <TradingHistoryStack>(); }