示例#1
0
 public RequestStatus DeletePendingOrderRequest(PendingOrder order, PendingOrderStatus status, int?positionId,
                                                string closeReason)
 {
     // снять отложенный ордер
     return(ServerInterface.DeletePendingOrder(order, status, positionId, closeReason)
         ? RequestStatus.OK : RequestStatus.ServerError);
 }
示例#2
0
        public RequestStatus SendDeletePendingOrderRequest(
            ProtectedOperationContext secCtx,
            PendingOrder order,
            PendingOrderStatus status, int?positionID, string closeReason)
        {
            if (UserOperationRightsStorage.IsProtectedOperation(UserOperation.CloseOrder))
            {
                if (!UserSessionStorage.Instance.PermitUserOperation(secCtx,
                                                                     UserOperationRightsStorage.IsTradeOperation(UserOperation.ModifyOrder), true))
                {
                    return(RequestStatus.Unauthorized);
                }
            }

            Account account;
            var     dealer = GetDealerByAccount(order.AccountID, out account);

            if (dealer == null)
            {
                return(RequestStatus.GroupUnsupported);
            }

            try
            {
                var rst = dealer.DeletePendingOrderRequest(order, status, positionID, closeReason);
                AccountLogger.InfoFormat("SendDeletePendingOrderRequest({0}, {1} {2} {3}): {4}",
                                         order.ID, (DealType)order.Side, order.PriceSide, order.Symbol, rst);
                return(rst);
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("Ошибка дилера {0}: {1}", dealer, ex);
                return(RequestStatus.DealerError);
            }
        }
示例#3
0
        public static PendingSection <T> Create <T>(PendingOrderStatus status, IEnumerable <T> orders)
            where T : PendingOrderBase
        {
            switch (status)
            {
            case PendingOrderStatus.UnpickedAboutToShip:
                return(new PendingSection <T>
                {
                    SectionLabel = "Warning",
                    SectionDescription = "Orders are scheduled to ship within 2 days and have not been picked",
                    SectionColor = Color.FromArgb(255, 255, 192, 192),
                    Items = orders
                });

            case PendingOrderStatus.Picked:
                return(new PendingSection <T>
                {
                    SectionLabel = "On Time",
                    SectionDescription = "Orders have been picked",
                    SectionColor = Color.FromArgb(255, 192, 192, 192),
                    Items = orders
                });

            case PendingOrderStatus.UnpickedNotAboutToShip:
                return(new PendingSection <T>
                {
                    SectionLabel = "Unpicked",
                    SectionDescription = "Orders have not been picked but are not scheduled to ship within 2 days",
                    SectionColor = Color.FromArgb(255, 255, 220, 220),
                    Items = orders
                });

            default: throw new ArgumentOutOfRangeException("status");
            }
        }
示例#4
0
 public override RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx, PendingOrder order,
                                                             PendingOrderStatus status, int?positionId, string closeReason)
 {
     order.Status      = status;
     order.CloseReason = closeReason;
     ordHistory.Add(order);
     orders.Remove(order);
     return(RequestStatus.OK);
 }
示例#5
0
        public bool DeletePendingOrder(PendingOrder orderDecorated,
                                       PendingOrderStatus status, int?positionID, string closeReason)
        {
            var order = LinqToEntity.UndecorateLiveActiveOrder(orderDecorated);

            using (var ctx = DatabaseContext.Instance.Make())
            {
                // получить текущую цену
                var pair        = QuoteStorage.Instance.ReceiveValue(order.Symbol);
                var priceClosed = pair == null ? 0 : order.Side > 0 ? pair.bid : pair.ask;

                var hist = new PENDING_ORDER_CLOSED
                {
                    OrderID       = order.ID,
                    AccountID     = order.AccountID,
                    Comment       = order.Comment,
                    ExpertComment = order.ExpertComment,
                    Magic         = order.Magic,
                    PairOCO       = order.PairOCO,
                    PriceFrom     = order.PriceFrom,
                    PriceTo       = order.PriceTo,
                    Side          = order.Side,
                    Status        = (int)status,
                    Stoploss      = order.Stoploss,
                    Takeprofit    = order.Takeprofit,
                    Symbol        = order.Symbol,
                    TimeClosed    = DateTime.Now,
                    Volume        = order.Volume,
                    PriceClosed   = (decimal)priceClosed,
                    Position      = positionID,
                    CloseReason   = closeReason
                };
                try
                {
                    ctx.PENDING_ORDER_CLOSED.Add(hist);

                    var ord = ctx.PENDING_ORDER.FirstOrDefault(p => p.ID == order.ID);
                    if (ord == null)
                    {
                        Logger.ErrorFormat("DeletePendingOrder - ордер {0} не найден", order.ID);
                        ServiceManagerClientManagerProxy.Instance.NewOrderResponse(null,
                                                                                   RequestStatus.ServerError, "crudsav");
                        return(false);
                    }
                    ctx.PENDING_ORDER.Remove(ord);
                    // сохранить изменения
                    ctx.SaveChanges();

                    return(true);
                }
                catch (Exception ex)
                {
                    Logger.ErrorFormat("Ошибка в DeletePendingOrder (#{0}): {1}", order.ID, ex);
                }
            }
            return(false);
        }
