Ejemplo n.º 1
0
        private void RejectOrder(Order order, OrderRejectReason reason, string message, string comment = null)
        {
            if (reason != OrderRejectReason.ParentPositionIsNotActive)
            {
                foreach (var positionId in order.PositionsToBeClosed)
                {
                    if (_ordersCache.Positions.TryGetPositionById(positionId, out var position) &&
                        position.Status == PositionStatus.Closing)
                    {
                        position.CancelClosing(_dateService.Now());
                    }
                }
            }

            if (order.OrderType == OrderType.Market ||
                reason != OrderRejectReason.NoLiquidity ||
                order.PendingOrderRetriesCount >= _marginTradingSettings.PendingOrderRetriesThreshold)
            {
                order.Reject(reason, message, comment, _dateService.Now());

                _orderRejectedEventChannel.SendEvent(this, new OrderRejectedEventArgs(order));
            }
            //TODO: think how to avoid infinite loop
            else if (!_ordersCache.TryGetOrderById(order.Id, out _)) // all pending orders should be returned to active state if there is no liquidity
            {
                order.CancelExecution(_dateService.Now());

                _ordersCache.Active.Add(order);
                _orderChangedEventChannel.SendEvent(this,
                                                    new OrderChangedEventArgs(order,
                                                                              new OrderChangedMetadata {
                    UpdatedProperty = OrderChangedProperty.None
                }));
            }
        }
Ejemplo n.º 2
0
 private void RejectOrder(Order order, OrderRejectReason reason, string message, string comment = null)
 {
     order.CloseDate        = DateTime.UtcNow;
     order.Status           = OrderStatus.Rejected;
     order.RejectReason     = reason;
     order.RejectReasonText = message;
     order.Comment          = comment;
     _orderRejectedEventChannel.SendEvent(this, new OrderRejectedEventArgs(order));
 }
Ejemplo n.º 3
0
 public ValidateOrderException(OrderRejectReason reason, string rejectReasonText, string comment = null) : base(rejectReasonText)
 {
     RejectReason = reason;
     Comment      = comment;
 }
Ejemplo n.º 4
0
 private void FireCreateRejected(Order order, OrderRejectReason reason)
 {
     OrderCreateRejected?.Invoke(this, new OrderCreateRejectedEventArgs(order, reason));
 }
Ejemplo n.º 5
0
 public Reject(Order order, OrderInfo orderInfo, OrderRejectReason reason)
     : base(ExecType.Rejected, OrderStatus.Rejected, order, orderInfo)
 {
     OrderRejectReason = reason;
     Text = "lookup table";
 }
Ejemplo n.º 6
0
 public OrderCreateRejectedEventArgs(Order order, OrderRejectReason reason)
     : base(order)
 {
     Reason = reason;
 }