Ejemplo n.º 1
0
        public void AddLockAndCreateEmergencyReplacementAndResubmitFor(Order rejectedExitOrder)
        {
            int emergencyCloseAttemptsMax = rejectedExitOrder.Alert.Bars.SymbolInfo.EmergencyCloseAttemptsMax;

            if (emergencyCloseAttemptsMax <= 0)
            {
                return;
            }

            try {
                throwLogIfNotRejectedClosingOrder(rejectedExitOrder);
            } catch (Exception) {
                return;
            }

            OrderPostProcessorEmergencyLock emergencyLock = new OrderPostProcessorEmergencyLock(rejectedExitOrder);
            string msg                   = "Setting an EmergencyLock[" + emergencyLock.ToString() + "]";
            Order  reason4lock           = this.GetReasonForLock(rejectedExitOrder);
            bool   isEmergencyClosingNow = (reason4lock != null);

            if (isEmergencyClosingNow)
            {
                msg = "ALREADY LOCKED (Rejected dupe?): " + msg;
                this.orderProcessor.AppendOrderMessageAndPropagateCheckThrowOrderNull(rejectedExitOrder, msg);
                return;
            }

            lock (this.emergencyLocks) {
                this.emergencyLocks.Add(emergencyLock);
            }
            CreateEmergencyReplacementAndResubmitFor(rejectedExitOrder);
        }
Ejemplo n.º 2
0
        private void throwLogAndAppendMessageIfNoEmergencyLockFor(Order order)
        {
            OrderPostProcessorEmergencyLock emergencyLock = new OrderPostProcessorEmergencyLock(order);

            if (this.emergencyLocks.Contains(emergencyLock) == false)
            {
                string msg = "who removed EmergencyLock before EmergencyCloseComplete?! " + emergencyLock.ToString();
                this.orderProcessor.AppendOrderMessageAndPropagateCheckThrowOrderNull(order, msg);
                Assembler.PopupException(msg);
                throw new Exception(msg);
            }
        }