示例#6
0
 public RequestStatus SendDeletePendingOrderRequestSafe(PendingOrder order,
                                                        PendingOrderStatus status, int?positionId, string closeReason)
 {
     if (InvokeRequired)
     {
         return((RequestStatus)Invoke(new Func <PendingOrder, PendingOrderStatus, int?, string, RequestStatus>(SendDeletePendingOrderRequestUnsafe),
                                      status, positionId, closeReason));
     }
     return(SendDeletePendingOrderRequestUnsafe(order, status, positionId, closeReason));
 }
示例#7
0
 private static RequestStatus SendDeletePendingOrderRequestUnsafe(PendingOrder order,
                                                                  PendingOrderStatus status, int?positionId, string closeReason)
 {
     try
     {
         var res = serverProxyTrade.proxy.SendDeletePendingOrderRequest(
             CurrentProtectedContext.Instance.MakeProtectedContext(),
             order, status, positionId, closeReason);
         if (res != RequestStatus.OK)
         {
             Instance.ShowMsgWindowSafe(new AccountEvent(
                                            Localizer.GetString("MessageErrorExecutingOrder"),
                                            EnumFriendlyName <RequestStatus> .GetString(res),
                                            AccountEventCode.ServerMessage));
         }
         return(res);
     }
     catch (Exception ex)
     {
         Logger.Error("SendDeletePendingOrderRequest", ex);
         return(RequestStatus.NoConnection);
     }
 }
示例#8
0
 public RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx, PendingOrder order, PendingOrderStatus status,
                                                    int?positionID, string closeReason)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public abstract RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
                                                             PendingOrder order, PendingOrderStatus status, int?positionId, string closeReason);
示例#10
0
 public override RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
                                                             PendingOrder order, PendingOrderStatus status, int?positionId, string closeReason)
 {
     return(proxyTrade.proxy.SendDeletePendingOrderRequest(ctx, order, status, positionId, closeReason));
 }
示例#11
0
 public override RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
     PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason)
 {
     return proxyTrade.proxy.SendDeletePendingOrderRequest(ctx, order, status, positionId, closeReason);
 }
示例#12
0
 public abstract RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx,
     PendingOrder order, PendingOrderStatus status, int? positionId, string closeReason);
示例#13
0
 public RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext secCtx, PendingOrder order, PendingOrderStatus status, int?positionID, string closeReason)
 {
     return(Channel.SendDeletePendingOrderRequest(secCtx, order, status, positionID, closeReason));
 }
示例#14
0
 public RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext secCtx, PendingOrder order, PendingOrderStatus status, int?positionID, string closeReason)
 {
     try
     {
         return(Proxy.SendDeletePendingOrderRequest(secCtx, order, status, positionID, closeReason));
     }
     catch (Exception) //no try-catch in original
     {
         RenewChannel();
         try
         {
             return(Proxy.SendDeletePendingOrderRequest(secCtx, order, status, positionID, closeReason));
         }
         catch (Exception)
         {
             return(RequestStatus.ServerError);
         }
     }
 }
 public RequestStatus SendDeletePendingOrderRequest(ProtectedOperationContext ctx, PendingOrder order, PendingOrderStatus status,
                                                    int? positionID, string closeReason)
 {
     throw new NotImplementedException();
 }