示例#1
0
 public LightweightExternalOrderbookService(
     IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel,
     IOrderBookProviderApi orderBookProviderApi,
     IDateService dateService,
     IConvertService convertService,
     IScheduleSettingsCacheService scheduleSettingsCache,
     IAssetPairDayOffService assetPairDayOffService,
     IAssetPairsCache assetPairsCache,
     ICqrsSender cqrsSender,
     IIdentityGenerator identityGenerator,
     ILog log,
     MarginTradingSettings marginTradingSettings)
 {
     _bestPriceChangeEventChannel = bestPriceChangeEventChannel;
     _orderBookProviderApi        = orderBookProviderApi;
     _dateService            = dateService;
     _convertService         = convertService;
     _scheduleSettingsCache  = scheduleSettingsCache;
     _assetPairDayOffService = assetPairDayOffService;
     _assetPairsCache        = assetPairsCache;
     _cqrsSender             = cqrsSender;
     _identityGenerator      = identityGenerator;
     _log = log;
     _defaultExternalExchangeId = string.IsNullOrEmpty(marginTradingSettings.DefaultExternalExchangeId)
         ? "Default"
         : marginTradingSettings.DefaultExternalExchangeId;
     _orderbookValidation = marginTradingSettings.OrderbookValidation;
 }
示例#2
0
 public Application(
     MarketMakerService marketMakerService,
     ILog logger,
     MarginTradingSettings marginSettings,
     IMaintenanceModeService maintenanceModeService,
     IRabbitMqService rabbitMqService,
     MatchingEngineRoutesManager matchingEngineRoutesManager,
     IMigrationService migrationService,
     IConvertService convertService,
     IFxRateCacheService fxRateCacheService,
     IExternalOrderbookService externalOrderbookService,
     BrokerSettingsChangedHandler brokerSettingsChangedHandler)
 {
     _marketMakerService           = marketMakerService;
     _logger                       = logger;
     _marginSettings               = marginSettings;
     _maintenanceModeService       = maintenanceModeService;
     _rabbitMqService              = rabbitMqService;
     _matchingEngineRoutesManager  = matchingEngineRoutesManager;
     _migrationService             = migrationService;
     _convertService               = convertService;
     _fxRateCacheService           = fxRateCacheService;
     _externalOrderbookService     = externalOrderbookService;
     _brokerSettingsChangedHandler = brokerSettingsChangedHandler;
 }
示例#3
0
 public AccountUpdateService(
     IFplService fplService,
     OrdersCache ordersCache,
     ILog log,
     ICfdCalculatorService cfdCalculatorService,
     IQuoteCacheService quoteCacheService,
     MarginTradingSettings marginTradingSettings,
     IClientProfileSettingsCache clientProfileSettingsCache,
     IAssetPairsCache assetPairsCache,
     IPositionsProvider positionsProvider,
     IOrdersProvider ordersProvider,
     IAccountsProvider accountsProvider,
     ITradingInstrumentsCacheService tradingInstrumentsCache)
 {
     _fplService                 = fplService;
     _log                        = log;
     _cfdCalculatorService       = cfdCalculatorService;
     _quoteCacheService          = quoteCacheService;
     _marginTradingSettings      = marginTradingSettings;
     _clientProfileSettingsCache = clientProfileSettingsCache;
     _assetPairsCache            = assetPairsCache;
     _positionsProvider          = positionsProvider;
     _ordersProvider             = ordersProvider;
     _accountsProvider           = accountsProvider;
     _tradingInstrumentsCache    = tradingInstrumentsCache;
 }
        public void SetUp()
        {
            _clientAccountsService = Mock.Of <IClientAccountService>(r =>
                                                                     r.GetMarginEnabledAsync("id of client") == Task.FromResult(new MarginEnabledSettingsModel()));
            var publisher = Mock.Of <IMessageProducer <MarginTradingEnabledChangedMessage> >();

            Mock.Get(publisher)
            .Setup(s => s.ProduceAsync(It.IsNotNull <MarginTradingEnabledChangedMessage>()))
            .Returns(Task.CompletedTask).Callback <MarginTradingEnabledChangedMessage>(m => _sentMessage = m);
            var expectedRabbitMqSettings = new RabbitMqSettings
            {
                ConnectionString = "conn str",
                ExchangeName     = "exchange name"
            };
            var rabbitMqService = Mock.Of <IRabbitMqService>(s =>
                                                             s.GetProducer(expectedRabbitMqSettings.Equivalent(), true,
                                                                           s.GetJsonSerializer <MarginTradingEnabledChangedMessage>()) ==
                                                             publisher);

            _marginSettings = new MarginTradingSettings
            {
                MtRabbitMqConnString = "conn str",
                RabbitMqQueues       = new RabbitMqQueues
                {
                    MarginTradingEnabledChanged = new RabbitMqQueueInfo {
                        ExchangeName = "exchange name"
                    }
                }
            };

            _marginTradingSettingsCacheService = Mock.Of <IMarginTradingSettingsCacheService>();
            _sut = new MarginTradingEnablingService(_clientAccountsService, rabbitMqService, _marginSettings,
                                                    _marginTradingSettingsCacheService);
            _sut.Start();
        }
