public NewOrderForm(TradingManager tradingManager, MainForm mainForm, Order orderToModify, Onixs.FixControls.ILogger logger) : this(tradingManager, mainForm, logger) { this.orderToModify = orderToModify; Text = "Modify Order"; txtClOrdID.Text = orderToModify.ClientOrderID; txtClOrdID.ReadOnly = true; txtClOrdID.Text = TradingManager.GetNextClientOrderID(); cmbOrderType.Text = orderToModify.Type.ToString(); cmbOrderType.Enabled = false; cmbSide.Text = orderToModify.Side.ToString(); cmbSide.Enabled = false; cmbSymbol.Text = orderToModify.Symbol; cmbSymbol.Enabled = false; cmbOrderType.Text = orderToModify.Type.ToString(); cmbOrderType.Enabled = false; cmbCurrency.Text = orderToModify.Currency; cmbCurrency.Enabled = false; txtQuantity.Text = orderToModify.Quantity.ToString(CultureInfo.InvariantCulture); txtPrice.Text = orderToModify.Price.ToString(CultureInfo.InvariantCulture); }
void CreateTradingManager() { if (null != tradingManager) { tradingManager.OrderStateChanged -= new EventHandler <TradingManager.OrderStateChangedArgs>(OnOrderStateChanged); tradingManager.Session.InboundApplicationMsgEvent -= new InboundApplicationMsgEventHandler(session_InboundApplicationMsgEvent); tradingManager.Session.InboundSessionMsgEvent -= new InboundSessionMsgEventHandler(session_InboundSessionMsgEvent); tradingManager.Session.OutboundApplicationMsgEvent -= new OutboundApplicationMsgEventHandler(session_OutboundApplicationMsgEvent); tradingManager.Session.OutboundSessionMsgEvent -= new OutboundSessionMsgEventHandler(session_OutboundSessionMsgEvent); tradingManager.Session.MessageResending -= new MessageResendingEventHandler(session_MessageResendingEvent); tradingManager.Session.StateChangeEvent -= new StateChangeEventHandler(tradingSession_StateChangeEvent); tradingManager.Session.WarningEvent -= new WarningEventHandler(session_WarningEvent); tradingManager.Session.ErrorEvent -= new FIXForge.NET.FIX.ErrorEventHandler(session_ErrorEvent); tradingManager.Session.Dispose(); } SessionConfiguration settings = (SessionConfiguration)ConfigurationHelper.GetSection("TradingSession"); tradingManager = new TradingManager(settings, eventView); tradingManager.OrderStateChanged += new EventHandler <TradingManager.OrderStateChangedArgs>(OnOrderStateChanged); tradingManager.Session.InboundApplicationMsgEvent += new InboundApplicationMsgEventHandler(session_InboundApplicationMsgEvent); tradingManager.Session.InboundSessionMsgEvent += new InboundSessionMsgEventHandler(session_InboundSessionMsgEvent); tradingManager.Session.OutboundApplicationMsgEvent += new OutboundApplicationMsgEventHandler(session_OutboundApplicationMsgEvent); tradingManager.Session.OutboundSessionMsgEvent += new OutboundSessionMsgEventHandler(session_OutboundSessionMsgEvent); tradingManager.Session.MessageResending += new MessageResendingEventHandler(session_MessageResendingEvent); tradingManager.Session.StateChangeEvent += new StateChangeEventHandler(tradingSession_StateChangeEvent); tradingManager.Session.WarningEvent += new WarningEventHandler(session_WarningEvent); tradingManager.Session.ErrorEvent += new FIXForge.NET.FIX.ErrorEventHandler(session_ErrorEvent); }
public NewOrderForm(TradingManager tradingManager, MainForm mainForm, Onixs.FixControls.ILogger logger) { this.tradingManager = tradingManager; this.mainForm = mainForm; logger_ = logger; InitializeComponent(); cmbOrderType.Items.AddRange(Enum.GetNames(typeof(Order.OrderType))); cmbSide.Items.AddRange(Enum.GetNames(typeof(Order.OrderSide))); Left = mainForm.Left + (mainForm.Width - Width) / 2; Top = mainForm.Top + (mainForm.Height - Height) / 2; mainForm.OnConnect += new EventHandler(mainForm_OnConnect); mainForm.OnDisconnect += new EventHandler(mainForm_OnDisconnect); cmbOrderType.SelectedIndex = 1; cmbSide.SelectedIndex = 0; cmbSymbol.SelectedIndex = 0; cmbCurrency.SelectedIndex = 0; txtClOrdID.Text = TradingManager.GetNextClientOrderID(); }
private void buttonSend_Click(object sender, EventArgs e) { try { bool detectedErrors = false; if (string.IsNullOrEmpty(txtClOrdID.Text)) { errorProvider.SetIconPadding(txtClOrdID, 4); errorProvider.SetError(txtClOrdID, "ClOrdID must be specified"); detectedErrors = true; } if (!tradingManager.IsClientOrderIdUnique(txtClOrdID.Text)) { errorProvider.SetIconPadding(txtClOrdID, 4); errorProvider.SetError(txtClOrdID, "ClOrdID must be unique"); detectedErrors = true; } if (string.IsNullOrEmpty(cmbSymbol.Text)) { errorProvider.SetIconPadding(cmbSymbol, 4); errorProvider.SetError(cmbSymbol, "Symbol must be specified"); detectedErrors = true; } double price; if (!double.TryParse(txtPrice.Text, NumberStyles.Currency, CultureInfo.InvariantCulture, out price)) { errorProvider.SetIconPadding(txtPrice, 4); errorProvider.SetError(txtPrice, "Price must be specified as correct number"); detectedErrors = true; } double quantity; if (!double.TryParse(txtQuantity.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out quantity)) { errorProvider.SetIconPadding(txtQuantity, 4); errorProvider.SetError(txtQuantity, "Quantity must be specified as correct number"); detectedErrors = true; } if (detectedErrors) { return; } Order order; if (null == orderToModify) { Order.OrderType orderType = (Order.OrderType)Enum.Parse(typeof(Order.OrderType), cmbOrderType.Text); Order.OrderSide orderSide = (Order.OrderSide)Enum.Parse(typeof(Order.OrderSide), cmbSide.Text); order = new Order(txtClOrdID.Text, orderType, orderSide, cmbSymbol.Text); order.ClientOrderID = txtClOrdID.Text; if (!string.IsNullOrEmpty(cmbCurrency.Text)) { order.Currency = cmbCurrency.Text; } } else { order = orderToModify; } if (!string.IsNullOrEmpty(txtText.Text)) { order.Text = txtText.Text; } order.TransactTime = DateTime.Now; order.Quantity = double.Parse(txtQuantity.Text, System.Globalization.CultureInfo.InvariantCulture); if (Order.OrderType.Market != order.Type && Order.OrderType.ForeignExchangeMarketOrder != order.Type) { order.Price = price; } if (null == orderToModify) { tradingManager.SendNewOrder(order); } } catch (Exception ex) { logger_.LogError("Cannot Send Order: " + ex.Message); Trace.TraceError("Cannot Send Order: " + ex.Message); MessageBox.Show(this, ex.Message, "Cannot Send Order", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } txtClOrdID.Text = TradingManager.GetNextClientOrderID(); }