Beispiel #1
0
    public void testOrderSend()
    {
        SessionNotFound exception = null;
        NewOrderSingle order = new NewOrderSingle();
        try
        {
            Session.sendToTarget(order);
        }
        catch(SessionNotFound e)
        {
            exception = e;
        }
        Assert.IsNotNull( exception, "no exception thrown" );

        exception = null;
        SessionID sessionID = new SessionID
            ("FIX.4.2", "TW", "ISLD");
        order.set(new ClOrdID("12345"));
        order.set(new Symbol("LNUX"));
        order.set(new HandlInst('1'));
        order.set(new Side(Side.BUY));
        order.set(new OrdType(OrdType.MARKET));
        order.set(new TransactTime());

        try
        {
            Assert.IsTrue(Session.sendToTarget(order, sessionID));
            QuickFix.Message message = application.getMessage();
            Assert.IsNotNull(message, "Message not received");
            //Assert.IsTrue("Message not a NewOrderSingle",
            //           message instanceof NewOrderSingle);
            Assert.IsTrue(Session.sendToTarget(order, sessionID));
        }
        catch(SessionNotFound e)
        {
            exception = e;
        }
        Assert.IsNull(exception, "exception thrown");
    }
 public virtual void onMessage( NewOrderSingle message, QuickFix.SessionID session ) 
   { throw new QuickFix.UnsupportedMessageType(); }
 public virtual void onMessage(NewOrderSingle message, QuickFix.SessionID session)
 {
     throw new QuickFix.UnsupportedMessageType();
 }
Beispiel #4
0
 public OrderInfo(NewOrderSingle fixorder)
 {
     rootclordid = fixorder.getClOrdID().getValue();
     order = fixorder;
     ordList = new SortedList();
     //rptlist = new ArrayList();
     ordid = null;
     ordList.Add(order.getClOrdID().getValue(), order);
 }
 public override void onMessage(QuickFix42.NewOrderSingle message, SessionID sessionID)
 {
     process(message, sessionID);
 }
Beispiel #6
0
            internal void UpdateValues(NewOrderSingle fixorder, ExecutionReport rpt)
            {
                try
                {
                    double avgpx = rpt.getAvgPx().getValue();
                    double cumqty = rpt.getCumQty().getValue();
                    double price = rpt.getPrice().getValue();
                    double qty = rpt.getOrderQty().getValue();
                    char status = rpt.getOrdStatus().getValue();
                    //string ordtype = rpt.getOrdType().ToString();
                    switch (status)
                    {
                        case QuickFix.OrdStatus.PARTIALLY_FILLED:
                            base.BackColor = Color.SkyBlue;
                            break;

                        case QuickFix.OrdStatus.FILLED:
                            base.BackColor = Color.Aquamarine;
                            break;

                        case QuickFix.OrdStatus.CANCELED:
                            base.BackColor = Color.Pink;
                            break;
                    }
                    string priceDisplay = "F2";
                    string pctDisplay = "P0";
                    string numDisplay = "N0";
                    double pct = cumqty / order.getOrderQty().getValue();
                    if (rpt.getExecType().getValue() == ExecType.REPLACE)
                    {
                        string clordid = fixorder.getClOrdID().getValue();
                        base.SubItems[0].Text = clordid;
                        base.SubItems[1].Text = rpt.getTransactTime().getValue().ToLocalTime().ToString("HH:mm:ss");
                        this.Name = clordid;
                        this.order = fixorder;
                    }
                    else
                    {
                        base.SubItems[0].Text = this.order.getClOrdID().getValue();
                        base.SubItems[1].Text = order.getTransactTime().getValue().ToLocalTime().ToString("HH:mm:ss");
                    }

                    base.SubItems[2].Text = this.order.getSymbol().getValue();
                    base.SubItems[3].Text = FixDataDictionary.getEnumString(FixDataDictionary.FixField.Side, this.order.getSide().ToString());
                    if (stratidtag != FIELDORDTYPE)
                    {
                        if (order.isSetField(stratidtag))
                        {
                            base.SubItems[4].Text = order.getField(stratidtag);
                        }
                    }
                    else
                    {
                        if (rpt.isSetOrdType())
                        {
                            base.SubItems[4].Text = FixDataDictionary.getEnumString(FixDataDictionary.FixField.OrdType, rpt.getOrdType().ToString());
                        }
                        else
                        {
                            base.SubItems[4].Text = FixDataDictionary.getEnumString(FixDataDictionary.FixField.OrdType, this.order.getOrdType().ToString());
                        }
                    }

                    if (rpt.isSetOrderQty())
                    {
                        base.SubItems[5].Text = qty.ToString(numDisplay);
                    }
                    else
                    {
                        base.SubItems[5].Text = this.order.getOrderQty().getValue().ToString();
                    }
                    if (rpt.isSetPrice())
                    {
                        base.SubItems[6].Text = price.ToString(priceDisplay);
                    }
                    else
                    {
                        base.SubItems[6].Text = this.order.getPrice().getValue().ToString(priceDisplay);
                    }
                    base.SubItems[7].Text = avgpx.ToString(priceDisplay);

                    base.SubItems[8].Text = pct.ToString(pctDisplay);

                    base.SubItems[9].Text = FixDataDictionary.getEnumString(FixDataDictionary.FixField.OrderStatus, status.ToString());
                    ordstatus = status;
                }
                catch (QuickFix.FieldNotFound e)
                {
                    Console.WriteLine("Missing field " + e.field);
                }

                //order.
            }
Beispiel #7
0
 internal OrderViewItem(NewOrderSingle order, int algofield)
     : base(new string[10])
 {
     this.order = order;
     this.Name = order.getClOrdID().getValue();
     stratidtag = algofield;
 }
Beispiel #8
0
 // Methods
 internal OrderViewItem(NewOrderSingle order)
     : this(order, FIELDORDTYPE)
 {
     //this.UpdateValues();
 }
Beispiel #9
0
        //private void CreateOrder(QuickFix.Side side)
        //{
        //    if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && textBox3.Text != string.Empty)
        //    {
        //        ClOrdID clordid =new ClOrdID ( DateTime.Now.ToString("yyMMddHHmmss"));//Ψһ��Ͷ����ָ����
        //        QuickFix.HandlInst inst = new QuickFix.HandlInst('1'); //1	=	Automated execution order, private, no Broker intervention
        //        //2	=	Automated execution order, public, Broker intervention OK
        //        //3	=	Manual order, best execution
        //        QuickFix.Account account  =new Account ("0103137186"); //2009  11 25 add  �˺�
        //        QuickFix.Symbol symbol = new QuickFix.Symbol(textBox1.Text);
        //        QuickFix.TransactTime time = new QuickFix.TransactTime();
        //        QuickFix.OrdType ordtype = new QuickFix.OrdType('2');//2	=	Limit
        //        QuickFix42.NewOrderSingle message = new QuickFix42.NewOrderSingle(clordid, inst, symbol, side, time, ordtype);
        //        message.setString(44, textBox3.Text);
        //        message.setString(38,textBox2.Text);
        //        message.setString(207, "SSE");   //207   sh �Ϻ�
        //        message.setString(1, "0002077141");//1  Account �˺�
        //        _quickFixWrapper.Send(message);
        //    }
        //    else
        //    {
        //        MessageBox.Show("ָ���������");
        //    }
        //}
        private void CreateOrder()
        {
            if (textBox1.Text != string.Empty && textBox2.Text != string.Empty && comboBox2.SelectedIndex != -1)
            {
                string id = GetNextID();
                ClOrdID clordid = new ClOrdID(id);//Ψһ��Ͷ����ָ����
                //1	=	Automated execution order, private, no Broker intervention
                //2	=	Automated execution order, public, Broker intervention OK
                //3	=	Manual order, best execution
                QuickFix.HandlInst inst = new QuickFix.HandlInst();
                if (comboBox6.SelectedIndex == -1)
                {
                    inst.setValue('1');
                }
                else
                {
                    switch (comboBox6.SelectedItem.ToString())
                    {
                        case "ֱͨ˽��":
                            inst.setValue('1');
                            break;
                        case "ֱͨ����":
                            inst.setValue('2');
                            break;
                        case "����̨":
                            inst.setValue('3');
                            break;
                    }
                }

                QuickFix.Side side = new QuickFix.Side();
                switch (comboBox2.SelectedItem.ToString())
                {
                    case "����":
                        side.setValue('1');
                        break;
                    case "���":
                        side.setValue('2');
                        break;
                    case "���":
                        side.setValue('5');
                        break;
                    case "�깺":
                        side.setValue('D');
                        break;
                    case "���":
                        side.setValue('E');
                        break;
                }
                //QuickFix.Account account = new Account("0103137186"); //2009  11 25 add  �˺�
                QuickFix.OrdType ordtype = new QuickFix.OrdType();
                if (comboBox3.SelectedIndex == -1)
                {
                    ordtype.setValue('1');
                }
                else
                {
                    switch (comboBox3.SelectedItem.ToString())
                    {
                        case "�м�":
                            ordtype.setValue('1');
                            break;
                        case "�޼�":
                            ordtype.setValue('2');
                            break;
                    }
                }

                QuickFix.Symbol symbol = new QuickFix.Symbol(textBox1.Text);
                QuickFix.TransactTime time = new QuickFix.TransactTime();
                QuickFix42.NewOrderSingle message = new QuickFix42.NewOrderSingle(clordid, inst, symbol, side, time, ordtype);
                if (ordtype.getValue () == QuickFix.OrdType.LIMIT)
                {
                    message.setString(44, textBox3.Text);//Limit Price
                }
                message.setString(38, textBox2.Text);//Quantity
                if (textBox1.Text.StartsWith("60"))
                {
                    message.setString(207, "SSE");   //207   sh �Ϻ�
                }
                else if (textBox1.Text.StartsWith("00"))
                {
                    message.setString(207, "SZSE");   //207   sz ����
                }
                //message.setString(1, "0002077141");//1  Account �˺�
                if (!ordersAll.ContainsKey(id))
                {
                    OrderInfo info = new OrderInfo(message);
                    ordersAll.Add(id, info);
                }
                _quickFixWrapper.Send(message);
            }
            else
            {
                MessageBox.Show("ָ���������");
            }
        }
Beispiel #10
0
 private void UpdateOrder(string newclordid)
 {
     if (ordList.ContainsKey(newclordid))
     {
         QuickFix.Message rpl = (QuickFix.Message)ordList[newclordid];
         NewOrderSingle order1 = new NewOrderSingle();
         foreach (StringField sf in rpl)
         {
             order1.setString(sf.getField(), sf.getValue());
         }
         if (order1.isSetField(41))
         {
             order1.removeField(41);//origcloridid
         }
         order = order1;
     }
 }