Esempio n. 1
0
        public void Setup()
        {
            this._currencyConverterService = A.Fake <ICurrencyConverterService>();
            this._ruleCtx                = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream            = A.Fake <IUniverseAlertStream>();
            this._clustering             = new ClusteringService();
            this._equitiesParameters     = A.Fake <IWashTradeRuleEquitiesParameters>();
            this._logger                 = A.Fake <ILogger>();
            this._ruleRunRepository      = A.Fake <IRuleRunDataRequestRepository>();
            this._stubRuleRunRepository  = A.Fake <IStubRuleRunDataRequestRepository>();
            this._loggerEquityCache      = A.Fake <ILogger <UniverseEquityMarketCacheFactory> >();
            this._loggerFixedIncomeCache = A.Fake <ILogger <UniverseFixedIncomeMarketCacheFactory> >();
            this._tradingLogger          = A.Fake <ILogger <TradingHistoryStack> >();

            this._orderFilter   = A.Fake <IUniverseOrderFilter>();
            this._equityFactory = new UniverseEquityMarketCacheFactory(
                this._stubRuleRunRepository,
                this._ruleRunRepository,
                this._loggerEquityCache);
            this._fixedIncomeFactory = new UniverseFixedIncomeMarketCacheFactory(
                this._stubRuleRunRepository,
                this._ruleRunRepository,
                this._loggerFixedIncomeCache);
            A.CallTo(() => this._orderFilter.Filter(A <IUniverseEvent> .Ignored))
            .ReturnsLazily(i => (IUniverseEvent)i.Arguments[0]);

            A.CallTo(() => this._equitiesParameters.PerformClusteringPositionAnalysis).Returns(true);
            A.CallTo(() => this._equitiesParameters.ClusteringPercentageValueDifferenceThreshold).Returns(0.05m);
        }