示例#5
0
文件: CqrsModule.cs 项目: alpo-8/MT
 public CqrsModule(CqrsSettings settings, ILog log, MarginTradingSettings marginTradingSettings)
 {
     _settings = settings;
     _marginTradingSettings = marginTradingSettings;
     _log = log;
     _defaultRetryDelayMs = (long)_settings.RetryDelay.TotalMilliseconds;
 }
示例#6
0
 public AccountManager(
     AccountsCacheService accountsCacheService,
     MarginTradingSettings marginSettings,
     IRabbitMqNotifyService rabbitMqNotifyService,
     ILog log,
     OrdersCache ordersCache,
     ITradingEngine tradingEngine,
     IAccountsApi accountsApi,
     IAccountBalanceHistoryApi accountBalanceHistoryApi,
     IConvertService convertService,
     IDateService dateService,
     ISystemClock systemClock,
     IAccountMarginFreezingRepository accountMarginFreezingRepository,
     IAccountMarginUnconfirmedRepository accountMarginUnconfirmedRepository)
     : base(nameof(AccountManager), 60000, log)
 {
     _accountsCacheService  = accountsCacheService;
     _marginSettings        = marginSettings;
     _rabbitMqNotifyService = rabbitMqNotifyService;
     _log                                = log;
     _ordersCache                        = ordersCache;
     _tradingEngine                      = tradingEngine;
     _accountsApi                        = accountsApi;
     _accountBalanceHistoryApi           = accountBalanceHistoryApi;
     _convertService                     = convertService;
     _dateService                        = dateService;
     _systemClock                        = systemClock;
     _accountMarginFreezingRepository    = accountMarginFreezingRepository;
     _accountMarginUnconfirmedRepository = accountMarginUnconfirmedRepository;
 }
 public ExternalOrderbookService(
     IEventChannel <BestPriceChangeEventArgs> bestPriceChangeEventChannel,
     IOrderBookProviderApi orderBookProviderApi,
     IDateService dateService,
     IConvertService convertService,
     IAssetPairDayOffService assetPairDayOffService,
     IScheduleSettingsCacheService scheduleSettingsCache,
     IAssetPairsCache assetPairsCache,
     ICqrsSender cqrsSender,
     IIdentityGenerator identityGenerator,
     ILog log,
     MarginTradingSettings marginTradingSettings)
 {
     _bestPriceChangeEventChannel = bestPriceChangeEventChannel;
     _orderBookProviderApi        = orderBookProviderApi;
     _dateService            = dateService;
     _convertService         = convertService;
     _assetPairDayOffService = assetPairDayOffService;
     _scheduleSettingsCache  = scheduleSettingsCache;
     _assetPairsCache        = assetPairsCache;
     _cqrsSender             = cqrsSender;
     _identityGenerator      = identityGenerator;
     _log = log;
     _marginTradingSettings = marginTradingSettings;
 }
