Beispiel #1
0
        private void eh_OrderStatus(object sender, OrderStatusEventArgs e)
        {
            DisplayedOrder dOrder = mainWin.Orders.FirstOrDefault <DisplayedOrder>(x => x.OrderId == e.OrderId);

            if (dOrder == null)
            {
                mainWin.LogList.Insert(0, new Log()
                {
                    Text = String.Format("Order Id: %d cannot be found", e.OrderId), Time = DateTime.Now
                });
            }
            else
            {
                // make a copy if every step needs keeping
                if (mainWin.UserPreference.KeepTradeSteps)
                {
                    dOrder      = dOrder.ShallowCopy();
                    dOrder.Time = DateTime.Now;
                    System.Windows.Threading.Dispatcher.FromThread(OrderManager.UIThread).Invoke(() =>
                    {
                        mainWin.Orders.Insert(0, dOrder);
                    });
                }
                System.Windows.Threading.Dispatcher.FromThread(OrderManager.UIThread).Invoke(() =>
                {
                    dOrder.Status    = e.Status;
                    dOrder.Filled    = e.Filled;
                    dOrder.Remaining = e.Remaining;
                    dOrder.AvgPrice  = e.AvgFillPrice;
                });
            }
        }
Beispiel #2
0
 private void eh_OpenOrder(object sender, OpenOrderEventArgs e)
 {
     System.Windows.Threading.Dispatcher.FromThread(OrderManager.UIThread).Invoke(() =>
     {
         DisplayedOrder dOrder = mainWin.Orders.FirstOrDefault <DisplayedOrder>(x => x.OrderId == e.OrderId);
         if (dOrder == null)
         {
             dOrder = new DisplayedOrder()
             {
                 OrderId   = e.Order.OrderId,
                 Action    = e.Order.Action,
                 Type      = e.Order.OrderType,
                 Symbol    = e.Contract.Symbol,
                 Currency  = e.Contract.Currency,
                 Status    = e.OrderState.Status,
                 Account   = e.Order.Account,
                 Tif       = e.Order.Tif,
                 GTD       = e.Order.GoodTillDate,
                 GAT       = e.Order.GoodAfterTime,
                 StopPrice = e.Order.TrailStopPrice,
                 LmtPrice  = e.Order.LmtPrice,
                 Quantity  = e.Order.TotalQuantity,
                 Exchange  = e.Contract.Exchange,
                 ParentId  = e.Order.ParentId,
                 OcaGroup  = e.Order.OcaGroup,
                 OcaType   = e.Order.OcaType,
                 Source    = DisplayName,
                 Time      = DateTime.Now
             };
             mainWin.Orders.Insert(0, dOrder);
         }
     });
 }