Ejemplo n.º 1
0
        private void FireBeforeCellEdit(object source, GTLEmbeddedControlEventArgs args)
        {
            args.Cancel = true;
            GTLTreeNode node = args.TreeNode;

            //
            //  You can cancel replace as long as it's
            //
            //      'NEW'
            //      'PARTIALLY_FILLED'
            //      'REPLACED'
            //

            string status = node.SubItems[DatabaseObject.RELEASE_STATUS].Text;

            if (status.Equals("NEW") ||
                status.Equals("PARTIALLY_FILLED") ||
                status.Equals("REPLACED"))
            {
                GTLColumn col = data.Columns[args.Column];

                if (col.Name.Equals(DatabaseObject.LIMIT_PRC) ||
                    col.Name.Equals(DatabaseObject.STOP_PRC))
                {
                    args.Cancel = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void FireBeforeCellEdit(object source, GTLEmbeddedControlEventArgs args)
        {
            args.Cancel = true;
            GTLTreeNode node = args.TreeNode;
            GTLSubItem  sub  = node.SubItems[args.Column];

            if (node.SubItems[args.Column].Text != null &&
                node.SubItems[args.Column].Text != "")
            {
                args.Cancel = false;
            }
        }
Ejemplo n.º 3
0
        private void FireAfterCellEdit(object source, GTLEmbeddedControlEventArgs args)
        {
            args.Cancel = true;
            GTLTreeNode node = args.TreeNode;
            GTLColumn   col  = data.Columns[args.Column];

            if (!controller.Cache.HasRelease(node.Tag))
            {
                MessageBox.Show("Unknown release: " + node.Tag);
                data.ClearSelection();
                return;
            }

            string release_type = node.SubItems[DatabaseObject.RELEASE_TYPE].Text;

            if (col.Name.Equals(DatabaseObject.LIMIT_PRC) &&
                (release_type.Equals("LIMIT") || release_type.Equals("STOP_LIMIT")))
            {
                //
                //  Get the current release
                //

                Release release = controller.Cache.GetRelease(node.Tag);
                TextBox tb      = (TextBox)args.Control;

                //
                //  Ensure something changed...
                //

                double old_limit_prc = release.ToDouble(DatabaseObject.LIMIT_PRC);

                try
                {
                    //
                    //  Test for a valid number
                    //

                    double limit_prc = Double.Parse(tb.Text);

                    //
                    //  Ensure new limit price is >= 0 and != old limit price
                    //

                    if (limit_prc >= 0 && limit_prc != old_limit_prc)
                    {
                        controller.SendRpc(
                            new CancelReplaceRelease(
                                release.Id,
                                release[DatabaseObject.STOP_PRC],
                                Convert.ToString(limit_prc)));
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        " Invalid Limit Price: " + tb.Text,
                        "REPLACE RELEASE Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);
                }

                data.ClearSelection();
            }

            if (col.Name.Equals(DatabaseObject.STOP_PRC) &&
                (release_type.Equals("STOP") || release_type.Equals("STOP_LIMIT")))
            {
                //
                //  Get the current release
                //

                Release release = controller.Cache.GetRelease(node.Tag);
                TextBox tb      = (TextBox)args.Control;

                //
                //  Ensure something changed...
                //

                double old_stop_prc = release.ToDouble(DatabaseObject.STOP_PRC);

                try
                {
                    //
                    //  Test for a valid number
                    //

                    double stop_prc = Double.Parse(tb.Text);

                    //
                    //  Ensure new limit price is >= 0 and != old limit price
                    //

                    if (stop_prc >= 0 && stop_prc != old_stop_prc)
                    {
                        controller.SendRpc(
                            new CancelReplaceRelease(
                                release.Id,
                                Convert.ToString(stop_prc),
                                release[DatabaseObject.LIMIT_PRC]));
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        " Invalid Stop Price: " + tb.Text,
                        "REPLACE RELEASE Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);
                }

                data.ClearSelection();
            }
        }
Ejemplo n.º 4
0
        private void FireAfterCellEdit(object source, GTLEmbeddedControlEventArgs args)
        {
            args.Cancel = true;
            ColorSubItem csi  = null;
            GTLTreeNode  node = args.TreeNode;
            GTLColumn    col  = data.Columns[args.Column];
            GTLSubItem   sub  = node.SubItems[args.Column];

            if (col.Name.Equals(DatabaseObject.MAX_OPEN_LONG_QTY) ||
                col.Name.Equals(DatabaseObject.MAX_OPEN_SHORT_QTY) ||
                col.Name.Equals(DatabaseObject.MAX_RELEASE_QTY))
            {
                TextBox tb = (TextBox)args.Control;

                //
                //  Ensure that the text box value is an integer greater
                //  than or equal to zero.
                //

                try
                {
                    int qty = Int32.Parse(tb.Text);

                    if (qty < 0)
                    {
                        MessageBox.Show(
                            " Invalid Quantity: " + tb.Text,
                            "UPDATE Account Limit Error",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation);

                        data.ClearSelection();

                        csi = new RedColorSubItem(Color.White,
                                                  node.SubItems[args.Column],
                                                  node.Tag + data.Columns[args.Column].Text);

                        colorNodes[csi.Tag] = csi;
                        return;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show(
                        " Invalid Quantity: " + tb.Text,
                        "UPDATE Account Limit Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);

                    data.ClearSelection();

                    csi = new RedColorSubItem(Color.White,
                                              node.SubItems[args.Column],
                                              node.Tag + data.Columns[args.Column].Text);

                    colorNodes[csi.Tag] = csi;
                    return;
                }

                //
                //  Update the account limit
                //

                string account_id,
                       symbol,
                       security_exchange,
                       fix_session_id,
                       max_open_long_qty,
                       max_open_short_qty,
                       max_release_qty;

                account_id        = node.SubItems[DatabaseObject.ACCOUNT_ID].Text;
                symbol            = node.SubItems[DatabaseObject.SYMBOL].Text;
                security_exchange = node.SubItems[DatabaseObject.SECURITY_EXCHANGE].Text;
                fix_session_id    = node.SubItems[DatabaseObject.SESSION_ID].Text;

                if (col.Name.Equals(DatabaseObject.MAX_OPEN_LONG_QTY))
                {
                    max_open_long_qty  = tb.Text;
                    max_open_short_qty = node.SubItems[DatabaseObject.MAX_OPEN_SHORT_QTY].Text;
                    max_release_qty    = node.SubItems[DatabaseObject.MAX_RELEASE_QTY].Text;
                }
                else if (col.Name.Equals(DatabaseObject.MAX_OPEN_SHORT_QTY))
                {
                    max_open_long_qty  = node.SubItems[DatabaseObject.MAX_OPEN_LONG_QTY].Text;
                    max_open_short_qty = tb.Text;
                    max_release_qty    = node.SubItems[DatabaseObject.MAX_RELEASE_QTY].Text;
                }
                else
                {
                    max_open_long_qty  = node.SubItems[DatabaseObject.MAX_OPEN_LONG_QTY].Text;
                    max_open_short_qty = node.SubItems[DatabaseObject.MAX_OPEN_SHORT_QTY].Text;
                    max_release_qty    = tb.Text;
                }

                ClientAdapterResponse response =
                    controller.SendRpc(new UpdateAccountLimit(
                                           account_id,
                                           symbol,
                                           security_exchange,
                                           fix_session_id,
                                           max_open_long_qty,
                                           max_open_short_qty,
                                           max_release_qty,
                                           "1"));

                response = controller.SendRpc(new ReloadStaticData( ));

                csi = new BlueColorSubItem(Color.White, sub,
                                           node.Tag + data.Columns[args.Column].Text);

                colorNodes[csi.Tag] = csi;

                args.Cancel = false;

                data.ClearSelection();
            }

            if (col.Name.Equals(DatabaseObject.SESSION_ID))
            {
                TextBox tb = (TextBox)args.Control;

                if ("".Equals(tb.Text))
                {
                    MessageBox.Show(
                        " Invalid FIX Session ID",
                        "UPDATE Account Limit Error",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Exclamation);

                    data.ClearSelection();

                    csi = new RedColorSubItem(Color.White,
                                              node.SubItems[args.Column],
                                              node.Tag + data.Columns[args.Column].Text);

                    colorNodes[csi.Tag] = csi;
                    return;
                }

                //
                //  Update the account limit
                //

                ClientAdapterResponse response =
                    controller.SendRpc(new UpdateAccountLimit(
                                           node.SubItems[DatabaseObject.ACCOUNT_ID].Text,
                                           node.SubItems[DatabaseObject.SYMBOL].Text,
                                           node.SubItems[DatabaseObject.SECURITY_EXCHANGE].Text,
                                           tb.Text,
                                           node.SubItems[DatabaseObject.MAX_OPEN_LONG_QTY].Text,
                                           node.SubItems[DatabaseObject.MAX_OPEN_SHORT_QTY].Text,
                                           node.SubItems[DatabaseObject.MAX_RELEASE_QTY].Text,
                                           "1"));

                response = controller.SendRpc(new ReloadStaticData( ));

                csi = new BlueColorSubItem(Color.White, sub,
                                           node.Tag + data.Columns[args.Column].Text);

                colorNodes[csi.Tag] = csi;

                args.Cancel = false;

                data.ClearSelection();
            }
        }