示例#8
0
 public AccountUpdateService(
     IFplService fplService,
     ITradingConditionsCacheService tradingConditionsCache,
     IAccountsCacheService accountsCacheService,
     OrdersCache ordersCache,
     IAssetsCache assetsCache,
     IAccountMarginFreezingRepository accountMarginFreezingRepository,
     IAccountMarginUnconfirmedRepository accountMarginUnconfirmedRepository,
     ILog log,
     MarginTradingSettings marginTradingSettings,
     ICfdCalculatorService cfdCalculatorService,
     IQuoteCacheService quoteCacheService)
 {
     _fplService                         = fplService;
     _tradingConditionsCache             = tradingConditionsCache;
     _accountsCacheService               = accountsCacheService;
     _ordersCache                        = ordersCache;
     _assetsCache                        = assetsCache;
     _accountMarginFreezingRepository    = accountMarginFreezingRepository;
     _accountMarginUnconfirmedRepository = accountMarginUnconfirmedRepository;
     _log = log;
     _marginTradingSettings = marginTradingSettings;
     _cfdCalculatorService  = cfdCalculatorService;
     _quoteCacheService     = quoteCacheService;
 }
示例#9
0
 public ValidateOrderService(
     IQuoteCacheService quoteCashService,
     IAccountUpdateService accountUpdateService,
     IAccountsCacheService accountsCacheService,
     ITradingInstrumentsCacheService accountAssetsCacheService,
     IAssetPairsCache assetPairsCache,
     OrdersCache ordersCache,
     IAssetPairDayOffService assetDayOffService,
     IIdentityGenerator identityGenerator,
     IDateService dateService,
     MarginTradingSettings marginSettings,
     ICfdCalculatorService cfdCalculatorService,
     IFeatureManager featureManager,
     CorrelationContextAccessor correlationContextAccessor)
 {
     _quoteCashService           = quoteCashService;
     _accountUpdateService       = accountUpdateService;
     _accountsCacheService       = accountsCacheService;
     _tradingInstrumentsCache    = accountAssetsCacheService;
     _assetPairsCache            = assetPairsCache;
     _ordersCache                = ordersCache;
     _assetDayOffService         = assetDayOffService;
     _identityGenerator          = identityGenerator;
     _dateService                = dateService;
     _marginSettings             = marginSettings;
     _cfdCalculatorService       = cfdCalculatorService;
     _featureManager             = featureManager;
     _correlationContextAccessor = correlationContextAccessor;
 }
示例#10
0
 public BackendMaintenanceModeService(
     ISlackNotificationsSender slackNotificationsSender,
     MarginTradingSettings settings)
 {
     _slackNotificationsSender = slackNotificationsSender;
     _settings = settings;
 }
示例#11
0
 public SpecialLiquidationCommandsHandler(
     ITradingEngine tradingEngine,
     IDateService dateService,
     IOrderReader orderReader,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     ILog log,
     MarginTradingSettings marginTradingSettings,
     IAssetPairsCache assetPairsCache,
     IAssetPairDayOffService assetPairDayOffService,
     IExchangeConnectorService exchangeConnectorService,
     IIdentityGenerator identityGenerator,
     IAccountsCacheService accountsCacheService)
 {
     _tradingEngine = tradingEngine;
     _dateService   = dateService;
     _orderReader   = orderReader;
     _chaosKitty    = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _log = log;
     _marginTradingSettings    = marginTradingSettings;
     _assetPairsCache          = assetPairsCache;
     _assetPairDayOffService   = assetPairDayOffService;
     _exchangeConnectorService = exchangeConnectorService;
     _identityGenerator        = identityGenerator;
     _accountsCacheService     = accountsCacheService;
 }
