Esempio n. 1
0
        public SpoofingSteps(ScenarioContext scenarioContext, UniverseSelectionState universeSelectionState)
        {
            this._scenarioContext        = scenarioContext ?? throw new ArgumentNullException(nameof(scenarioContext));
            this._universeSelectionState =
                universeSelectionState ?? throw new ArgumentNullException(nameof(universeSelectionState));
            this._orderAnalysisService = new OrderAnalysisService();
            this._ruleCtx     = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream = A.Fake <IUniverseAlertStream>();

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

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

            this._equityRuleSpoofingFactory = new EquityRuleSpoofingFactory(
                equityMarketCacheFactory,
                fixedIncomeMarketCacheFactory,
                new UniverseEquityOrderFilterService(new NullLogger <UniverseEquityOrderFilterService>()),
                new PortfolioFactory(),
                this._orderAnalysisService,
                new NullLogger <SpoofingRule>(),
                new NullLogger <TradingHistoryStack>());
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SpoofingRule"/> class.
 /// </summary>
 /// <param name="equitiesParameters">
 /// The equities parameters.
 /// </param>
 /// <param name="ruleContext">
 /// The rule context.
 /// </param>
 /// <param name="alertStream">
 /// The alert stream.
 /// </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="runMode">
 /// The run mode.
 /// </param>
 /// <param name="portfolioFactory">
 /// The portfolio factory.
 /// </param>
 /// <param name="analysisService">
 /// The analysis service.
 /// </param>
 /// <param name="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingHistoryLogger">
 /// The trading history logger.
 /// </param>
 public SpoofingRule(
     ISpoofingRuleEquitiesParameters equitiesParameters,
     ISystemProcessOperationRunRuleContext ruleContext,
     IUniverseAlertStream alertStream,
     IUniverseOrderFilter orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     RuleRunMode runMode,
     IPortfolioFactory portfolioFactory,
     IOrderAnalysisService analysisService,
     ILogger logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromMinutes(30),
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromMinutes(30),
         equitiesParameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
         Rules.Spoofing,
         EquityRuleSpoofingFactory.Version,
         "Spoofing Rule",
         ruleContext,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.equitiesParameters =
         equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));
     this.logger           = logger ?? throw new ArgumentNullException(nameof(logger));
     this.alertStream      = alertStream ?? throw new ArgumentNullException(nameof(alertStream));
     this.orderFilter      = orderFilter ?? throw new ArgumentNullException(nameof(orderFilter));
     this.portfolioFactory = portfolioFactory ?? throw new ArgumentNullException(nameof(portfolioFactory));
     this.analysisService  = analysisService ?? throw new ArgumentNullException(nameof(analysisService));
     this.ruleContext      = ruleContext ?? throw new ArgumentNullException(nameof(ruleContext));
 }
Esempio n. 3
0
        public void Setup()
        {
            this._orderFilterService   = A.Fake <IUniverseEquityOrderFilterService>();
            this._equityFactory        = A.Fake <IUniverseEquityMarketCacheFactory>();
            this._fixedIncomeFactory   = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
            this._portfolioFactory     = A.Fake <IPortfolioFactory>();
            this._orderAnalysisService = A.Fake <IOrderAnalysisService>();
            this._logger = new NullLogger <SpoofingRule>();
            this._tradingHistoryLogger = new NullLogger <TradingHistoryStack>();

            this._spoofingEquitiesParameters = A.Fake <ISpoofingRuleEquitiesParameters>();
            this._ruleCtx     = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream = A.Fake <IUniverseAlertStream>();
        }
Esempio n. 4
0
 public EquityRuleSpoofingFactory(
     IUniverseEquityMarketCacheFactory equityFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeFactory,
     IUniverseEquityOrderFilterService orderFilterService,
     IPortfolioFactory portfolioFactory,
     IOrderAnalysisService analysisService,
     ILogger <SpoofingRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
 {
     this._orderFilterService =
         orderFilterService ?? throw new ArgumentNullException(nameof(orderFilterService));
     this._equityFactory        = equityFactory ?? throw new ArgumentNullException(nameof(equityFactory));
     this._fixedIncomeFactory   = fixedIncomeFactory ?? throw new ArgumentNullException(nameof(fixedIncomeFactory));
     this._portfolioFactory     = portfolioFactory ?? throw new ArgumentNullException(nameof(portfolioFactory));
     this._orderAnalysisService = analysisService ?? throw new ArgumentNullException(nameof(analysisService));
     this._logger = logger ?? throw new ArgumentNullException(nameof(logger));
     this._tradingHistoryLogger =
         tradingHistoryLogger ?? throw new ArgumentNullException(nameof(tradingHistoryLogger));
 }
Esempio n. 5
0
        public LayeringSteps(ScenarioContext scenarioContext, UniverseSelectionState universeSelectionState)
        {
            this._scenarioContext        = scenarioContext ?? throw new ArgumentNullException(nameof(scenarioContext));
            this._universeSelectionState =
                universeSelectionState ?? throw new ArgumentNullException(nameof(universeSelectionState));
            this._orderAnalysisService = new OrderAnalysisService();
            this._ruleCtx     = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream = A.Fake <IUniverseAlertStream>();

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

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

            var repository = A.Fake <IMarketOpenCloseApiCachingDecorator>();

            A.CallTo(() => repository.GetAsync()).Returns(
                new[]
            {
                new ExchangeDto
                {
                    Code              = "XLON",
                    MarketOpenTime    = TimeSpan.FromHours(8),
                    MarketCloseTime   = TimeSpan.FromHours(16),
                    IsOpenOnMonday    = true,
                    IsOpenOnTuesday   = true,
                    IsOpenOnWednesday = true,
                    IsOpenOnThursday  = true,
                    IsOpenOnFriday    = true,
                    IsOpenOnSaturday  = true,
                    IsOpenOnSunday    = true
                },
                new ExchangeDto
                {
                    Code              = "NASDAQ",
                    MarketOpenTime    = TimeSpan.FromHours(15),
                    MarketCloseTime   = TimeSpan.FromHours(23),
                    IsOpenOnMonday    = true,
                    IsOpenOnTuesday   = true,
                    IsOpenOnWednesday = true,
                    IsOpenOnThursday  = true,
                    IsOpenOnFriday    = true,
                    IsOpenOnSaturday  = true,
                    IsOpenOnSunday    = true
                }
            });

            this._tradingHoursService = new MarketTradingHoursService(
                repository,
                new NullLogger <MarketTradingHoursService>());

            this._equityRuleLayeringFactory = new EquityRuleLayeringFactory(
                new UniverseEquityOrderFilterService(new NullLogger <UniverseEquityOrderFilterService>()),
                _tradingHoursService,
                equityMarketCacheFactory,
                fixedIncomeMarketCacheFactory,
                new NullLogger <EquityRuleLayeringFactory>(),
                new NullLogger <TradingHistoryStack>());
        }