Example #1
0
        private void FireShutdownButton(object o, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                //
                // Stop button is one-shot per login.
                //

                stopButton.Enabled = false;
                string request_id = Guid.NewGuid().ToString();
                string timestamp  = com.quantmodel.common.network.message.ClientMessage.getTimestamp();

                InvestmentSystemOneRequest hades_request =
                    InvestmentSystemOneRequest.CreateBuilder()
                    .SetRequestId(request_id)
                    .SetTimestamp(timestamp)
                    .SetType(InvestmentSystemOneRequest.Types.RequestType.SHUTDOWN)
                    .Build();

                InvestmentSystemResponse response = sendRPC(
                    InvestmentSystemRequest.CreateBuilder()
                    .SetRequestId(request_id)
                    .SetSessionId(request_id)
                    .SetTimestamp(timestamp)
                    .SetType(InvestmentSystemRequest.Types.RequestType.COMMAND)
                    .SetDelegate(System.Text.Encoding.UTF8.GetString(hades_request.ToByteArray()))
                    .Build());
            }
        }
Example #2
0
        private void FirePauseButton(object o, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                string request_id = Guid.NewGuid().ToString();
                string timestamp  = com.quantmodel.common.network.message.ClientMessage.getTimestamp();

                if (pauseButton.Text == "PAUSE INVESTMENT SYSTEM")
                {
                    normal_bordercolor    = pauseButton.ForeColor;
                    pauseButton.Text      = "RESUME INVESTMENT SYSTEM";
                    pauseButton.ForeColor = Color.Red;

                    InvestmentSystemOneRequest hades_request =
                        InvestmentSystemOneRequest.CreateBuilder()
                        .SetRequestId(request_id)
                        .SetTimestamp(timestamp)
                        .SetType(InvestmentSystemOneRequest.Types.RequestType.PAUSE)
                        .Build();

                    InvestmentSystemResponse response = sendRPC(
                        InvestmentSystemRequest.CreateBuilder()
                        .SetRequestId(request_id)
                        .SetSessionId(request_id)
                        .SetTimestamp(timestamp)
                        .SetType(InvestmentSystemRequest.Types.RequestType.COMMAND)
                        .SetDelegate(System.Text.Encoding.UTF8.GetString(hades_request.ToByteArray()))
                        .Build());
                }
                else
                {
                    pauseButton.Text      = "PAUSE INVESTMENT SYSTEM";
                    pauseButton.ForeColor = normal_bordercolor;

                    InvestmentSystemOneRequest hades_request =
                        InvestmentSystemOneRequest.CreateBuilder()
                        .SetRequestId(request_id)
                        .SetTimestamp(timestamp)
                        .SetType(InvestmentSystemOneRequest.Types.RequestType.RESUME)
                        .Build();

                    InvestmentSystemResponse response = sendRPC(
                        InvestmentSystemRequest.CreateBuilder()
                        .SetRequestId(request_id)
                        .SetSessionId(request_id)
                        .SetTimestamp(timestamp)
                        .SetType(InvestmentSystemRequest.Types.RequestType.COMMAND)
                        .SetDelegate(System.Text.Encoding.UTF8.GetString(hades_request.ToByteArray()))
                        .Build());
                }
            }
        }
Example #3
0
        private void FireFlattenButton(object o, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift)
            {
                string request_id = Guid.NewGuid().ToString();
                string timestamp  = com.quantmodel.common.network.message.ClientMessage.getTimestamp();

                InvestmentSystemOneRequest hades_request =
                    InvestmentSystemOneRequest.CreateBuilder()
                    .SetRequestId(request_id)
                    .SetTimestamp(timestamp)
                    .SetType(InvestmentSystemOneRequest.Types.RequestType.FLATTEN)
                    .Build();

                InvestmentSystemResponse response = sendRPC(
                    InvestmentSystemRequest.CreateBuilder()
                    .SetRequestId(request_id)
                    .SetSessionId(request_id)
                    .SetTimestamp(timestamp)
                    .SetType(InvestmentSystemRequest.Types.RequestType.COMMAND)
                    .SetDelegate(System.Text.Encoding.UTF8.GetString(hades_request.ToByteArray()))
                    .Build());
            }
        }
Example #4
0
        private void FireLogin(object sender, EventArgs e)
        {
            string request_id = Guid.NewGuid().ToString();
            string timestamp  = com.quantmodel.common.network.message.ClientMessage.getTimestamp();

            InvestmentSystemOneRequest hades_request =
                InvestmentSystemOneRequest.CreateBuilder()
                .SetRequestId(request_id)
                .SetTimestamp(timestamp)
                .SetType(InvestmentSystemOneRequest.Types.RequestType.LOGIN)
                .Build();

            InvestmentSystemResponse response = sendRPC(
                InvestmentSystemRequest.CreateBuilder()
                .SetRequestId(request_id)
                .SetSessionId(request_id)
                .SetTimestamp(timestamp)
                .SetType(InvestmentSystemRequest.Types.RequestType.COMMAND)
                .SetDelegate(System.Text.Encoding.UTF8.GetString(hades_request.ToByteArray()))
                .Build());

            InvestmentSystemOneData invsys_one_data =
                InvestmentSystemOneData.ParseFrom(response.Delegate);

            foreach (Timebar timebar in invsys_one_data.TimebarList)
            {
                chartPanel.UpdateTimebarData(timebar, true);
            }

            foreach (Trend trend in invsys_one_data.TrendList)
            {
                chartPanel.AddTrendData(trend);
            }

            foreach (OrderExecution execution in invsys_one_data.OrderExecutionList)
            {
                chartPanel.AddOrderExecutionData(execution, true);

                GTLTreeNode node = new GTLTreeNode(
                    EPOCH.AddSeconds(execution.Timestamp)
                    .ToLocalTime().ToString());

                if (execution.Type == OrderExecution.Types.ExecutionType.BUY)
                {
                    node.SubItems.AddRange(new GTLSubItem [] {
                        new GTLSubItem(EPOCH.AddSeconds(execution.Timebar).ToLocalTime().ToString()),
                        new GTLSubItem("BUY"),
                        new GTLSubItem("" + execution.Quantity),
                        new GTLSubItem("" + execution.Price)
                    });
                }
                else
                {
                    node.SubItems.AddRange(new GTLSubItem [] {
                        new GTLSubItem(EPOCH.AddSeconds(execution.Timebar).ToLocalTime().ToString()),
                        new GTLSubItem("SELL"),
                        new GTLSubItem("" + execution.Quantity),
                        new GTLSubItem("" + execution.Price)
                    });
                }

                data.Nodes.Insert(0, node);
            }

            chartPanel.Redraw();
            loginFlag = true;
        }