コード例 #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            //Sell Modfiy
            try
            {
                using (OrdersProxy p = new OrdersProxy())
                {
                    //Dictionary<string, object> optionalParams = new Dictionary<string, object>();
                    //optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.REGULAR);
                    //optionalParams.Add("UnifiedCode", "2079333");

                    Guid reqGuid = new Guid(tbRequestGuid.Text);


                    p.Handle(new ModifyCancelOrder()
                    {
                        ClientKey = clientKey, OrderType = "Limit", Price = double.Parse(tbPrice.Text), Quantity = int.Parse(tbQty.Text), RequesterOrderID = reqGuid, TimeInForce = "Day", OptionalParam = null
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!isSubscribed)
            {
                MessageBox.Show(this, "ya 3am subscribe first!", "Subscription Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }


            try
            {
                string result = IsValid();
                if (result != "valid")
                {
                    MessageBox.Show(this, result, "Invalid Order", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }

                if (MessageBox.Show(this, "Send Order?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                using (OrdersProxy p = new OrdersProxy())
                {//EGMFC003PX11
                    //p.HandleRequest(new NewSingleOrder() { ClientKey = clientKey, RequesterOrderID = buyRequesterOrderID, ClientID = 1001, CustodyID = "4508", OrderType = "Limit", Price = 18, Quantity = 100, SecurityID = "EGS48031C016", OrderSide = "Buy", TimeInForce = "Day", CurrencyCode = "EGP", DateTime = DateTime.Now, ExchangeID = "CA" });
                    //p.HandleRequest(new NewSingleOrder() { ClientKey = clientKey, RequesterOrderID = buyRequesterOrderID, ClientID = 3001, CustodyID = "4999", OrderType = "Limit", Price = 20, Quantity = 10, SecurityID = "EGS48031C016", OrderSide = "Buy", TimeInForce = "Day", DateTime = DateTime.Now, ExchangeID = "CA", HandleInst = Contract.Enums.HandleInstruction.No_Broker_Invention });
                    for (int i = 0; i < nudRepeat.Value; i++)
                    {
                        Dictionary <string, object> optionalParams = new Dictionary <string, object>();
                        //optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.REGULAR);
                        //optionalParams.Add("UnifiedCode", "2079333");
                        Guid reqGuid = Guid.NewGuid();
                        tbRequestGuid.Text = reqGuid.ToString();
                        p.Handle(new NewSingleOrder()
                        {
                            ClientKey = clientKey, RequesterOrderID = reqGuid, ClientID = int.Parse(tbClient.Text), CustodyID = tbCust.Text, OrderType = rbLimit.Checked ? "Limit" : "Market", Price = rbLimit.Checked ? double.Parse(tbPrice.Text) : 0, Quantity = int.Parse(tbQty.Text), SecurityID = lblCode.Text.Trim(), OrderSide = "Buy", TimeInForce = combTimeInforce.Text.Trim(), DateTime = DateTime.Now, ExchangeID = tbMarket.Text, HandleInst = Contract.Enums.HandleInstruction.No_Broker_Invention, ExpirationDateTime = DateTime.Now.AddDays(3), OptionalParam = optionalParams
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #3
0
        private void btnCancelBuy_Click(object sender, EventArgs e)
        {
            try
            {
                using (OrdersProxy p = new OrdersProxy())
                {
                    Dictionary <string, object> optionalParams = new Dictionary <string, object>();
                    //optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.REGULAR);
                    //optionalParams.Add("UnifiedCode", "2079333");

                    Guid reqGuid = new Guid(tbRequestGuid.Text);

                    p.Handle(new CancelSingleOrder()
                    {
                        ClientKey = clientKey, OptionalParam = optionalParams, RequesterOrderID = reqGuid
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #4
0
        private void PlaceSellOrderWithAllocation()
        {
            using (OrdersProxy p = new OrdersProxy())
            {
                Guid reqGuid = Guid.NewGuid();  // request orderid created by client.

                Dictionary <string, object> optionalParams = new Dictionary <string, object>();

                string allocType = comboBoxAllocationType.SelectedItem.ToString();

                optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.REGULAR); // to allocate t+2
                // or   // optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.SAMEDAY); // to allocate t+0
                // or //  optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.SAMEDAYPLUS); // to allocate same day plus.
                // client UnifiedCode is mandatory.
                optionalParams.Add("UnifiedCode", txtUnifiedCode.Text.Trim());

                p.Handle(new NewSingleOrder()
                {
                    ClientKey          = clientKey,                // session Guid key
                    RequesterOrderID   = reqGuid,                  // unique orderid GUID
                    ClientID           = int.Parse(tbClient.Text), // Bimsi ClientID
                    CustodyID          = "4603",
                    OrderType          = "Limit",                  // or "Market"
                    Price              = 212.5,
                    Quantity           = 100,
                    SecurityID         = "EGB48011G026",
                    OrderSide          = "Sell",
                    TimeInForce        = "Day",
                    DateTime           = DateTime.Now,
                    ExchangeID         = "CA",
                    HandleInst         = Contract.Enums.HandleInstruction.No_Broker_Invention,
                    ExpirationDateTime = DateTime.Now,  // order expiry dayte
                    OptionalParam      = optionalParams
                });
            }
        }
コード例 #5
0
        //public class IOrdersCallbackHandler : IOrdersCallback
        //{

        //    #region IOrdersCallback Members

        //    public void PushUpdates(object msg)
        //    {
        //        if (msg.GetType() == typeof(Rejection))
        //        {
        //            MessageBox.Show(string.Format("Order: {0} Rejected: {1}", ((Rejection)msg).RequesterOrderID, ((Rejection)msg).RejectionReason));
        //        }
        //        if (msg.GetType() == typeof(OrderStatusResponse))
        //        {
        //            OrderStatusResponse status = (OrderStatusResponse)msg;
        //            MessageBox.Show(string.Format("Order: {0} Status: {1} Message: {2}",status.RequesterOrderID, status.OrderStatus.ToString(), status.Message));
        //        }
        //        else if (msg.GetType() == typeof(string))
        //        {
        //            MessageBox.Show((msg.ToString()));
        //        }
        //    }

        //    #endregion
        //}

        private void button2_Click(object sender, EventArgs e)
        {
            if (!isSubscribed)
            {
                MessageBox.Show(this, "ya 3am subscribe first!", "Subscription Required", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            try
            {
                string result = IsValid();
                if (result != "valid")
                {
                    MessageBox.Show(this, result, "Invalid Order", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    return;
                }


                if (MessageBox.Show(this, "Send Order?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }


                using (OrdersProxy p = new OrdersProxy())
                {                                                                                                                                   //2183732
                    //p.HandleRequest(new NewSingleOrder() { ClientKey = clientKey, RequesterOrderID = sellRequesterOrderID, OrderType = "Limit", ClientID = 9001, CustodyID = "4508", Price = 35, Quantity = 100, SecurityID = "EGMFC003PX11", OrderSide = "Sell", TimeInForce = "Day" });
                    //p.HandleRequest(new NewSingleOrder() { ClientKey = clientKey, RequesterOrderID = sellRequesterOrderID, OrderType = "Limit", ClientID = 3001, CustodyID = "4999", Price = 20, Quantity = 10, SecurityID = "EGS48031C016", OrderSide = "Sell", TimeInForce = "Day", DateTime = DateTime.Now, ExchangeID = "CA" });
                    for (int i = 0; i < nudRepeat.Value; i++)
                    {
                        Guid reqGuid = Guid.NewGuid();
                        tbRequestGuid.Text = reqGuid.ToString();


                        Dictionary <string, object> optionalParams = new Dictionary <string, object>();



                        string allocType = comboBoxAllocationType.SelectedItem.ToString();

                        switch (allocType)
                        {
                        case "Regular":
                            optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.REGULAR);
                            break;

                        case "SameDay":
                            optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.SAMEDAY);
                            break;

                        case "SameDay_Plus":
                            optionalParams.Add("ALLOC_TYPE", ALLOC_TYPE.SAMEDAYPLUS);
                            break;

                        default:
                            break;
                        }

                        optionalParams.Add("UnifiedCode", txtUnifiedCode.Text.Trim());

                        p.Handle(new NewSingleOrder()
                        {
                            ClientKey = clientKey, RequesterOrderID = reqGuid, ClientID = int.Parse(tbClient.Text), CustodyID = tbCust.Text, OrderType = rbLimit.Checked ? "Limit" : "Market", Price = rbLimit.Checked ? double.Parse(tbPrice.Text) : 0, Quantity = int.Parse(tbQty.Text), SecurityID = lblCode.Text.Trim(), OrderSide = "Sell", TimeInForce = combTimeInforce.Text.Trim(), DateTime = DateTime.Now, ExchangeID = tbMarket.Text, HandleInst = Contract.Enums.HandleInstruction.No_Broker_Invention, OptionalParam = optionalParams
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }