Пример #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);
        }
Пример #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);
            }
        }
Пример #3
0
        public Order GetReasonForLock(Order order2check4similarLock)
        {
            Order ret = null;
            OrderPostProcessorEmergencyLock lock4check = new OrderPostProcessorEmergencyLock(order2check4similarLock);

            lock (this.emergencyLocks) {
                //bool contains = EmergencyLocks.Contains(orderGenerator);
                //bool ret = false;
                foreach (OrderPostProcessorEmergencyLock locks in this.emergencyLocks)
                {
                    if (locks.Equals(lock4check))
                    {
                        ret = locks.OrderReasonForLock;
                    }
                }
                //if (contains != ret) throw new Exception("contains[" + contains + "] != ret[" + ret + "]");
            }
            return(ret);
        }
Пример #4
0
        private void removeEmergencyLock(Order filledEmergencyOrder, OrderState stateCompletedOrInterrupted)
        {
            OrderPostProcessorEmergencyLock emergencyLock = new OrderPostProcessorEmergencyLock(filledEmergencyOrder);
            string msgPost = "EmergencyLock Removed [" + emergencyLock + "]";

            if (this.emergencyLocks.Contains(emergencyLock) == false)
            {
                string msg = "no EmergencyLock to remove: multiple QUIK callbacks? if u can find [" + msgPost
                             + "] earlier in thisOrder.Messages then it's ok";
                this.orderProcessor.AppendOrderMessageAndPropagateCheckThrowOrderNull(filledEmergencyOrder, msg);
                Assembler.PopupException(msg);
                //throw new Exception(msg);
                return;
            }

            lock (this.emergencyLocks) {
                this.emergencyLocks.Remove(emergencyLock);
            }
            OrderStateMessage omsgPost = new OrderStateMessage(filledEmergencyOrder, stateCompletedOrInterrupted, msgPost);

            this.orderProcessor.UpdateOrderStateAndPostProcess(filledEmergencyOrder, omsgPost);
        }