コード例 #1
0
		private void NewStopOrderClick(object sender, RoutedEventArgs e)
		{
			var newOrder = new OrderConditionalWindow
			{
				Order = new Order
				{
					Security = SecurityPicker.SelectedSecurity,
					Type = OrderTypes.Conditional,
				},
				Connector = MainWindow.Instance.Trader,
			};

			if (newOrder.ShowModal(this))
				MainWindow.Instance.Trader.RegisterOrder(newOrder.Order);
		}
コード例 #2
0
		void NewStopOrderClick(object sender, RoutedEventArgs e)
		{
			var newOrder = new OrderConditionalWindow
			{
				Order = new Order
				{
					Security = SecurityPicker.SelectedSecurity,
					Type = OrderTypes.Conditional,
				},
				SecurityProvider = MainWindow.Instance.Trader,
				MarketDataProvider = MainWindow.Instance.Trader,
				Portfolios = new PortfolioDataSource(MainWindow.Instance.Trader),
				Adapter = MainWindow.Instance.Trader.Adapter
			};

			if (newOrder.ShowModal(this))
				MainWindow.Instance.Trader.RegisterOrder(newOrder.Order);
		}
コード例 #3
0
		public OrdersConditionalPanel()
		{
			InitializeComponent();

			Security prevSecurity = null;
			Portfolio prevPortfolio = null;

			Func<Order> createOrder = () => new Order
			{
				Type = OrderTypes.Conditional,
				Security = prevSecurity,
				Portfolio = prevPortfolio,
			};

			OrderGrid.OrderRegistering += () =>
			{
				var wnd = new OrderConditionalWindow
				{
					SecurityProvider = ConfigManager.TryGetService<ISecurityProvider>(),
					Order = createOrder()
				};

				if (!wnd.ShowModal(this))
					return;

				var order = wnd.Order;

				prevSecurity = order.Security;
				prevPortfolio = order.Portfolio;

				new RegisterOrderCommand(order).Process(this);
			};
			OrderGrid.OrderReRegistering += order =>
			{
				var window = new OrderWindow
				{
					Title = LocalizedStrings.Str2976Params.Put(order.TransactionId),
					Order = order.ReRegisterClone(newVolume: order.Balance),
				};

				if (window.ShowModal(this))
				{
					new ReRegisterOrderCommand(order, window.Order).Process(this);
				}
			};
			OrderGrid.OrderCanceling += orders => new CancelOrderCommand(orders).Process(this);
			OrderGrid.SelectionChanged += (s, e) => new SelectCommand<Order>(OrderGrid.SelectedOrder, false).Process(this);
			OrderGrid.PropertyChanged += (s, e) => new ControlChangedCommand(this).Process(this);

			GotFocus += (s, e) => new SelectCommand<Order>(OrderGrid.SelectedOrder, false).Process(this);

			var cmdSvc = ConfigManager.GetService<IStudioCommandService>();
			cmdSvc.Register<ResetedCommand>(this, false, cmd => OrderGrid.Orders.Clear());
			cmdSvc.Register<OrderCommand>(this, false, cmd =>
			{
				if (cmd.Action == OrderActions.Registering && cmd.Order.Type == OrderTypes.Conditional)
					OrderGrid.Orders.Add(cmd.Order);
			});
			cmdSvc.Register<ReRegisterOrderCommand>(this, false, cmd => OrderGrid.Orders.Add(cmd.NewOrder));
			cmdSvc.Register<OrderFailCommand>(this, false, cmd =>
			{
				if (cmd.Action == OrderActions.Registering)
					OrderGrid.AddRegistrationFail(cmd.Fail);
			});
		}