示例#1
0
 public MtController(
     IMarginTradingAccountHistoryRepository accountsHistoryRepository,
     IMarginTradingOrdersHistoryRepository ordersHistoryRepository,
     IMicrographCacheService micrographCacheService,
     IAccountAssetsCacheService accountAssetsCacheService,
     IAssetPairsCache assetPairsCache,
     IMarketMakerMatchingEngine matchingEngine,
     ITradingEngine tradingEngine,
     IAccountsCacheService accountsCacheService,
     IMarginTradingOperationsLogService operationsLogService,
     IConsole consoleWriter,
     OrdersCache ordersCache,
     MarginSettings marginSettings,
     AccountManager accountManager,
     IAssetPairDayOffService assetDayOffService,
     IQuoteCacheService quoteCacheService,
     IIdentityGenerator identityGenerator)
 {
     _accountsHistoryRepository = accountsHistoryRepository;
     _ordersHistoryRepository   = ordersHistoryRepository;
     _micrographCacheService    = micrographCacheService;
     _accountAssetsCacheService = accountAssetsCacheService;
     _assetPairsCache           = assetPairsCache;
     _matchingEngine            = matchingEngine;
     _tradingEngine             = tradingEngine;
     _accountsCacheService      = accountsCacheService;
     _operationsLogService      = operationsLogService;
     _consoleWriter             = consoleWriter;
     _ordersCache        = ordersCache;
     _marginSettings     = marginSettings;
     _accountManager     = accountManager;
     _assetDayOffService = assetDayOffService;
     _quoteCacheService  = quoteCacheService;
     _identityGenerator  = identityGenerator;
 }
示例#2
0
        public RandomOrdersProcessedInParallelClassFixture()
        {
            // Arrange
            Orders             = GetRandomOrders();
            ActualOpenedOrders = new List <Order>();
            ActualClosedOrders = new List <Order>();

            var concurrentOrders = new ConcurrentQueue <Order>(Orders);

            Sut = new QueuedTradingEngine(new OrdersMatchingRule());

            Sut.OrderOpened += (sender, args) => { ActualOpenedOrders.Add(args.Order); };
            Sut.OrderClosed += (sender, args) => { ActualClosedOrders.Add(args.Order); };

            const int threadCount = 5;

            //Simulate multi-threading environment
            var tasks = new List <Task>();

            for (var i = 0; i < threadCount; i++)
            {
                tasks.Add(Task.Run(() => PlaceOrder(Sut, concurrentOrders)));
            }

            Task.WhenAll(tasks).Wait();
        }
示例#3
0
 public AccountManager(AccountsCacheService accountsCacheService,
                       IMarginTradingAccountsRepository repository,
                       IConsole console,
                       MarginSettings marginSettings,
                       IRabbitMqNotifyService rabbitMqNotifyService,
                       IAccountGroupCacheService accountGroupCacheService,
                       IClientNotifyService clientNotifyService,
                       IClientAccountClient clientAccountClient,
                       IMarginTradingAccountsRepository accountsRepository,
                       ITradingConditionsCacheService tradingConditionsCacheService,
                       ILog log,
                       OrdersCache ordersCache,
                       IEventChannel <AccountBalanceChangedEventArgs> acountBalanceChangedEventChannel,
                       ITradingEngine tradingEngine)
     : base(nameof(AccountManager), 60000, log)
 {
     _accountsCacheService = accountsCacheService;
     _clientAccountClient  = clientAccountClient;
     _repository           = repository;
     _console                       = console;
     _marginSettings                = marginSettings;
     _rabbitMqNotifyService         = rabbitMqNotifyService;
     _accountGroupCacheService      = accountGroupCacheService;
     _accountsRepository            = accountsRepository;
     _tradingConditionsCacheService = tradingConditionsCacheService;
     _log = log;
     _clientNotifyService = clientNotifyService;
     _ordersCache         = ordersCache;
     _acountBalanceChangedEventChannel = acountBalanceChangedEventChannel;
     _tradingEngine = tradingEngine;
 }
示例#4
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;
 }
示例#5
0
 private static void PlaceOrder(ITradingEngine engine, ConcurrentQueue <Order> orders)
 {
     while (orders.TryDequeue(out var order))
     {
         engine.PlaceAsync(order);
     }
 }
