public SimulationTypeManager(ILogger logger, IAppConfigurationManager configurationManager, IDiagnosticManager diagnosticManager, IMarketDataManager marketDataManager, INotificationManager notificationManager, ICalendarRebalanceScheduleManager rebalanceScheduleManager) { _account = configurationManager.GetAccount(); _logger = logger; _diagnosticManager = diagnosticManager; _notificationManager = notificationManager; _marketDataManager = marketDataManager; _calendarRebalanceScheduleManager = rebalanceScheduleManager; var containerBuilder = new ContainerBuilder(); containerBuilder.Register <IDiagnosticManager>(x => _diagnosticManager).SingleInstance(); containerBuilder.Register <IMarketDataManager>(x => _marketDataManager).SingleInstance(); containerBuilder.Register <INotificationManager>(x => _notificationManager).SingleInstance(); containerBuilder.Register <ICalendarRebalanceScheduleManager>(x => _calendarRebalanceScheduleManager).SingleInstance(); containerBuilder.Register <IAppConfigurationManager>(x => configurationManager).SingleInstance(); containerBuilder.Register <ILogger>(x => _logger).SingleInstance(); containerBuilder.RegisterType <RebalanceSimulationManager>().As <ISimulationManager, IRebalanceSimulationManager>().SingleInstance(); containerBuilder.RegisterType <BuyAndHoldSimulationManager>().As <ISimulationManager, IBuyAndHoldSimulationManager>().SingleInstance(); _container = containerBuilder.Build(); }
private MainViewModel GetVm() { MainViewModel.IsUnitTesting = true; _ibClient = new IBClient(new EReaderMonitorSignal()); _connectionService = Substitute.For <IConnectionService>(); _orderManager = Substitute.For <IOrderManager>(); _accountManager = Substitute.For <IAccountManager>(); _contractManager = Substitute.For <IContractManager>(); _marketDataManager = Substitute.For <IMarketDataManager>(); _historicalDataManager = Substitute.For <IHistoricalDataManager>(); _orderCalculationService = Substitute.For <IOrderCalculationService>(); _exchangeRateService = Substitute.For <IExchangeRateService>(); _tradeRepository = Substitute.For <ITradeRepository>(); var orderManager = Substitute.For <IOrderManager>(); _ordersViewModel = new OrdersViewModel(_contractManager, _marketDataManager, _historicalDataManager, _orderCalculationService, orderManager, _tradeRepository); _statusBarViewModel = Substitute.For <StatusBarViewModel>(); var positionsManager = Substitute.For <IPositionManager>(); var contractManager = Substitute.For <IContractManager>(); var positionsViewModel = new PositionsViewModel(_marketDataManager, _accountManager, positionsManager, contractManager); var detailsViewModel = new DetailsViewModel(); _settingsViewModel = new SettingsViewModel(); return(new MainViewModel(_ibClient, _connectionService, _orderManager, _accountManager, _ordersViewModel, _statusBarViewModel, _historicalDataManager, _exchangeRateService, _orderCalculationService, positionsViewModel, detailsViewModel, _settingsViewModel)); }
private PositionsViewModel GetVm(IMarketDataManager marketDataManager = null) { var manager = marketDataManager ?? Substitute.For <IMarketDataManager>(); var accountManager = Substitute.For <IAccountManager>(); var positionsManager = Substitute.For <IPositionManager>(); var contractManager = Substitute.For <IContractManager>(); return(new PositionsViewModel(manager, accountManager, positionsManager, contractManager)); }
public FindSymbolService( IMarketDataManager marketDataManager, IHistoricalDataManager historicalDataManager, IContractManager contractManager) { _marketDataManager = marketDataManager; _historicalDataManager = historicalDataManager; _contractManager = contractManager; }
public BuyAndHoldSimulationManager(ILogger logger, IAppConfigurationManager configurationManager, IMarketDataManager marketDataManager, INotificationManager notificationManager, IDiagnosticManager diagnosticManager) { _logger = logger; _account = configurationManager.GetAccount(); _marketDataManager = marketDataManager; _notificationManager = notificationManager; _diagnosticManager = diagnosticManager; _notificationManager.SimulationEnded += NotificationManager_SimulationEnded; }
private PositionsViewModel GetVm( IMarketDataManager marketDataManager = null, IPositionManager positionManager = null, IContractManager contractManager = null, ITradeRecordingService tradeRecordingService = null) { var manager = marketDataManager ?? Substitute.For <IMarketDataManager>(); _accountManager = Substitute.For <IAccountManager>(); if (positionManager == null) { positionManager = Substitute.For <IPositionManager>(); positionManager.RequestOpenOrdersAsync().Returns(Task.FromResult(new List <OpenOrderEventArgs>())); } if (contractManager == null) { contractManager = Substitute.For <IContractManager>(); contractManager.RequestDetailsAsync(Arg.Any <Contract>()).Returns(Task.FromResult(new List <ContractDetails>())); } var queueProcessor = Substitute.For <IQueueProcessor>(); queueProcessor .When(x => x.Enqueue(Arg.Any <Action>())) .Do(x => { var action = x.Arg <Action>(); action.Invoke(); }); var dispatcherHelper = Substitute.For <IDispatcherHelper>(); dispatcherHelper .When(x => x.InvokeOnUiThread(Arg.Any <Action>())) .Do(x => { var action = x.Arg <Action>(); action.Invoke(); }); if (tradeRecordingService == null) { tradeRecordingService = Substitute.For <ITradeRecordingService>(); } return(new PositionsViewModel(dispatcherHelper, manager, _accountManager, positionManager, contractManager, queueProcessor, tradeRecordingService)); }
private PositionsViewModel GetPositionForSymbolTest( PositionItem item, IMarketDataManager marketDataManager = null, IPositionManager positionManager = null, IContractManager contractManager = null) { var vm = GetVm(marketDataManager, positionManager, contractManager); var positions = new List <PositionItem> { item }; // Act _accountManager.RequestPositionsAsync().Returns(positions); return(vm); }
public RebalanceSimulationManager(ILogger logger, IAppConfigurationManager configurationManager, IDiagnosticManager diagnosticManager, IMarketDataManager marketDataManager, INotificationManager notificationManager, ICalendarRebalanceScheduleManager rebalanceScheduleManager) { _calendarRebalanceScheduleManager = rebalanceScheduleManager; _diagnosticManager = diagnosticManager; _marketDataManager = marketDataManager; _account = configurationManager.GetAccount(); _notificationManager = notificationManager; _logger = logger; _notificationManager.SimulationEnded += NotificationManager_SimulationEnded; }
public OrdersListViewModel( IDispatcherHelper dispatcherHelper, IQueueProcessor queueProcessor, INewOrderViewModelFactory newOrderViewModelFactory, ITradeRepository tradeRepository, IMarketDataManager marketDataManager) : base(dispatcherHelper, queueProcessor) { _newOrderViewModelFactory = newOrderViewModelFactory; _tradeRepository = tradeRepository; _marketDataManager = marketDataManager; PopulateDirectionList(); Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Orders, OnOrderStatusChangedMessage); Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage); Orders = new ObservableCollectionNoReset <NewOrderViewModel>(dispatcherHelper: DispatcherHelper); Orders.CollectionChanged += OnOrdersCollectionChanged; }
private static OrdersListViewModel GetVm( ITradeRepository tradeRepository = null, IMarketDataManager marketDataManager = null, IOrderCalculationService orderCalculationService = null, IOrderManager orderManager = null) { var dispatcherHelper = Substitute.For <IDispatcherHelper>(); dispatcherHelper .When(x => x.InvokeOnUiThread(Arg.Any <Action>())) .Do(x => x.Arg <Action>().Invoke()); var queueProcessor = Substitute.For <IQueueProcessor>(); if (tradeRepository == null) { tradeRepository = Substitute.For <ITradeRepository>(); } if (marketDataManager == null) { marketDataManager = Substitute.For <IMarketDataManager>(); } var findSymbolService = Substitute.For <IFindSymbolService>(); if (orderCalculationService == null) { orderCalculationService = Substitute.For <IOrderCalculationService>(); } if (orderManager == null) { orderManager = Substitute.For <IOrderManager>(); } var factory = new NewOrderViewModelFactory(dispatcherHelper, queueProcessor, findSymbolService, orderCalculationService, orderManager); return(new OrdersListViewModel(dispatcherHelper, Substitute.For <IQueueProcessor>(), factory, tradeRepository, marketDataManager)); }
public PositionsViewModel( IDispatcherHelper dispatcherHelper, IMarketDataManager marketDataManager, IAccountManager accountManager, IPositionManager positionManager, IContractManager contractManager, IQueueProcessor queueProcessor, ITradeRecordingService tradeRecordingService) : base(dispatcherHelper, queueProcessor) { Positions = new ObservableCollectionNoReset <PositionItem>(dispatcherHelper: DispatcherHelper); Messenger.Default.Register <ConnectionChangingMessage>(this, HandleConnectionChangingMessage); Messenger.Default.Register <OrderStatusChangedMessage>(this, OrderStatusChangedMessage.Tokens.Positions, OnOrderStatusChangedMessage); Messenger.Default.Register <BarPriceMessage>(this, HandleBarPriceMessage); _marketDataManager = marketDataManager; _accountManager = accountManager; _positionManager = positionManager; _contractManager = contractManager; _queueProcessor = queueProcessor; _tradeRecordingService = tradeRecordingService; }