示例#12
0
 public BackendServicesModule(MtBackendSettings mtSettings, MarginTradingSettings settings, IHostingEnvironment environment, ILog log)
 {
     _mtSettings  = mtSettings;
     _settings    = settings;
     _environment = environment;
     _log         = log;
 }
示例#13
0
 public SpecialLiquidationSaga(
     IDateService dateService,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     IRfqService specialLiquidationService,
     MarginTradingSettings marginTradingSettings,
     CqrsContextNamesSettings cqrsContextNamesSettings,
     LiquidationHelper liquidationHelper,
     OrdersCache ordersCache,
     IRfqPauseService rfqPauseService,
     ILog log,
     IAssetPairsCache assetPairsCache)
 {
     _dateService = dateService;
     _chaosKitty  = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _specialLiquidationService        = specialLiquidationService;
     _marginTradingSettings            = marginTradingSettings;
     _cqrsContextNamesSettings         = cqrsContextNamesSettings;
     _liquidationHelper = liquidationHelper;
     _ordersCache       = ordersCache;
     _rfqPauseService   = rfqPauseService;
     _log             = log;
     _assetPairsCache = assetPairsCache;
 }
示例#14
0
 public ValidateOrderService(
     IQuoteCacheService quoteCashService,
     IAccountUpdateService accountUpdateService,
     IAccountsCacheService accountsCacheService,
     ITradingInstrumentsCacheService accountAssetsCacheService,
     IAssetPairsCache assetPairsCache,
     OrdersCache ordersCache,
     IAssetPairDayOffService assetDayOffService,
     IIdentityGenerator identityGenerator,
     IDateService dateService,
     MarginTradingSettings marginSettings,
     ICfdCalculatorService cfdCalculatorService)
 {
     _quoteCashService        = quoteCashService;
     _accountUpdateService    = accountUpdateService;
     _accountsCacheService    = accountsCacheService;
     _tradingInstrumentsCache = accountAssetsCacheService;
     _assetPairsCache         = assetPairsCache;
     _ordersCache             = ordersCache;
     _assetDayOffService      = assetDayOffService;
     _identityGenerator       = identityGenerator;
     _dateService             = dateService;
     _marginSettings          = marginSettings;
     _cfdCalculatorService    = cfdCalculatorService;
 }
示例#15
0
 public IsAliveController(
     MarginTradingSettings settings,
     IDateService dateService)
 {
     _settings    = settings;
     _dateService = dateService;
 }
示例#16
0
 public TestingController(IFakeSnapshotService fakeSnapshotService,
                          MarginTradingSettings settings,
                          IRfqService rfqService)
 {
     _fakeSnapshotService = fakeSnapshotService;
     _rfqService          = rfqService;
     _protectionKey       = settings.TestSettings?.ProtectionKey;
 }
示例#17
0
 public RabbitMqNotifyService(IDateService dateService, MarginTradingSettings settings,
                              IIndex <string, IMessageProducer <string> > publishers, ILog log, IOrderReader orderReader)
 {
     _dateService = dateService;
     _settings    = settings;
     _publishers  = publishers;
     _log         = log;
     _orderReader = orderReader;
 }
 public StartupDeduplicationService(
     IHostingEnvironment hostingEnvironment,
     ILog log,
     MarginTradingSettings marginTradingSettings)
 {
     _hostingEnvironment = hostingEnvironment;
     _log = log;
     _marginTradingSettings = marginTradingSettings;
 }
示例#19
0
 public MarginTradingEnablingService(IClientAccountService clientAccountService, IRabbitMqService rabbitMqService,
                                     MarginTradingSettings settings,
                                     IMarginTradingSettingsCacheService marginTradingSettingsCacheService)
 {
     _marginSettings       = settings;
     _rabbitMqService      = rabbitMqService;
     _clientAccountService = clientAccountService;
     _marginTradingSettingsCacheService = marginTradingSettingsCacheService;
 }