示例#6
0
 public LiquidationCommandsHandler(
     IAccountsCacheService accountsCache,
     IDateService dateService,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     IChaosKitty chaosKitty,
     ITradingEngine tradingEngine,
     OrdersCache ordersCache,
     ILog log,
     IAccountUpdateService accountUpdateService,
     IEventChannel <LiquidationEndEventArgs> liquidationEndEventChannel,
     LiquidationHelper liquidationHelper,
     ILiquidationFailureExecutor failureExecutor)
 {
     _accountsCache = accountsCache;
     _dateService   = dateService;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _chaosKitty                 = chaosKitty;
     _tradingEngine              = tradingEngine;
     _ordersCache                = ordersCache;
     _log                        = log;
     _accountUpdateService       = accountUpdateService;
     _liquidationEndEventChannel = liquidationEndEventChannel;
     _liquidationHelper          = liquidationHelper;
     _failureExecutor            = failureExecutor;
 }
示例#7
0
 public LiquidationCommandsHandler(
     ITradingInstrumentsCacheService tradingInstrumentsCacheService,
     IAccountsCacheService accountsCache,
     IDateService dateService,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     IChaosKitty chaosKitty,
     IMatchingEngineRouter matchingEngineRouter,
     ITradingEngine tradingEngine,
     OrdersCache ordersCache,
     ILog log,
     IAccountUpdateService accountUpdateService,
     IEventChannel <LiquidationEndEventArgs> liquidationEndEventChannel)
 {
     _tradingInstrumentsCacheService = tradingInstrumentsCacheService;
     _accountsCache = accountsCache;
     _dateService   = dateService;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _chaosKitty           = chaosKitty;
     _matchingEngineRouter = matchingEngineRouter;
     _tradingEngine        = tradingEngine;
     _ordersCache          = ordersCache;
     _log = log;
     _accountUpdateService       = accountUpdateService;
     _liquidationEndEventChannel = liquidationEndEventChannel;
 }
示例#8
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 PendingOrdersCleaningService(ILog log, IOrderReader orderReader, ITradingEngine tradingEngine,
                                     IAssetPairDayOffService assetDayOffService)
     : base(nameof(PendingOrdersCleaningService), 60000, log)
 {
     _log                = log;
     _orderReader        = orderReader;
     _tradingEngine      = tradingEngine;
     _assetDayOffService = assetDayOffService;
 }
示例#10
0
        private static void PlaceOrder(ITradingEngine engine, ConcurrentQueue <Order> orders)
        {
            Order order;

            while (orders.TryDequeue(out order))
            {
                Console.WriteLine("Place: " + order);
                engine.Place(order);
            }
        }
示例#11
0
        private static void PlaceOrder(ITradingEngine engine, ConcurrentQueue <Order> orders)
        {
            Order order;

            while (orders.TryDequeue(out order))
            {
                Console.WriteLine("PlaceAsync: " + order + " Thread: " + Thread.CurrentThread.ManagedThreadId);
                engine.PlaceAsync(order).GetAwaiter().GetResult();
            }
        }
示例#12
0
 public IsAliveController(
     IMarketMakerMatchingEngine matchingEngine,
     ITradingEngine tradingEngine,
     MarginSettings settings,
     IDateService dateService)
 {
     _matchingEngine = matchingEngine;
     _tradingEngine  = tradingEngine;
     _settings       = settings;
     _dateService    = dateService;
 }
示例#13
0
 public AssetPairProjection(
     ITradingEngine tradingEngine,
     IAssetPairsCache assetPairsCache,
     IOrderReader orderReader,
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     ILog log)
 {
     _tradingEngine   = tradingEngine;
     _assetPairsCache = assetPairsCache;
     _orderReader     = orderReader;
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _log = log;
 }
示例#14
0
 public DeleteAccountsCommandsHandler(
     IOrderReader orderReader,
     IDateService dateService,
     IAccountsCacheService accountsCacheService,
     ITradingEngine tradingEngine,
     IChaosKitty chaosKitty,
     IOperationExecutionInfoRepository operationExecutionInfoRepository,
     ILog log)
 {
     _orderReader                      = orderReader;
     _dateService                      = dateService;
     _accountsCacheService             = accountsCacheService;
     _tradingEngine                    = tradingEngine;
     _chaosKitty                       = chaosKitty;
     _operationExecutionInfoRepository = operationExecutionInfoRepository;
     _log = log;
 }
示例#15
0
 public PositionsController(
     ITradingEngine tradingEngine,
     IOperationsLogService operationsLogService,
     ILog log,
     OrdersCache ordersCache,
     IAssetPairDayOffService assetDayOffService,
     IIdentityGenerator identityGenerator,
     ICqrsSender cqrsSender,
     IDateService dateService)
 {
     _tradingEngine        = tradingEngine;
     _operationsLogService = operationsLogService;
     _log                = log;
     _ordersCache        = ordersCache;
     _assetDayOffService = assetDayOffService;
     _identityGenerator  = identityGenerator;
     _cqrsSender         = cqrsSender;
     _dateService        = dateService;
 }
