public void From(trade.MultiLegOrder mlOrder)
        {
            LastOrder = mlOrder;

            OrderId     = mlOrder.OrderId;
            OpenOrderId = mlOrder.OpenOrderId;
            Reason      = GetReasonDisplayText(mlOrder.Reason);
            PortfolioId = mlOrder.PortfolioId;
            Quantity    = mlOrder.Quantity;
            IsOpenOrder = mlOrder.OrderId == mlOrder.OpenOrderId;

            bool allFinished = false;

            for (int i = 0; i < mlOrder.Legs.Count; ++i)
            {
                if (_orders.Count == i)
                {
                    _orders.Add(new OrderVM());
                }

                var legOrder = mlOrder.Legs[i];
                _orders[i].From(legOrder, true);
                allFinished = _orders[i].IsFinished;
            }

            IsAllFinished = allFinished;

            if (!string.IsNullOrEmpty(mlOrder.StatusMsg))
            {
                EventLogger.Write("组合下单({0}) - {1}", mlOrder.OrderId, mlOrder.StatusMsg);
            }
        }
Exemple #2
0
 public MultiLegOrderVM Update(string accountId, trade.MultiLegOrder mlOrder)
 {
     lock (this)
     {
         string          ordId     = mlOrder.OrderId;
         MultiLegOrderVM mlOrderVm = null;
         mlOrderVm = GetMlOrderVm(accountId, ordId);
         if (mlOrderVm != null)
         {
             mlOrderVm.From(mlOrder);
             if (!mlOrderVm.IsOpenOrder && mlOrderVm.IsAllFinished)
             {
                 if (!string.IsNullOrEmpty(mlOrder.OpenOrderId))
                 {
                     var openOrderVm = GetMlOrderVm(accountId, mlOrder.OpenOrderId);
                     if (openOrderVm != null)
                     {
                         mlOrderVm.CalcProfit(openOrderVm);
                     }
                 }
             }
             return(null);
         }
         else
         {
             mlOrderVm = new MultiLegOrderVM(accountId);
             mlOrderVm.From(mlOrder);
             this.Add(mlOrderVm);
             return(mlOrderVm);
         }
     }
 }
Exemple #3
0
        void _client_OnMultiLegOrderUpdated(trade.MultiLegOrder obj)
        {
            string info = string.Format("mlOrder: {0}\t{1}\t{2}", obj.OrderId, obj.PortfolioId, obj.Quantity);

            EventAggregator.GetEvent <MultiLegOrderUpdatedEvent>().Publish(
                new MultiLegOrderUpdateArgs {
                AccountId = Id, MultiLegOrder = obj
            });
        }
Exemple #4
0
        void _client_OnMultiLegOrderUpdated(trade.MultiLegOrder obj)
        {
            string info = string.Format("mlOrder: {0}\t{1}\t{2}", obj.OrderId, obj.PortfolioId, obj.Quantity);

            OutputMessage(info);
        }