Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HighProfitMarketClosureRule"/> class.
 /// </summary>
 /// <param name="equitiesParameters">
 /// The equities 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 HighProfitMarketClosureRule(
     IHighProfitsRuleEquitiesParameters equitiesParameters,
     ISystemProcessOperationRunRuleContext ruleContext,
     ICostCalculatorFactory costCalculatorFactory,
     IRevenueCalculatorFactory revenueCalculatorFactory,
     IExchangeRateProfitCalculator exchangeRateProfitCalculator,
     IUniverseOrderFilter orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     IEquityMarketDataCacheStrategyFactory marketDataCacheFactory,
     IUniverseDataRequestsSubscriber dataRequestSubscriber,
     IHighProfitJudgementService judgementService,
     ICurrencyConverterService currencyConverterService,
     RuleRunMode runMode,
     ILogger <HighProfitsRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         equitiesParameters,
         ruleContext,
         costCalculatorFactory,
         revenueCalculatorFactory,
         exchangeRateProfitCalculator,
         orderFilter,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         marketDataCacheFactory,
         dataRequestSubscriber,
         judgementService,
         currencyConverterService,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.MarketClosureRule = true;
 }
 public EquityRuleHighProfitFactory(
     ICostCalculatorFactory costCalculatorFactory,
     IRevenueCalculatorFactory revenueCalculatorFactory,
     IExchangeRateProfitCalculator exchangeRateProfitCalculator,
     IUniverseEquityOrderFilterService orderFilterService,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     IEquityMarketDataCacheStrategyFactory cacheStrategyFactory,
     ICurrencyConverterService currencyConversionService,
     ILogger <HighProfitsRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
 {
     this._costCalculatorFactory =
         costCalculatorFactory ?? throw new ArgumentNullException(nameof(costCalculatorFactory));
     this._revenueCalculatorFactory = revenueCalculatorFactory
                                      ?? throw new ArgumentNullException(nameof(revenueCalculatorFactory));
     this._exchangeRateProfitCalculator = exchangeRateProfitCalculator
                                          ?? throw new ArgumentNullException(
                                                    nameof(exchangeRateProfitCalculator));
     this._equityMarketCacheFactory =
         equityMarketCacheFactory ?? throw new ArgumentNullException(nameof(equityMarketCacheFactory));
     this._fixedIncomeMarketCacheFactory =
         fixedIncomeMarketCacheFactory ?? throw new ArgumentNullException(nameof(fixedIncomeMarketCacheFactory));
     this._cacheStrategyFactory =
         cacheStrategyFactory ?? throw new ArgumentNullException(nameof(cacheStrategyFactory));
     this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
     this._tradingHistoryLogger =
         tradingHistoryLogger ?? throw new ArgumentNullException(nameof(tradingHistoryLogger));
     this._orderFilterService =
         orderFilterService ?? throw new ArgumentNullException(nameof(orderFilterService));
     this._currencyConversionService = currencyConversionService ?? throw new ArgumentNullException(nameof(currencyConversionService));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HighProfitStreamRule"/> class.
 /// </summary>
 /// <param name="equitiesParameters">
 /// The equities 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 HighProfitStreamRule(
     IHighProfitsRuleEquitiesParameters equitiesParameters,
     ISystemProcessOperationRunRuleContext ruleContext,
     ICostCalculatorFactory costCalculatorFactory,
     IRevenueCalculatorFactory revenueCalculatorFactory,
     IExchangeRateProfitCalculator exchangeRateProfitCalculator,
     IUniverseOrderFilter orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     IEquityMarketDataCacheStrategyFactory marketDataCacheFactory,
     IUniverseDataRequestsSubscriber dataRequestSubscriber,
     IHighProfitJudgementService judgementService,
     ICurrencyConverterService currencyConversionService,
     RuleRunMode runMode,
     ILogger <HighProfitsRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromHours(8),
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromHours(8),
         equitiesParameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
         Rules.HighProfits,
         EquityRuleHighProfitFactory.Version,
         "High Profit Rule",
         ruleContext,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.EquitiesParameters =
         equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));
     this.RuleContext           = 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.currencyConversionService = currencyConversionService ?? throw new ArgumentNullException(nameof(currencyConversionService));
     this.JudgementService          = judgementService ?? throw new ArgumentNullException(nameof(judgementService));
     this.Logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }
        public void Setup()
        {
            this._orderFilterService            = A.Fake <IUniverseEquityOrderFilterService>();
            this._costCalculatorFactory         = A.Fake <ICostCalculatorFactory>();
            this._revenueCalculatorFactory      = A.Fake <IRevenueCalculatorFactory>();
            this._exchangeRateProfitCalculator  = A.Fake <IExchangeRateProfitCalculator>();
            this._equityMarketCacheFactory      = A.Fake <IUniverseEquityMarketCacheFactory>();
            this._fixedIncomeMarketCacheFactory = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
            this._cacheStrategyFactory          = A.Fake <IEquityMarketDataCacheStrategyFactory>();
            this._judgementService         = A.Fake <IJudgementService>();
            this._logger                   = new NullLogger <HighProfitsRule>();
            this._tradingHistoryLogger     = new NullLogger <TradingHistoryStack>();
            this._currencyConverterService = A.Fake <ICurrencyConverterService>();

            this._equitiesParameters    = A.Fake <IHighProfitsRuleEquitiesParameters>();
            this._ruleCtxStream         = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._ruleCtxMarket         = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._dataRequestSubscriber = A.Fake <IUniverseDataRequestsSubscriber>();
            this._scheduledExecution    = new ScheduledExecution();
        }
        /// <summary>
        /// The test setup.
        /// </summary>
        private void Setup()
        {
            this.tradingHoursService = A.Fake <IMarketTradingHoursService>();

            A.CallTo(() => this.tradingHoursService.GetTradingHoursForMic("XLON")).Returns(
                new TradingHours
            {
                CloseOffsetInUtc = TimeSpan.FromHours(16),
                IsValid          = true,
                Mic             = "XLON",
                OpenOffsetInUtc = TimeSpan.FromHours(8)
            });

            A.CallTo(() => this.tradingHoursService.GetTradingHoursForMic("NASDAQ")).Returns(
                new TradingHours
            {
                CloseOffsetInUtc = TimeSpan.FromHours(23),
                IsValid          = true,
                Mic             = "NASDAQ",
                OpenOffsetInUtc = TimeSpan.FromHours(15)
            });

            this.equityMarketCacheFactory = new UniverseEquityMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseEquityMarketCacheFactory>());

            this.fixedIncomeMarketCacheFactory = new UniverseFixedIncomeMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseFixedIncomeMarketCacheFactory>());

            this.universeOrderFilterService = A.Fake <IUniverseEquityOrderFilterService>();
            this.logger                = new NullLogger <HighProfitsRule>();
            this.tradingLogger         = new NullLogger <TradingHistoryStack>();
            this.ruleContext           = A.Fake <ISystemProcessOperationRunRuleContext>();
            this.dataRequestSubscriber = A.Fake <IUniverseDataRequestsSubscriber>();

            this.exchangeRateProfitCalculator   = A.Fake <IExchangeRateProfitCalculator>();
            this.marketDataCacheStrategyFactory = new EquityMarketDataCacheStrategyFactory();

            this.costCalculatorFactory = new CostCalculatorFactory(
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                new NullLogger <CostCalculator>(),
                new NullLogger <CostCurrencyConvertingCalculator>());

            this.revenueCalculatorFactory = new RevenueCalculatorFactory(
                this.tradingHoursService,
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                new NullLogger <RevenueCurrencyConvertingCalculator>(),
                new NullLogger <RevenueCalculator>());

            this.equityRuleHighProfitFactory = new EquityRuleHighProfitFactory(
                this.costCalculatorFactory,
                this.revenueCalculatorFactory,
                this.exchangeRateProfitCalculator,
                this.universeOrderFilterService,
                this.equityMarketCacheFactory,
                this.fixedIncomeMarketCacheFactory,
                this.marketDataCacheStrategyFactory,
                new CurrencyConverterService(
                    this.exchangeRateSelection.ExchangeRateRepository,
                    new NullLogger <CurrencyConverterService>()),
                this.logger,
                this.tradingLogger);

            this.judgementRepository  = A.Fake <IJudgementRepository>();
            this.ruleViolationService = A.Fake <IRuleViolationService>();

            this.judgementService = new JudgementService(
                this.judgementRepository,
                this.ruleViolationService,
                new HighProfitJudgementMapper(new NullLogger <HighProfitJudgementMapper>()),
                new FixedIncomeHighProfitJudgementMapper(new NullLogger <FixedIncomeHighProfitJudgementMapper>()),
                new FixedIncomeHighVolumeJudgementMapper(new NullLogger <FixedIncomeHighVolumeJudgementMapper>()),
                new NullLogger <JudgementService>());

            this.exchangeRateProfitCalculator   = A.Fake <IExchangeRateProfitCalculator>();
            this.marketDataCacheStrategyFactory = new EquityMarketDataCacheStrategyFactory();
        }