예제 #1
0
        private static void ProcessSignalCloseOrder(TradeSignalActionClose action)
        {
            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var targetPositions = ctx.POSITION.Where(p => p.MasterOrder ==
                                                             action.OrderId).ToList().Select(LinqToEntity.DecorateOrder);

                    foreach (var order in targetPositions)
                    {
                        // исполнить сигнал - закрыть ордер
                        try
                        {
                            var status = ProxyTrade.SendCloseRequest(ProtectedOperationContext.MakeServerSideContext(),
                                                                     order.AccountID, order.ID,
                                                                     PositionExitReason.ClosedBySignal);
                            if (status != RequestStatus.OK)
                            {
                                Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - ошибка: {1}", action.OrderId, status);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - исключение при отправке запроса: {1}",
                                               action.OrderId, ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - исключение: {1}", action.OrderId, ex);
            }
        }
예제 #2
0
        public void MakeOrderClosedSignal(int accountId, int orderId, float priceExit)
        {
            var signalCat = ManagementTraderList.Instance.IsSignaller(accountId);

            if (!signalCat.HasValue)
            {
                return;
            }
            var action = new TradeSignalActionClose
            {
                OrderId   = orderId,
                Price     = priceExit,
                ServiceId = signalCat.Value
            };

            ServiceManagerClientManagerProxy.Instance.ProcessTradeSignalAction(action);
        }
예제 #3
0
 /// <summary>
 /// закрыть сделку по сигналу
 /// </summary>
 private void ProcessTradeSignalActionClose(TradeSignalActionClose trade)
 {
 }
예제 #4
0
 public void MakeOrderClosedSignal(int accountId, int orderId, float priceExit)
 {
     var signalCat = ManagementTraderList.Instance.IsSignaller(accountId);
     if (!signalCat.HasValue) return;
     var action = new TradeSignalActionClose
     {
         OrderId = orderId,
         Price = priceExit,
         ServiceId = signalCat.Value
     };
     ServiceManagerClientManagerProxy.Instance.ProcessTradeSignalAction(action);
 }
예제 #5
0
        private static void ProcessSignalCloseOrder(TradeSignalActionClose action)
        {
            try
            {
                using (var ctx = DatabaseContext.Instance.Make())
                {
                    var targetPositions = ctx.POSITION.Where(p => p.MasterOrder ==
                        action.OrderId).ToList().Select(LinqToEntity.DecorateOrder);

                    foreach (var order in targetPositions)
                    {
                        // исполнить сигнал - закрыть ордер
                        try
                        {
                            var status = ProxyTrade.SendCloseRequest(ProtectedOperationContext.MakeServerSideContext(),
                                                                     order.AccountID, order.ID,
                                                                     PositionExitReason.ClosedBySignal);
                            if (status != RequestStatus.OK)
                                Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - ошибка: {1}", action.OrderId, status);
                        }
                        catch (Exception ex)
                        {
                            Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - исключение при отправке запроса: {1}",
                                               action.OrderId, ex);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.DebugFormat("ProcessSignalCloseOrder(#{0}) - исключение: {1}", action.OrderId, ex);
            }
        }