Esempio n. 2
0
 /// <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));
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="T:com.kiranpatel.crimecluster.webservice.Controllers.ClusterController"/> class.
        /// </summary>
        /// <param name="repository">Repository.</param>
        /// <param name="configService">Config service.</param>
        /// <param name="logger">Logger.</param>
        /// <param name="serialisationService">Serialisation service.</param>
        /// <param name="incidentService">Incident service.</param>
        public ClusterController(
            IRepository repository,
            IConfigurationService configService,
            ILogger logger,
            ISerialisationService serialisationService,
            IIncidentService incidentService,
            IClusteringService clusteringService)
            : base(repository, configService, logger, serialisationService)
        {
            this.incidentService   = incidentService;
            this.clusteringService = clusteringService;

            var googleMapsKey = this.configService.Get(ConfigurationKey.GoogleMapsKey, string.Empty);

            if (String.IsNullOrEmpty(googleMapsKey))
            {
                throw new InvalidOperationException(nameof(googleMapsKey));
            }

            this.logger.debug("Google Maps Key Loaded");
            ViewBag.GoogleMapsKey = googleMapsKey;

            int counter = 0;

            this.crimeTypes = new Dictionary <int, CrimeType>();
            foreach (CrimeType currentType in Enum.GetValues(typeof(CrimeType)))
            {
                crimeTypes.Add(counter, currentType);
                counter++;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="WashTradeRule"/> class.
 /// </summary>
 /// <param name="equitiesParameters">
 /// The equities parameters.
 /// </param>
 /// <param name="ruleContext">
 /// The rule context.
 /// </param>
 /// <param name="clustering">
 /// The clustering.
 /// </param>
 /// <param name="alertStream">
 /// The alert stream.
 /// </param>
 /// <param name="currencyConverterService">
 /// The currency converter service.
 /// </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="logger">
 /// The logger.
 /// </param>
 /// <param name="tradingHistoryLogger">
 /// The trading history logger.
 /// </param>
 public WashTradeRule(
     IWashTradeRuleEquitiesParameters equitiesParameters,
     ISystemProcessOperationRunRuleContext ruleContext,
     IClusteringService clustering,
     IUniverseAlertStream alertStream,
     ICurrencyConverterService currencyConverterService,
     IUniverseOrderFilter orderFilter,
     IUniverseEquityMarketCacheFactory equityMarketCacheFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeMarketCacheFactory,
     RuleRunMode runMode,
     ILogger logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
     : base(
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1),
         equitiesParameters?.Windows?.BackwardWindowSize ?? TimeSpan.FromDays(1),
         equitiesParameters?.Windows?.FutureWindowSize ?? TimeSpan.Zero,
         Rules.WashTrade,
         EquityRuleWashTradeFactory.Version,
         "Wash Trade Rule",
         ruleContext,
         equityMarketCacheFactory,
         fixedIncomeMarketCacheFactory,
         runMode,
         logger,
         tradingHistoryLogger)
 {
     this.equitiesParameters =
         equitiesParameters ?? throw new ArgumentNullException(nameof(equitiesParameters));
     this.clustering = clustering ?? throw new ArgumentNullException(nameof(clustering));
     this.currencyConverterService =
         currencyConverterService ?? throw new ArgumentNullException(nameof(currencyConverterService));
     this.orderFilter = orderFilter ?? throw new ArgumentNullException(nameof(orderFilter));
     this.alertStream = alertStream ?? throw new ArgumentNullException(nameof(alertStream));
     this.logger      = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Esempio n. 5
0
 public MachineLearningController(IAnomalyDetectionsService <object> anomalyDetectionsService,
                                  IMulticlassClassificationsService <CustomerOrdersMulticlassClassificationsModel> multiclassClassificationsService,
                                  IClusteringService <FactStrategyPlanClusteringData> clusteringService,
                                  IMainDirectories dropDownList)
 {
     _dropDownList                     = dropDownList;
     _anomalyDetectionsService         = anomalyDetectionsService;
     _multiclassClassificationsService = multiclassClassificationsService;
     _clusteringService                = clusteringService;
 }
Esempio n. 6
0
 public ClusteringController(
     IRecordsService service,
     IMapper mapper,
     IClusteringService clusteringService,
     ITranslateService translateService)
 {
     this.service            = service;
     this.mapper             = mapper;
     this._clusteringService = clusteringService;
     this._translateService  = translateService;
 }
Esempio n. 7
0
 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>();
 }
        public void Setup()
        {
            this._currencyConverterService = A.Fake <ICurrencyConverterService>();
            this._clustering           = A.Fake <IClusteringService>();
            this._orderFilterService   = A.Fake <IUniverseEquityOrderFilterService>();
            this._equityFactory        = A.Fake <IUniverseEquityMarketCacheFactory>();
            this._fixedIncomeFactory   = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
            this._logger               = new NullLogger <WashTradeRule>();
            this._tradingHistoryLogger = new NullLogger <TradingHistoryStack>();

            this._equitiesParameters = A.Fake <IWashTradeRuleEquitiesParameters>();
            this._ruleCtx            = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream        = A.Fake <IUniverseAlertStream>();
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:com.kiranpatel.crimecluster.framework.MixedMarkovModel"/> class.
        /// </summary>
        /// <param name="clusteringService">Clustering service.</param>
        /// <param name="incidentService">Incident service.</param>
        /// <param name="logger">Logger service.</param>
        /// <param name="start">Start date of the incidents in the MMM.</param>
        /// <param name="end">End date of the incidents in the MMM.</param>
        public MixedMarkovModel(
            IClusteringService clusteringService,
            IIncidentService incidentService,
            ILogger logger,
            DateTime start,
            DateTime end)
        {
            this.modelLookup   = new Dictionary <CrimeType, MarkovModel>();
            this.incidentCache = new Dictionary <CrimeType, HashSet <Incident> >();

            this.clusteringService = clusteringService;
            this.incidentService   = incidentService;
            this.logger            = logger;

            this.start = start;
            this.end   = end;
        }
        private void Setup()
        {
            this._orderFilterService = A.Fake <IUniverseFixedIncomeOrderFilterService>();
            this._ruleCtx            = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream        = A.Fake <IUniverseAlertStream>();

            this._portfolioFactory         = new PortfolioFactory();
            this._clusteringService        = new ClusteringService();
            this._equityMarketCacheFactory = new UniverseEquityMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseEquityMarketCacheFactory>());
            this._fixedIncomeMarketCacheFactory = new UniverseFixedIncomeMarketCacheFactory(
                new StubRuleRunDataRequestRepository(),
                new StubRuleRunDataRequestRepository(),
                new NullLogger <UniverseFixedIncomeMarketCacheFactory>());
        }
Esempio n. 11
0
        public WashTradeSteps(ScenarioContext scenarioContext, UniverseSelectionState universeSelectionState)
        {
            this._scenarioContext        = scenarioContext;
            this._universeSelectionState = universeSelectionState;

            var exchangeRateApiRepository = A.Fake <IExchangeRateApiCachingDecorator>();

            var exchangeRateDto = new ExchangeRateDto
            {
                DateTime         = new DateTime(2018, 01, 01),
                Name             = "GBX/USD",
                FixedCurrency    = "GBX",
                VariableCurrency = "USD",
                Rate             = 200d
            };

            A.CallTo(() => exchangeRateApiRepository.GetAsync(A <DateTime> .Ignored, A <DateTime> .Ignored)).Returns(
                new Dictionary <DateTime, IReadOnlyCollection <ExchangeRateDto> >
            {
                { new DateTime(2018, 01, 01), new[] { exchangeRateDto } }
            });

            var currencyLogger = new NullLogger <CurrencyConverterService>();

            this._currencyConverterService = new CurrencyConverterService(exchangeRateApiRepository, currencyLogger);

            this._washTradeClustering           = new ClusteringService();
            this._universeOrderFilterService    = A.Fake <IUniverseEquityOrderFilterService>();
            this._equityMarketCacheFactory      = A.Fake <IUniverseEquityMarketCacheFactory>();
            this._fixedIncomeMarketCacheFactory = A.Fake <IUniverseFixedIncomeMarketCacheFactory>();
            this._logger        = new NullLogger <WashTradeRule>();
            this._tradingLogger = new NullLogger <TradingHistoryStack>();

            this._equityRuleWashTradeFactory = new EquityRuleWashTradeFactory(
                this._currencyConverterService,
                this._washTradeClustering,
                this._universeOrderFilterService,
                this._equityMarketCacheFactory,
                this._fixedIncomeMarketCacheFactory,
                this._logger,
                this._tradingLogger);

            this._ruleCtx     = A.Fake <ISystemProcessOperationRunRuleContext>();
            this._alertStream = A.Fake <IUniverseAlertStream>();
        }
Esempio n. 12
0
 public DetectedObjectController(
     IDetectedObjectRepository detectedObjectRepository,
     IOperationsRepository operationRepository,
     IMissionRepository missionRepository,
     IUserRepository userRepository,
     IHubContext <NotificationHub> notificationHub,
     IClusteringService clusteringService,
     IMapper mapper
     )
 {
     _detectedObjectRepository = detectedObjectRepository;
     _operationRepository      = operationRepository;
     _missionRepository        = missionRepository;
     _userRepository           = userRepository;
     _clusteringService        = clusteringService;
     _notificationHub          = notificationHub;
     _mapper = mapper;
 }
Esempio n. 13
0
 public EquityRuleWashTradeFactory(
     ICurrencyConverterService currencyConverterService,
     IClusteringService clustering,
     IUniverseEquityOrderFilterService orderFilterService,
     IUniverseEquityMarketCacheFactory equityFactory,
     IUniverseFixedIncomeMarketCacheFactory fixedIncomeFactory,
     ILogger <WashTradeRule> logger,
     ILogger <TradingHistoryStack> tradingHistoryLogger)
 {
     this._currencyConverterService = currencyConverterService
                                      ?? throw new ArgumentNullException(nameof(currencyConverterService));
     this._clustering         = clustering ?? throw new ArgumentNullException(nameof(clustering));
     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._logger               = logger ?? throw new ArgumentNullException(nameof(logger));
     this._tradingHistoryLogger =
         tradingHistoryLogger ?? throw new ArgumentNullException(nameof(tradingHistoryLogger));
 }
Esempio n. 14
0
 public ClusteringTests()
 {
     _clusteringService = new KMeansClusteringService();
 }
Esempio n. 15
0
 public ClusteringController(IClusteringService clusteringService)
 {
     _clusteringService = clusteringService;
 }