示例#20
0
 public RfqExecutionInfoRepositoryDecorator(IOperationExecutionInfoRepository decoratee,
                                            ILog log,
                                            IRabbitMqNotifyService notifyService,
                                            MarginTradingSettings settings)
 {
     _decoratee     = decoratee;
     _log           = log;
     _notifyService = notifyService;
     _brokerId      = settings.BrokerId;
 }
示例#21
0
 public BrokerSettingsChangedHandler(
     MarginTradingSettings settings,
     IScheduleSettingsCacheService scheduleSettingsCache,
     IOvernightMarginService overnightMarginService,
     IScheduleControlService scheduleControlService)
 {
     _settings = settings;
     _scheduleSettingsCache  = scheduleSettingsCache;
     _overnightMarginService = overnightMarginService;
     _scheduleControlService = scheduleControlService;
 }
示例#22
0
 public FplService(
     ICfdCalculatorService cfdCalculatorService,
     IAssetPairsCache assetPairsCache,
     IAccountsCacheService accountsCacheService,
     ITradingInstrumentsCacheService tradingInstrumentsCache,
     MarginTradingSettings marginTradingSettings)
 {
     _cfdCalculatorService    = cfdCalculatorService;
     _accountsCacheService    = accountsCacheService;
     _tradingInstrumentsCache = tradingInstrumentsCache;
     _marginTradingSettings   = marginTradingSettings;
 }
示例#23
0
 public QuoteCacheService(ILog log,
                          IMarginTradingBlobRepository blobRepository,
                          IExternalOrderbookService externalOrderbookService,
                          MarginTradingSettings marginTradingSettings)
     : base(nameof(QuoteCacheService),
            marginTradingSettings.BlobPersistence.QuotesDumpPeriodMilliseconds,
            log)
 {
     _log                      = log;
     _blobRepository           = blobRepository;
     _externalOrderbookService = externalOrderbookService;
 }
示例#24
0
        private StartupDeduplicationService RunHealthChecks(MarginTradingSettings marginTradingSettings)
        {
            var deduplicationService = new StartupDeduplicationService(Environment, LogLocator.CommonLog,
                                                                       marginTradingSettings);

            deduplicationService
            .HoldLock();

            new StartupQueuesCheckerService(marginTradingSettings)
            .Check();

            return(deduplicationService);
        }
示例#25
0
        public StopOutConsumer(IThreadSwitcher threadSwitcher,
                               IOperationsLogService operationsLogService,
                               IRabbitMqNotifyService rabbitMqNotifyService,
                               IDateService dateService,
                               MarginTradingSettings settings)
        {
            _threadSwitcher        = threadSwitcher;
            _operationsLogService  = operationsLogService;
            _rabbitMqNotifyService = rabbitMqNotifyService;
            _dateService           = dateService;

            _settings = settings;
        }
示例#26
0
 public FxRateCacheService(ILog log,
                           IMarginTradingBlobRepository blobRepository,
                           IEventChannel <FxBestPriceChangeEventArgs> fxBestPriceChangeEventChannel,
                           MarginTradingSettings marginTradingSettings,
                           IAssetPairDayOffService assetPairDayOffService)
     : base(nameof(FxRateCacheService), marginTradingSettings.BlobPersistence.FxRatesDumpPeriodMilliseconds, log)
 {
     _log            = log;
     _blobRepository = blobRepository;
     _fxBestPriceChangeEventChannel = fxBestPriceChangeEventChannel;
     _assetPairDayOffService        = assetPairDayOffService;
     _quotes = new Dictionary <string, InstrumentBidAskPair>();
 }
示例#27
0
 public OrderBookSaveService(
     IMarginTradingBlobRepository blobRepository,
     OrderBookList orderBookList,
     MarginTradingSettings marginTradingSettings,
     ILog log,
     IContextFactory contextFactory)
     : base(nameof(OrderBookSaveService), marginTradingSettings.BlobPersistence.OrderbooksDumpPeriodMilliseconds, log)
 {
     _blobRepository = blobRepository;
     _orderBookList  = orderBookList;
     _log            = log;
     _contextFactory = contextFactory;
 }
