Esempio n. 1
0
        private void SendOrder(Side side)
        {
            try
            {
                Trace.WriteLine(String.Format("Send New Order: Type={0} Side={1} Symbol=[{2}] Qty=[{3}] LimitPrice=[{4}] TIF={5}",
                                              this.OrderType.ToString(), side.ToString(), this.Symbol,
                                              this.OrderQtyString, this.LimitPriceString, this.TimeInForce.ToString()));

                Dictionary <int, string> customFieldsDict = new Dictionary <int, string>();
                foreach (CustomFieldRecord cfr in this.CustomFields)
                {
                    customFieldsDict[cfr.Tag] = cfr.Value;
                }

                int     orderQty   = int.Parse(this.OrderQtyString);
                decimal limitPrice = decimal.Parse(this.LimitPriceString);

                QuickFix.FIX44.NewOrderSingle nos = MessageCreator44.NewOrderSingle(
                    customFieldsDict,
                    this.OrderType, side, this.Symbol, orderQty, this.TimeInForce, limitPrice);

                OrderRecord r = new OrderRecord(nos);
                lock (_ordersLock)
                {
                    Orders.Add(r);
                }

                _qfapp.Send(nos);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to send order\n" + e.ToString());
            }
        }
        // commands
        private void SendNews(object ignored)
        {
            try
            {
                Trace.WriteLine(String.Format("Send news: Head=[{0}] Line1=[{1}]", this.Headline, this.Line1Text));
                string         h     = this.Headline;
                IList <string> lines = new List <string>();
                if (this.IsLine1Enabled)
                {
                    lines.Add(this.Line1Text);
                }
                if (this.IsLine2Enabled)
                {
                    lines.Add(this.Line2Text);
                }
                if (this.IsLine3Enabled)
                {
                    lines.Add(this.Line3Text);
                }

                QuickFix.FIX44.News news = MessageCreator44.News(h, lines);

                _qfapp.Send(news);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Failed to send news message.\n" + e.ToString());
            }
        }