public void CalcProfit(MultiLegOrderVM openOrderVm)
        {
            double profit = 0;

            if (LastOrder == null)
            {
                return;
            }

            foreach (var closeOrd in LastOrder.Legs)
            {
                var openOrd = openOrderVm.LastOrder.Legs.FirstOrDefault(l => closeOrd.InstrumentID == l.InstrumentID);
                if (openOrd != null)
                {
                    if (closeOrd.Direction == trade.TradeDirectionType.SELL)
                    {
                        profit += (closeOrd.LimitPrice - openOrd.LimitPrice);
                    }
                    else
                    {
                        profit += (openOrd.LimitPrice - closeOrd.LimitPrice);
                    }
                }
            }

            Profit = profit;
        }
Beispiel #2
0
        private static void OnClosePorfOrder(MultiLegOrderVM mlOrderVm)
        {
            IEventAggregator evtAgg = ServiceLocator.Current.GetInstance <IEventAggregator>();

            evtAgg.GetEvent <CloseMlOrderEvent>().Publish(
                new CloseMlOrderArgs
            {
                AccountId   = mlOrderVm.AccountId,
                MlOrder     = mlOrderVm.LastOrder,
                LegOrderRef = ""
            });
        }
Beispiel #3
0
        private static void OnCancelPortfOrder(MultiLegOrderVM mlOrderVm)
        {
            IEventAggregator evtAgg = ServiceLocator.Current.GetInstance <IEventAggregator>();

            foreach (var ord in mlOrderVm.LastOrder.Legs)
            {
                if (
                    ord.OrderSubmitStatus != PTEntity.OrderSubmitStatusType.NOT_SUBMITTED &&
                    ord.OrderStatus != PTEntity.OrderStatusType.ALL_TRADED &&
                    ord.OrderStatus != PTEntity.OrderStatusType.ORDER_CANCELED)
                {
                    evtAgg.GetEvent <CancelOrderEvent>().Publish(
                        new CancelOrderEventArgs
                    {
                        AccountId     = mlOrderVm.AccountId,
                        OrderToCancel = ord
                    });
                }
            }
        }