示例#28
0
 public OrderCacheManager(OrdersCache orderCache,
                          IMarginTradingBlobRepository blobRepository,
                          IOrdersHistoryRepository ordersHistoryRepository,
                          IPositionsHistoryRepository positionsHistoryRepository,
                          MarginTradingSettings marginTradingSettings,
                          ILog log)
     : base(nameof(OrderCacheManager), marginTradingSettings.BlobPersistence.OrdersDumpPeriodMilliseconds, log)
 {
     _orderCache                 = orderCache;
     _blobRepository             = blobRepository;
     _ordersHistoryRepository    = ordersHistoryRepository;
     _positionsHistoryRepository = positionsHistoryRepository;
     _log = log;
 }
示例#29
0
        public RabbitMqNotifyService(IDateService dateService,
                                     MarginTradingSettings settings,
                                     ILog log,
                                     IOrderReader orderReader,
                                     IRabbitMqService rabbitMqService)
        {
            _dateService = dateService;
            _settings    = settings;
            _log         = log;
            _orderReader = orderReader;
            _publishers  = new Dictionary <string, Lykke.RabbitMqBroker.Publisher.IMessageProducer <string> >();

            RegisterPublishers(rabbitMqService);
        }
示例#30
0
        public TradingEngine(
            IEventChannel <MarginCallEventArgs> marginCallEventChannel,
            IEventChannel <OrderPlacedEventArgs> orderPlacedEventChannel,
            IEventChannel <OrderExecutedEventArgs> orderClosedEventChannel,
            IEventChannel <OrderCancelledEventArgs> orderCancelledEventChannel,
            IEventChannel <OrderChangedEventArgs> orderChangedEventChannel,
            IEventChannel <OrderExecutionStartedEventArgs> orderExecutionStartedEventChannel,
            IEventChannel <OrderActivatedEventArgs> orderActivatedEventChannel,
            IEventChannel <OrderRejectedEventArgs> orderRejectedEventChannel,
            IValidateOrderService validateOrderService,
            IAccountsCacheService accountsCacheService,
            OrdersCache ordersCache,
            IMatchingEngineRouter meRouter,
            IThreadSwitcher threadSwitcher,
            IAssetPairDayOffService assetPairDayOffService,
            ILog log,
            IDateService dateService,
            ICfdCalculatorService cfdCalculatorService,
            IIdentityGenerator identityGenerator,
            IAssetPairsCache assetPairsCache,
            ICqrsSender cqrsSender,
            IEventChannel <StopOutEventArgs> stopOutEventChannel,
            IQuoteCacheService quoteCacheService,
            MarginTradingSettings marginTradingSettings)
        {
            _marginCallEventChannel           = marginCallEventChannel;
            _orderPlacedEventChannel          = orderPlacedEventChannel;
            _orderExecutedEventChannel        = orderClosedEventChannel;
            _orderCancelledEventChannel       = orderCancelledEventChannel;
            _orderActivatedEventChannel       = orderActivatedEventChannel;
            _orderExecutionStartedEvenChannel = orderExecutionStartedEventChannel;
            _orderChangedEventChannel         = orderChangedEventChannel;
            _orderRejectedEventChannel        = orderRejectedEventChannel;

            _validateOrderService   = validateOrderService;
            _accountsCacheService   = accountsCacheService;
            _ordersCache            = ordersCache;
            _meRouter               = meRouter;
            _threadSwitcher         = threadSwitcher;
            _assetPairDayOffService = assetPairDayOffService;
            _log                   = log;
            _dateService           = dateService;
            _cfdCalculatorService  = cfdCalculatorService;
            _identityGenerator     = identityGenerator;
            _assetPairsCache       = assetPairsCache;
            _cqrsSender            = cqrsSender;
            _stopOutEventChannel   = stopOutEventChannel;
            _quoteCacheService     = quoteCacheService;
            _marginTradingSettings = marginTradingSettings;
        }