示例#16
0
 public OrdersController(
     ITradingEngine tradingEngine,
     IOperationsLogService operationsLogService,
     ILog log,
     OrdersCache ordersCache,
     IDateService dateService,
     IValidateOrderService validateOrderService,
     IIdentityGenerator identityGenerator,
     ICqrsSender cqrsSender)
 {
     _tradingEngine        = tradingEngine;
     _operationsLogService = operationsLogService;
     _log                  = log;
     _ordersCache          = ordersCache;
     _dateService          = dateService;
     _validateOrderService = validateOrderService;
     _identityGenerator    = identityGenerator;
     _cqrsSender           = cqrsSender;
 }
示例#17
0
 public OvernightMarginService(
     IDateService dateService,
     ITradingEngine tradingEngine,
     IAccountsCacheService accountsCacheService,
     IAccountUpdateService accountUpdateService,
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     IOvernightMarginParameterContainer overnightMarginParameterContainer,
     ILog log,
     IEventChannel <MarginCallEventArgs> marginCallEventChannel,
     OvernightMarginSettings overnightMarginSettings)
 {
     _dateService                       = dateService;
     _tradingEngine                     = tradingEngine;
     _accountsCacheService              = accountsCacheService;
     _accountUpdateService              = accountUpdateService;
     _scheduleSettingsCacheService      = scheduleSettingsCacheService;
     _overnightMarginParameterContainer = overnightMarginParameterContainer;
     _log = log;
     _marginCallEventChannel  = marginCallEventChannel;
     _overnightMarginSettings = overnightMarginSettings;
 }
示例#18
0
 public ProductChangedProjection(
     ITradingEngine tradingEngine,
     IAssetPairsCache assetPairsCache,
     IOrderReader orderReader,
     IScheduleSettingsCacheService scheduleSettingsCacheService,
     ITradingInstrumentsManager tradingInstrumentsManager,
     IRfqService rfqService,
     IRfqPauseService rfqPauseService,
     MarginTradingSettings mtSettings,
     ILog log,
     IQuoteCacheService quoteCache)
 {
     _tradingEngine   = tradingEngine;
     _assetPairsCache = assetPairsCache;
     _orderReader     = orderReader;
     _scheduleSettingsCacheService = scheduleSettingsCacheService;
     _tradingInstrumentsManager    = tradingInstrumentsManager;
     _rfqService      = rfqService;
     _rfqPauseService = rfqPauseService;
     _mtSettings      = mtSettings;
     _log             = log;
     _quoteCache      = quoteCache;
 }
示例#19
0
 public PositionsController(
     ITradingEngine tradingEngine,
     IOperationsLogService operationsLogService,
     ILog log,
     OrdersCache ordersCache,
     IAssetPairDayOffService assetDayOffService,
     IIdentityGenerator identityGenerator,
     ICqrsSender cqrsSender,
     IDateService dateService,
     IAccountHistoryRepository accountHistoryRepository,
     IMarginTradingBlobRepository blobRepository)
 {
     _tradingEngine        = tradingEngine;
     _operationsLogService = operationsLogService;
     _log                      = log;
     _ordersCache              = ordersCache;
     _assetDayOffService       = assetDayOffService;
     _identityGenerator        = identityGenerator;
     _cqrsSender               = cqrsSender;
     _dateService              = dateService;
     _accountHistoryRepository = accountHistoryRepository;
     _blobRepository           = blobRepository;
 }
示例#20
0
 public OrdersController(IAssetPairsCache assetPairsCache,
                         ITradingEngine tradingEngine,
                         IAccountsCacheService accountsCacheService,
                         IOperationsLogService operationsLogService,
                         ILog log,
                         OrdersCache ordersCache,
                         IAssetPairDayOffService assetDayOffService,
                         IDateService dateService,
                         IValidateOrderService validateOrderService,
                         IIdentityGenerator identityGenerator,
                         ICqrsSender cqrsSender)
 {
     _assetPairsCache      = assetPairsCache;
     _tradingEngine        = tradingEngine;
     _accountsCacheService = accountsCacheService;
     _operationsLogService = operationsLogService;
     _log                  = log;
     _ordersCache          = ordersCache;
     _assetDayOffService   = assetDayOffService;
     _dateService          = dateService;
     _validateOrderService = validateOrderService;
     _identityGenerator    = identityGenerator;
     _cqrsSender           = cqrsSender;
 }