Esempio n. 1
0
        private void PopulateOrderRow(int rowIndex, OpenOrderMessage orderMessage)
        {
            /*
             * liveOrdersGrid[0, rowIndex].Value = orderMessage.Order.PermId;
             * liveOrdersGrid[1, rowIndex].Value = orderMessage.Order.ClientId;
             * liveOrdersGrid[2, rowIndex].Value = orderMessage.Order.OrderId;
             * liveOrdersGrid[3, rowIndex].Value = orderMessage.Order.Account;
             * liveOrdersGrid[4, rowIndex].Value = orderMessage.Order.Action;
             * liveOrdersGrid[5, rowIndex].Value = orderMessage.Order.TotalQuantity;
             * liveOrdersGrid[6, rowIndex].Value = orderMessage.Contract.Symbol + " " + orderMessage.Contract.SecType + " " + orderMessage.Contract.Exchange;
             * liveOrdersGrid[7, rowIndex].Value = orderMessage.OrderState.Status;
             */
            String action = orderMessage.Order.Action;
            int    bqty   = 0;
            int    sqty   = 0;

            if ("BUY".Equals(action))
            {
                bqty = orderMessage.Order.TotalQuantity;
            }
            if ("SELL".Equals(action))
            {
                sqty = orderMessage.Order.TotalQuantity;
            }
            OrderRecord record = null;

            if (appStgManager.getAppOrderManager().OrderRepositry.ContainsKey(orderMessage.OrderId.ToString()))
            {
                record = appStgManager.getAppOrderManager().OrderRepositry[orderMessage.OrderId.ToString()];
            }
            liveOrdersGrid[0, rowIndex].Value = orderMessage.Order.PermId;
            liveOrdersGrid[1, rowIndex].Value = orderMessage.Contract.LocalSymbol;
            liveOrdersGrid[2, rowIndex].Value = bqty;
            liveOrdersGrid[3, rowIndex].Value = sqty;
            liveOrdersGrid[4, rowIndex].Value = orderMessage.Order.LmtPrice;
            liveOrdersGrid[5, rowIndex].Value = orderMessage.Order.AuxPrice;
            if (record != null)
            {
                liveOrdersGrid[6, rowIndex].Value = String.Format("{0:yyyyMMdd HH:mm:ss}", record.orderTime);
            }
            liveOrdersGrid[7, rowIndex].Value = orderMessage.OrderState.Status;
            //liveOrdersGrid[8, rowIndex].Value = String.Format("{0:0,0.0}", orderMessage.OrderState.Commission);

            liveOrdersGrid[8, rowIndex].Value = orderMessage.OrderState.Commission;
            if (record != null)
            {
                liveOrdersGrid[9, rowIndex].Value = record.sno;
            }
        }
Esempio n. 2
0
        private void PopulateTradeLog(int index, ExecutionMessage message)
        {
            /*
             * tradeLogGrid[0, index].Value = message.Execution.ExecId;
             * tradeLogGrid[1, index].Value = message.Execution.Time;
             * tradeLogGrid[2, index].Value = message.Execution.AcctNumber;
             * tradeLogGrid[3, index].Value = message.Execution.Side;
             * tradeLogGrid[4, index].Value = message.Execution.Shares;
             * tradeLogGrid[5, index].Value = message.Contract.Symbol + " " + message.Contract.SecType + " " + message.Contract.Exchange;
             * tradeLogGrid[6, index].Value = message.Execution.Price;
             */
            String side = message.Execution.Side;
            int    bqty = 0;
            int    sqty = 0;

            if ("BOT".Equals(side))
            {
                bqty = message.Execution.Shares;
            }
            if ("SLD".Equals(side))
            {
                sqty = message.Execution.Shares;
            }

            OrderRecord record = null;

            if (appStgManager.getAppOrderManager().OrderRepositry.ContainsKey(message.Execution.OrderId.ToString()))
            {
                record = appStgManager.getAppOrderManager().OrderRepositry[message.Execution.OrderId.ToString()];
            }
            tradeLogGrid[0, index].Value = message.Execution.ExecId;
            tradeLogGrid[1, index].Value = message.Contract.LocalSymbol;
            tradeLogGrid[2, index].Value = bqty.ToString();
            tradeLogGrid[3, index].Value = sqty.ToString();
            tradeLogGrid[4, index].Value = message.Execution.Price;
            tradeLogGrid[5, index].Value = message.Execution.Time;
            tradeLogGrid[6, index].Value = "Filled";
            if (record != null)
            {
                tradeLogGrid[7, index].Value = record.sno;
            }
        }
Esempio n. 3
0
        private void btn_test_sell_Click(object sender, EventArgs e)
        {
            IAppOrderManager appOrderManager = appStrategyManager.getAppOrderManager();
            Contract         contract        = GetMDContract();
            Order            order           = GetOrder("SELL", "LMT");

            order.OrderId = ibClient.NextOrderId;
            ibClient.NextOrderId++;
            orderManager.PlaceOrder(contract, order);
            //if (orderId != 0)
            //    orderId = 0;
            txt_console.Text = order.OrderId.ToString();
            OrderRecord orderR = new OrderRecord();

            orderR.orderId   = order.OrderId;
            orderR.sno       = txt_sno.Text;
            orderR.orderTime = DateTime.Now;
            //orderRepositry.Add(order.OrderId.ToString(), orderR);
            appOrderManager.OrderRepositry.AddOrUpdate(order.OrderId.ToString(), orderR, (KeyDown, oldValue) => oldValue);
            List <OrderRecord> orderRecords = new List <OrderRecord>();

            orderRecords.Add(orderR);
            appStrategyManager.getAppOrderManager().OrderPersister.SaveLastRow(orderRecords);
        }