コード例 #1
0
        /// <summary>
        /// The decorate with filters.
        /// </summary>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="highProfits">
        /// The high profits.
        /// </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,
            IHighProfitsRuleFixedIncomeParameters parameters,
            IUniverseRule highProfits,
            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(
                    highProfits,
                    parameters.Accounts,
                    parameters.Traders,
                    parameters.Markets,
                    parameters.Funds,
                    parameters.Strategies,
                    null,
                    null,
                    null,
                    null,
                    null,
                    ruleRunMode,
                    "High Profits Fixed Income",
                    universeDataRequestsSubscriber,
                    processOperationRunRuleContext);
                filteredUniverse.Subscribe(highProfits);

                return(filteredUniverse);
            }

            return(highProfits);
        }
コード例 #2
0
 public void Setup()
 {
     this.fixedIncomeHighProfitJudgement = A.Fake <IFixedIncomeHighProfitJudgement>();
     this.ruleBreachContext     = A.Fake <IRuleBreachContext>();
     this.fixedIncomeParameters = A.Fake <IHighProfitsRuleFixedIncomeParameters>();
     this.profitBreakdown       = A.Fake <IExchangeRateProfitBreakdown>();
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighProfitsMarketClosureRule"/> class.
 /// </summary>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="ruleContext">
 /// The rule context.
 /// </param>
 /// <param name="costCalculatorFactory">
 /// The cost calculator factory.
 /// </param>
 /// <param name="revenueCalculatorFactory">
 /// The revenue calculator factory.
 /// </param>
 /// <param name="exchangeRateProfitCalculator">
 /// The exchange rate profit calculator.
 /// </param>
 /// <param name="orderFilter">
 /// The order filter.
 /// </param>
 /// <param name="equityMarketCacheFactory">
 /// The market cache factory.
 /// </param>
 /// <param name="fixedIncomeMarketCacheFactory">
 /// The market cache factory.
 /// </param>
 /// <param name="marketDataCacheFactory">
 /// The market data cache factory.
 /// </param>
 /// <param name="dataRequestSubscriber">
 /// The data request subscriber.
 /// </param>
 /// <param name="judgementService">
 /// The judgement service.
 /// </param>
 /// <param name="runMode">
 /// The run mode.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingHistoryLogger">
 /// The trading history logger.
 /// </param>
 public FixedIncomeHighProfitsMarketClosureRule(
     IHighProfitsRuleFixedIncomeParameters fixedIncomeParameters,
     ISystemProcessOperationRunRuleContext ruleContext,
     ICostCalculatorFactory costCalculatorFactory,
     IRevenueCalculatorFactory revenueCalculatorFactory,
     IExchangeRateProfitCalculator exchangeRateProfitCalculator,
     IUniverseFixedIncomeOrderFilterService orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     IFixedIncomeMarketDataCacheStrategyFactory marketDataCacheFactory,
     IUniverseDataRequestsSubscriber dataRequestSubscriber,
     IFixedIncomeHighProfitJudgementService judgementService,
     ICurrencyConverterService currencyConverterService,
     RuleRunMode runMode,
     ILogger <FixedIncomeHighProfitsRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         fixedIncomeParameters,
         ruleContext,
         costCalculatorFactory,
         revenueCalculatorFactory,
         exchangeRateProfitCalculator,
         orderFilter,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         marketDataCacheFactory,
         dataRequestSubscriber,
         judgementService,
         currencyConverterService,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.MarketClosureRule = true;
 }
 public void Setup()
 {
     this.streamRule        = A.Fake <IFixedIncomeHighProfitsStreamRule>();
     this.marketClosureRule = A.Fake <IFixedIncomeHighProfitsMarketClosureRule>();
     this.parameters        = A.Fake <IHighProfitsRuleFixedIncomeParameters>();
     this.logger            = A.Fake <ILogger <FixedIncomeHighProfitsRule> >();
     this.universeEvent     = A.Fake <IUniverseEvent>();
 }
 public void Setup()
 {
     this.logger            = A.Fake <ILogger <FixedIncomeHighProfitJudgementMapper> >();
     this.judgementContext  = A.Fake <IFixedIncomeHighProfitJudgementContext>();
     this.ruleBreachContext = A.Fake <IRuleBreachContext>();
     this.parameters        = A.Fake <IHighProfitsRuleFixedIncomeParameters>();
     this.profitBreakdown   = A.Fake <IExchangeRateProfitBreakdown>();
 }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FixedIncomeHighProfitsStreamRule"/> class.
        /// Constructor for the high profits stream rule
        /// </summary>
        /// <param name="fixedIncomeParameters">
        /// parameters from the client service user interface
        /// </param>
        /// <param name="ruleContext">
        /// auditing helper
        /// </param>
        /// <param name="costCalculatorFactory">
        /// cost logic service factory
        /// </param>
        /// <param name="revenueCalculatorFactory">
        /// revenue logic service factory
        /// </param>
        /// <param name="exchangeRateProfitCalculator">
        /// exchange rate service
        /// </param>
        /// <param name="orderFilter">
        /// classification financial instruments filtering service
        /// </param>
        /// <param name="equityMarketCacheFactory">
        /// time bar cache factory
        /// </param>
        /// /// <param name="fixedIncomeMarketCacheFactory">
        /// time bar cache factory
        /// </param>
        /// <param name="marketDataCacheFactory">
        /// market time bar cache factory
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// data fetch pattern helper
        /// </param>
        /// <param name="judgementService">
        /// rule analysis service
        /// </param>
        /// <param name="runMode">
        /// forced or validation
        /// </param>
        /// <param name="logger">
        /// logging helper
        /// </param>
        /// <param name="tradingHistoryLogger">
        /// logging helper for trading history
        /// </param>
        public FixedIncomeHighProfitsStreamRule(
            IHighProfitsRuleFixedIncomeParameters fixedIncomeParameters,
            ISystemProcessOperationRunRuleContext ruleContext,
            ICostCalculatorFactory costCalculatorFactory,
            IRevenueCalculatorFactory revenueCalculatorFactory,
            IExchangeRateProfitCalculator exchangeRateProfitCalculator,
            IUniverseFixedIncomeOrderFilterService orderFilter,
            IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
            IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
            IFixedIncomeMarketDataCacheStrategyFactory marketDataCacheFactory,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            IFixedIncomeHighProfitJudgementService judgementService,
            ICurrencyConverterService currencyService,
            RuleRunMode runMode,
            ILogger <FixedIncomeHighProfitsRule> logger,
            ILogger <TradingHistoryStack> tradingHistoryLogger)
            : base(
                fixedIncomeParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromHours(8),
                fixedIncomeParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromHours(8),
                fixedIncomeParameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
                Domain.Surveillance.Scheduling.Rules.FixedIncomeHighProfits,
                FixedIncomeHighProfitFactory.Version,
                "Fixed Income High Profit Rule",
                ruleContext,
                equityMarketCacheFactory,
                fixedIncomeMarketCacheFactory,
                runMode,
                logger,
                tradingHistoryLogger)
        {
            this.FixedIncomeParameters =
                fixedIncomeParameters ?? throw new ArgumentNullException(nameof(fixedIncomeParameters));

            this.RuleCtx = ruleContext ?? throw new ArgumentNullException(nameof(ruleContext));

            this.costCalculatorFactory =
                costCalculatorFactory ?? throw new ArgumentNullException(nameof(costCalculatorFactory));

            this.revenueCalculatorFactory = revenueCalculatorFactory
                                            ?? throw new ArgumentNullException(nameof(revenueCalculatorFactory));

            this.marketDataCacheFactory =
                marketDataCacheFactory ?? throw new ArgumentNullException(nameof(marketDataCacheFactory));

            this.exchangeRateProfitCalculator = exchangeRateProfitCalculator
                                                ?? throw new ArgumentNullException(
                                                          nameof(exchangeRateProfitCalculator));

            this.orderFilter = orderFilter ?? throw new ArgumentNullException(nameof(orderFilter));

            this.dataRequestSubscriber =
                dataRequestSubscriber ?? throw new ArgumentNullException(nameof(dataRequestSubscriber));

            this.JudgementService         = judgementService ?? throw new ArgumentNullException(nameof(judgementService));
            this.currencyConverterService = currencyService ?? throw new ArgumentNullException(nameof(currencyService));

            this.Logger = logger ?? throw new ArgumentNullException(nameof(logger));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighProfitsRule"/> class.
 /// </summary>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="streamRule">
 /// The stream rule.
 /// </param>
 /// <param name="marketClosureRule">
 /// The market closure rule.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 public FixedIncomeHighProfitsRule(
     IHighProfitsRuleFixedIncomeParameters fixedIncomeParameters,
     IFixedIncomeHighProfitsStreamRule streamRule,
     IFixedIncomeHighProfitsMarketClosureRule marketClosureRule,
     ILogger <FixedIncomeHighProfitsRule> logger)
 {
     this.fixedIncomeParameters =
         fixedIncomeParameters ?? throw new ArgumentNullException(nameof(fixedIncomeParameters));
     this.streamRule        = streamRule ?? throw new ArgumentNullException(nameof(streamRule));
     this.marketClosureRule = marketClosureRule ?? throw new ArgumentNullException(nameof(marketClosureRule));
     this.logger            = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        /// <summary>
        /// The build rule.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="ruleContext">
        /// The rule context.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <param name="dataRequestSubscriber">
        /// The data request subscriber.
        /// </param>
        /// <param name="runMode">
        /// The run mode.
        /// </param>
        /// <param name="scheduledExecution">
        /// The scheduled execution.
        /// </param>
        /// <returns>
        /// The <see cref="IFixedIncomeHighProfitsRule"/>.
        /// </returns>
        public IFixedIncomeHighProfitsRule BuildRule(
            IHighProfitsRuleFixedIncomeParameters parameters,
            ISystemProcessOperationRunRuleContext ruleContext,
            IFixedIncomeHighProfitJudgementService judgementService,
            IUniverseDataRequestsSubscriber dataRequestSubscriber,
            RuleRunMode runMode,
            ScheduledExecution scheduledExecution)
        {
            var fixedIncomeStreamRule = new FixedIncomeHighProfitsStreamRule(
                parameters,
                ruleContext,
                this.costCalculatorFactory,
                this.revenueCalculatorFactory,
                this.exchangeRateProfitCalculator,
                this.fixedIncomeOrderFilterService,
                this.equityMarketCacheFactory,
                this.fixedIncomeCacheFactory,
                this.marketDataCacheStrategyFactory,
                dataRequestSubscriber,
                judgementService,
                currencyConverterService,
                runMode,
                this.logger,
                this.stackLogger);

            var fixedIncomeMarketClosureRule = new FixedIncomeHighProfitsMarketClosureRule(
                parameters,
                ruleContext,
                this.costCalculatorFactory,
                this.revenueCalculatorFactory,
                this.exchangeRateProfitCalculator,
                this.fixedIncomeOrderFilterService,
                this.equityMarketCacheFactory,
                this.fixedIncomeCacheFactory,
                this.marketDataCacheStrategyFactory,
                dataRequestSubscriber,
                judgementService,
                currencyConverterService,
                runMode,
                this.logger,
                this.stackLogger);

            return(new FixedIncomeHighProfitsRule(
                       parameters,
                       fixedIncomeStreamRule,
                       fixedIncomeMarketClosureRule,
                       this.logger));
        }
コード例 #9
0
        /// <summary>
        /// The subscribe to parameters.
        /// </summary>
        /// <param name="execution">
        /// The execution.
        /// </param>
        /// <param name="operationContext">
        /// The operation context.
        /// </param>
        /// <param name="universeDataRequestsSubscriber">
        /// The universe data requests subscriber.
        /// </param>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="judgementService">
        /// The judgement service.
        /// </param>
        /// <returns>
        /// The <see cref="IUniverseRule"/>.
        /// </returns>
        private IUniverseRule SubscribeToParameters(
            ScheduledExecution execution,
            ISystemProcessOperationContext operationContext,
            IUniverseDataRequestsSubscriber universeDataRequestsSubscriber,
            IHighProfitsRuleFixedIncomeParameters parameters,
            IJudgementService judgementService)
        {
            var ruleCtx = operationContext.CreateAndStartRuleRunContext(
                Rules.FixedIncomeHighProfits.GetDescription(),
                FixedIncomeHighProfitFactory.Version,
                parameters.Id,
                (int)Rules.FixedIncomeHighProfits,
                execution.IsBackTest,
                execution.TimeSeriesInitiation.DateTime,
                execution.TimeSeriesTermination.DateTime,
                execution.CorrelationId,
                execution.IsForceRerun);

            var runMode = execution.IsForceRerun ? RuleRunMode.ForceRun : RuleRunMode.ValidationRun;

            var highProfits =
                this.fixedIncomeRuleHighProfitsFactory.BuildRule(
                    parameters,
                    ruleCtx,
                    judgementService,
                    universeDataRequestsSubscriber,
                    runMode,
                    execution);

            var highProfitsOrgFactors = this.brokerServiceFactory.Build(
                highProfits,
                parameters.Factors,
                parameters.AggregateNonFactorableIntoOwnCategory);

            var highProfitsFiltered = this.DecorateWithFilters(
                operationContext,
                parameters,
                highProfitsOrgFactors,
                universeDataRequestsSubscriber,
                ruleCtx,
                runMode);

            return(highProfitsFiltered);
        }
コード例 #10
0
 public void Setup()
 {
     this.fixedIncomeOrderFilterService  = A.Fake <IUniverseFixedIncomeOrderFilterService>();
     this.equityMarketCacheFactory       = A.Fake <IUniverseEquityMarketCacheFactory>();
     this.fixedIncomeMarketCacheFactory  = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
     this.marketDataCacheStrategyFactory = A.Fake <IFixedIncomeMarketDataCacheStrategyFactory>();
     this.costCalculatorFactory          = A.Fake <ICostCalculatorFactory>();
     this.revenueCalculatorFactory       = A.Fake <IRevenueCalculatorFactory>();
     this.exchangeRateProfitCalculator   = A.Fake <IExchangeRateProfitCalculator>();
     this.logger                   = A.Fake <ILogger <FixedIncomeHighProfitsRule> >();
     this.stackLogger              = A.Fake <ILogger <TradingHistoryStack> >();
     this.parameters               = A.Fake <IHighProfitsRuleFixedIncomeParameters>();
     this.ruleContext              = A.Fake <ISystemProcessOperationRunRuleContext>();
     this.judgementService         = A.Fake <IFixedIncomeHighProfitJudgementService>();
     this.dataRequestSubscriber    = A.Fake <IUniverseDataRequestsSubscriber>();
     this.currencyConverterService = A.Fake <ICurrencyConverterService>();
     this.runMode                  = RuleRunMode.ValidationRun;
     this.scheduledExecution       = new ScheduledExecution();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="FixedIncomeHighProfitJudgementContext"/> class.
 /// </summary>
 /// <param name="judgement">
 /// The judgement.
 /// </param>
 /// <param name="projectToAlert">
 /// The project to alert.
 /// </param>
 /// <param name="ruleBreachContext">
 /// The rule breach context.
 /// </param>
 /// <param name="fixedIncomeParameters">
 /// The fixed income parameters.
 /// </param>
 /// <param name="absoluteProfits">
 /// The absolute profits.
 /// </param>
 /// <param name="absoluteProfitCurrency">
 /// The absolute profit currency.
 /// </param>
 /// <param name="relativeProfits">
 /// The relative profits.
 /// </param>
 /// <param name="hasAbsoluteProfitBreach">
 /// The has absolute profit breach.
 /// </param>
 /// <param name="hasRelativeProfitBreach">
 /// The has relative profit breach.
 /// </param>
 /// <param name="profitBreakdown">
 /// The profit breakdown.
 /// </param>
 public FixedIncomeHighProfitJudgementContext(
     IFixedIncomeHighProfitJudgement judgement,
     bool projectToAlert,
     IRuleBreachContext ruleBreachContext,
     IHighProfitsRuleFixedIncomeParameters fixedIncomeParameters,
     Money?absoluteProfits,
     string absoluteProfitCurrency,
     decimal?relativeProfits,
     bool hasAbsoluteProfitBreach,
     bool hasRelativeProfitBreach,
     IExchangeRateProfitBreakdown profitBreakdown)
 {
     this.Judgement               = judgement;
     this.RaiseRuleViolation      = projectToAlert;
     this.RuleBreachContext       = ruleBreachContext;
     this.FixedIncomeParameters   = fixedIncomeParameters;
     this.AbsoluteProfits         = absoluteProfits;
     this.AbsoluteProfitCurrency  = absoluteProfitCurrency;
     this.RelativeProfits         = relativeProfits;
     this.HasAbsoluteProfitBreach = hasAbsoluteProfitBreach;
     this.HasRelativeProfitBreach = hasRelativeProfitBreach;
     this.ExchangeRateProfits     = profitBreakdown;
 }